dladdr in executable and shared object

Andreas Bachmann bachi at te-clan.ch
Sun Feb 19 08:59:51 PST 2006


Hello!

Want to have a runtime stacktrace like in a java environment.
Why will dladdr get an incorrect dli_fname, when I execute a
standalone (without shared object) program?
http://bachi.te-clan.ch/freebsd/i386-freebsd-backtrace.c
http://bachi.te-clan.ch/freebsd/i386-freebsd-backtrace.result

When I create a shared object and link it with a executable,
all functions in the shared object will be resolved, but all
other functions will get an incorrect result.
http://bachi.te-clan.ch/freebsd/i386-freebsd-backtrace-lib.c
http://bachi.te-clan.ch/freebsd/i386-freebsd-backtrace-load.c
http://bachi.te-clan.ch/freebsd/i386-freebsd-backtrace-lib.result

In solaris also standalone programs will get correct dli_fname...
http://bachi.te-clan.ch/freebsd/sparc-solaris-backtrace.c
http://bachi.te-clan.ch/freebsd/sparc-solaris-backtrace.result

I think the whole dynamic linking functions are buggy.
dlsym will also not work.
http://bachi.te-clan.ch/freebsd/i386-freebsd-dlsym.c
http://bachi.te-clan.ch/freebsd/i386-freebsd-dlsym.result

Is this a gap and will be implemented/fixed?
Are there other functions to translate addresses
to symbols on runtime?

greets

Andreas



More information about the freebsd-hackers mailing list