When I tried to get the content of .debug_line
section, I used the commands like decodedline
to get the readable format. But when I tried to dig into the details of the results, I could not understand the reason why there would be single line number mapped to multiple starting address. What should we identify this starting address as?
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
The above is the result of readelf --debug=decodedline ./bof
. Following are the source code and the corresponding assembly language (intel) of starting address.
Source code of 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 }
...
Assembly language:
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>
...
As for the example above, line number 10 is mapped to 0x1193
and 0x119d
. Can anyone help me to explain the reason for this? Thanks.