欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

gdb调试动态链接 _start位置

程序员文章站 2022-05-27 09:22:19
...
#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


aaa@qq.com ~ $ 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

gdb调试动态链接 _start位置

地址: 0x7ffff7dd6093并没有加载到继承的地址空间,应该是放到了加载器的空间里面,此处待补充

相关标签: 调试