Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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 ``` [wanyi@devvm9268.frc0 ~/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>] [wanyi@devvm9268.frc0 ~/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
- Loading branch information