GDB - 断点地址 [英] GDB - Address of breakpoint

查看:49
本文介绍了GDB - 断点地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个简单的汇编代码,现在我正在尝试使用 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

请注意,0x64e0x000055555555464e 在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