incomplete symtabs via dl_iterate_phdr?
Daniel Jacobowitz
drow@false.org
Tue Jan 2 15:56:00 GMT 2007
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
More information about the Binutils
mailing list