public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12939] New: resolving shared library symbols returns wrong file
@ 2011-06-27 16:52 andi-bz at firstfloor dot org
  2012-02-21  2:15 ` [Bug ld.so|libdl/12939] " jsm28 at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: andi-bz at firstfloor dot org @ 2011-06-27 16:52 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12939

           Summary: resolving shared library symbols returns wrong file
           Product: glibc
           Version: 2.14
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: andi-bz@firstfloor.org


dladdr() when called with a shared library symbol like printf
returns the name of the main executable in dli_fname

I suspect it happens because it resolves the PLT, but that's clearly
unexpected and makes it hard to use if you want to know
what .so printf is in. Is there a way around it?

Maybe the function could check for PLTs and resolve them?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ld.so|libdl/12939] resolving shared library symbols returns wrong file
  2011-06-27 16:52 [Bug libc/12939] New: resolving shared library symbols returns wrong file andi-bz at firstfloor dot org
@ 2012-02-21  2:15 ` jsm28 at gcc dot gnu.org
  2012-12-19 10:47 ` [Bug dynamic-link/12939] " schwab@linux-m68k.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-02-21  2:15 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12939

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libc                        |ld.so|libdl

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug dynamic-link/12939] resolving shared library symbols returns wrong file
  2011-06-27 16:52 [Bug libc/12939] New: resolving shared library symbols returns wrong file 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 ` schwab@linux-m68k.org
  2014-06-27 13:03 ` fweimer at redhat dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2012-12-19 10:47 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12939

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|drepper.fsp at gmail dot    |unassigned at sourceware
                   |com                         |dot org

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug dynamic-link/12939] resolving shared library symbols returns wrong file
  2011-06-27 16:52 [Bug libc/12939] New: resolving shared library symbols returns wrong file 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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 13:03 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=12939

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug dynamic-link/12939] resolving shared library symbols returns wrong file
  2011-06-27 16:52 [Bug libc/12939] New: resolving shared library symbols returns wrong file andi-bz at firstfloor dot org
                   ` (2 preceding siblings ...)
  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
  2015-01-12 20:27 ` p.kopyl at samsung dot com
  5 siblings, 0 replies; 7+ messages in thread
From: alexander.long91 at gmail dot com @ 2014-07-02 15:38 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=12939

Alex Long <alexander.long91 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alexander.long91 at gmail dot com

--- Comment #1 from Alex Long <alexander.long91 at gmail dot com> ---
Created attachment 7675
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7675&action=edit
dladdr arm vs x86_64 different behavior example

compiled with
g++ main.cpp -o main -Wall -Wextra -ldl -fPIC

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug dynamic-link/12939] resolving shared library symbols returns wrong file
  2011-06-27 16:52 [Bug libc/12939] New: resolving shared library symbols returns wrong file andi-bz at firstfloor dot org
                   ` (3 preceding siblings ...)
  2014-07-02 15:38 ` alexander.long91 at gmail dot com
@ 2014-07-02 15:39 ` alexander.long91 at gmail dot com
  2015-01-12 20:27 ` p.kopyl at samsung dot com
  5 siblings, 0 replies; 7+ messages in thread
From: alexander.long91 at gmail dot com @ 2014-07-02 15:39 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug dynamic-link/12939] resolving shared library symbols returns wrong file
  2011-06-27 16:52 [Bug libc/12939] New: resolving shared library symbols returns wrong file andi-bz at firstfloor dot org
                   ` (4 preceding siblings ...)
  2014-07-02 15:39 ` alexander.long91 at gmail dot com
@ 2015-01-12 20:27 ` p.kopyl at samsung dot com
  5 siblings, 0 replies; 7+ messages in thread
From: p.kopyl at samsung dot com @ 2015-01-12 20:27 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=12939

Pavel Kopyl <p.kopyl at samsung dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |p.kopyl at samsung dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-12 20:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-27 16:52 [Bug libc/12939] New: resolving shared library symbols returns wrong file 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
2015-01-12 20:27 ` p.kopyl at samsung dot com

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).