计算机系统篇之链接(8):位置无关代码(中)——真正理解 PIC 数据引用的工作原理(Linux X86-64 示例)

Author: stormQ

Created: Wednesday, 15. April 2020 04:35PM

Last Modified: Sunday, 01. November 2020 11:34AM



摘要

本文以 Linux X86-64 程序为例,利用 gdb 详细分析了位置无关代码技术中数据引用的过程,从而真正理解位置无关代码的工作原理。

研究过程

step 1: 生成共享库

1)第一个共享库的源文件——add.cpp:

int g_sum = 0;

int add(int a, int b)
{
    g_sum = a + b;
    return g_sum;
}

生成第一个共享库——libadd_debug.so

$ g++ -fpic -shared -g -o libadd_debug.so add.cpp

2)第二个共享库的源文件——sub.cpp:

int g_sub = 0;

int sub(int aint b)
{
    g_sub = a - b;
    return g_sub;
}

生成第二个共享库——libsub_debug.so

$ g++ -fpic -shared -g -o libsub_debug.so sub.cpp

step 2: 生成测试程序(用于调用以上两个共享库)——main_mix

测试程序的源文件——main_mix.cpp:

extern int add(intint);
extern int sub(intint);

int main()
{
    add(0xb0xc);
    add(0xb0xc);
    sub(0xf, 0xd);
    sub(0xf, 0xd);
    return 0;
}

生成测试程序——main_mix

$ g++ -o main_mix main_mix.cpp ./libadd_debug.so ./libsub_debug.so -g

step 3: 查看共享库的代码段

1)查看共享库libadd_debug.so的代码段

# 查看共享库中可执行的sections(包含了.text section)
$ objdump -d libadd_debug.so

输出结果为(只保留add()函数的汇编代码):

; ...... Skip

Disassembly of section .text:
; ...... Skip

0000000000000640 <_Z3addii>:
 640:    55                      push   %rbp
 641:    48 89 e5                mov    %rsp,%rbp
 644:    89 7d fc                mov    %edi,-0x4(%rbp)
 647:    89 75 f8                mov    %esi,-0x8(%rbp)
 64a:    855 fc                mov    -0x4(%rbp),%edx
 64d:    845 f8                mov    -0x8(%rbp),%eax
 650:    01 c2                   add    %eax,%edx
 652:    48 805 7f 09 20 00    mov    0x20097f(%rip),%rax        # 200fd8 <_DYNAMIC+0x158>
 659:    89 10                   mov    %edx,(%rax)
 65b:    48 805 76 09 20 00    mov    0x200976(%rip),%rax        # 200fd8 <_DYNAMIC+0x158>
 662:    800                   mov    (%rax),%eax
 664:    5d                      pop    %rbp
 665:    c3                      retq

; ...... Skip

输出结果分析:

推导过程:

a)首先查看共享库中.got section的位置

$ readelf -S libadd_debug.so

输出结果为:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
; ......
  [17] .got              PROGBITS         0000000000200fd0  00000fd0
       0000000000000030  0000000000000008  WA       0     0     8
; ......

从输出结果中可以看出,共享库中存放.got section的起始地址为0x200fd0——即共享库中.got section的起始位置相对于共享库加载地址的偏移量为0x200fd0,.got section的大小为0x30——即.got中的条目个数为6(.got的每个条目占8字节)。

b)接下来查看共享库中的重定位信息

readelf -r libadd_debug.so

输出结果为:

Relocation section '.rela.dyn' at offset 0x420 contains 9 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000200e68  000000000008 R_X86_64_RELATIVE                    610
000000200e70  000000000008 R_X86_64_RELATIVE                    5d0
000000201018  000000000008 R_X86_64_RELATIVE                    201018
000000200fd0  000200000006 R_X86_64_GLOB_DAT 0000000000000000 __cxa_finalize + 0
000000200fd8  000700000006 R_X86_64_GLOB_DAT 0000000000201024 g_sum + 0
000000200fe0  000300000006 R_X86_64_GLOB_DAT 0000000000000000 _ITM_registerTMCloneTa + 0
000000200fe8  000400000006 R_X86_64_GLOB_DAT 0000000000000000 _ITM_deregisterTMClone + 0
000000200ff0  000500000006 R_X86_64_GLOB_DAT 0000000000000000 _Jv_RegisterClasses + 0
000000200ff8  000600000006 R_X86_64_GLOB_DAT 0000000000000000 __gmon_start__ + 0

从输出结果中可以看出,共享库中全局变量g_sum相对于共享库加载地址的偏移量为0x200fd8,并且重定位方式为R_X86_64_GLOB_DATR_X86_64_GLOB_DAT的含义:一旦知道g_sum的运行时地址,就把它放入0x200fd8处(R_X86_64_GLOB_DAT:The relocation type is used to set a global offset table entry to the address of the specified symbol. The special relocation type allows one to determine the correspondence between symbols and global offset table entries.)。

c)所以可以得出,结论1:共享库libadd_debug.so中的GOT[1]条目(位于进程虚拟地址空间中的共享库的内存映射区域)是用于保存全局变量g_sum的运行时地址的

d)mov 0x20097f(%rip),%rax指令中0x20097f的计算过程:共享库中GOT[1]条目的地址(0x200fd8)减去共享模块中下一条指令(即mov %edx,(%rax))的地址(0x659),计算结果为0x20097f(这种寻址方式被称为“PC相对寻址”)——意味着共享库中GOT[1]条目与共享库中下一条指令之间的距离或偏移量为0x20097f,该偏移量在生成共享库时就可以确定,并且在加载共享库时不会发生变化。编译器这是利用了这一事实,来实现“PIC 数据引用”的。

