public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "i at maskray dot me" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/14932] dlsym(handle, "foo") and dlsym(RTLD_NEXT, "foo") return different result with versioned "foo"
Date: Fri, 20 May 2022 07:40:36 +0000	[thread overview]
Message-ID: <bug-14932-131-SsnhqDk6Io@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-14932-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=14932

--- Comment #7 from Fangrui Song <i at maskray dot me> ---
The issue is that dlsym(RTLD_DEFAULT, ...) sets flags to
DL_LOOKUP_RETURN_NEWEST (along with one or two other bits) while
dlsym(RTLD_NEXT, ...) passes flags==0 to dl_lookup_symbol_x.
When DL_LOOKUP_RETURN_NEWEST is in action, the default version definition is
preferred over a non-default version definition.

The following patch will make dlsym(RTLD_NEXT, ...) use DL_LOOKUP_RETURN_NEWEST
and therefore fix the bug:

--- i/elf/dl-sym.c
+++ w/elf/dl-sym.c
@@ -144,7 +144,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
     {

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-05-20  7:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-14932-131@http.sourceware.org/bugzilla/>
2014-02-07  3:05 ` jsm28 at gcc dot gnu.org
2014-06-14  7:38 ` fweimer at redhat dot com
2014-10-27 18:47 ` carlos at redhat dot com
2021-02-09 18:07 ` i at maskray dot me
2021-08-10  9:59 ` jakub at redhat dot com
2021-08-10 10:07 ` fweimer at redhat dot com
2021-08-10 18:21 ` ppluzhnikov at google dot com
2022-05-20  7:40 ` i at maskray dot me [this message]
2022-05-27 19:47 ` i at maskray dot me
2022-05-27 20:09 ` i at maskray dot me

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=bug-14932-131-SsnhqDk6Io@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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).