aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-load.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2025-02-02 20:10:09 +0100
committerFlorian Weimer <fweimer@redhat.com>2025-02-02 20:10:09 +0100
commit749310c61b66aa2af0422db25686440b64a14800 (patch)
tree4e03db64b2ef074947e9e5b9556739f99567145a /elf/dl-load.c
parentaa1bf8903992cc0d26cacb9e5930a9fed8f50548 (diff)
downloadglibc-749310c61b66aa2af0422db25686440b64a14800.zip
glibc-749310c61b66aa2af0422db25686440b64a14800.tar.gz
glibc-749310c61b66aa2af0422db25686440b64a14800.tar.bz2
elf: Add l_soname accessor function for DT_SONAME values
It's not necessary to introduce temporaries because the compiler is able to evaluate l_soname just once in constracts like: l_soname (l) != NULL && strcmp (l_soname (l), LIBC_SO) != 0
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r--elf/dl-load.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index deb1b32..4998652 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1421,10 +1421,8 @@ cannot enable executable stack as shared object requires");
/* When we profile the SONAME might be needed for something else but
loading. Add it right away. */
- if (__glibc_unlikely (GLRO(dl_profile) != NULL)
- && l->l_info[DT_SONAME] != NULL)
- add_name_to_object (l, ((const char *) D_PTR (l, l_info[DT_STRTAB])
- + l->l_info[DT_SONAME]->d_un.d_val));
+ if (__glibc_unlikely (GLRO(dl_profile) != NULL) && l_soname (l) != NULL)
+ add_name_to_object (l, l_soname (l));
#else
/* Audit modules only exist when linking is dynamic so ORIGNAME
cannot be non-NULL. */
@@ -1434,9 +1432,7 @@ cannot enable executable stack as shared object requires");
/* If we have newly loaded libc.so, update the namespace
description. */
if (GL(dl_ns)[nsid].libc_map == NULL
- && l->l_info[DT_SONAME] != NULL
- && strcmp (((const char *) D_PTR (l, l_info[DT_STRTAB])
- + l->l_info[DT_SONAME]->d_un.d_val), LIBC_SO) == 0)
+ && l_soname (l) != NULL && strcmp (l_soname(l), LIBC_SO) == 0)
GL(dl_ns)[nsid].libc_map = l;
/* _dl_close can only eventually undo the module ID assignment (via
@@ -1903,19 +1899,12 @@ _dl_lookup_map (Lmid_t nsid, const char *name)
continue;
if (!_dl_name_match_p (name, l))
{
- const char *soname;
-
- if (__glibc_likely (l->l_soname_added)
- || l->l_info[DT_SONAME] == NULL)
- continue;
-
- soname = ((const char *) D_PTR (l, l_info[DT_STRTAB])
- + l->l_info[DT_SONAME]->d_un.d_val);
- if (strcmp (name, soname) != 0)
+ if (__glibc_likely (l->l_soname_added) || l_soname (l) == NULL
+ || strcmp (name, l_soname (l)) != 0)
continue;
/* We have a match on a new name -- cache it. */
- add_name_to_object (l, soname);
+ add_name_to_object (l, l_soname (l));
l->l_soname_added = 1;
}