Reputation: 554
How to force GCC to include the .symtab section for ELF executables/shared libraries? I have already tried using -static and -ggdb but it didn't work.
EDIT: readelf -l yields the following:
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
03 .init_array .fini_array .dynamic .got .got.plt .data .bss
04 .dynamic
05 .note.ABI-tag .note.gnu.build-id
06 .eh_frame_hdr
07
08 .init_array .fini_array .dynamic .got
Upvotes: 4
Views: 2531
Reputation: 213636
By default .symtab
is included, you don't need to do anything to get it.
readelf -l yields the following:
That command is used to list segments. Since you are interested in sections, you should use
readelf -WS $binary
instead.
Your binary could still be missing the .symtab
section. If it does, the most common cause is a "stray" -s
(strip) option on the link line (or running strip
on the binary from a Makefile
).
Upvotes: 5