Force gdb to load shared library at randomized address

Is there any way to disable this gdb’s feature? Yes, you can set disable-randomization off before running the program. See this part of gdb documentation: set disable-randomization off Leave the behavior of the started executable unchanged. Some bugs rear their ugly heads only when the program is loaded at certain addresses. If your bug disappears … Read more

Disable and re-enable address space layout randomization only for myself

The best way to disable locally the ASLR on a Linux-based system is to use processes personality flags. The command to manipulate personality flags is setarch with -R, –addr-no-randomize Disables randomization of the virtual address space (turns on ADDR_NO_RANDOMIZE). Here is how to proceed: $> setarch $(uname -m) -R /bin/bash This command runs a shell … Read more

Address canonical form and pointer arithmetic

The canonical address rules mean there is a giant hole in the 64-bit virtual address space. 2^47-1 is not contiguous with the next valid address above it, so a single mmap won’t include any of the unusable range of 64-bit addresses. +———-+ | 2^64-1 | 0xffffffffffffffff | … | | 2^64-2^47| 0xffff800000000000 +———-+ | | … Read more

What is the -fPIE option for position-independent executables in gcc and ld?

PIE is to support address space layout randomization (ASLR) in executable files. Before the PIE mode was created, the program’s executable could not be placed at a random address in memory, only position independent code (PIC) dynamic libraries could be relocated to a random offset. It works very much like what PIC does for dynamic … Read more