gpt4 book ai didi

linux - 指令内存地址是否改变?

转载 作者:太空宇宙 更新时间:2023-11-04 09:15:24 25 4
gpt4 key购买 nike

我正在使用 gdb 反汇编 my_fun

#    0x7ffff5792a60 <PRIVATE0000000000579168>:  push   %r12
# => 0x7ffff5792a62 <PRIVATE0000000000579168+2>: push %r13
# 0x7ffff5792a64 <PRIVATE0000000000579168+4>: push %r14

我注意到指令的内存位置,例如0x7ffff5792a60 在不同的 gdb 调试 session 中是相同的。

这怎么可能?它是一个虚拟内存地址吗?我们保证有相同的内存地址吗?这取决于应用程序的编译方式吗?

最佳答案

I notice that the memory location of instructions e.g. 0x7ffff5792a60 is the same in different gdb debug sessions.

这是真的,因为默认情况下 gdb 禁用虚拟地址空间的随机化。您可以尝试使用 set disable-randomization off 启用随机化,您可能会在地址 0x7ffff5792a60 处看到另一条指令。参见 documentation :

set disable-randomization on

This option (enabled by default in GDB) will turn off the native randomization of the virtual address space of the started program. This option is useful for multiple debugging sessions to make the execution better reproducible and memory addresses reusable across debugging sessions.

关于linux - 指令内存地址是否改变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48444346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com