tags:

views:

48

answers:

1

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?

A: 

Presumably the ->strtab_index struct member is referring to the sh_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 - thus sectionHeaderTable[elf_header->e_shstrndx] is likely what you want (the section header for the section header string table).

caf