This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ #14932] make dlsym return the newest symbol version


Hi,

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[1][2] 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
inconsistency.

Can someone who was active back then throw some light on this?

Thanks,
Siddhesh

	[BZ #14932]
	* elf/dl-sym.c (do_sym): Pass flags to dl_lookup_symbol_x for
	RTLD_NEXT.

diff --git a/elf/dl-sym.c b/elf/dl-sym.c
index 05de6c1..a988068 100644
--- a/elf/dl-sym.c
+++ b/elf/dl-sym.c
@@ -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);
     }
   else
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]