It is specified that when using mmap
with NULL
addr, the kernel chooses the (page-aligned) address at which to create the mapping:
mmap() creates a new mapping in the virtual address space of the calling process. The starting address for the new mapping is specified in addr. The length argument specifies the length of the mapping (which must be greater than 0). If addr is NULL, then the kernel chooses the (page-aligned) address at which to create the mapping; this is the most portable method of creating a new mapping.
Supposing I have the code below :
void (*x)(void);
void (*y)(void);
x=mmap(NULL, 0x500, PROT..., FLAGS..., FD..., 0);
y=mmap(NULL, 0x500, PROT..., FLAGS..., FD..., 0);
Does it means that y
will follow just after x
?
Thanks.
No, it does not say anything about the relative positioning of the mappings so you can't make any assumptions about it. Treat each mapping as completely separate from all others.