e)mov 0x20097f(%rip),%rax指令中0x20097f(%rip)的作用:运行时%rip寄存器(即PC寄存器)中存放着下一条指令在内存中的运行时地址,0x20097f(%rip)表示以%rip寄存器的值加上0x20097f作为起始地址,并取该地址后面的8字节——即GOT[1]条目的运行时地址。接下来通过GOT[1]条目的内容——&g_sum来访问全局变量g_sum,也就是mov %edx,(%rax)(将%edx寄存器的值(存放着a+b的计算结果)赋值给全局变量g_sum)的作用。

2)同理,分析共享库libsub_debug.so后,可以得出,结论2:共享库libsub_debug.so中的GOT[1]条目(位于进程虚拟地址空间中的共享库的内存映射区域)是用于保存全局变量g_sub的运行时地址的

step 4: 分析共享库是如何访问全局变量的

1)使用 gdb(使用了GEF插件)运行测试程序——main_mix

$ gdb -q main_mix
gef➤ start

2)反汇编add函数

反汇编add函数,并在0x00007ffff7bd56520x00007ffff7bd5659处设置断点。

gef➤  disas add
Dump of assembler code for function add(intint):
   0x00007ffff7bd5640 <+0>:    push   rbp
   0x00007ffff7bd5641 <+1>:    mov    rbp,rsp
   0x00007ffff7bd5644 <+4>:    mov    DWORD PTR [rbp-0x4],edi
   0x00007ffff7bd5647 <+7>:    mov    DWORD PTR [rbp-0x8],esi
   0x00007ffff7bd564a <+10>:    mov    edx,DWORD PTR [rbp-0x4]
   0x00007ffff7bd564d <+13>:    mov    eax,DWORD PTR [rbp-0x8]
   0x00007ffff7bd5650 <+16>:    add    edx,eax
   0x00007ffff7bd5652 <+18>:    mov    rax,QWORD PTR [rip+0x20097f]        # 0x7ffff7dd5fd8
   0x00007ffff7bd5659 <+25>:    mov    DWORD PTR [rax],edx
   0x00007ffff7bd565b <+27>:    mov    rax,QWORD PTR [rip+0x200976]        # 0x7ffff7dd5fd8
   0x00007ffff7bd5662 <+34>:    mov    eax,DWORD PTR [rax]
   0x00007ffff7bd5664 <+36>:    pop    rbp
   0x00007ffff7bd5665 <+37>:    ret
End of assembler dump.
gef➤  b *0x00007ffff7bd5652
gef➤  b *0x00007ffff7bd5659

3)反汇编sub函数

反汇编sub函数,并在0x00007ffff79d36520x00007ffff79d3659处设置断点。

gef➤  disas sub
Dump of assembler code for function sub(intint):
   0x00007ffff79d3640 <+0>:    push   rbp
   0x00007ffff79d3641 <+1>:    mov    rbp,rsp
   0x00007ffff79d3644 <+4>:    mov    DWORD PTR [rbp-0x4],edi
   0x00007ffff79d3647 <+7>:    mov    DWORD PTR [rbp-0x8],esi
   0x00007ffff79d364a <+10>:    mov    eax,DWORD PTR [rbp-0x4]
   0x00007ffff79d364d <+13>:    sub    eax,DWORD PTR [rbp-0x8]
   0x00007ffff79d3650 <+16>:    mov    edx,eax
   0x00007ffff79d3652 <+18>:    mov    rax,QWORD PTR [rip+0x20097f]        # 0x7ffff7bd3fd8
   0x00007ffff79d3659 <+25>:    mov    DWORD PTR [rax],edx
   0x00007ffff79d365b <+27>:    mov    rax,QWORD PTR [rip+0x200976]        # 0x7ffff7bd3fd8
   0x00007ffff79d3662 <+34>:    mov    eax,DWORD PTR [rax]
   0x00007ffff79d3664 <+36>:    pop    rbp
   0x00007ffff79d3665 <+37>:    ret
End of assembler dump.
gef➤  b *0x00007ffff79d3652
gef➤  b *0x00007ffff79d3659

4)分析共享库libadd_debug.so是如何访问全局变量g_sum的

a)继续执行程序(断点1会被击中),查看当前运行的汇编代码

gef➤  c
gef➤  disas
Dump of assembler code for function add(intint):
   0x00007ffff7bd5640 <+0>:    push   rbp
   0x00007ffff7bd5641 <+1>:    mov    rbp,rsp
   0x00007ffff7bd5644 <+4>:    mov    DWORD PTR [rbp-0x4],edi
   0x00007ffff7bd5647 <+7>:    mov    DWORD PTR [rbp-0x8],esi
   0x00007ffff7bd564a <+10>:    mov    edx,DWORD PTR [rbp-0x4]
   0x00007ffff7bd564d <+13>:    mov    eax,DWORD PTR [rbp-0x8]
   0x00007ffff7bd5650 <+16>:    add    edx,eax
=> 0x00007ffff7bd5652 <+18>:    mov    rax,QWORD PTR [rip+0x20097f]        # 0x7ffff7dd5fd8
   0x00007ffff7bd5659 <+25>:    mov    DWORD PTR [rax],edx
   0x00007ffff7bd565b <+27>:    mov    rax,QWORD PTR [rip+0x200976]        # 0x7ffff7dd5fd8
   0x00007ffff7bd5662 <+34>:    mov    eax,DWORD PTR [rax]
   0x00007ffff7bd5664 <+36>:    pop    rbp
   0x00007ffff7bd5665 <+37>:    ret
