当我尝试获取.debug_line
部分的内容时,我使用了诸如decodedline
获取可读格式之类的命令。但是当我试图深入研究结果的细节时,我无法理解为什么会有单行号映射到多个起始地址。我们应该将这个起始地址标识为什么?
File name Line number Starting address View Stmt
bof.c 6 0x1189 x
bof.c 6 0x1189 1
bof.c 7 0x118d x
bof.c 7 0x118d 1
bof.c 8 0x1192
bof.c 10 0x1193 x
bof.c 10 0x1193 1
bof.c 10 0x119d
以上是 的结果readelf --debug=decodedline ./bof
。以下是起始地址的源代码和对应的汇编语言(intel)。
bof源代码:
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdbool.h>
5
6 bool check(int lenofbuf, int input) {
7 return input <= lenofbuf ? true : false;
8 }
9
10 int main(int argc, char** argv) {
11 if (argc != 2) {
12 printf("Arguments: <buffer input>\n");
13 exit(1);
14 }
...
汇编语言:
0000000000001189 <check>:
check():
/home/xxx/Desktop/angr/research/bof/bof1-afterpatch/./bof.c:6
1189: f3 0f 1e fa endbr64
/home/xxx/Desktop/angr/research/bof/bof1-afterpatch/./bof.c:7
118d: 39 fe cmp esi,edi
118f: 0f 9e c0 setle al
/home/xxx/Desktop/angr/research/bof/bof1-afterpatch/./bof.c:8
1192: c3 ret
0000000000001193 <main>:
main():
/home/xxx/Desktop/angr/research/bof/bof1-afterpatch/./bof.c:10
1193: f3 0f 1e fa endbr64
1197: 50 push rax
1198: 58 pop rax
1199: 48 83 ec 18 sub rsp,0x18
119d: 64 48 8b 04 25 28 00 mov rax,QWORD PTR fs:0x28
11a4: 00 00
11a6: 48 89 44 24 08 mov QWORD PTR [rsp+0x8],rax
11ab: 31 c0 xor eax,eax
/home/xxx/Desktop/angr/research/bof/bof1-afterpatch/./bof.c:11
11ad: 83 ff 02 cmp edi,0x2
11b0: 75 49 jne 11fb <main+0x68>
...
对于上面的示例,第 10 行映射到0x1193
和0x119d
。谁能帮我解释一下这个原因?谢谢。