[PATCH] D87497: [llvm-objcopy][MachO] Fix --add-section

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 01:38:26 PDT 2020


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

First, the old test wasn't triggering the code paths it was supposed to because the input binaries were actually invalid (perhaps, the result of manual trimming down of the input files) (in particular, the segment name ('') didn't match the name specified in sections).
Second, the old test tried to share the checks between 32-bit and 64-bit binaries as well as different cases, this makes much harder to reason about the expected output. 
In this diff we first fix --add-section functionality and simplify the tests organization. 
The layout algorithm for MachO (see MachOLayoutBuilder) is driven by the virtual addresses (which we never change), everything else  is recalculated. Therefore for a new section / new segment we need to assign a new vmaddr.

Test plan: make check-all


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87497

Files:
  llvm/test/tools/llvm-objcopy/MachO/add-section.test
  llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
  llvm/tools/llvm-objcopy/MachO/Object.cpp
  llvm/tools/llvm-objcopy/MachO/Object.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87497.291157.patch
Type: text/x-patch
Size: 16207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200911/b3f45008/attachment.bin>


More information about the llvm-commits mailing list