没有符号信息时,如何使用 GDB 为 x86 程序集设置断点?
How to set breakpoint using GDB for x86 assembly when no symbol information is present?
当没有符号信息时,如何使用 GDB 为 x86 汇编代码设置断点,即无法编写 b *_start
.
我想立即停止执行,但是写b *0
不是很有用,因为这会在地址0
处停止执行,但我需要在地址[=]处中断执行13=] 相对于起始点(当没有符号信息时是未知的)。
使用类似objdump -f
的东西来显示入口点地址的数值。或者 inside gdb, info files
will show you the entry point.
Copy/paste 将该值放入 gdb 命令中:b *0x...
在入口点中断。然后您可以从那里单步执行。
另请参阅 x86 标签 wiki 的底部,了解一些 asm 调试技巧,例如 layout reg
。
来自 objdump -f
的示例输出:
/bin/ls: file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000404870 <<---- copy this address
而不是寻找入口点地址
b *0
将在 gdb 尝试设置断点时导致错误。这导致在任何指令执行之前在入口点停止。删除伪造的断点(否则当您尝试单步执行或继续时它会一直出错)。
Stopping at the first machine code instruction in GDB
当没有符号信息时,如何使用 GDB 为 x86 汇编代码设置断点,即无法编写 b *_start
.
我想立即停止执行,但是写b *0
不是很有用,因为这会在地址0
处停止执行,但我需要在地址[=]处中断执行13=] 相对于起始点(当没有符号信息时是未知的)。
使用类似objdump -f
的东西来显示入口点地址的数值。或者 inside gdb, info files
will show you the entry point.
Copy/paste 将该值放入 gdb 命令中:b *0x...
在入口点中断。然后您可以从那里单步执行。
另请参阅 x86 标签 wiki 的底部,了解一些 asm 调试技巧,例如 layout reg
。
来自 objdump -f
的示例输出:
/bin/ls: file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000404870 <<---- copy this address
而不是寻找入口点地址
b *0
将在 gdb 尝试设置断点时导致错误。这导致在任何指令执行之前在入口点停止。删除伪造的断点(否则当您尝试单步执行或继续时它会一直出错)。
Stopping at the first machine code instruction in GDB