[PATCH] D76839: [lld-macho] Extend SyntheticSections to cover all segment load commands

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 01:36:51 PDT 2020


int3 added inline comments.


================
Comment at: lld/MachO/InputSection.cpp:24
 
+uint32_t InputSection::getFileOffset() const {
+  return parent->fileOff + addr - parent->firstSection()->addr;
----------------
ruiu wrote:
> int3 wrote:
> > ruiu wrote:
> > > It is safer to use uint64_t to represent file offsets. At least on Linux, we actually create binaries that are larger than 4 GiB.
> > Sections are limited to 32-bit file offsets even in 64-bit MachO binaries. Even hidden sections addressed by e.g. LC_DYLD_LOAD_INFO must be 32-bit. Segments can have 64-bit file offsets though... so I've changed fileOff in OutputSegment but kept this 32-bit.
> For PE/COFF, we are using uint64 as file offsets at least in some part of the code instead of uint32 even though PE/COFF file is limited to <4GiB, because it makes it easy to find errors when we are creating a file that is too large. If we are using 32-bit integers, we need to have an error check for integer wraparound at many places, but if we are using 64-bit integers, we can just proceed until we create an actual file and then we can do an error check at that point.
> 
> I don't know if that technique is useful to this particular function, but that's something you want to keep in mind.
Good point :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76839





More information about the llvm-commits mailing list