【问题标题】:Why is the address of __libc_start_main always the same inside GDB even though ASLR is on?为什么即使 ASLR 开启,__libc_start_main 的地址在 GDB 中总是相同的?
【发布时间】:2020-01-16 15:02:26
【问题描述】:
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,为什么?怎么了?

【问题讨论】:

  • 地址空间随机化是否也随机化函数地址或仅随机化变量地址?
  • 如果您启动一个新的 gdb 会话来检查地址,而不是在同一个 gdb 会话中重新运行程序,您会看到相同的结果吗?
  • @JohnBollinger 我已经试过了

标签: c linux gdb libc aslr


【解决方案1】:

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

set disable-randomization off

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-08
    • 2014-09-19
    • 2020-10-02
    • 1970-01-01
    • 2021-09-13
    • 1970-01-01
    • 2017-07-02
    相关资源
    最近更新 更多