public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elf: Simplify version test when searching a versioned symbol
@ 2022-05-01  7:46 Fangrui Song
  2022-05-01  7:56 ` Fangrui Song
  0 siblings, 1 reply; 4+ messages in thread
From: Fangrui Song @ 2022-05-01  7:46 UTC (permalink / raw)
  To: libc-alpha, Florian Weimer

---
 elf/dl-lookup.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 989b073e4f..3ad6c95d79 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -110,14 +110,14 @@ check_match (const char *const undef_name,
 	}
       else
 	{
-	  /* We can match the version information or use the
-	     default one if it is not hidden.  */
-	  ElfW(Half) ndx = verstab[symidx] & 0x7fff;
+	  /* When the version does not match, allow VER_NDX_GLOBAL fallback when
+	     resolving relocations (version->hidden==0).  Don't bother with the
+	     check done by the linker: VER_NDX_GLOBAL symbol cannot be hidden.
+	     */
+	  ElfW (Half) ndx = verstab[symidx] & 0x7fff;
 	  if ((map->l_versions[ndx].hash != version->hash
 	       || strcmp (map->l_versions[ndx].name, version->name))
-	      && (version->hidden || map->l_versions[ndx].hash
-		  || (verstab[symidx] & 0x8000)))
-	    /* It's not the version we want.  */
+	      && (version->hidden || ndx != VER_NDX_GLOBAL))
 	    return NULL;
 	}
     }
-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-02 18:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-01  7:46 [PATCH] elf: Simplify version test when searching a versioned symbol Fangrui Song
2022-05-01  7:56 ` Fangrui Song
2022-05-02  8:40   ` Florian Weimer
2022-05-02 18:58     ` Fangrui Song

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).