[PATCH] D91152: [obj2yaml] - Dump section offsets in some cases.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 06:14:58 PST 2020


grimar added a comment.

In D91152#2390116 <https://reviews.llvm.org/D91152#2390116>, @MaskRay wrote:

> In D91152#2388533 <https://reviews.llvm.org/D91152#2388533>, @grimar wrote:
>
>> In D91152#2388491 <https://reviews.llvm.org/D91152#2388491>, @jhenderson wrote:
>>
>>> Doesn't the behaviour of a SHT_NOBITS section depend on whether it is a non-last member of a segment? IIRC, SHT_NOBITS sections in a segment which are last do not need file space, but to ensure correct addresses for sections appearing after them in a segment, they are allocated filespace by a linker if non-NOBITS appear after them in the same segment. (The behaviour you're doing here looks fine for when such sections are not inside segments, e.g. for ET_REL objects).
>>
>> True. But how much necessary to support this case now? The problem is that we at first dump sections and then dump program headers.
>> To implement the precise behavior, I think we need to delay assigning offsets to be able to call `shouldAllocateFileSpace`, which does the job:
>
> In `dumpProgramHeaders` we call `isInSegment` to know the parent segment of a section. If we move the logic earlier before `setOffsets`, we can refine the computation of the expected sh_offset.
> With a containing PT_LOAD, sh_offset should equal its address modulo p_align.

This should work, but it introduces the depencency on the VA. Perhaps I'd try to avoid adding more dependencies. I don't have a strong opinion though,
but I have a feeling that just delaying of the offsets assigning migth look a bit simpler (or at least not that bad as it sounds). Going to try to see how it will look like.


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

https://reviews.llvm.org/D91152



More information about the llvm-commits mailing list