[PATCH] D118570: [lld-macho] Add support for -image_base, -static, -pagezero_size, and -version_load_command

Jared Irwin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 31 07:22:42 PST 2022


Link1J added inline comments.


================
Comment at: lld/MachO/Writer.cpp:49
 public:
-  Writer() : buffer(errorHandler().outputBuffer) {}
+  Writer() : buffer(errorHandler().outputBuffer), addr(config->imageBase) {}
 
----------------
int3 wrote:
> from what I understand, `-image_base` should control the address of the mach header, but setting `addr` here means that we're setting the start address of `__PAGEZERO` instead, which doesn't seem right
> 
> Also, I wonder what happens when `-image_base` points to an address within the `__PAGEZERO` segment...
>From the testing I had done, I thought it was setting the start address for `__PAGEZERO`. I did more testing, and found it is not.

And if `-image_base` is inside the `__PAGEZERO`, it prints out the section list, says the last non `__LINKEDIT` section overlaps the `__PAGEZERO`, and doesn't output anything. I think we could do better, because ld64 error message doesn't even say error anywhere in it. 


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

https://reviews.llvm.org/D118570



More information about the llvm-commits mailing list