[PATCH] D90796: [llvm-objcopy][MachO] Skip sections with zero offset

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 09:00:04 PST 2020


alexshap added a comment.

In D90796#2375510 <https://reviews.llvm.org/D90796#2375510>, @jhenderson wrote:

> I'm not an expert, but seems reasonable to me.
>
>> previously the tool would allocate file space for them.
>
> This confused me a little - what file space did the tool actually allocate for a zero-sized section? Alignment padding?

When the tool builds the final layout it allocates segments, these "zombie" sections (with zero size and zero original offset) still have valid addresses (objcopy doesn't change virtual addresses, only recalculates offsets / sizes). Then the following effect takes place: if a segment's address is A, but it contains a section with address B > A, then the size of this segment has to be at least (B - A) (simplified picture, the actual logic which takes into account alignment, padding etc is in the class MachOLayoutBuilder), this also affects the offsets of the segments which go after this one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90796/new/

https://reviews.llvm.org/D90796



More information about the llvm-commits mailing list