tags:

views:

78

answers:

1

I am frustrated. I have a simple doubt .. I compile a simple program with gcc and if I see the section header using objdump, it does not show the section ".symtab". for the same a.out file, readelf shows the section. see the below snip -

[25] .symtab SYMTAB 00000000 000ca4 000480 10 26 2c 4 [26] .strtab STRTAB 00000000 001124 00025c 00 0 0 1

Why ?

In the default linker script I don't find a definition for .symtab section. If I add a definition by myself like in the linker script :

.... PROVIDE(__start_sym) .symtab : { *(.symtab)} PROVIDE(__end_sym) ....

the difference b/w the addresses of __start_sym and __end_sym is zero, which means no such section is added in the output file.

But the readelf is able to read the section and dump the contents of this section .. How ? why ?

A: 

Of course the symtab section is present; the tools just provide information in a different way. The symtab is listed as a dynamic section in objdump (try -x) in this form (or alike)

...
  STRTAB               0x08048408
  SYMTAB               0x08048178
  STRSZ                0x0000016d
...

Objdump seems more focusing on the file as "object" (allowing e.g. to disassemble too), while readelf more on the information ELF format can provide, i.e. on the file "structure" itself.

ShinTakezou