End of assembler dump.

b)计算用于保存全局变量g_sum运行时地址的GOT条目的地址

; 执行 mov    rax,QWORD PTR [rip+0x20097f] 时,%rip寄存器(即PC寄存器)中存放着下一条指令(mov    DWORD PTR [rax],edx)的运行时地址(0x00007ffff7bd5659)。此时,打印%rip寄存器的值,会发现其值为0x00007ffff7bd5652,这是因为当前指令(最左侧带=>的)还未执行。

gef➤  p /x 0x00007ffff7bd5659+0x20097f    ; 1)计算 mov    rax,QWORD PTR [rip+0x20097f]  的下一条指令的地址(0x00007ffff7bd5659)与偏移量0x20097f相加的结果
$2 = 0x7ffff7dd5fd8                        ; 计算结果为0x7ffff7dd5fd8,即共享库libadd_debug.so中GOT[1]条目的地址为0x7ffff7dd5fd8

为什么0x7ffff7dd5fd8是共享库libadd_debug.so中GOT[1]条目的地址,这一点可以通过查看可执行文件的虚拟内存映射得到验证。

gef➤  vmmap                     ; 1)查看可执行文件的虚拟内存映射
Start              End                Offset             Perm Path
0x0000000000400000 0x0000000000401000 0x0000000000000000 r-x /home/test/Desktop/localization_sim/main_mix
0x0000000000600000 0x0000000000601000 0x0000000000000000 r-- /home/test/Desktop/localization_sim/main_mix
0x0000000000601000 0x0000000000602000 0x0000000000001000 rw- /home/test/Desktop/localization_sim/main_mix
0x00007ffff7609000 0x00007ffff77c9000 0x0000000000000000 r-x /lib/x86_64-linux-gnu/libc-2.23.so
0x00007ffff77c9000 0x00007ffff79c9000 0x00000000001c0000 --- /lib/x86_64-linux-gnu/libc-2.23.so
0x00007ffff79c9000 0x00007ffff79cd000 0x00000000001c0000 r-- /lib/x86_64-linux-gnu/libc-2.23.so
0x00007ffff79cd000 0x00007ffff79cf000 0x00000000001c4000 rw- /lib/x86_64-linux-gnu/libc-2.23.so
0x00007ffff79cf000 0x00007ffff79d3000 0x0000000000000000 rw- 
0x00007ffff79d3000 0x00007ffff79d4000 0x0000000000000000 r-x /home/test/Desktop/localization_sim/libsub_debug.so
0x00007ffff79d4000 0x00007ffff7bd3000 0x0000000000001000 --- /home/test/Desktop/localization_sim/libsub_debug.so
0x00007ffff7bd3000 0x00007ffff7bd4000 0x0000000000000000 r-- /home/test/Desktop/localization_sim/libsub_debug.so
0x00007ffff7bd4000 0x00007ffff7bd5000 0x0000000000001000 rw- /home/test/Desktop/localization_sim/libsub_debug.so
0x00007ffff7bd5000 0x00007ffff7bd6000 0x0000000000000000 r-x /home/test/Desktop/localization_sim/libadd_debug.so
0x00007ffff7bd6000 0x00007ffff7dd5000 0x0000000000001000 --- /home/test/Desktop/localization_sim/libadd_debug.so
0x00007ffff7dd5000 0x00007ffff7dd6000 0x0000000000000000 r-- /home/test/Desktop/localization_sim/libadd_debug.so
0x00007ffff7dd6000 0x00007ffff7dd7000 0x0000000000001000 rw- /home/test/Desktop/localization_sim/libadd_debug.so
0x00007ffff7dd7000 0x00007ffff7dfd000 0x0000000000000000 r-x /lib/x86_64-linux-gnu/ld-2.23.so
0x00007ffff7fd1000 0x00007ffff7fd4000 0x0000000000000000 rw- 
0x00007ffff7ff6000 0x00007ffff7ff7000 0x0000000000000000 rw- 
0x00007ffff7ff7000 0x00007ffff7ffa000 0x0000000000000000 r-- [vvar]
0x00007ffff7ffa000 0x00007ffff7ffc000 0x0000000000000000 r-x [vdso]
0x00007ffff7ffc000 0x00007ffff7ffd000 0x0000000000025000 r-- /lib/x86_64-linux-gnu/ld-2.23.so
0x00007ffff7ffd000 0x00007ffff7ffe000 0x0000000000026000 rw- /lib/x86_64-linux-gnu/ld-2.23.so
0x00007ffff7ffe000 0x00007ffff7fff000 0x0000000000000000 rw- 
0x00007ffffffdd000 0x00007ffffffff000 0x0000000000000000 rw- [stack]
0xffffffffff600000 0xffffffffff601000 0x0000000000000000 r-x [vsyscall]
gef➤  xinfo 0x7ffff7dd5fd8        ; 2)查看地址0x7ffff7dd5fd8的信息
───────────────────────────────────────────────────────────────────────────────── xinfo: 0x7ffff7dd5fd8 ─────────────────────────────────────────────────────────────────────────────────
Page: 0x00007ffff7dd5000  →  0x00007ffff7dd6000 (size=0x1000)
Permissions: r--
Pathname: /home/test/Desktop/localization_sim/libadd_debug.so
Offset (from page): 0xfd8
Inode: 4132975
Segment: .got (0x00007ffff7dd5fd0-0x00007ffff7dd6000)

