7c0489
commit 71bcfa62451dfaa015326d3524f2a0e2d09d80ed
7c0489
Author: David Kilroy <David.Kilroy@arm.com>
7c0489
Date:   Wed Feb 12 14:30:31 2020 -0300
7c0489
7c0489
    elf: avoid redundant sort in dlopen
7c0489
    
7c0489
    l_initfini is already sorted by dependency in _dl_map_object_deps(),
7c0489
    so avoid sorting again in dl_open_worker().
7c0489
    
7c0489
    Tested by running the testsuite on x86_64.
7c0489
7c0489
diff --git a/elf/dl-open.c b/elf/dl-open.c
7c0489
index d31356f7e17dfb14..980a28c836ca9a7a 100644
7c0489
--- a/elf/dl-open.c
7c0489
+++ b/elf/dl-open.c
7c0489
@@ -614,9 +614,10 @@ dl_open_worker (void *a)
7c0489
   if (GLRO(dl_lazy))
7c0489
     reloc_mode |= mode & RTLD_LAZY;
7c0489
 
7c0489
-  /* Sort the objects by dependency for the relocation process.  This
7c0489
-     allows IFUNC relocations to work and it also means copy
7c0489
-     relocation of dependencies are if necessary overwritten.  */
7c0489
+  /* Objects must be sorted by dependency for the relocation process.
7c0489
+     This allows IFUNC relocations to work and it also means copy
7c0489
+     relocation of dependencies are if necessary overwritten.
7c0489
+     __dl_map_object_deps has already sorted l_initfini for us.  */
7c0489
   unsigned int nmaps = 0;
7c0489
   unsigned int j = 0;
7c0489
   struct link_map *l = new->l_initfini[0];
7c0489
@@ -639,7 +640,6 @@ dl_open_worker (void *a)
7c0489
       l = new->l_initfini[++j];
7c0489
     }
7c0489
   while (l != NULL);
7c0489
-  _dl_sort_maps (maps, nmaps, NULL, false);
7c0489
 
7c0489
   int relocation_in_progress = 0;
7c0489