From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16176 invoked by alias); 27 Nov 2013 12:10:59 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 16123 invoked by uid 48); 27 Nov 2013 12:10:55 -0000 From: "srk31 at srcf dot ucam.org" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/16262] New: Semantics of dladdr don't quite match documentation Date: Wed, 27 Nov 2013 12:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: 2.17 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: srk31 at srcf dot ucam.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg00296.txt.bz2 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.