[PATCH] D78888: [llvm-objcopy][MachO] Fix symbol table

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 26 17:31:45 PDT 2020


alexshap created this revision.
alexshap created this object with visibility "All Users".
Herald added subscribers: abrachet, MaskRay.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.
alexshap added reviewers: smeenai, MaskRay.

In this diff multiple issues related to symbols are resolved.

1. The calculation of symbol properties is fixed, for the reference see

https://developer.apple.com/documentation/kernel/nlist_64/1583944-n_type?language=objc .
In particular, STAB entries are handled correctly now, 
the method isExtern() is fixed (N_PEXT bit should not affect it, e.g. symbols with N_PEXT bit set but without N_EXT should be treated as local symbols, this behavior has been verified on multiple binaries (using the information from the load command LC_DYSYMTAB).

2. This (1) also fixes the construction of the symbol table since it relies on the correct ordering of symbols (local < defined external < undefined external).

To verify this functionality a new test (symbol-table.test) is introduced. The test is based on a real-world tiny binary (containing 18 symbols, 13 are compiler-generated) from which everything except the symbol table and the sections has been removed.

Test plan: make check-all


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78888

Files:
  llvm/test/tools/llvm-objcopy/MachO/symbol-table.test
  llvm/tools/llvm-objcopy/MachO/Object.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78888.260190.patch
Type: text/x-patch
Size: 14673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/2373d1f4/attachment.bin>


More information about the llvm-commits mailing list