You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[llvm-gsymutil] Option --symtab-file to specify a separate binary for symbol table
Summary:
I made minimal changes possible to enable this for Strobelight's llvm-gsymutil migration.
Since Strobelight is only on linux dealing with ELF, and no Universal Binary will be involved, I am making the `--symtab-file` option limited to the simple object file case.
We will need to refactor the code to better handle the `MachOUniversalBinary` type given there're different arch involved.
Test Plan:
I made a private build of `llvm-gsymutil` that can be downloaded with
```
jf download GICWmABaZb_9K94FAI4uIkiuhtZebpZBAAAB --file "llvm-gsymutil"
```
Manually tested the conversion using files from IndexerTest.cpp unit tests.
Use both `main` & `main.debug`
```
$ /home/wanyi/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/llvm-gsymutil --convert main.debug --symtab-file main -o main.gsym
Input file: main.debug
Output file (x86_64): main.gsym
Loaded 1 functions from DWARF.
Using symbol table file: main
Loaded 9 functions from symbol table.
Pruned 0 functions, ended with 10 total
```
Use only `main.debug` (debug info only)
```
$ /home/wanyi/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/llvm-gsymutil --convert main.debug -o debug_info_only.gsym
Input file: main.debug
Output file (x86_64): debug_info_only.gsym
Loaded 1 functions from DWARF.
Loaded 0 functions from symbol table.
Pruned 0 functions, ended with 1 total
```
Use only `main` (symbol table only)
```
$ /home/wanyi/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/llvm-gsymutil --convert main -o symbol_table_only.gsym
Input file: main
Output file (x86_64): symbol_table_only.gsym
Loaded 0 functions from DWARF.
Loaded 10 functions from symbol table.
Pruned 0 functions, ended with 10 total
```
ELF debug info + universal binary for symbol table
```
[[email protected] ~/fbsource/fbcode/services_efficiency/symbol_service/tests/testpackage3 (71a39fcf2|remote/master)]$ file universal universal: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>] [arm64:Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>]
[[email protected] ~/fbsource/fbcode/services_efficiency/symbol_service/tests/testpackage3 (71a39fcf2|remote/master)]$ /home/wanyi/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/llvm-gsymutil --convert main.debug --symtab-file universal
Input file: main.debug
Output file (x86_64): main.debug.gsym
Loaded 1 functions from DWARF.
Using symbol table file: universal
DWARF conversion failed: : Input symbol table file universal is not a valid object file.
Supported files are ELF and mach-o (exclude universal binary) files.
```
Symbol table only
```
Desktop/tmp/test_llvm-gsymutil
▶ /Users/wanyi/llvm-sand/build/Debug/Darwin-arm64/toolchain/bin/llvm-gsymutil --convert universal
Input file: universal
Output file (x86_64): universal.gsym.x86_64
Loaded 0 functions from DWARF.
Loaded 50 functions from symbol table.
Pruned 0 functions, ended with 50 total
Output file (arm64): universal.gsym.arm64
Loaded 0 functions from DWARF.
Loaded 50 functions from symbol table.
Pruned 0 functions, ended with 50 total
```
dSYM -both debug info & symbol table
```
Desktop/tmp/test_llvm-gsymutil
▶ /Users/wanyi/llvm-sand/build/Debug/Darwin-arm64/toolchain/bin/llvm-gsymutil --convert universal.dSYM/Contents/Resources/DWARF/universal -o debug_info
Input file: universal.dSYM/Contents/Resources/DWARF/universal
Output file (x86_64): debug_info.x86_64
Loaded 49 functions from DWARF.
Loaded 1 functions from symbol table.
Pruned 0 functions, ended with 50 total
Output file (arm64): debug_info.arm64
Loaded 49 functions from DWARF.
Loaded 1 functions from symbol table.
Pruned 0 functions, ended with 50 total
```
`--symtab-file` flag should fail
```
Desktop/tmp/test_llvm-gsymutil
▶ /Users/wanyi/llvm-sand/build/Debug/Darwin-arm64/toolchain/bin/llvm-gsymutil --convert universal.dSYM/Contents/Resources/DWARF/universal --symtab-file universal
Input file: universal.dSYM/Contents/Resources/DWARF/universal
DWARF conversion failed: : --symtab-file is not accepted for universal binary conversion
```
I wasn't able to strip the symbol table out of the DWARF
Tried following
```
Desktop/tmp/test_llvm-gsymutil
▶ /opt/llvm/bin/llvm-objcopy --only-keep-debug arm64.dSYM/Contents/Resources/DWARF/arm64 arm64.debug
Desktop/tmp/test_llvm-gsymutil
▶ objdump --syms arm64.debug | awk '{print $5;}' > symbols
Desktop/tmp/test_llvm-gsymutil
▶ /opt/llvm/bin/llvm-objcopy --strip-symbols=./symbols arm64.debug
```
dSYM - both debug info & symbol table
```
Desktop/tmp/test_llvm-gsymutil
▶ /Users/wanyi/llvm-sand/build/Debug/Darwin-arm64/toolchain/bin/llvm-gsymutil --convert arm64.dSYM/Contents/Resources/DWARF/arm64 -o arm64_debug_info
Input file: arm64.dSYM/Contents/Resources/DWARF/arm64
Output file (aarch64): arm64_debug_info
Loaded 49 functions from DWARF.
Loaded 1 functions from symbol table.
Pruned 0 functions, ended with 50 total
```
Symbol table only
```
Desktop/tmp/test_llvm-gsymutil
▶ /Users/wanyi/llvm-sand/build/Debug/Darwin-arm64/toolchain/bin/llvm-gsymutil --convert arm64 -o arm64_symbol_table
Input file: arm64
Output file (aarch64): arm64_symbol_table
Loaded 0 functions from DWARF.
Loaded 50 functions from symbol table.
Pruned 0 functions, ended with 50 total
```
Reviewers: slinger, jeffreytan
Reviewed By: jeffreytan
Subscribers: ayermolo, #lldb_team
Differential Revision: https://phabricator.intern.facebook.com/D45341225
Tasks: T151296270
Tags: aarch64
Commit #2 Differential Revision: https://phabricator.intern.facebook.com/D45792908
Commit #2 Tasks: T152287419
Commit llvm#3 Differential Revision: https://phabricator.intern.facebook.com/D49360184
Copy file name to clipboardExpand all lines: llvm/tools/llvm-gsymutil/Opts.td
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -40,3 +40,6 @@ def addresses_from_stdin :
40
40
defm json_summary_file :
41
41
Eq<"json-summary-file",
42
42
"Output a categorized summary of errors into the JSON file specified.">;
43
+
defm symtab_file :
44
+
Eq<"symtab-file",
45
+
"Specify a separate file for symbol table to GSYM conversion.\nIn case the symbol table and debug info are not in the same binary. Does not support universal binary.">;
0 commit comments