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

标签 linux assembly gdb

我正在使用 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/

相关文章:

c - 我应该使用什么方法来设置调度优先级?

c - 如何在 gdb 中 fork() ed 的不同进程之间切换?

c++ - x86 - 为什么编译器会在下一条指令中插入看似无意义的 JMP?

linux - 如何在 x86_64 程序集中打印字符串

python - gdb python : How to do arithmetic operation on a gdb. 值?

gdb - 在不创建文件的情况下将 gdb 与管道输入一起使用

linux - 匹配目录中的目录

c - mktime() 奇怪地改变了日期

linux - Yocto/i.Mx.6 : How to support touch on touchscreen monitor

c++ - 汇编如何做参数传递: by value,引用,不同类型/数组的指针?