This is the mail archive of the
mailing list for the glibc project.
[PATCH][BZ #14932] make dlsym return the newest symbol version
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Tue, 16 Apr 2013 13:53:45 +0530
- Subject: [PATCH][BZ #14932] make dlsym return the newest symbol version
pr #14932 reports an inconsistency in the return value of dlsym when
called with a dlopen'd handle vs RTLD_NEXT. dlsym(RTLD_NEXT) seems to
pick up the oldest version of the symbol whereas dlsym(handle) picks
up the latest version. A trivial patch (below, tested on x86_64 and
i686) fixes this.
The bug report mentions a previous discussion about this which
seems to indicate that the issue of RTLD_NEXT returning the older
symbol was deliberately not fixed to preserve compatibility - I'm not
sure though, since I feel like I'm misinterpreting Geoff's response.
In any case, I dug through the history of dl-lookup.c and dl-sym.c and
found that this inconsistency most likely wasn't always there.
Starting with f9f2a150e845fa19fc047285aa38e9164e42aa6a up to the point
that consolidation was done into do_lookup_symbol_x, both RTLD_NEXT
and the usual dlsym paths used DL_LOOKUP_RETURN_NEWEST to do the
symbol search, which I guess should return the newest version of the
symbol. So this doesn't rule out an error being the cause of this
Can someone who was active back then throw some light on this?
* elf/dl-sym.c (do_sym): Pass flags to dl_lookup_symbol_x for
diff --git a/elf/dl-sym.c b/elf/dl-sym.c
index 05de6c1..a988068 100644
@@ -159,7 +159,7 @@ RTLD_NEXT used in code not dynamically loaded"));
l = l->l_loader;
result = GLRO(dl_lookup_symbol_x) (name, match, &ref, l->l_local_scope,
- vers, 0, 0, match);
+ vers, 0, flags, match);