Why is the address of __libc_start_main always the same inside GDB even though ASLR is on?

痞子三分冷 提交于 2020-02-29 10:08:38

问题


Breakpoint 1, 0x00007ffff7de8060 in __libc_start_main () from /usr/lib/libc.so.6
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/firstlove/projects/org-ioslide/example/a.out 

Breakpoint 1, 0x00007ffff7de8060 in __libc_start_main () from /usr/lib/libc.so.6
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/firstlove/projects/org-ioslide/example/a.out 

Breakpoint 1, 0x00007ffff7de8060 in __libc_start_main () from /usr/lib/libc.so.6
(gdb) Quit
(gdb) quit
A debugging session is active.

        Inferior 1 [process 16372] will be killed.

Quit anyway? (y or n) y
firstlove-pc% cat /proc/sys/kernel/randomize_va_space
2

IIUC, ASLR should randomize all address, including the one of libc.so, but I found that the address of __libc_start_main() is always 0x00007ffff7de8060 on my Linux machine, why? What is wrong?


回答1:


When you run a program inside gdb, gdb tries to help you debugging by disabling address randomization. You can use the following command to enable it (effective from the next run of the program):

set disable-randomization off


来源:https://stackoverflow.com/questions/59772399/why-is-the-address-of-libc-start-main-always-the-same-inside-gdb-even-though-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!