保存动态链接器所需要的基本信息,比如依赖什么共享对象,动态链接符号表的位置,动态链接重定位表的位置,共享对象初始化代码的地址等等

dynamic 段的内容很像文件头,不过所有属性都是在动态链接的语境下的

readelf -d Lib.so
Dynamic section at offset 0x2e00 contains 24 entries:
 Tag        Type                         Name/Value
0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
0x000000000000000c (INIT)               0x1000
0x000000000000000d (FINI)               0x1194
0x0000000000000019 (INIT_ARRAY)         0x3df0
0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
0x000000000000001a (FINI_ARRAY)         0x3df8
0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
0x000000006ffffef5 (GNU_HASH)           0x260
0x0000000000000005 (STRTAB)             0x360
0x0000000000000006 (SYMTAB)             0x288
0x000000000000000a (STRSZ)              134 (bytes)
0x000000000000000b (SYMENT)             24 (bytes)
0x0000000000000003 (PLTGOT)             0x3fe8
0x0000000000000002 (PLTRELSZ)           48 (bytes)
0x0000000000000014 (PLTREL)             RELA
0x0000000000000017 (JMPREL)             0x4f0
0x0000000000000007 (RELA)               0x418
0x0000000000000008 (RELASZ)             216 (bytes)
0x0000000000000009 (RELAENT)            24 (bytes)
0x000000006ffffffe (VERNEED)            0x3f8
0x000000006fffffff (VERNEEDNUM)         1
0x000000006ffffff0 (VERSYM)             0x3e6
0x000000006ffffff9 (RELACOUNT)          4
0x0000000000000000 (NULL)               0x0

另外 linux 还提供了一个命令来查看一个程序主模块或者一个共享库依赖于哪些共享库:

ldd Program1
linux-vdso.so.1 (0x00007ffef05f5000)
./Lib.so (0x00007f6a002be000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6a000c2000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6a002ca000)