This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Reading symbols from dynamic symbol table
- From: Jaimon Jose <jjaimon at Yahoo dot com>
- To: gdb at sources dot redhat dot com
- Cc: Daniel Jacobowitz <drow at false dot org>
- Date: Wed, 08 Dec 2004 12:20:50 +0530
- Subject: Re: Reading symbols from dynamic symbol table
- References: <41B68423.9080509@Yahoo.com> <20041208044558.GA2913@nevyn.them.org>
- Reply-to: jjaimon at yahoo dot com
Yes. This is ELF
Here is an example. I create a shared library with the following
functions.
int func3(void)
{
char *nullptr = 0;
printf("func3\n");
*nullptr = '\0';
}
int func2(void)
{
printf("func2\n");
func3();
}
extern "C" int func_entry(void)
{
printf("func_entry\n");
func2();
}
I create the sharedlibrary and link to another program that calls
func_entry.
$>g++ -shared -o libprgshared.so prgshared.cpp
$>nm --defined-only libprgshared.so
00001aa0 A __bss_start
00000740 t call_gmon_start
00001aa0 b completed.1
00001a70 d __CTOR_END__
00001a6c d __CTOR_LIST__
00000890 t __do_global_ctors_aux
00000770 t __do_global_dtors_aux
00001900 d __dso_handle
00001a78 d __DTOR_END__
00001a74 d __DTOR_LIST__
00001984 A _DYNAMIC
00001aa0 A _edata
00001aa4 A _end
000008c4 T _fini
000007e0 t frame_dummy
00001980 r __FRAME_END__
0000086c T func_entry
00001a80 A _GLOBAL_OFFSET_TABLE_
000006f8 T _init
00001a7c d __JCR_END__
00001a7c d __JCR_LIST__
00001904 d p.0
0000084e T _Z5func2v
00000828 T _Z5func3v
$>g++ -O2 -o prgmain prgmain.cpp libprgshared.so
$>./prgmain
$>gdb ./prgmain core
(gdb) where
#0 0x40018848 in func3 () from libprgshared.so
#1 0x40018869 in func2 () from libprgshared.so
#2 0x40018887 in func_entry () from ibprgshared.so
#3 0x080485ca in main ()
Now I create the shared object with --retain-symbols-file by just
exporting only func_entry
$>g++ -shared -o libprgshared.so -Wl,--retain-symbols-file
-Wl,prgshared.sym prgshared.cpp
$>nm --defined-only libprgshared.so
0000086c T func_entry
$>nm -D --defined-only libprgshared.so
00001aa0 A __bss_start
00001984 A _DYNAMIC
00001aa0 A _edata
00001aa4 A _end
000008c4 T _fini
0000086c T func_entry
00001a80 A _GLOBAL_OFFSET_TABLE_
000006f8 T _init
0000084e T _Z5func2v
00000828 T _Z5func3v
I link this against my main program and look at the new core file.
(gdb) where
#0 0x40018848 in ?? () from libprgshared.so
#1 0x40018869 in ?? () from libprgshared.so
#2 0x40018887 in func_entry () from libprgshared.so
#3 0x080485ca in main ()
Frame #0 and #1 no longer shows the function name though it is available
in the dynamic section of shared library. How do I force gdb to read
symbols from this section?
I'm using the following versions of programs
$>ld -V
GNU ld version 2.15.90.0.1.1 20040303 (SuSE Linux)
Supported emulations:
elf_i386
i386linux
elf_x86_64
$>gdb --version
GNU gdb 6.1
Copyright 2004 Free Software Foundation, Inc
$>>gcc --version
gcc (GCC) 3.3.3 (SuSE Linux)
Copyright (C) 2003 Free Software Foundation, Inc.
thanks,
--jaimon
Daniel Jacobowitz wrote the following on 12/08/2004 10:15 AM:
On Wed, Dec 08, 2004 at 10:03:39AM +0530, Jaimon Jose wrote:
I have few libraries built with --retain-symbols-file ld option. I
can't see the correct symbols when I open the core file due to this. It
always shows the stack trace with few exported symbols+offset. However,
'nm' is able to read all the symbols from dynamic symbol table. Is
there a way to instruct gdb to read symbols from dynamic symbol table?
It normally does - is this ELF? You'll have to investigate why it
isn't working.