Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String table in ELF

  1. I get some symbol and I get (a hexdump of) an ELF file. How can I know in which section this symbol appears?

  2. 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?

like image 505
user1479376 Avatar asked Jul 02 '12 08:07

user1479376


People also ask

What is string table ELF?

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.

What is string table and why it is used?

String table sections hold null-terminated character sequences, commonly called strings. The object file uses these strings to represent symbol and section names.

What is string table?

A string table is a Windows resource that contains a list of IDs, values, and captions for all the strings of your application. For example, the status-bar prompts are located in the string table. While developing an application, you can have several string tables — one for each language or condition.


1 Answers

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.

like image 120
Samir Baid Avatar answered Oct 23 '22 09:10

Samir Baid