diff mbox series

[3/4] elf: Support version-less lookup in _dl_lookup_direct

Message ID 52bda11381ea8bec52decc1809373971e46abbab.1640284721.git.fweimer@redhat.com
State New
Headers show
Series _r_debug copy relocation support | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Florian Weimer Dec. 23, 2021, 6:43 p.m. UTC
---
 elf/dl-lookup-direct.c     | 5 +++++
 sysdeps/generic/ldsodefs.h | 7 ++++---
 2 files changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/elf/dl-lookup-direct.c b/elf/dl-lookup-direct.c
index 08ac4d4104..6617962c4d 100644
--- a/elf/dl-lookup-direct.c
+++ b/elf/dl-lookup-direct.c
@@ -54,6 +54,11 @@  check_match (const struct link_map *const map, const char *const undef_name,
     /* Not the symbol we are looking for.  */
     return NULL;
 
+  if (map->l_versyms == NULL || version == NULL)
+    /* No symbol versioning information available, or no symbol
+       version requested.  Accepted the symbol.  */
+    return sym;
+
   ElfW(Half) ndx = map->l_versyms[symidx] & 0x7fff;
   if (map->l_versions[ndx].hash != version_hash
       || strcmp (map->l_versions[ndx].name, version) != 0)
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 9efd5506b6..8ff06d6b02 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -1051,9 +1051,10 @@  extern lookup_t _dl_lookup_symbol_x (const char *undef,
    MAP) for the symbol UNDEF_NAME, with GNU hash NEW_HASH (computed
    with dl_new_hash), symbol version VERSION, and symbol version hash
    VERSION_HASH (computed with _dl_elf_hash).  Returns a pointer to
-   the symbol table entry in MAP on success, or NULL on failure.  MAP
-   must have symbol versioning information, or otherwise the result is
-   undefined.  */
+   the symbol table entry in MAP on success, or NULL on failure.
+
+   If VERSION is NULL or MAP does not have symbol versioning
+   information, any symbol version is accepted.  */
 const ElfW(Sym) *_dl_lookup_direct (struct link_map *map,
 				    const char *undef_name,
 				    uint32_t new_hash,