I'm using a 32-bit x86 Ubuntu desktop. I looked at the /proc/[pid]/mmaps, and found the stack base address always changes (e.g. 0xbfe76000 in the following case). So I guess the kernel (or the ELF loader) must randomize the stack location every time the process starts.
I'm wondering what/where is the exact code (in kernel or ELF loader) for the stack base address randomization. Cause I want to allocate (e.g. via mmap) a few pages right below 0xC0000000, and I'm just not sure whether there is any possibility the stack could be located at, let's say, 0xbffff000. Thank you!
... ...
b7762000-b7763000 rw-p 00020000 fc:00 1188263 /lib/i386-linux-gnu/ld-2.19.so
bfe55000-bfe76000 rw-p 00000000 00:00 0 [stack]