public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "satoru at 0xcc dot net" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/2683] dladdr() returns wrong symbol names in rare cases
Date: Sun, 28 May 2006 05:04:00 -0000 [thread overview]
Message-ID: <20060528050412.18533.qmail@sourceware.org> (raw)
In-Reply-To: <20060522145631.2683.satoru@0xcc.net>
------- Additional Comments From satoru at 0xcc dot net 2006-05-28 05:04 -------
(In reply to comment #1)
> Correct patch, I applied it to CVS.
Thank you for fixing the bug.
I just realized that completly skipping undefined references
could be a problem. Consider the following code.
#include <stdio.h>
int main() {
printf("%p\n", &printf);
return 0;
}
If I compile it without -fPIC on my machine (Debian GNU/Linux sarge on a x86_32
machine),
&printf points to a memory address in PLT.
% gcc test.c
% ./a.out
0x8048288
% readelf -S a.out |grep " \.plt"
[11] .plt PROGBITS 08048270 000270 000030 04 AX 0 0 4
The binary contains the undefined symbols for printf both in
.dysym and .symtab sections and the values of the undefined symbols
correspond to the memory address in PLT (0x8048288).
% readelf --symbols a.out |grep printf
2: 08048288 57 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.0 (2)
99: 08048288 57 FUNC GLOBAL DEFAULT UND printf@@GLIBC_2.0
Hence, to support dladdr(&printf, info) for non-pic binaries,
probably we need to allow the condition something like this as well.
(ELFW(ST_TYPE) (symtab->st_info) == STT_FUNC
&& symtab->st_shndx == SHN_UNDEF
&& match->l_addr + symtab->st_value == addr)
On the other hand, if I compile the same code with -fPIC,
&printf points to the printf definition in the map of glibc.
There is no problem in this case for doing dladdr(&printf, info).
% gcc -fPIC test.c
% ./a.out
0x4006e8e0
% ldd a.out
libc.so.6 => /lib/libc.so.6 (0x4001f000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
% readelf --symbols /lib/libc.so.6|grep " printf"
157: 0004f8e0 57 FUNC GLOBAL DEFAULT 11 printf@@GLIBC_2.0
% python
>>> "%x" % (0x4001f000 + 0x0004f8e0)
'4006e8e0'
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
http://sourceware.org/bugzilla/show_bug.cgi?id=2683
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
next prev parent reply other threads:[~2006-05-28 5:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-22 14:57 [Bug libc/2683] New: " satoru at 0xcc dot net
2006-05-24 19:25 ` [Bug libc/2683] " drepper at redhat dot com
2006-05-28 5:04 ` satoru at 0xcc dot net [this message]
2006-08-24 20:20 ` drepper at redhat 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=20060528050412.18533.qmail@sourceware.org \
--to=sourceware-bugzilla@sourceware.org \
--cc=glibc-bugs@sources.redhat.com \
/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: link
Be 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).