That's what ld64 uses for 64-bit targets. I figured it's best
to make this change sooner rather than later since a bunch of our tests
are relying on hardcoded addresses that depend on this value.
Depends on D80169.
Differential D80177
[lld-macho] Set __PAGEZERO size to 4GB int3 on May 18 2020, 9:09 PM. Authored by
Details That's what ld64 uses for 64-bit targets. I figured it's best Depends on D80169.
Diff Detail
Event TimelineComment Actions 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 Actions Looks great, thanks!
Comment Actions Thanks for the heads up, just pushed a likely fix and will monitor http://lab.llvm.org:8011/builders/lld-x86_64-win. I'll set up a local Windows VM to catch future such issues earlier... Comment Actions @int3, can you please point out the fix you pushed? The tests are failing downstream, and I am looking for the commit that fixes it. Moreover, in the head llvm-project there are still issues for 32-bit host builds: enum : uint64_t { ... PageZeroSize = 1ull << 32, // XXX should be 4096 for 32-bit targets ... }; PageZeroSize is a 64-bit constant, but it is being returned as size_t, which is 4 bytes for 32-bit hosts: class PageZeroSection : public SyntheticSection { ... size_t getSize() const override { return PageZeroSize; } ... Could you please fix this? Comment Actions rGd767de44bf9527cb5058f5fe16aac2f23c21977c was the referenced fix. Good point about size_t, I'll change that Comment Actions Thanks. The enum change does not fix the fails on my side. I guess it has to be the size_t issue. |
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 :/