macOS 11 ARM64: allocate memory in 32-bit address space

On x86_64 we can build application with -pagezero_size 10000 linker flag and perform mmap to allocate memory with 32-bit address in pointer, like this:
mmap(start, size, PROT_NONE, (MAP_PRIVATE | MAP_FIXED | MAP_EXCL |(MAP_PRIVATE | MAP_FIXED | MAP_EXCL)), -1, 0);

But if we build application targeting arm64-apple-macos11 with -pagezero_size 10000 we will got "Malformed Mach-o file" error

In other case, with -pagezero_size 100010000 application executes success

Does new macOS kernel mach loader limit vmsize of __PAGEZERO segment to minimal size 0x100000000 for arm64?

P.S. Sory for my English

Replies

I'm facing the same problem. Can I just ignore -pagezero_size 10000 linker flag when building for arm64? Is there more information on this issue?
Modifying pagezero_size isn't a supportable option in the arm64 environment. arm64 code must be in an ASLR binary, which using a custom pagezero_size is incompatible with. An ASLR binary encodes signed pointers using a large random size along with the expected page zero size, and this combination is going to extend beyond the range of values covered in the lower 32-bits. Further, even if that did work, 32-bit pointers are completely incompatible with the arm64e architecture, which is available as a preview technology.

To move forward, you should look at getting your library compiled natively for arm64, and remove the assumptions and needs that require you to address the lower 32-bits.