Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Feb 2006 17:59:47 +0100
From:      Andreas Bachmann <bachi@te-clan.ch>
To:        hackers@freebsd.org
Subject:   dladdr in executable and shared object
Message-ID:  <1140368387.28785.63.camel@localhost>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1140368387.28785.63.camel>