从输出结果中可以看出,在可执行程序的虚拟内存映射中,共享库libadd_debug.so的.got section的虚拟内存地址范围为0x00007ffff7dd5fd0-0x00007ffff7dd6000。另外,GOT的每个条目占8字节。所以,0x7ffff7dd5fd8是共享库libadd_debug.so的GOT[1]条目的地址。

c)查看全局变量g_sum的值

gef➤  x/gx 0x7ffff7dd5fd8                ; 2)查看该GOT[1]条目的内容,即&g_sum
0x7ffff7dd5fd8:    0x00007ffff7dd6024      ; GOT[1]条目的值为0x00007ffff7dd6024,即全局变量g_sum的运行时地址为0x00007ffff7dd6024
gef➤  p /x &g_sum                        ; 3)查看全局变量g_sum的运行时地址
$3 = 0x7ffff7dd6024                        ; 打印结果也为0x7ffff7dd6024,验证了“GOT[1] = &g_sum”
gef➤  x/wx 0x00007ffff7dd6024            ; 4)查看全局变量g_sum的值
0x7ffff7dd6024 <g_sum>:    0x00000000      ; 全局变量g_sum的值为0x0(g_sum的初始值)

d)至此,验证了“结论1:共享库libadd_debug.so中的GOT[1]条目(位于进程虚拟地址空间中的共享库的内存映射区域)是用于保存全局变量g_sum的运行时地址的”

5)同理,可以分析共享库libsub_debug.so是如何访问全局变量g_sub的

6)查看可执行文件运行期的sections

