Why does memory mapping change in GDB after
For instance, the main function below is initially at 0x00000560 and then after
run it is at 0x80000560.
Is it possible to run/configure gdb the way it shows real mapping from the beginning?
Reading symbols from prog...(no debugging symbols found)...done. (gdb) disas main Dump of assembler code for function main: 0x00000560 : push %ebp 0x00000561 : mov %esp,%ebp 0x00000563 : sub $0x10,%esp 0x00000566 : call 0x580 0x0000056b : add $0x1a95,%eax 0x00000570 : movl $0x0,-0x4(%ebp) 0x00000577 : addl $0x1,-0x4(%ebp) 0x0000057b : mov -0x4(%ebp),%eax 0x0000057e : leave 0x0000057f : ret End of assembler dump. (gdb) run Starting program: /home/mike/gdb/prog [Inferior 1 (process 9607) exited with code 01] (gdb) disas main Dump of assembler code for function main: 0x80000560 : push %ebp 0x80000561 : mov %esp,%ebp 0x80000563 : sub $0x10,%esp 0x80000566 : call 0x80000580 0x8000056b : add $0x1a95,%eax 0x80000570 : movl $0x0,-0x4(%ebp) 0x80000577 : addl $0x1,-0x4(%ebp) 0x8000057b : mov -0x4(%ebp),%eax 0x8000057e : leave 0x8000057f : ret End of assembler dump.
For instance, the main function below is initially at 0x00000560 and then after run it is at 0x80000
You have a position-independent executable (really just a special kind of shared library, linked with
-pie flag). It is relocated to a random address before it starts executing.
Note that GDB will usually try to disable address randomization, so the random address will not actually vary from run to run under GDB. However, it will vary when the program is run outside of GDB, or if you use
(gdb) set disable-randomization off.
User contributions licensed under CC BY-SA 3.0