为什么在符号地址而不是指定地址处中断?

时间:2020-06-10 13:07:23

标签: debugging assembly gdb x86-64

具有:

0000000000001135 <f1>:
    1135:   55                      push   %rbp
    1136:   48 89 e5                mov    %rsp,%rbp
    1139:   c7 45 fc 01 00 00 00    movl   $0x1,-0x4(%rbp)
    1140:   c7 45 f8 02 00 00 00    movl   $0x2,-0x8(%rbp)
    1147:   c7 45 f4 03 00 00 00    movl   $0x3,-0xc(%rbp)
    114e:   90                      nop
    114f:   5d                      pop    %rbp
    1150:   c3                      retq  
    ....

我想在起始地址(0x0000000000001135)处打断 gdb:

Reading symbols from a.out...done.
(gdb) break *0x0000000000001135
+break *0x0000000000001135
Breakpoint 1 at 0x1135: file a.c, line 3.
(gdb) layout asm
+layout asm
(gdb) r
+r
Starting program: /home/shepherd/Desktop/bin/a.out 

[4]+  Stopped                 gdb -q -tui a.out

结果:明确指定地址后崩溃。

但是,被用作符号,没问题: 从a.out ... done中读取符号。

(gdb) layout asm
+layout asm
(gdb) break *f1
+break *f1
Breakpoint 1 at 0x1135: file a.c, line 3.
(gdb) r
+r
Starting program: /home/shepherd/Desktop/bin/a.out 

Breakpoint 1, f1 () at a.c:3
(gdb) si
+si
(gdb) 
...

我观察了两个地址。在break *f1之前和break *f1之后。第一个是0x0000000000001135。之后是 0x555555555135 <f1>。那么gdb为什么要说谎呢?以及如何找出要使用的内容?

0 个答案:

没有答案