gef➤  xfiles 
Start              End                Name                  File
0x0000000000400238 0x0000000000400254 .interp               /home/test/Desktop/localization_sim/main_mix
0x0000000000400254 0x0000000000400274 .note.ABI-tag         /home/test/Desktop/localization_sim/main_mix
0x0000000000400274 0x0000000000400298 .note.gnu.build-id    /home/test/Desktop/localization_sim/main_mix
0x0000000000400298 0x00000000004002d0 .gnu.hash             /home/test/Desktop/localization_sim/main_mix
0x00000000004002d0x0000000000400408 .dynsym               /home/test/Desktop/localization_sim/main_mix
0x0000000000400408 0x00000000004004e4 .dynstr               /home/test/Desktop/localization_sim/main_mix
0x00000000004004e4 0x00000000004004fe .gnu.version          /home/test/Desktop/localization_sim/main_mix
0x0000000000400500 0x0000000000400520 .gnu.version_r        /home/test/Desktop/localization_sim/main_mix
0x0000000000400520 0x0000000000400538 .rela.dyn             /home/test/Desktop/localization_sim/main_mix
0x0000000000400538 0x0000000000400580 .rela.plt             /home/test/Desktop/localization_sim/main_mix
0x0000000000400580 0x000000000040059a .init                 /home/test/Desktop/localization_sim/main_mix
0x00000000004005a0 0x00000000004005e0 .plt                  /home/test/Desktop/localization_sim/main_mix
0x00000000004005e0 0x00000000004005e8 .plt.got              /home/test/Desktop/localization_sim/main_mix
0x00000000004005f0x0000000000400782 .text                 /home/test/Desktop/localization_sim/main_mix
0x0000000000400784 0x000000000040078d .fini                 /home/test/Desktop/localization_sim/main_mix
0x0000000000400790 0x0000000000400794 .rodata               /home/test/Desktop/localization_sim/main_mix
0x0000000000400794 0x00000000004007c8 .eh_frame_hdr         /home/test/Desktop/localization_sim/main_mix
0x00000000004007c8 0x00000000004008bc .eh_frame             /home/test/Desktop/localization_sim/main_mix
0x0000000000600df0x0000000000600df8 .init_array           /home/test/Desktop/localization_sim/main_mix
0x0000000000600df0x0000000000600e00 .fini_array           /home/test/Desktop/localization_sim/main_mix
0x0000000000600e00 0x0000000000600e08 .jcr                  /home/test/Desktop/localization_sim/main_mix
0x0000000000600e08 0x0000000000600ff8 .dynamic              /home/test/Desktop/localization_sim/main_mix
0x0000000000600ff0x0000000000601000 .got                  /home/test/Desktop/localization_sim/main_mix
0x0000000000601000 0x0000000000601030 .got.plt              /home/test/Desktop/localization_sim/main_mix
0x0000000000601030 0x0000000000601040 .data                 /home/test/Desktop/localization_sim/main_mix
0x0000000000601040 0x0000000000601048 .bss                  /home/test/Desktop/localization_sim/main_mix
0x00007ffff7dd71c8 0x00007ffff7dd71ec .note.gnu.build-id    /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd71f0x00007ffff7dd72b0 .hash                 /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd72b0 0x00007ffff7dd7390 .gnu.hash             /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7390 0x00007ffff7dd7648 .dynsym               /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7648 0x00007ffff7dd77ef .dynstr               /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd77f0x00007ffff7dd782a .gnu.version          /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7830 0x00007ffff7dd78d4 .gnu.version_d        /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd78d0x00007ffff7dd79f8 .rela.dyn             /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd79f0x00007ffff7dd7a58 .rela.plt             /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7a60 0x00007ffff7dd7ab0 .plt                  /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7ab0 0x00007ffff7dd7ab8 .plt.got              /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7ac0 0x00007ffff7df5850 .text                 /lib64/ld-linux-x86-64.so.2
0x00007ffff7df5860 0x00007ffff7df9920 .rodata               /lib64/ld-linux-x86-64.so.2
0x00007ffff7df9920 0x00007ffff7df9921 .stapsdt.base         /lib64/ld-linux-x86-64.so.2
0x00007ffff7df9924 0x00007ffff7df9f60 .eh_frame_hdr         /lib64/ld-linux-x86-64.so.2
0x00007ffff7df9f60 0x00007ffff7dfc3f8 .eh_frame             /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffcbc0 0x00007ffff7ffce6c .data.rel.ro          /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffce70 0x00007ffff7ffcfe0 .dynamic              /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffcfe0 0x00007ffff7ffcff0 .got                  /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffd000 0x00007ffff7ffd038 .got.plt              /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffd040 0x00007ffff7ffdfc0 .data                 /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffdfc0 0x00007ffff7ffe168 .bss                  /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffa120 0x00007ffff7ffa160 .hash                 /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa160 0x00007ffff7ffa1a8 .gnu.hash             /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa1a8 0x00007ffff7ffa2b0 .dynsym               /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa2b0 0x00007ffff7ffa30e .dynstr               /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa30e 0x00007ffff7ffa324 .gnu.version          /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa328 0x00007ffff7ffa360 .gnu.version_d        /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa360 0x00007ffff7ffa470 .dynamic              /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa470 0x00007ffff7ffa7b0 .rodata               /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa7b0 0x00007ffff7ffa7ec .note                 /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa7ec 0x00007ffff7ffa828 .eh_frame_hdr         /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa828 0x00007ffff7ffa968 .eh_frame             /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa970 0x00007ffff7ffaf6a .text                 /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffaf6a 0x00007ffff7ffaff9 .altinstructions      /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffaff0x00007ffff7ffb01b .altinstr_replacement /home/test/Desktop/localization_sim/main_mix
0x00007ffff7bd51c8 0x00007ffff7bd51ec .note.gnu.build-id    ./libadd_debug.so
0x00007ffff7bd51f0x00007ffff7bd5230 .gnu.hash             ./libadd_debug.so
0x00007ffff7bd5230 0x00007ffff7bd5380 .dynsym               ./libadd_debug.so
0x00007ffff7bd5380 0x00007ffff7bd541c .dynstr               ./libadd_debug.so
0x00007ffff7bd5420 0x00007ffff7bd54f8 .rela.dyn             ./libadd_debug.so
0x00007ffff7bd54f0x00007ffff7bd5512 .init                 ./libadd_debug.so
0x00007ffff7bd5520 0x00007ffff7bd5530 .plt                  ./libadd_debug.so
0x00007ffff7bd5530 0x00007ffff7bd5540 .plt.got              ./libadd_debug.so
0x00007ffff7bd5540 0x00007ffff7bd5666 .text                 ./libadd_debug.so
0x00007ffff7bd5668 0x00007ffff7bd5671 .fini                 ./libadd_debug.so
0x00007ffff7bd5674 0x00007ffff7bd5690 .eh_frame_hdr         ./libadd_debug.so
0x00007ffff7bd5690 0x00007ffff7bd56f4 .eh_frame             ./libadd_debug.so
0x00007ffff7dd5e68 0x00007ffff7dd5e70 .init_array           ./libadd_debug.so
0x00007ffff7dd5e70 0x00007ffff7dd5e78 .fini_array           ./libadd_debug.so
0x00007ffff7dd5e78 0x00007ffff7dd5e80 .jcr                  ./libadd_debug.so
0x00007ffff7dd5e80 0x00007ffff7dd5fd0 .dynamic              ./libadd_debug.so
0x00007ffff7dd5fd0x00007ffff7dd6000 .got                  ./libadd_debug.so
0x00007ffff7dd6000 0x00007ffff7dd6018 .got.plt              ./libadd_debug.so
0x00007ffff7dd6018 0x00007ffff7dd6020 .data                 ./libadd_debug.so
0x00007ffff7dd6020 0x00007ffff7dd6028 .bss                  ./libadd_debug.so
0x00007ffff79d31c8 0x00007ffff79d31ec .note.gnu.build-id    ./libsub_debug.so
0x00007ffff79d31f0x00007ffff79d3230 .gnu.hash             ./libsub_debug.so
0x00007ffff79d3230 0x00007ffff79d3380 .dynsym               ./libsub_debug.so
0x00007ffff79d3380 0x00007ffff79d341c .dynstr               ./libsub_debug.so
0x00007ffff79d3420 0x00007ffff79d34f8 .rela.dyn             ./libsub_debug.so
0x00007ffff79d34f0x00007ffff79d3512 .init                 ./libsub_debug.so
0x00007ffff79d3520 0x00007ffff79d3530 .plt                  ./libsub_debug.so
0x00007ffff79d3530 0x00007ffff79d3540 .plt.got              ./libsub_debug.so
0x00007ffff79d3540 0x00007ffff79d3666 .text                 ./libsub_debug.so
0x00007ffff79d3668 0x00007ffff79d3671 .fini                 ./libsub_debug.so
0x00007ffff79d3674 0x00007ffff79d3690 .eh_frame_hdr         ./libsub_debug.so
0x00007ffff79d3690 0x00007ffff79d36f4 .eh_frame             ./libsub_debug.so
0x00007ffff7bd3e68 0x00007ffff7bd3e70 .init_array           ./libsub_debug.so
0x00007ffff7bd3e70 0x00007ffff7bd3e78 .fini_array           ./libsub_debug.so
0x00007ffff7bd3e78 0x00007ffff7bd3e80 .jcr                  ./libsub_debug.so
0x00007ffff7bd3e80 0x00007ffff7bd3fd0 .dynamic              ./libsub_debug.so
0x00007ffff7bd3fd0x00007ffff7bd4000 .got                  ./libsub_debug.so
0x00007ffff7bd4000 0x00007ffff7bd4018 .got.plt              ./libsub_debug.so
0x00007ffff7bd4018 0x00007ffff7bd4020 .data                 ./libsub_debug.so
0x00007ffff7bd4020 0x00007ffff7bd4028 .bss                  ./libsub_debug.so
0x00007ffff7609270 0x00007ffff7609294 .note.gnu.build-id    /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7609294 0x00007ffff76092b4 .note.ABI-tag         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff76092b8 0x00007ffff760cd80 .gnu.hash             /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff760cd80 0x00007ffff7619ff8 .dynsym               /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7619ff0x00007ffff761f9d7 .dynstr               /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff761f9d0x00007ffff7620b62 .gnu.version          /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7620b68 0x00007ffff7620edc .gnu.version_d        /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7620ee0 0x00007ffff7620f10 .gnu.version_r        /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7620f10 0x00007ffff7628680 .rela.dyn             /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7628680 0x00007ffff76287b8 .rela.plt             /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff76287c0 0x00007ffff76288a0 .plt                  /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff76288a0 0x00007ffff76288b0 .plt.got              /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff76288b0 0x00007ffff777bb04 .text                 /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff777bb10 0x00007ffff777e02d __libc_freeres_fn     /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff777e030 0x00007ffff777e2f2 __libc_thread_freeres_fn /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff777e300 0x00007ffff779f650 .rodata               /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff779f650 0x00007ffff779f651 .stapsdt.base         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff779f660 0x00007ffff779f67c .interp               /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff779f67c 0x00007ffff77a4b38 .eh_frame_hdr         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff77a4b38 0x00007ffff77c53cc .eh_frame             /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff77c53cc 0x00007ffff77c580d .gcc_except_table     /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff77c5810 0x00007ffff77c8b10 .hash                 /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c97c0 0x00007ffff79c97d0 .tdata                /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c97d0x00007ffff79c9838 .tbss                 /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c97d0x00007ffff79c97e0 .init_array           /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c97e0 0x00007ffff79c98d8 __libc_subfreeres     /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c98d0x00007ffff79c98e0 __libc_atexit         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c98e0 0x00007ffff79c9900 __libc_thread_subfreeres /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c9900 0x00007ffff79ccba0 .data.rel.ro          /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79ccba0 0x00007ffff79ccd80 .dynamic              /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79ccd80 0x00007ffff79ccff0 .got                  /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79cd000 0x00007ffff79cd080 .got.plt              /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79cd080 0x00007ffff79ce720 .data                 /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79ce720 0x00007ffff79d29a0 .bss                  /lib/x86_64-linux-gnu/libc.so.6
0x0000000000400238 0x0000000000400254 .interp               /home/test/Desktop/localization_sim/main_mix
0x0000000000400254 0x0000000000400274 .note.ABI-tag         /home/test/Desktop/localization_sim/main_mix
0x0000000000400274 0x0000000000400298 .note.gnu.build-id    /home/test/Desktop/localization_sim/main_mix
0x0000000000400298 0x00000000004002d0 .gnu.hash             /home/test/Desktop/localization_sim/main_mix
0x00000000004002d0x0000000000400408 .dynsym               /home/test/Desktop/localization_sim/main_mix
0x0000000000400408 0x00000000004004e4 .dynstr               /home/test/Desktop/localization_sim/main_mix
0x00000000004004e4 0x00000000004004fe .gnu.version          /home/test/Desktop/localization_sim/main_mix
0x0000000000400500 0x0000000000400520 .gnu.version_r        /home/test/Desktop/localization_sim/main_mix
0x0000000000400520 0x0000000000400538 .rela.dyn             /home/test/Desktop/localization_sim/main_mix
0x0000000000400538 0x0000000000400580 .rela.plt             /home/test/Desktop/localization_sim/main_mix
0x0000000000400580 0x000000000040059a .init                 /home/test/Desktop/localization_sim/main_mix
0x00000000004005a0 0x00000000004005e0 .plt                  /home/test/Desktop/localization_sim/main_mix
0x00000000004005e0 0x00000000004005e8 .plt.got              /home/test/Desktop/localization_sim/main_mix
0x00000000004005f0x0000000000400782 .text                 /home/test/Desktop/localization_sim/main_mix
0x0000000000400784 0x000000000040078d .fini                 /home/test/Desktop/localization_sim/main_mix
0x0000000000400790 0x0000000000400794 .rodata               /home/test/Desktop/localization_sim/main_mix
0x0000000000400794 0x00000000004007c8 .eh_frame_hdr         /home/test/Desktop/localization_sim/main_mix
0x00000000004007c8 0x00000000004008bc .eh_frame             /home/test/Desktop/localization_sim/main_mix
0x0000000000600df0x0000000000600df8 .init_array           /home/test/Desktop/localization_sim/main_mix
0x0000000000600df0x0000000000600e00 .fini_array           /home/test/Desktop/localization_sim/main_mix
0x0000000000600e00 0x0000000000600e08 .jcr                  /home/test/Desktop/localization_sim/main_mix
0x0000000000600e08 0x0000000000600ff8 .dynamic              /home/test/Desktop/localization_sim/main_mix
0x0000000000600ff0x0000000000601000 .got                  /home/test/Desktop/localization_sim/main_mix
0x0000000000601000 0x0000000000601030 .got.plt              /home/test/Desktop/localization_sim/main_mix
0x0000000000601030 0x0000000000601040 .data                 /home/test/Desktop/localization_sim/main_mix
0x0000000000601040 0x0000000000601048 .bss                  /home/test/Desktop/localization_sim/main_mix
0x00007ffff7dd71c8 0x00007ffff7dd71ec .note.gnu.build-id    /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd71f0x00007ffff7dd72b0 .hash                 /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd72b0 0x00007ffff7dd7390 .gnu.hash             /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7390 0x00007ffff7dd7648 .dynsym               /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7648 0x00007ffff7dd77ef .dynstr               /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd77f0x00007ffff7dd782a .gnu.version          /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7830 0x00007ffff7dd78d4 .gnu.version_d        /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd78d0x00007ffff7dd79f8 .rela.dyn             /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd79f0x00007ffff7dd7a58 .rela.plt             /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7a60 0x00007ffff7dd7ab0 .plt                  /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7ab0 0x00007ffff7dd7ab8 .plt.got              /lib64/ld-linux-x86-64.so.2
0x00007ffff7dd7ac0 0x00007ffff7df5850 .text                 /lib64/ld-linux-x86-64.so.2
0x00007ffff7df5860 0x00007ffff7df9920 .rodata               /lib64/ld-linux-x86-64.so.2
0x00007ffff7df9920 0x00007ffff7df9921 .stapsdt.base         /lib64/ld-linux-x86-64.so.2
0x00007ffff7df9924 0x00007ffff7df9f60 .eh_frame_hdr         /lib64/ld-linux-x86-64.so.2
0x00007ffff7df9f60 0x00007ffff7dfc3f8 .eh_frame             /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffcbc0 0x00007ffff7ffce6c .data.rel.ro          /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffce70 0x00007ffff7ffcfe0 .dynamic              /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffcfe0 0x00007ffff7ffcff0 .got                  /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffd000 0x00007ffff7ffd038 .got.plt              /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffd040 0x00007ffff7ffdfc0 .data                 /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffdfc0 0x00007ffff7ffe168 .bss                  /lib64/ld-linux-x86-64.so.2
0x00007ffff7ffa120 0x00007ffff7ffa160 .hash                 /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa160 0x00007ffff7ffa1a8 .gnu.hash             /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa1a8 0x00007ffff7ffa2b0 .dynsym               /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa2b0 0x00007ffff7ffa30e .dynstr               /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa30e 0x00007ffff7ffa324 .gnu.version          /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa328 0x00007ffff7ffa360 .gnu.version_d        /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa360 0x00007ffff7ffa470 .dynamic              /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa470 0x00007ffff7ffa7b0 .rodata               /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa7b0 0x00007ffff7ffa7ec .note                 /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa7ec 0x00007ffff7ffa828 .eh_frame_hdr         /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa828 0x00007ffff7ffa968 .eh_frame             /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffa970 0x00007ffff7ffaf6a .text                 /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffaf6a 0x00007ffff7ffaff9 .altinstructions      /home/test/Desktop/localization_sim/main_mix
0x00007ffff7ffaff0x00007ffff7ffb01b .altinstr_replacement /home/test/Desktop/localization_sim/main_mix
0x00007ffff7bd51c8 0x00007ffff7bd51ec .note.gnu.build-id    ./libadd_debug.so
0x00007ffff7bd51f0x00007ffff7bd5230 .gnu.hash             ./libadd_debug.so
0x00007ffff7bd5230 0x00007ffff7bd5380 .dynsym               ./libadd_debug.so
0x00007ffff7bd5380 0x00007ffff7bd541c .dynstr               ./libadd_debug.so
0x00007ffff7bd5420 0x00007ffff7bd54f8 .rela.dyn             ./libadd_debug.so
0x00007ffff7bd54f0x00007ffff7bd5512 .init                 ./libadd_debug.so
0x00007ffff7bd5520 0x00007ffff7bd5530 .plt                  ./libadd_debug.so
0x00007ffff7bd5530 0x00007ffff7bd5540 .plt.got              ./libadd_debug.so
0x00007ffff7bd5540 0x00007ffff7bd5666 .text                 ./libadd_debug.so
0x00007ffff7bd5668 0x00007ffff7bd5671 .fini                 ./libadd_debug.so
0x00007ffff7bd5674 0x00007ffff7bd5690 .eh_frame_hdr         ./libadd_debug.so
0x00007ffff7bd5690 0x00007ffff7bd56f4 .eh_frame             ./libadd_debug.so
0x00007ffff7dd5e68 0x00007ffff7dd5e70 .init_array           ./libadd_debug.so
0x00007ffff7dd5e70 0x00007ffff7dd5e78 .fini_array           ./libadd_debug.so
0x00007ffff7dd5e78 0x00007ffff7dd5e80 .jcr                  ./libadd_debug.so
0x00007ffff7dd5e80 0x00007ffff7dd5fd0 .dynamic              ./libadd_debug.so
0x00007ffff7dd5fd0x00007ffff7dd6000 .got                  ./libadd_debug.so
0x00007ffff7dd6000 0x00007ffff7dd6018 .got.plt              ./libadd_debug.so
0x00007ffff7dd6018 0x00007ffff7dd6020 .data                 ./libadd_debug.so
0x00007ffff7dd6020 0x00007ffff7dd6028 .bss                  ./libadd_debug.so
0x00007ffff79d31c8 0x00007ffff79d31ec .note.gnu.build-id    ./libsub_debug.so
0x00007ffff79d31f0x00007ffff79d3230 .gnu.hash             ./libsub_debug.so
0x00007ffff79d3230 0x00007ffff79d3380 .dynsym               ./libsub_debug.so
0x00007ffff79d3380 0x00007ffff79d341c .dynstr               ./libsub_debug.so
0x00007ffff79d3420 0x00007ffff79d34f8 .rela.dyn             ./libsub_debug.so
0x00007ffff79d34f0x00007ffff79d3512 .init                 ./libsub_debug.so
0x00007ffff79d3520 0x00007ffff79d3530 .plt                  ./libsub_debug.so
0x00007ffff79d3530 0x00007ffff79d3540 .plt.got              ./libsub_debug.so
0x00007ffff79d3540 0x00007ffff79d3666 .text                 ./libsub_debug.so
0x00007ffff79d3668 0x00007ffff79d3671 .fini                 ./libsub_debug.so
0x00007ffff79d3674 0x00007ffff79d3690 .eh_frame_hdr         ./libsub_debug.so
0x00007ffff79d3690 0x00007ffff79d36f4 .eh_frame             ./libsub_debug.so
0x00007ffff7bd3e68 0x00007ffff7bd3e70 .init_array           ./libsub_debug.so
0x00007ffff7bd3e70 0x00007ffff7bd3e78 .fini_array           ./libsub_debug.so
0x00007ffff7bd3e78 0x00007ffff7bd3e80 .jcr                  ./libsub_debug.so
0x00007ffff7bd3e80 0x00007ffff7bd3fd0 .dynamic              ./libsub_debug.so
0x00007ffff7bd3fd0x00007ffff7bd4000 .got                  ./libsub_debug.so
0x00007ffff7bd4000 0x00007ffff7bd4018 .got.plt              ./libsub_debug.so
0x00007ffff7bd4018 0x00007ffff7bd4020 .data                 ./libsub_debug.so
0x00007ffff7bd4020 0x00007ffff7bd4028 .bss                  ./libsub_debug.so
0x00007ffff7609270 0x00007ffff7609294 .note.gnu.build-id    /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7609294 0x00007ffff76092b4 .note.ABI-tag         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff76092b8 0x00007ffff760cd80 .gnu.hash             /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff760cd80 0x00007ffff7619ff8 .dynsym               /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7619ff0x00007ffff761f9d7 .dynstr               /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff761f9d0x00007ffff7620b62 .gnu.version          /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7620b68 0x00007ffff7620edc .gnu.version_d        /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7620ee0 0x00007ffff7620f10 .gnu.version_r        /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7620f10 0x00007ffff7628680 .rela.dyn             /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7628680 0x00007ffff76287b8 .rela.plt             /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff76287c0 0x00007ffff76288a0 .plt                  /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff76288a0 0x00007ffff76288b0 .plt.got              /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff76288b0 0x00007ffff777bb04 .text                 /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff777bb10 0x00007ffff777e02d __libc_freeres_fn     /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff777e030 0x00007ffff777e2f2 __libc_thread_freeres_fn /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff777e300 0x00007ffff779f650 .rodata               /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff779f650 0x00007ffff779f651 .stapsdt.base         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff779f660 0x00007ffff779f67c .interp               /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff779f67c 0x00007ffff77a4b38 .eh_frame_hdr         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff77a4b38 0x00007ffff77c53cc .eh_frame             /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff77c53cc 0x00007ffff77c580d .gcc_except_table     /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff77c5810 0x00007ffff77c8b10 .hash                 /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c97c0 0x00007ffff79c97d0 .tdata                /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c97d0x00007ffff79c9838 .tbss                 /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c97d0x00007ffff79c97e0 .init_array           /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c97e0 0x00007ffff79c98d8 __libc_subfreeres     /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c98d0x00007ffff79c98e0 __libc_atexit         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c98e0 0x00007ffff79c9900 __libc_thread_subfreeres /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79c9900 0x00007ffff79ccba0 .data.rel.ro          /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79ccba0 0x00007ffff79ccd80 .dynamic              /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79ccd80 0x00007ffff79ccff0 .got                  /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79cd000 0x00007ffff79cd080 .got.plt              /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79cd080 0x00007ffff79ce720 .data                 /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79ce720 0x00007ffff79d29a0 .bss                  /lib/x86_64-linux-gnu/libc.so.6

或者

(gdb) info files

注:xfiles命令GEF插件扩展的命令,info files是GDB原生的命令。

输出结果中:

step 5:进一步研究

如果可执行文件和共享库都调用由共享库定义的全局变量时,那么:

注:重定位方式R_X86_64_COPY的含义:The link editor creates this relocation type for dynamic linking. Its offset member refers to a location in a writable segment. The symbol table index specifies a symbol that should exist both in the current object file and in a shared object. During execution, the dynamic linker copies data associated with the shared object's symbol to the specified by the offset.


下一篇:计算机系统篇之链接(9):位置无关代码(下)——真正理解 PIC 函数调用的工作原理(Linux X86-64 示例)

上一篇:计算机系统篇之链接(7):位置无关代码(上)

首页