在工程师milter:ELF文件分析指引zhuanlan.zhihu.com
中,我们大概了解了ELF文件的结构,知道了ELF文件由文件头和段组成。今天我们继续学习ELF文件的链接。
段的具体结构
上篇文章中,我们知道段表中存储着每个段的基本信息,这些基本信息用一个叫段描述符的结构来组织。 想要查看段描述符的结构,可以在 /usr/include/elf.h中搜Elf32_Shdr,如下所示:
typedef struct
{
Elf32_Word sh_name; /* Section name (string tbl index) */
Elf32_Word sh_type; /* Section type */
Elf32_Word sh_flags;/* Section flags */
Elf32_Addr sh_addr; /* Section virtual addr at execution */
Elf32_Off sh_offset; /* Section file offset */
Elf32_Word sh_size; /* Section size in bytes */
Elf32_Word sh_link; /* Link to another section */
Elf32_Word sh_info; /* Additional section information */
Elf32_Word sh_addralign;/* Section alignment */
Elf32_Word sh_entsize;