[PATCH] D78898: [llvm-objcopy][MachO] Avoid accidental invalid relocations in tests

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 00:29:27 PDT 2020


alexshap created this revision.
alexshap added reviewers: seiya, MaskRay, smeenai, jhenderson.
Herald added a reviewer: rupprecht.
Herald added a subscriber: abrachet.
Herald added a project: LLVM.
alexshap edited the summary of this revision.
alexshap edited the summary of this revision.

Until recently yaml2obj didn't properly support relocations for MachO and whenever it saw nreloc != 0 and reloff != 0 it was populating those bytes with 0s. This behavior results in binaries having invalid relocations, e.g. if r_extern == 0 then r_symbolnum should be >= 1 (because in this case r_symbolnum is supposed to be an index of a section and for MachO section indices start from 1), but it's equal to 0. 
In this diff we adjust the existing tests (for the tests which don't actually look at any relocations at all - we remove them 
(this causes the binary to shrink a little bit),  for the tests which essentially depend on relocations - we fix them).
This change is a preparation to unblock https://reviews.llvm.org/D71647 .

Test plan: make check-all


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78898

Files:
  llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
  llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-32-copy.test
  llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-64-copy.test
  llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-32-copy.test
  llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-64-copy.test
  llvm/test/tools/llvm-objcopy/MachO/strip-debug.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78898.260220.patch
Type: text/x-patch
Size: 10077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/8230440a/attachment.bin>


More information about the llvm-commits mailing list