2

假设如下:

Elf_Section_Header *sectionHeaderTable //points to the start of a ELF section header table
Elf_Section_Header *symtabHeader  //points to the start of the symtab section header

为什么以下内容不指向关联的字符串表部分标题?

Elf_Section_Header *strTabSectionHeader = (Elf_Section_Header *)((char *)sectionHeaderTable + (symtabHeader->strtab_index));

strTabSectionHeader->type == SHT_STRTAB等于假

我应该如何指向关联的字符串表部分标题?

4

3 回答 3

4

据推测,->strtab_index结构成员是指sh_name符号表头的成员(如 ELF 规范中所命名)。

这实际上是节头字符串表节的索引,而不是字符串表的位置。

字符串表存储在它们自己的部分中。尤其是节头字符串表由e_shstrndxELF 头的成员定位。这是节标题表的索引 - 因此sectionHeaderTable[elf_header->e_shstrndx]可能是您想要的(节标题字符串表的节标题)。

于 2010-05-28T03:22:30.040 回答
0

节头的 sh_name 成员保存到节头字符串表节的索引,由 ELF 头的 e_shstrndx 成员指定。 极低频规格

于 2013-06-10T16:55:00.543 回答
0

每个二进制通常包含三个字符串表 -

1. .dynstr
2. .shstrtab
3. .strtab

在上述问题中,我们关注 .shstrtab,它在扩展时代表 - Section Header STRing TABle。在读取 ELF 标头后,我们在 ELF 标头中找到以下字段 - e_shstrndx。这是我们可以找到 .shstrtab 的索引。以下公式可用于计算它将如何完成 -

offset = ((elfHdr.e_shstrndx)*elfHdr.e_shentsize)+elfHdr.e_shoff

每个参数的含义 -

elfHdr.e_shstrndx = index where we can find .shstrtab
elfHdr.e_shentsize = Size of each Section Header
elfHdr.e_shoff = Offset at which section header starts.

如果您需要更多详细信息,请发表评论

于 2012-05-18T15:54:15.127 回答