What do debugging symbols look like?

gcc (GCC) 4.6.0 GNU gdb (GDB) Fedora (7.2.90.20110525-38.fc15)

I recently had a problem when I was trying to debug my problem using gdb. When I uploaded my binary, gdb complained: "No debugging symbols found"

So, when I did the following:

nm ass1 

I got the following result (sample only)

 00000000006026e0 t __init_array_end 00000000006026d0 t __init_array_start 00000000004020e0 T __libc_csu_fini 0000000000402050 T __libc_csu_init U __libc_start_main@ @GLIBC_2.2.5 00000000006029ec A _edata 0000000000602b28 A _end 000000000040212c T _fini 0000000000401420 T _init 0000000000401610 T _start U atoi@ @GLIBC_2.2.5 000000000040163c t call_gmon_start 0000000000602b10 b completed.5886 00000000006029e8 W data_start 0000000000602b18 b dtor_idx.5888 00000000004016d0 t frame_dummy 00000000004016f4 T main 

The problem was that I forgot to add -g. So I decided to compile with -g and run nm again. I got simliar output, this contains the debug symbols that I used -g and gdb did not complain this time:

  U __libc_start_main@ @GLIBC_2.2.5 00000000006029ec A _edata 0000000000602b28 A _end 000000000040212c T _fini 0000000000401420 T _init 0000000000401610 T _start U atoi@ @GLIBC_2.2.5 000000000040163c t call_gmon_start 0000000000602b10 b completed.5886 00000000006029e8 W data_start 0000000000602b18 b dtor_idx.5888 00000000004016d0 t frame_dummy 00000000004016f4 T main w pthread_cancel 

In addition, the binary size is larger. I could notice any use of nm. I wonder what should I look for? What do debug symbols look like?

Thanks so much for any suggestions,

+7
source share
1 answer

nm hides debugging symbols by default. Use the -a option to show them.

Modern systems often do not use debugging symbols as such. The stabs debugging stabs was designed for use with a.out format executables, which can only represent a limited amount of internal structure; this led to a lot of things hidden in the symbol table, such as debug symbols and initializers / constructors . COFF (currently mostly obsolete) and ELF file formats allow arbitrary sections to be used, and most modern Linux distributions configure gcc to use DWARF 2 debugging information. You should be able to use GNU objdump to learn this information.

(It seems that I don’t have access to the machine whose binutils will generate the stabs or GNU stabs+ format, so I will postpone Google .)

+7
source

All Articles