public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "alexander.long91 at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/12939] resolving shared library symbols returns wrong file Date: Wed, 02 Jul 2014 15:39:00 -0000 [thread overview] Message-ID: <bug-12939-131-l3ddoR6kLY@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-12939-131@http.sourceware.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.
next prev parent reply other threads:[~2014-07-02 15:39 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-06-27 16:52 [Bug libc/12939] New: " andi-bz at firstfloor dot org 2012-02-21 2:15 ` [Bug ld.so|libdl/12939] " jsm28 at gcc dot gnu.org 2012-12-19 10:47 ` [Bug dynamic-link/12939] " schwab@linux-m68k.org 2014-06-27 13:03 ` fweimer at redhat dot com 2014-07-02 15:38 ` alexander.long91 at gmail dot com 2014-07-02 15:39 ` alexander.long91 at gmail dot com [this message] 2015-01-12 20:27 ` p.kopyl at samsung dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-12939-131-l3ddoR6kLY@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).