#include <stdio.h>
int main()
{
int a = 0x55;
printf("%d hellow world!\n", a);
while (1) {
};
return a;
}
動態鏈接文件的調試,
gcc -g -o test test.c
因爲動態鏈接方式,readelf 到的entry point並不是真正的入口點
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x540
Start of program headers: 64 (bytes into file)
Start of section headers: 8584 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 34
Section header string table index: 33
運行之後,查看 cat /proc/xxx/maps
xxxxxx@pc ~ $ cat /proc/19970/maps
55e468aa3000-55e468aa4000 r-xp 00000000 08:01 1835098 /home/guozheng.li/test
55e468ca3000-55e468ca4000 r--p 00000000 08:01 1835098 /home/guozheng.li/test
55e468ca4000-55e468ca5000 rw-p 00001000 08:01 1835098 /home/guozheng.li/test
55e46936b000-55e46938c000 rw-p 00000000 00:00 0 [heap]
7f2ced069000-7f2ced250000 r-xp 00000000 08:01 8786634 /lib/x86_64-linux-gnu/libc-2.27.so
7f2ced250000-7f2ced450000 ---p 001e7000 08:01 8786634 /lib/x86_64-linux-gnu/libc-2.27.so
7f2ced450000-7f2ced454000 r--p 001e7000 08:01 8786634 /lib/x86_64-linux-gnu/libc-2.27.so
7f2ced454000-7f2ced456000 rw-p 001eb000 08:01 8786634 /lib/x86_64-linux-gnu/libc-2.27.so
7f2ced456000-7f2ced45a000 rw-p 00000000 00:00 0
7f2ced45a000-7f2ced481000 r-xp 00000000 08:01 8786606 /lib/x86_64-linux-gnu/ld-2.27.so
7f2ced63d000-7f2ced63f000 rw-p 00000000 00:00 0
7f2ced681000-7f2ced682000 r--p 00027000 08:01 8786606 /lib/x86_64-linux-gnu/ld-2.27.so
7f2ced682000-7f2ced683000 rw-p 00028000 08:01 8786606 /lib/x86_64-linux-gnu/ld-2.27.so
7f2ced683000-7f2ced684000 rw-p 00000000 00:00 0
7fff0b379000-7fff0b39b000 rw-p 00000000 00:00 0 [stack]
7fff0b3b8000-7fff0b3bb000 r--p 00000000 00:00 0 [vvar]
7fff0b3bb000-7fff0b3bd000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
開始進入gdb
地址: 0x7ffff7dd6093並沒有加載到繼承的地址空間,應該是放到了加載器的空間裏面,此處待補充