diff mbox

[v4,2/3] elf: avoid redundant sort in dlopen

Message ID 1580296643-36839-3-git-send-email-david.kilroy@arm.com
State New
Headers show

Commit Message

David Kilroy Jan. 29, 2020, 11:17 a.m. UTC
l_initfini is already sorted by dependency in _dl_map_object_deps(),
so avoid sorting again in dl_open_worker().

Tested by running the testsuite on x86_64.
---
 elf/dl-open.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Adhemerval Zanella Feb. 10, 2020, 5:55 p.m. UTC | #1
On 29/01/2020 08:17, David Kilroy wrote:
> l_initfini is already sorted by dependency in _dl_map_object_deps(),
> so avoid sorting again in dl_open_worker().
> 
> Tested by running the testsuite on x86_64.

Still LGTM, thanks.

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

> ---
>  elf/dl-open.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/elf/dl-open.c b/elf/dl-open.c
> index ecb2ba9..314adc2 100644
> --- a/elf/dl-open.c
> +++ b/elf/dl-open.c
> @@ -617,9 +617,10 @@ dl_open_worker (void *a)
>    if (GLRO(dl_lazy))
>      reloc_mode |= mode & RTLD_LAZY;
>  
> -  /* Sort the objects by dependency for the relocation process.  This
> -     allows IFUNC relocations to work and it also means copy
> -     relocation of dependencies are if necessary overwritten.  */
> +  /* Objects must be sorted by dependency for the relocation process.
> +     This allows IFUNC relocations to work and it also means copy
> +     relocation of dependencies are if necessary overwritten.
> +     __dl_map_object_deps has already sorted l_initfini for us.  */
>    unsigned int nmaps = 0;
>    unsigned int j = 0;
>    struct link_map *l = new->l_initfini[0];
> @@ -642,7 +643,6 @@ dl_open_worker (void *a)
>        l = new->l_initfini[++j];
>      }
>    while (l != NULL);
> -  _dl_sort_maps (maps, nmaps, NULL, false);
>  
>    int relocation_in_progress = 0;
>  
>
diff mbox

Patch

diff --git a/elf/dl-open.c b/elf/dl-open.c
index ecb2ba9..314adc2 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -617,9 +617,10 @@  dl_open_worker (void *a)
   if (GLRO(dl_lazy))
     reloc_mode |= mode & RTLD_LAZY;
 
-  /* Sort the objects by dependency for the relocation process.  This
-     allows IFUNC relocations to work and it also means copy
-     relocation of dependencies are if necessary overwritten.  */
+  /* Objects must be sorted by dependency for the relocation process.
+     This allows IFUNC relocations to work and it also means copy
+     relocation of dependencies are if necessary overwritten.
+     __dl_map_object_deps has already sorted l_initfini for us.  */
   unsigned int nmaps = 0;
   unsigned int j = 0;
   struct link_map *l = new->l_initfini[0];
@@ -642,7 +643,6 @@  dl_open_worker (void *a)
       l = new->l_initfini[++j];
     }
   while (l != NULL);
-  _dl_sort_maps (maps, nmaps, NULL, false);
 
   int relocation_in_progress = 0;