为什么即使ASLR开启,__ libc_start_main的地址在GDB中也总是相同的?


16
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应该随机化所有地址,包括其中之一libc.so,但是我发现Linux 的地址__libc_start_main()始终0x00007ffff7de8060在我的Linux机器上,为什么?怎么了?


1
地址空间随机化还会随机化函数地址还是仅随机化变量地址?
rubenvb

如果启动一个用于检查地址的新gdb会话,而不是在同一gdb会话中重新运行该程序,是否会看到相同的结果?
John Bollinger

@JohnBollinger我已经尝试了
陈力

Answers:


24

当您在内部运行程序时gdbgdb尝试通过禁用地址随机化来帮助您进行调试。您可以使用以下命令启用它(从程序的下一次运行开始生效):

set disable-randomization off
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.