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