GDB-断点地址 [英] GDB - Address of breakpoint
问题描述
我编写了一个简单的汇编代码,现在我正尝试使用gdb对其进行调试.
I scripted a simply assembly code, and now i'm trying to debug it using gdb.
在gdb中,我输入了:
In gdb i typed :
(gdb) break _start
Breakpoint 1 at 0x4000b0
断点地址(0x4000b0)是否相对于代码行的硬盘存储位置?还是仅与程序长度有关? (我认为目前程序仍未加载到RAM中)
Is the breakpoint address (0x4000b0) relative to the hard-disk memory location of the code line ? Or is it only relative to the program length ? (I think that at this point the program is still not loaded in RAM)
推荐答案
这是RAM中的虚拟地址.您有一个与位置相关的可执行文件,因此将加载到的绝对地址就在ELF元数据中. (您可以使用readelf my_program
或GDB命令info files
.)
It's a virtual address in RAM. You have a position-dependent executable, so the absolute address it will be loaded to is right there in the ELF metadata. (you can use readelf my_program
, or the GDB command info files
.)
如果您具有PIE可执行文件并在启动前设置了断点,则GDB将为您提供尚未重定位的断点地址,因此文件的第一个字节被视为地址0
.例如
If you had a PIE executable and set a breakpoint before starting it, GDB will give you a breakpoint address that isn't relocated yet, so the first byte of the file is treated as address 0
. e.g.
(gdb) b main
Breakpoint 1 at 0x64e: file hello.c, line 3.
(gdb) run
Starting program: /tmp/hello
Breakpoint 1, main () at hello.c:3
(gdb) info br
Num Type Disp Enb Address What
1 breakpoint keep y 0x000055555555464e in main at hello.c:3
breakpoint already hit 1 time
请注意,0x64e
和0x000055555555464e
在4k页面中具有相同的偏移量,因为文件已映射到页面对齐的地址.
Note that 0x64e
and 0x000055555555464e
have the same offset within a 4k page, because the file gets mapped to a page-aligned address.
这篇关于GDB-断点地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!