Skip to content

Support C++ mangled name lookup and serialization in Ghidra scripts #156

@kumarak

Description

@kumarak

When decompiling a single C++ function via --function _ZN5Debug7Command10VarHandler10GetVarInfoEPNS0_7Context, the function is not found even though it exists in the binary. Additionally, the serialized JSON output demangles local names rather than mangled symbols.

Root Causes

  1. decompileSingleFunction() calls getGlobalFunctions(name) only searches by demangled local name in the global namespace. For C++ symbols, Ghidra demangles them and stores them in namespaces (e.g., GetVarInfo in Debug::Command::VarHandler), so mangled-name lookups return empty results.
  2. PcodeSerializer and FunctionSerializer emit function.getName() (demangled local name) rather than the original mangled symbol name needed by downstream tools to link back to binary symbols.

Fix

Implement a multi-strategy function name lookup for mangled names in the global namespace, and also look up local names in defined namespaces before serialization. Serialize the external functions with their mangled names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions