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