[PATCH] D80177: [lld-macho] Set __PAGEZERO size to 4GB

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 19 13:44:48 PDT 2020


smeenai requested changes to this revision.
smeenai added a comment.
This revision now requires changes to proceed.

Thanks for fixing this! It'll make it way easier to compare results with ld64.

Requesting changes cos I think we're gonna mess up entryoff as this stands, and we definitely need to add test coverage for that.



================
Comment at: lld/MachO/Target.h:28
+  PageZeroSize = 1ull << 32, // XXX should be 4096 for 32-bit targets
   ImageBase = 4096,
   MaxAlignmentPowerOf2 = 32,
----------------
It's really confusing to have PageZeroSize and ImageBase be different, and for that matter, to have both of them.

With this diff, we're only using ImageBase in one place: https://github.com/llvm/llvm-project/blob/master/lld/MachO/Writer.cpp#L171. From looking into LC_MAIN, it seems like the entryoff is supposed to be an offset in the file rather than a virtual address, so computing it in terms of `getVA` is confusing. We should also fix that and then get rid of either ImageBase or PageZeroSize.

For that matter, is our LC_MAIN entryoff calculation gonna be correct after this? I have a hard time imagining that, and we don't have any tests for it :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80177





More information about the llvm-commits mailing list