This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug dynamic-link/16262] New: Semantics of dladdr don't quite match documentation
- From: "srk31 at srcf dot ucam.org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 27 Nov 2013 12:10:53 +0000
- Subject: [Bug dynamic-link/16262] New: Semantics of dladdr don't quite match documentation
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16262
Bug ID: 16262
Summary: Semantics of dladdr don't quite match documentation
Product: glibc
Version: 2.17
Status: NEW
Severity: normal
Priority: P2
Component: dynamic-link
Assignee: unassigned at sourceware dot org
Reporter: srk31 at srcf dot ucam.org
Created attachment 7307
--> https://sourceware.org/bugzilla/attachment.cgi?id=7307&action=edit
Program illustrating the behaviour I'm querying
The man page of dladdr(3) states that dladdr(addr, &info) populates
info such that info.dli_sname is "the name of the nearest symbol with
address lower than addr".
In fact, on ELF platforms, it seems only to do so if a symbol *overlaps*
addr, i.e. using the symbol's length information. I've attached a very
small test case. If the documented semantics held, the decrement-by-one
logic would never be hit (client.c:72).
I'm not sure whether this is a bug with the documentation or with
dladdr(), but I'd argue that the documented behaviour would be useful to
have, perhaps as an alternative to the actual behaviour.
Background: I was hoping to use dladdr() as a portable interface for
walking (backwards) through all dynamic symbols defined in a text
segment. Owing to this quirk, though, I get stuck the moment I hit an
address that is not overlapped by a dynamic symbol. If it had the
documented semantics, I'd always get the next lowest symbol.
The documented semantics are also what any implementation for object
formats *without* length information would give. So, this is perhaps a
portability issue (I can do something on those platforms that then
doesn't work on ELF).
I realise the "right way" to do this is to use libelf or bfd, but it's
frustrating to come so close to not needing the big hammer, especially
when the documentation makes it look like I don't need it.
--
You are receiving this mail because:
You are on the CC list for the bug.