访问ELF字符串表节头
假设以下情况:
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
等于 false
我应该如何指向关联的字符串表节头?
Assume the following:
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
Why doesn't the following point me to the associated string table section header?
Elf_Section_Header *strTabSectionHeader = (Elf_Section_Header *)((char *)sectionHeaderTable + (symtabHeader->strtab_index));
strTabSectionHeader->type == SHT_STRTAB
is equal to false
How should I point to the associated string table section header?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据推测,
->strtab_index
结构成员引用了符号表头的sh_name
成员(如 ELF 规范中所命名)。这实际上是节头字符串表节内的索引,而不是字符串表的位置。
字符串表存储在它们自己的部分中。节头字符串表特别位于 ELF 头的
e_shstrndx
成员中。这是节头表的索引 - 因此sectionHeaderTable[elf_header->e_shstrndx]
可能就是您想要的(节头字符串表的节头)。Presumably the
->strtab_index
struct member is referring to thesh_name
member of the symbol table header (as named in the ELF spec).This is actually an index within the section header string table section, not the location of a string table.
String tables are stored in their own sections. The section header string table in particular is located by the
e_shstrndx
member of the ELF header. This is an index into the section header table - thussectionHeaderTable[elf_header->e_shstrndx]
is likely what you want (the section header for the section header string table).每个二进制文件通常包含三个字符串表 -
在上面的问题中,我们关注的是 .shstrtab,它在展开时代表 - 节标题 STRing TABle。读取 ELF 标头后,我们在 ELF 标头中找到以下字段 - e_shstrndx。这是我们可以找到 .shstrtab 的索引。以下公式可用于计算如何完成 -
每个参数的含义 -
如果您需要更多详细信息,请评论
Each Binary generally contains three String tables -
IN the above question we are concerned with .shstrtab which when expanded stands for - Section Header STRing TABle. Upon reading the ELF header we find the following field in ELF header - e_shstrndx. This is the index where we can find .shstrtab. Following formula can be used to calculate how it will be done -
Meaning of each parameter -
PLease comment if u need more details
节头的 sh_name 成员保存节头字符串表节的索引,由 ELF 头的 e_shstrndx 成员指定。
ELF 规范
A section header’s sh_name member holds an index into the section header string table section, as designated by the e_shstrndx member of the ELF header.
ELF Specification