This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug dynamic-link/12939] resolving shared library symbols returns wrong file
- From: "alexander.long91 at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 02 Jul 2014 15:39:15 +0000
- Subject: [Bug dynamic-link/12939] resolving shared library symbols returns wrong file
- Auto-submitted: auto-generated
- References: <bug-12939-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=12939
--- Comment #2 from Alex Long <alexander.long91 at gmail dot com> ---
As suggested in the dladdr() man-page, compiling your code to be position
independent, using -fPIC for example, may cause dladdr to return the path to
the shared library the symbol comes from rather than return the path to the
executable.
However, one issue with this that I've noticed is that when building on or
cross-compiling for armv7l, dladdr will always return the path to the
executable for exported symbols that also happen to be called within the
program.
When compiled with
/usr/bin/g++-4.7 main.cpp -o main-ARM -Wall -Wextra -ldl -fPIC
the attached example program prints
"printf comes from /lib/x86_64-linux-gnu/libc.so.6" on x86_64 machines
and
"printf comes from ./main" on armv7l
--
You are receiving this mail because:
You are on the CC list for the bug.