elf section类型_ELF中Section的sh_type字段详解【含部分节的结构源码】

本文详细介绍了ELF文件中的Section Header结构及其sh_type字段,包括不同类型的含义,如SHT_PROGBITS、SHT_SYMTAB、SHT_RELA等,并提供了相关数据结构如Elf32_Shdr、Elf32_Sym等的定义。此外,还特别讲解了全局偏移表(GOT)在SHT_PROGBITS节中的作用。
摘要由CSDN通过智能技术生成

• Section Header

ELF文件中的Section Header定义如下(32位):

/*Section header.*/typedefstruct{

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;/*Entry size if section holds table*/} Elf32_Shdr;

• sh_type

其中的sh_type字段表示节的类型,在elf.h文件中sh_type的合法值有以下定义:

/*Legal values for sh_type (section type).*/

#define SHT_NULL 0 /* Section header table entry unused */

#define SHT_PROGBITS 1 /* Program data */

#define SHT_SYMTAB 2 /* Symbol table */

#define SHT_STRTAB 3 /* String table */

#define SHT_RELA 4 /* Relocation entries with addends */

#define SHT_HASH 5 /* Symbol hash table */

#define SHT_DYNAMIC 6 /* Dynamic linking information */

#define SHT_NOTE 7 /* Notes */

#define SHT_NOBITS 8 /* Program space with no data (bss) */

#define SHT_REL 9 /* Relocation entries, no addends */

#define SHT_SHLIB 10 /* Reserved */

#define SHT_DYNSYM 11 /* Dynamic linker symbol table */

#define SHT_INIT_ARRAY 14 /* Array of constructors */

#define SHT_FINI_ARRAY 15 /* Array of destructors */

#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */

#define SHT_GROUP 17 /* Section group */

#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */

#define SHT_NUM 19 /* Number of defined types. */

#define SHT_LOOS

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值