This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: incomplete symtabs via dl_iterate_phdr?
- From: Daniel Jacobowitz <drow at false dot org>
- To: Thomas Kühne <thomas at kuehne dot cn>
- Cc: binutils at sourceware dot org
- Date: Tue, 2 Jan 2007 10:56:20 -0500
- Subject: Re: incomplete symtabs via dl_iterate_phdr?
- References: <459A8053.4020500@kuehne.cn>
On Tue, Jan 02, 2007 at 04:54:59PM +0100, Thomas Kühne wrote:
> I am trying to find all global symbols of a programm at runtime
> from within that very programm. If I use dl_iterate_phdr
> and search the DT_SYMTAB sections the result is incomplete.
>
> source:
> http://svn.dsource.org/projects/flectioned/trunk/elf2.c
>
> That way only 55 symbols are found in libc while
> "nm --extern-only --defined-only libc.a" returns 2455 symbols.
>
> Is there any way to get a list of all defined symbols, their names
> and addresses at runtime?
nm is looking at the static symbol table, not the global symbol table.
Compare to nm -D. If you're only getting 55, though, you've got
something else wrong... assuming you're using a dynamic libc.so.
Why are you using sym->st_value as a loop termination condition?
That is definitely wrong. I don't believe the size of the symtab
is available, but you're going to stop at the first undefined symbol.
--
Daniel Jacobowitz
CodeSourcery