.dynamic section保存的是一系列和动态链接相关的结构。d_tag成员控制着d_un结构体的内容。
typedef struct {
Elf32_Sword d_tag;
union {
Elf32_Word d_val;
Elf32_Addr d_ptr;
} d_un;
} Elf32_Dyn;
extern Elf32_Dyn _DYNAMIC[];
typedef struct {
Elf64_Sxword d_tag;
union {
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
} Elf64_Dyn;
extern Elf64_Dyn _DYNAMIC[];
d_tag 值从下面这些值中选择:
DT_NULL 标记dynamic section的结尾
DT_NEEDED String table offset to name of a needed library
DT_PLTRELSZ PLT重定位条目的大小
DT_PLTGOT PLT和GOT或PLT的地址
DT_HASH symbol hash table的地址
DT_STRTAB string table的地址
DT_SYMTAB symbol table的地址
DT_RELA Rela relocation table的地址
DT_RELASZ Rela relocation table的大小
DT_RELAENT Rela relocation table entry的大小
DT_STRSZ string table的大小
DT_SYMENT symbol table entry的大小
DT_INIT 初始化接口的地址
DT_FINI 终止接口的地址
DT_SONAME String table offset to name of shared object
DT_RPATH String table offset to library search path (不宜用)
DT_SYMBOLIC 提醒链接器在executable for symbols之前搜索此共享目标文件
DT_REL Rel relocation table的地址
DT_RELSZ Rel relocation table的大小
DT_RELENT Rel table entry的大小
DT_PLTREL PLT查找的(Rela或Rel)重定位条目类型
DT_DEBUG Undefined use for debugging
DT_TEXTREL 没有此条目意味着没有应该应用于不可写段的重定位条目
DT_JMPREL 仅与PLT关联的重定位项的地址
DT_BIND_NOW 指示动态链接器在将控制转移到可执行文件之前处理所有重定位
DT_RUNPATH String table offset to library search path
DT_LOPROC,DT_HIPROC
[DT_LOPROC, DT_HIPROC]用于处理器特定的语义
d_val This member represents integer values with various interpretations.
d_ptr 代表程序虚拟地址。当解析这个地址的时候,实际地址应该基于original file value
和memory base address去计算。文件不包含修复此地址的重定位条目。
_DYNAMIC
包含所有动态结构的数组在.dynamic section中。这是由链接器自动填充的。