From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C5C763857423; Fri, 20 May 2022 07:40:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5C763857423 From: "i at maskray dot me" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i at maskray dot me X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2022 07:40:36 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D14932 --- Comment #7 from Fangrui Song --- 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=3D=3D0 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_NE= WEST 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 =3D l->l_loader; result =3D GLRO(dl_lookup_symbol_x) (name, match, &ref, l->l_local_s= cope, - vers, 0, 0, match); + vers, 0, flags, match); } else { --=20 You are receiving this mail because: You are on the CC list for the bug.=