This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug dynamic-link/12939] resolving shared library symbols returns wrong file


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]