首页 > 解决方案 > 为什么即使 ASLR 开启,__libc_start_main 的地址在 GDB 中总是相同的?

问题描述

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,但是我发现 的地址__libc_start_main()总是0x00007ffff7de8060在我的 Linux 机器上,为什么?怎么了?

标签: clinuxgdblibcaslr

解决方案


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

set disable-randomization off

推荐阅读