[PATCH] D58426: llvm-objcopy: Change sectionWithinSegment() to use virtual addresses instead of file offsets.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 03:20:37 PDT 2019


jhenderson added a subscriber: bd1976llvm.
jhenderson added a comment.
Herald added a reviewer: jhenderson.

My thought on this is that file offsets are generally better, but as pointed out by @bd1976llvm pointed out on the mailing list, a recent discussion on the gABI mailing list shows that SHT_NOBITS section offsets should be considered meaningless and ignored. That means that we can only use addresses for determining NOBITS section parentalness.

It is perfectly valid to put non-alloc sections in segments, (and indeed, I have made changes to that effect recently), just they don't make much sense in PT_LOAD segments. A loader or binary utility can read the program headers to find information in the ELF without having to rely on section headers, which might have been stripped (see the purpose of PT_NOTE for example). Such sections/segments will have no address, but clearly a section can be determined to be in the segment via its file offset.

Conclusion:
I think we should continue to rely on offsets for all sections EXCEPT SHT_NOBITS sections, which instead use the address field. We might still need some special-case logic for PT_TLS/.tbss, and possibly for zero-file-sized segments but this will otherwise work, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58426





More information about the llvm-commits mailing list