Like "malloc" in the first 4GB on x86_64

Platform: Mac OS X
Lang: Obj-C / C

Is it possible to somehow make "malloc" to allocate memory in the first 4 GB of the process address space?

I am emulating an i386 stack and must ensure that this address is within the valid 32 bit range.

Using mmap + MAP_FIXED requires WRITING memory before any "malloc", this is not entirely convenient. "malloc" with restrictions will be much more convenient.

+4
source share
1 answer

, malloc ( malloc, ).

malloc -s mmap ( sbrk) syscalls (., , syscalls (2) Linux (3) MacOSX), (, - ASLR, ).

PS. Linux mmap (2) MAP_NORESERVE MAP_32BIT, MacOSX mmap (2), , .

+5

All Articles