I get some symbol and I get (a hexdump of) an ELF file. How can I know in which section this symbol appears?
What is the difference between .strtab
and .shstrtab
? Is there another array of symbol strings?
When I get an index for the symbol names table, is it an index in .strtab
or in .shstrtab
?
For the first question, we would need the hexedit of the elf file to understand properly.
For the second question - strtab stands for String Table shstrtab stands for Section Header String table.
When we read ELF header, we see that every ElfHeader structure contains a member called e_shstrndx. This is an index to the shstrtab. If you use this index and then read from shstrtab you can find the name of that section.
strtab, is the string table for all other references. When you read symbols from an ELF object, every SYmbol structure (Elf32_Sym) has a member called st_name. This is an index into strtab to get the string name of that symbol.
Can you please elaborate more on array of symbol strings? Also, what do you mean by names table?
You can refer to the following link - Reading ELF String Table on Linux from C
Hope this answers your question.