我正在调试早期的Linux内核程序集,而GDB似乎没有在正确的地址上设置断点。 objdump显示函数的地址:
c0008778 <__lookup_processor_type>:
GDB似乎正确地知道符号地址,但在设置断点时使用了错误的地址:
(gdb) print __lookup_processor_type
$1 = {<text variable, no debug info>} 0x8778 <__lookup_processor_type>
(gdb) break __lookup_processor_type
Breakpoint 2 at 0x877c: file arch/arm/kernel/head-common.S, line 154.
在正确的地址有一条汇编指令:
c0008778: e28f3030 add r3, pc, #48 ; 0x30
手动设置断点工作正常:
(gdb) break *0x8778
Breakpoint 3 at 0x8778: file arch/arm/kernel/head-common.S, line 153.
(gdb) cont
Continuing.
Breakpoint 3, __lookup_processor_type () at arch/arm/kernel/head-common.S:153
153 adr r3, __lookup_processor_type_data
为什么GDB拒绝在正确的地址设置断点?
如果它是相关的,这是我如何加载符号表。 Objdump报告了这些部分:
Idx Name Size VMA LMA File off Algn
0 .head.text 00000220 c0008000 c0008000 00008000 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text 00470acc c0008240 c0008240 00008240 2**6
CONTENTS, ALLOC, LOAD, READONLY, CODE
我在GDB中加载符号:
add-symbol-file vmlinux 0x8240 -s .head.text 0x8000