diff mbox series

[RFC,v12,3/8] Use the new DSO finder helper function

Message ID 20210708163255.812-4-vivek@collabora.com
State Superseded
Delegated to: Adhemerval Zanella Netto
Headers show
Series Implementation of RTLD_SHARED for dlmopen | expand

Checks

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

Commit Message

Vivek Das Mohapatra July 8, 2021, 4:32 p.m. UTC
---
 elf/dl-load.c | 28 +++-------------------------
 1 file changed, 3 insertions(+), 25 deletions(-)

Comments

Adhemerval Zanella Aug. 9, 2021, 12:59 p.m. UTC | #1
I think it would be better to merge it with the previous patch.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

On 08/07/2021 13:32, Vivek Das Mohapatra via Libc-alpha wrote:
> ---
>  elf/dl-load.c | 28 +++-------------------------
>  1 file changed, 3 insertions(+), 25 deletions(-)
> 
> diff --git a/elf/dl-load.c b/elf/dl-load.c
> index 26680b7f68..050c64135a 100644
> --- a/elf/dl-load.c
> +++ b/elf/dl-load.c
> @@ -2082,32 +2082,10 @@ _dl_map_object (struct link_map *loader, const char *name,
>    assert (nsid < GL(dl_nns));
>  
>    /* Look for this name among those already loaded.  */
> -  for (l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next)
> +  l = _dl_find_dso (name, nsid);
> +
> +  if (l != NULL)
>      {
> -      /* If the requested name matches the soname of a loaded object,
> -	 use that object.  Elide this check for names that have not
> -	 yet been opened.  */
> -      if (__glibc_unlikely ((l->l_faked | l->l_removed) != 0))
> -	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)
> -	    continue;
> -
> -	  /* We have a match on a new name -- cache it.  */
> -	  add_name_to_object (l, soname);
> -	  l->l_soname_added = 1;
> -	}
> -
> -      /* We have a match.  */
>        return l;
>      }
>  
>
diff mbox series

Patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 26680b7f68..050c64135a 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -2082,32 +2082,10 @@  _dl_map_object (struct link_map *loader, const char *name,
   assert (nsid < GL(dl_nns));
 
   /* Look for this name among those already loaded.  */
-  for (l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next)
+  l = _dl_find_dso (name, nsid);
+
+  if (l != NULL)
     {
-      /* If the requested name matches the soname of a loaded object,
-	 use that object.  Elide this check for names that have not
-	 yet been opened.  */
-      if (__glibc_unlikely ((l->l_faked | l->l_removed) != 0))
-	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)
-	    continue;
-
-	  /* We have a match on a new name -- cache it.  */
-	  add_name_to_object (l, soname);
-	  l->l_soname_added = 1;
-	}
-
-      /* We have a match.  */
       return l;
     }