llvm-project
dc58013d - [llvm-gsymutil] Replace truncated DWARF names with mangled names from symbol table (#184221)

Commit
1 day ago
[llvm-gsymutil] Replace truncated DWARF names with mangled names from symbol table (#184221) ## Summary - During `GsymCreator::finalize()`, when deduplicating entries with the same address range, check if the DWARF entry's name is a truncated version of the symbol table's mangled name - If the DWARF name is a substring of the demangled symbol table name, replace it with the full mangled name before discarding the symbol table entry - This allows downstream tools to properly demangle and display full function signatures ## Test plan ### Unit tests - `TestMangledNameReplacement`: Verifies DWARF name `make_ftype` is replaced with `_Z10make_ftypePci` and line table is preserved - `TestMangledNameReplacementNegative`: Verifies no replacement when both names are mangled, or when names are unrelated - All 51 GSYM unit tests pass ### Lit test - `elf-mangled-name-replacement.yaml`: End-to-end test creating an ELF with DWARF + symbol table, converting to GSYM, and verifying the output - All 9/9 applicable GSYM lit tests pass (6 unsupported are ARM/macOS tests on x86_64 Linux) ### Manual end-to-end testing Created ELF binaries with `yaml2obj` containing both DWARF debug info and symbol table entries for the same function, then converted to GSYM with `llvm-gsymutil --convert` and verified the output with `llvm-gsymutil` dump. **Test 1: Name replacement happens when DWARF name is truncated** - DWARF has function named `make_ftype` with line table at `0x401000` - Symbol table has `_Z10make_ftypePci` (demangles to `make_ftype(char*, int)`) at same address - After conversion, GSYM output shows: `"_Z10make_ftypePci"` with line table preserved ✅ **Test 2: No replacement when names are unrelated** - DWARF has function named `unrelated_func` with line table at `0x401000` - Symbol table has `_Z10make_ftypePci` at same address - After conversion, GSYM output shows: `"unrelated_func"` — name unchanged ✅ **Test 3: Replacement works with namespaced functions** - DWARF has function named `make_ftype` with line table at `0x401000` - Symbol table has `_ZN12_GLOBAL__N_110make_ftypeEPci` (demangles to `(anonymous namespace)::make_ftype(char*, int)`) at same address - After conversion, GSYM output shows: `"_ZN12_GLOBAL__N_110make_ftypeEPci"` with line table preserved ✅ Co-authored-by: Chen Li <chenlii@fb.com>
Author
Parents
Loading