Search code examples
x86elfaslrposition-independent-code

Does ASLR affect the maps file?


Does ASLR affect the maps file? AFAIK the default virtual address for the text segment is 0x400000 for 64-bit binaries, but while parsing the /proc/pid/maps file I found that the OS was apparently using random addresses for the text and data segments, namely:

564992f16000-564992f17000 r-xp 00000000 00:2c 306966 /tmp/foo 564993116000-564993117000 r--p 00000000 00:2c 306966 /tmp/foo 564993117000-564993118000 rw-p 00001000 00:2c 306966 /tmp/foo

Can someone explain what is going on here?


Solution

  • If the main program is PIE (Position-Independent Executable), its load address will be randomized as well. Even disabling ASLR (say by running under GDB with defaults) will not return it to 0x400000, it will typically be address 0x555555554000 (but this could depend on the kernel).