08c3a6
commit b19de59d620b3a9e6adf937f322f4281b67fc712
08c3a6
Author: Fangrui Song <maskray@google.com>
08c3a6
Date:   Thu Oct 7 11:55:02 2021 -0700
08c3a6
08c3a6
    elf: Avoid nested functions in the loader [BZ #27220]
08c3a6
    
08c3a6
    dynamic-link.h is included more than once in some elf/ files (rtld.c,
08c3a6
    dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
08c3a6
    functions. This harms readability and the nested functions usage
08c3a6
    is the biggest obstacle prevents Clang build (Clang doesn't support GCC
08c3a6
    nested functions).
08c3a6
    
08c3a6
    The key idea for unnesting is to add extra parameters (struct link_map
08c3a6
    *and struct r_scope_elm *[]) to RESOLVE_MAP,
08c3a6
    ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
08c3a6
    elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
08c3a6
    by Stan Shebs' ppc64/x86-64 implementation in the
08c3a6
    google/grte/v5-2.27/master which uses mixed extra parameters and static
08c3a6
    variables.)
08c3a6
    
08c3a6
    Future simplification:
08c3a6
    * If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
08c3a6
      elf_machine_runtime_setup can drop the `scope` parameter.
08c3a6
    * If TLSDESC no longer need to be in elf_machine_lazy_rel,
08c3a6
      elf_machine_lazy_rel can drop the `scope` parameter.
08c3a6
    
08c3a6
    Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
08c3a6
    sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
08c3a6
    In addition, tested build-many-glibcs.py with {arc,csky,microblaze,nios2}-linux-gnu
08c3a6
    and riscv64-linux-gnu-rv64imafdc-lp64d.
08c3a6
    
08c3a6
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
08c3a6
    (cherry picked from commit 490e6c62aa31a8aa5c4a059f6e646ede121edf0a)
08c3a6
08c3a6
diff --git a/elf/dl-conflict.c b/elf/dl-conflict.c
08c3a6
index 31a2f90770ce2a55..5c8e51d19ae095d6 100644
08c3a6
--- a/elf/dl-conflict.c
08c3a6
+++ b/elf/dl-conflict.c
08c3a6
@@ -27,20 +27,12 @@
08c3a6
 #include <sys/types.h>
08c3a6
 #include "dynamic-link.h"
08c3a6
 
08c3a6
-void
08c3a6
-_dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
08c3a6
-		       ElfW(Rela) *conflictend)
08c3a6
-{
08c3a6
-#if ! ELF_MACHINE_NO_RELA
08c3a6
-  if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC))
08c3a6
-    _dl_debug_printf ("\nconflict processing: %s\n", DSO_FILENAME (l->l_name));
08c3a6
-
08c3a6
-  {
08c3a6
-    /* Do the conflict relocation of the object and library GOT and other
08c3a6
-       data.  */
08c3a6
+/* Used at loading time solely for prelink executable.  It is not called
08c3a6
+   concurrently so it is be safe to defined as static.  */
08c3a6
+static struct link_map *resolve_conflict_map __attribute__ ((__unused__));
08c3a6
 
08c3a6
     /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
08c3a6
-#define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL)
08c3a6
+#define RESOLVE_MAP(map, scope, ref, version, flags) (*ref = NULL, NULL)
08c3a6
 #define RESOLVE(ref, version, flags) (*ref = NULL, 0)
08c3a6
 #define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \
08c3a6
   do {									      \
08c3a6
@@ -51,12 +43,23 @@ _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
08c3a6
     (map) = resolve_conflict_map;					      \
08c3a6
   } while (0)
08c3a6
 
08c3a6
+#include "dynamic-link.h"
08c3a6
+
08c3a6
+void
08c3a6
+_dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
08c3a6
+		       ElfW(Rela) *conflictend)
08c3a6
+{
08c3a6
+#if ! ELF_MACHINE_NO_RELA
08c3a6
+  if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC))
08c3a6
+    _dl_debug_printf ("\nconflict processing: %s\n", DSO_FILENAME (l->l_name));
08c3a6
+
08c3a6
+  {
08c3a6
+    /* Do the conflict relocation of the object and library GOT and other
08c3a6
+       data.  */
08c3a6
+
08c3a6
     /* Prelinking makes no sense for anything but the main namespace.  */
08c3a6
     assert (l->l_ns == LM_ID_BASE);
08c3a6
-    struct link_map *resolve_conflict_map __attribute__ ((__unused__))
08c3a6
-      = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
08c3a6
-
08c3a6
-#include "dynamic-link.h"
08c3a6
+    resolve_conflict_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
08c3a6
 
08c3a6
     /* Override these, defined in dynamic-link.h.  */
08c3a6
 #undef CHECK_STATIC_TLS
08c3a6
@@ -67,8 +70,8 @@ _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
08c3a6
     GL(dl_num_cache_relocations) += conflictend - conflict;
08c3a6
 
08c3a6
     for (; conflict < conflictend; ++conflict)
08c3a6
-      elf_machine_rela (l, conflict, NULL, NULL, (void *) conflict->r_offset,
08c3a6
-			0);
08c3a6
+      elf_machine_rela (l, NULL, conflict, NULL, NULL,
08c3a6
+			(void *) conflict->r_offset, 0);
08c3a6
   }
08c3a6
 #endif
08c3a6
 }
08c3a6
diff --git a/elf/dl-reloc-static-pie.c b/elf/dl-reloc-static-pie.c
08c3a6
index 2fb02d727654c87d..a52ba8aeb8b573cb 100644
08c3a6
--- a/elf/dl-reloc-static-pie.c
08c3a6
+++ b/elf/dl-reloc-static-pie.c
08c3a6
@@ -19,8 +19,14 @@
08c3a6
 #if ENABLE_STATIC_PIE
08c3a6
 /* Mark symbols hidden in static PIE for early self relocation to work.  */
08c3a6
 # pragma GCC visibility push(hidden)
08c3a6
+#include <assert.h>
08c3a6
 #include <unistd.h>
08c3a6
 #include <ldsodefs.h>
08c3a6
+
08c3a6
+#include <dl-machine.h>
08c3a6
+
08c3a6
+#define STATIC_PIE_BOOTSTRAP
08c3a6
+#define RESOLVE_MAP(map, scope, sym, version, flags) map
08c3a6
 #include "dynamic-link.h"
08c3a6
 
08c3a6
 /* Relocate static executable with PIE.  */
08c3a6
@@ -30,11 +36,6 @@ _dl_relocate_static_pie (void)
08c3a6
 {
08c3a6
   struct link_map *main_map = _dl_get_dl_main_map ();
08c3a6
 
08c3a6
-# define STATIC_PIE_BOOTSTRAP
08c3a6
-# define BOOTSTRAP_MAP (main_map)
08c3a6
-# define RESOLVE_MAP(sym, version, flags) BOOTSTRAP_MAP
08c3a6
-# include "dynamic-link.h"
08c3a6
-
08c3a6
   /* Figure out the run-time load address of static PIE.  */
08c3a6
   main_map->l_addr = elf_machine_load_address ();
08c3a6
 
08c3a6
@@ -53,12 +54,12 @@ _dl_relocate_static_pie (void)
08c3a6
   elf_get_dynamic_info (main_map);
08c3a6
 
08c3a6
 # ifdef ELF_MACHINE_BEFORE_RTLD_RELOC
08c3a6
-  ELF_MACHINE_BEFORE_RTLD_RELOC (main_map->l_info);
08c3a6
+  ELF_MACHINE_BEFORE_RTLD_RELOC (main_map, main_map->l_info);
08c3a6
 # endif
08c3a6
 
08c3a6
   /* Relocate ourselves so we can do normal function calls and
08c3a6
      data access using the global offset table.  */
08c3a6
-  ELF_DYNAMIC_RELOCATE (main_map, 0, 0, 0);
08c3a6
+  ELF_DYNAMIC_RELOCATE (main_map, NULL, 0, 0, 0);
08c3a6
   main_map->l_relocated = 1;
08c3a6
 
08c3a6
   /* Initialize _r_debug.  */
08c3a6
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
08c3a6
index e13a672ade6d7a28..3447de7f3536cd70 100644
08c3a6
--- a/elf/dl-reloc.c
08c3a6
+++ b/elf/dl-reloc.c
08c3a6
@@ -162,6 +162,32 @@ _dl_nothread_init_static_tls (struct link_map *map)
08c3a6
 }
08c3a6
 #endif /* !THREAD_GSCOPE_IN_TCB */
08c3a6
 
08c3a6
+/* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
08c3a6
+#define RESOLVE_MAP(l, scope, ref, version, r_type)			      \
08c3a6
+    ((ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL			      \
08c3a6
+      && __glibc_likely (!dl_symbol_visibility_binds_local_p (*ref)))	      \
08c3a6
+     ? ((__glibc_unlikely ((*ref) == l->l_lookup_cache.sym)		      \
08c3a6
+	 && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class)  \
08c3a6
+	? (bump_num_cache_relocations (),				      \
08c3a6
+	   (*ref) = l->l_lookup_cache.ret,				      \
08c3a6
+	   l->l_lookup_cache.value)					      \
08c3a6
+	: ({ lookup_t _lr;						      \
08c3a6
+	     int _tc = elf_machine_type_class (r_type);			      \
08c3a6
+	     l->l_lookup_cache.type_class = _tc;			      \
08c3a6
+	     l->l_lookup_cache.sym = (*ref);				      \
08c3a6
+	     const struct r_found_version *v = NULL;			      \
08c3a6
+	     if ((version) != NULL && (version)->hash != 0)		      \
08c3a6
+	       v = (version);						      \
08c3a6
+	     _lr = _dl_lookup_symbol_x ((const char *) D_PTR (l, l_info[DT_STRTAB]) + (*ref)->st_name, \
08c3a6
+					l, (ref), scope, v, _tc,	      \
08c3a6
+					DL_LOOKUP_ADD_DEPENDENCY	      \
08c3a6
+					| DL_LOOKUP_FOR_RELOCATE, NULL);      \
08c3a6
+	     l->l_lookup_cache.ret = (*ref);				      \
08c3a6
+	     l->l_lookup_cache.value = _lr; }))				      \
08c3a6
+     : l)
08c3a6
+
08c3a6
+#include "dynamic-link.h"
08c3a6
+
08c3a6
 void
08c3a6
 _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
 		     int reloc_mode, int consider_profiling)
08c3a6
@@ -243,36 +269,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
   {
08c3a6
     /* Do the actual relocation of the object's GOT and other data.  */
08c3a6
 
08c3a6
-    /* String table object symbols.  */
08c3a6
-    const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
08c3a6
-
08c3a6
-    /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
08c3a6
-#define RESOLVE_MAP(ref, version, r_type) \
08c3a6
-    ((ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL			      \
08c3a6
-      && __glibc_likely (!dl_symbol_visibility_binds_local_p (*ref)))	      \
08c3a6
-     ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0)		      \
08c3a6
-	 && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class)  \
08c3a6
-	? (bump_num_cache_relocations (),				      \
08c3a6
-	   (*ref) = l->l_lookup_cache.ret,				      \
08c3a6
-	   l->l_lookup_cache.value)					      \
08c3a6
-	: ({ lookup_t _lr;						      \
08c3a6
-	     int _tc = elf_machine_type_class (r_type);			      \
08c3a6
-	     l->l_lookup_cache.type_class = _tc;			      \
08c3a6
-	     l->l_lookup_cache.sym = (*ref);				      \
08c3a6
-	     const struct r_found_version *v = NULL;			      \
08c3a6
-	     if ((version) != NULL && (version)->hash != 0)		      \
08c3a6
-	       v = (version);						      \
08c3a6
-	     _lr = _dl_lookup_symbol_x (strtab + (*ref)->st_name, l, (ref),   \
08c3a6
-					scope, v, _tc,			      \
08c3a6
-					DL_LOOKUP_ADD_DEPENDENCY	      \
08c3a6
-					| DL_LOOKUP_FOR_RELOCATE, NULL);      \
08c3a6
-	     l->l_lookup_cache.ret = (*ref);				      \
08c3a6
-	     l->l_lookup_cache.value = _lr; }))				      \
08c3a6
-     : l)
08c3a6
-
08c3a6
-#include "dynamic-link.h"
08c3a6
-
08c3a6
-    ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc);
08c3a6
+    ELF_DYNAMIC_RELOCATE (l, scope, lazy, consider_profiling, skip_ifunc);
08c3a6
 
08c3a6
 #ifndef PROF
08c3a6
     if (__glibc_unlikely (consider_profiling)
08c3a6
diff --git a/elf/do-rel.h b/elf/do-rel.h
08c3a6
index 321ac2b359c1028c..f441b749190c2641 100644
08c3a6
--- a/elf/do-rel.h
08c3a6
+++ b/elf/do-rel.h
08c3a6
@@ -37,8 +37,8 @@
08c3a6
    relocations; they should be set up to call _dl_runtime_resolve, rather
08c3a6
    than fully resolved now.  */
08c3a6
 
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
-elf_dynamic_do_Rel (struct link_map *map,
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
+elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		    ElfW(Addr) reladdr, ElfW(Addr) relsize,
08c3a6
 		    __typeof (((ElfW(Dyn) *) 0)->d_un.d_val) nrelative,
08c3a6
 		    int lazy, int skip_ifunc)
08c3a6
@@ -68,13 +68,13 @@ elf_dynamic_do_Rel (struct link_map *map,
08c3a6
 	  }
08c3a6
 	else
08c3a6
 # endif
08c3a6
-	  elf_machine_lazy_rel (map, l_addr, r, skip_ifunc);
08c3a6
+	  elf_machine_lazy_rel (map, scope, l_addr, r, skip_ifunc);
08c3a6
 
08c3a6
 # ifdef ELF_MACHINE_IRELATIVE
08c3a6
       if (r2 != NULL)
08c3a6
 	for (; r2 <= end2; ++r2)
08c3a6
 	  if (ELFW(R_TYPE) (r2->r_info) == ELF_MACHINE_IRELATIVE)
08c3a6
-	    elf_machine_lazy_rel (map, l_addr, r2, skip_ifunc);
08c3a6
+	    elf_machine_lazy_rel (map, scope, l_addr, r2, skip_ifunc);
08c3a6
 # endif
08c3a6
     }
08c3a6
   else
08c3a6
@@ -134,7 +134,7 @@ elf_dynamic_do_Rel (struct link_map *map,
08c3a6
 #endif
08c3a6
 
08c3a6
 	      ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)] & 0x7fff;
08c3a6
-	      elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)],
08c3a6
+	      elf_machine_rel (map, scope, r, &symtab[ELFW(R_SYM) (r->r_info)],
08c3a6
 			       &map->l_versions[ndx],
08c3a6
 			       (void *) (l_addr + r->r_offset), skip_ifunc);
08c3a6
 	    }
08c3a6
@@ -146,7 +146,7 @@ elf_dynamic_do_Rel (struct link_map *map,
08c3a6
 		{
08c3a6
 		  ElfW(Half) ndx
08c3a6
 		    = version[ELFW(R_SYM) (r2->r_info)] & 0x7fff;
08c3a6
-		  elf_machine_rel (map, r2,
08c3a6
+		  elf_machine_rel (map, scope, r2,
08c3a6
 				   &symtab[ELFW(R_SYM) (r2->r_info)],
08c3a6
 				   &map->l_versions[ndx],
08c3a6
 				   (void *) (l_addr + r2->r_offset),
08c3a6
@@ -167,14 +167,14 @@ elf_dynamic_do_Rel (struct link_map *map,
08c3a6
 	      }
08c3a6
 	    else
08c3a6
 # endif
08c3a6
-	      elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
08c3a6
+	      elf_machine_rel (map, scope, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
08c3a6
 			       (void *) (l_addr + r->r_offset), skip_ifunc);
08c3a6
 
08c3a6
 # ifdef ELF_MACHINE_IRELATIVE
08c3a6
 	  if (r2 != NULL)
08c3a6
 	    for (; r2 <= end2; ++r2)
08c3a6
 	      if (ELFW(R_TYPE) (r2->r_info) == ELF_MACHINE_IRELATIVE)
08c3a6
-		elf_machine_rel (map, r2, &symtab[ELFW(R_SYM) (r2->r_info)],
08c3a6
+		elf_machine_rel (map, scope, r2, &symtab[ELFW(R_SYM) (r2->r_info)],
08c3a6
 				 NULL, (void *) (l_addr + r2->r_offset),
08c3a6
 				 skip_ifunc);
08c3a6
 # endif
08c3a6
diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h
08c3a6
index 3eb24ba3a6cee40b..7cc30211649d3820 100644
08c3a6
--- a/elf/dynamic-link.h
08c3a6
+++ b/elf/dynamic-link.h
08c3a6
@@ -59,31 +59,33 @@ int _dl_try_allocate_static_tls (struct link_map *map, bool optional)
08c3a6
    copying memory, breaking the very code written to handle the
08c3a6
    unaligned cases.  */
08c3a6
 # if ! ELF_MACHINE_NO_REL
08c3a6
-auto inline void __attribute__((always_inline))
08c3a6
-elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
08c3a6
-		 const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
+elf_machine_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		 const ElfW(Rel) *reloc, const ElfW(Sym) *sym,
08c3a6
+		 const struct r_found_version *version,
08c3a6
 		 void *const reloc_addr, int skip_ifunc);
08c3a6
-auto inline void __attribute__((always_inline))
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
 elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
08c3a6
 			  void *const reloc_addr);
08c3a6
 # endif
08c3a6
 # if ! ELF_MACHINE_NO_RELA
08c3a6
-auto inline void __attribute__((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
-		  const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
-		  void *const reloc_addr, int skip_ifunc);
08c3a6
-auto inline void __attribute__((always_inline))
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
08c3a6
+		  const struct r_found_version *version, void *const reloc_addr,
08c3a6
+		  int skip_ifunc);
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 			   void *const reloc_addr);
08c3a6
 # endif
08c3a6
 # if ELF_MACHINE_NO_RELA || defined ELF_MACHINE_PLT_REL
08c3a6
-auto inline void __attribute__((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
08c3a6
 		      int skip_ifunc);
08c3a6
 # else
08c3a6
-auto inline void __attribute__((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 		      int skip_ifunc);
08c3a6
 # endif
08c3a6
@@ -114,7 +116,7 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
    consumes precisely the very end of the DT_REL*, or DT_JMPREL and DT_REL*
08c3a6
    are completely separate and there is a gap between them.  */
08c3a6
 
08c3a6
-# define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, skip_ifunc, test_rel) \
08c3a6
+# define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, scope, do_lazy, skip_ifunc, test_rel) \
08c3a6
   do {									      \
08c3a6
     struct { ElfW(Addr) start, size;					      \
08c3a6
 	     __typeof (((ElfW(Dyn) *) 0)->d_un.d_val) nrelative; int lazy; }  \
08c3a6
@@ -152,18 +154,18 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
       }									      \
08c3a6
 									      \
08c3a6
     if (ELF_DURING_STARTUP)						      \
08c3a6
-      elf_dynamic_do_##reloc ((map), ranges[0].start, ranges[0].size,	      \
08c3a6
-			      ranges[0].nrelative, 0, skip_ifunc);	      \
08c3a6
+      elf_dynamic_do_##reloc ((map), scope, ranges[0].start, ranges[0].size,  \
08c3a6
+			      ranges[0].nrelative, 0, skip_ifunc);  \
08c3a6
     else								      \
08c3a6
       {									      \
08c3a6
 	int ranges_index;						      \
08c3a6
 	for (ranges_index = 0; ranges_index < 2; ++ranges_index)	      \
08c3a6
-	  elf_dynamic_do_##reloc ((map),				      \
08c3a6
+	  elf_dynamic_do_##reloc ((map), scope,				      \
08c3a6
 				  ranges[ranges_index].start,		      \
08c3a6
 				  ranges[ranges_index].size,		      \
08c3a6
 				  ranges[ranges_index].nrelative,	      \
08c3a6
 				  ranges[ranges_index].lazy,		      \
08c3a6
-				  skip_ifunc);				      \
08c3a6
+				  skip_ifunc);		      \
08c3a6
       }									      \
08c3a6
   } while (0)
08c3a6
 
08c3a6
@@ -175,29 +177,29 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
 
08c3a6
 # if ! ELF_MACHINE_NO_REL
08c3a6
 #  include "do-rel.h"
08c3a6
-#  define ELF_DYNAMIC_DO_REL(map, lazy, skip_ifunc) \
08c3a6
-  _ELF_DYNAMIC_DO_RELOC (REL, Rel, map, lazy, skip_ifunc, _ELF_CHECK_REL)
08c3a6
+#  define ELF_DYNAMIC_DO_REL(map, scope, lazy, skip_ifunc)	      \
08c3a6
+  _ELF_DYNAMIC_DO_RELOC (REL, Rel, map, scope, lazy, skip_ifunc, _ELF_CHECK_REL)
08c3a6
 # else
08c3a6
-#  define ELF_DYNAMIC_DO_REL(map, lazy, skip_ifunc) /* Nothing to do.  */
08c3a6
+#  define ELF_DYNAMIC_DO_REL(map, scope, lazy, skip_ifunc) /* Nothing to do.  */
08c3a6
 # endif
08c3a6
 
08c3a6
 # if ! ELF_MACHINE_NO_RELA
08c3a6
 #  define DO_RELA
08c3a6
 #  include "do-rel.h"
08c3a6
-#  define ELF_DYNAMIC_DO_RELA(map, lazy, skip_ifunc) \
08c3a6
-  _ELF_DYNAMIC_DO_RELOC (RELA, Rela, map, lazy, skip_ifunc, _ELF_CHECK_REL)
08c3a6
+#  define ELF_DYNAMIC_DO_RELA(map, scope, lazy, skip_ifunc)	      \
08c3a6
+  _ELF_DYNAMIC_DO_RELOC (RELA, Rela, map, scope, lazy, skip_ifunc, _ELF_CHECK_REL)
08c3a6
 # else
08c3a6
-#  define ELF_DYNAMIC_DO_RELA(map, lazy, skip_ifunc) /* Nothing to do.  */
08c3a6
+#  define ELF_DYNAMIC_DO_RELA(map, scope, lazy, skip_ifunc) /* Nothing to do.  */
08c3a6
 # endif
08c3a6
 
08c3a6
 /* This can't just be an inline function because GCC is too dumb
08c3a6
    to inline functions containing inlines themselves.  */
08c3a6
-# define ELF_DYNAMIC_RELOCATE(map, lazy, consider_profile, skip_ifunc) \
08c3a6
+# define ELF_DYNAMIC_RELOCATE(map, scope, lazy, consider_profile, skip_ifunc) \
08c3a6
   do {									      \
08c3a6
-    int edr_lazy = elf_machine_runtime_setup ((map), (lazy),		      \
08c3a6
+    int edr_lazy = elf_machine_runtime_setup ((map), (scope), (lazy),	      \
08c3a6
 					      (consider_profile));	      \
08c3a6
-    ELF_DYNAMIC_DO_REL ((map), edr_lazy, skip_ifunc);			      \
08c3a6
-    ELF_DYNAMIC_DO_RELA ((map), edr_lazy, skip_ifunc);			      \
08c3a6
+    ELF_DYNAMIC_DO_REL ((map), (scope), edr_lazy, skip_ifunc);		      \
08c3a6
+    ELF_DYNAMIC_DO_RELA ((map), (scope), edr_lazy, skip_ifunc);		      \
08c3a6
   } while (0)
08c3a6
 
08c3a6
 #endif
08c3a6
diff --git a/elf/get-dynamic-info.h b/elf/get-dynamic-info.h
08c3a6
index 4aa2058abf6443c9..15c316b38c05a90c 100644
08c3a6
--- a/elf/get-dynamic-info.h
08c3a6
+++ b/elf/get-dynamic-info.h
08c3a6
@@ -16,18 +16,15 @@
08c3a6
    License along with the GNU C Library; if not, see
08c3a6
    <https://www.gnu.org/licenses/>.  */
08c3a6
 
08c3a6
-/* This file is included multiple times and therefore lacks a header
08c3a6
-   file inclusion guard.  */
08c3a6
+/* Populate dynamic tags in l_info.  */
08c3a6
+
08c3a6
+#ifndef _GET_DYNAMIC_INFO_H
08c3a6
+#define _GET_DYNAMIC_INFO_H
08c3a6
 
08c3a6
 #include <assert.h>
08c3a6
 #include <libc-diag.h>
08c3a6
 
08c3a6
-#ifndef RESOLVE_MAP
08c3a6
-static
08c3a6
-#else
08c3a6
-auto
08c3a6
-#endif
08c3a6
-inline void __attribute__ ((unused, always_inline))
08c3a6
+static inline void __attribute__ ((unused, always_inline))
08c3a6
 elf_get_dynamic_info (struct link_map *l)
08c3a6
 {
08c3a6
 #if __ELF_NATIVE_CLASS == 32
08c3a6
@@ -165,3 +162,5 @@ elf_get_dynamic_info (struct link_map *l)
08c3a6
     info[DT_RPATH] = NULL;
08c3a6
 #endif
08c3a6
 }
08c3a6
+
08c3a6
+#endif
08c3a6
diff --git a/elf/rtld.c b/elf/rtld.c
08c3a6
index 84eac9a8df7125a6..ee45657aeac14f3c 100644
08c3a6
--- a/elf/rtld.c
08c3a6
+++ b/elf/rtld.c
08c3a6
@@ -502,13 +502,9 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
08c3a6
   return start_addr;
08c3a6
 }
08c3a6
 
08c3a6
-static ElfW(Addr) __attribute_used__
08c3a6
-_dl_start (void *arg)
08c3a6
-{
08c3a6
 #ifdef DONT_USE_BOOTSTRAP_MAP
08c3a6
 # define bootstrap_map GL(dl_rtld_map)
08c3a6
 #else
08c3a6
-  struct dl_start_final_info info;
08c3a6
 # define bootstrap_map info.l
08c3a6
 #endif
08c3a6
 
08c3a6
@@ -517,13 +513,16 @@ _dl_start (void *arg)
08c3a6
      Since ld.so must not have any undefined symbols the result
08c3a6
      is trivial: always the map of ld.so itself.  */
08c3a6
 #define RTLD_BOOTSTRAP
08c3a6
-#define BOOTSTRAP_MAP (&bootstrap_map)
08c3a6
-#define RESOLVE_MAP(sym, version, flags) BOOTSTRAP_MAP
08c3a6
+#define RESOLVE_MAP(map, scope, sym, version, flags) map
08c3a6
 #include "dynamic-link.h"
08c3a6
 
08c3a6
+static ElfW(Addr) __attribute_used__
08c3a6
+_dl_start (void *arg)
08c3a6
+{
08c3a6
 #ifdef DONT_USE_BOOTSTRAP_MAP
08c3a6
   rtld_timer_start (&start_time);
08c3a6
 #else
08c3a6
+  struct dl_start_final_info info;
08c3a6
   rtld_timer_start (&info.start_time);
08c3a6
 #endif
08c3a6
 
08c3a6
@@ -557,7 +556,7 @@ _dl_start (void *arg)
08c3a6
 #endif
08c3a6
 
08c3a6
 #ifdef ELF_MACHINE_BEFORE_RTLD_RELOC
08c3a6
-  ELF_MACHINE_BEFORE_RTLD_RELOC (bootstrap_map.l_info);
08c3a6
+  ELF_MACHINE_BEFORE_RTLD_RELOC (&bootstrap_map, bootstrap_map.l_info);
08c3a6
 #endif
08c3a6
 
08c3a6
   if (bootstrap_map.l_addr || ! bootstrap_map.l_info[VALIDX(DT_GNU_PRELINKED)])
08c3a6
@@ -565,7 +564,7 @@ _dl_start (void *arg)
08c3a6
       /* Relocate ourselves so we can do normal function calls and
08c3a6
 	 data access using the global offset table.  */
08c3a6
 
08c3a6
-      ELF_DYNAMIC_RELOCATE (&bootstrap_map, 0, 0, 0);
08c3a6
+      ELF_DYNAMIC_RELOCATE (&bootstrap_map, NULL, 0, 0, 0);
08c3a6
     }
08c3a6
   bootstrap_map.l_relocated = 1;
08c3a6
 
08c3a6
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
08c3a6
index d29d827ab32a78ee..34c0790b893a529b 100644
08c3a6
--- a/sysdeps/aarch64/dl-machine.h
08c3a6
+++ b/sysdeps/aarch64/dl-machine.h
08c3a6
@@ -65,7 +65,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((unused))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   if (l->l_info[DT_JMPREL] && lazy)
08c3a6
     {
08c3a6
@@ -243,10 +244,11 @@ elf_machine_plt_value (struct link_map *map,
08c3a6
 
08c3a6
 #ifdef RESOLVE_MAP
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
-		  const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   ElfW(Addr) *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -259,7 +261,8 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
   else
08c3a6
     {
08c3a6
       const ElfW(Sym) *const refsym = sym;
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       ElfW(Addr) value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       if (sym != NULL
08c3a6
@@ -383,9 +386,9 @@ elf_machine_rela_relative (ElfW(Addr) l_addr,
08c3a6
   *reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      ElfW(Addr) l_addr,
08c3a6
 		      const ElfW(Rela) *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
@@ -412,7 +415,7 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
 		    (const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
08c3a6
 		  version = &map->l_versions[vernum[symndx] & 0x7fff];
08c3a6
 		}
08c3a6
-	      elf_machine_rela (map, reloc, sym, version, reloc_addr,
08c3a6
+	      elf_machine_rela (map, scope, reloc, sym, version, reloc_addr,
08c3a6
 				skip_ifunc);
08c3a6
 	      return;
08c3a6
 	    }
08c3a6
@@ -439,7 +442,8 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
 
08c3a6
       /* Always initialize TLS descriptors completely, because lazy
08c3a6
 	 initialization requires synchronization at every TLS access.  */
08c3a6
-      elf_machine_rela (map, reloc, sym, version, reloc_addr, skip_ifunc);
08c3a6
+      elf_machine_rela (map, scope, reloc, sym, version, reloc_addr,
08c3a6
+			skip_ifunc);
08c3a6
     }
08c3a6
   else if (__glibc_unlikely (r_type == AARCH64_R(IRELATIVE)))
08c3a6
     {
08c3a6
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h
08c3a6
index 2cd2213d9ab25287..66e1db524bb378f6 100644
08c3a6
--- a/sysdeps/alpha/dl-machine.h
08c3a6
+++ b/sysdeps/alpha/dl-machine.h
08c3a6
@@ -70,7 +70,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int
08c3a6
-elf_machine_runtime_setup (struct link_map *map, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   extern char _dl_runtime_resolve_new[] attribute_hidden;
08c3a6
   extern char _dl_runtime_profile_new[] attribute_hidden;
08c3a6
@@ -361,9 +362,9 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
 
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		  const Elf64_Rela *reloc,
08c3a6
 		  const Elf64_Sym *sym,
08c3a6
 		  const struct r_found_version *version,
08c3a6
@@ -411,7 +412,8 @@ elf_machine_rela (struct link_map *map,
08c3a6
       return;
08c3a6
   else
08c3a6
     {
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf64_Addr sym_value;
08c3a6
       Elf64_Addr sym_raw_value;
08c3a6
 
08c3a6
@@ -489,7 +491,7 @@ elf_machine_rela (struct link_map *map,
08c3a6
    can be skipped.  */
08c3a6
 #define ELF_MACHINE_REL_RELATIVE 1
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -506,9 +508,9 @@ elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
   memcpy (reloc_addr_arg, &reloc_addr_val, 8);
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
08c3a6
index e6ce7f0ff6d9ac34..4b64ffec256b7f3b 100644
08c3a6
--- a/sysdeps/arc/dl-machine.h
08c3a6
+++ b/sysdeps/arc/dl-machine.h
08c3a6
@@ -122,7 +122,8 @@ elf_machine_load_address (void)
08c3a6
 
08c3a6
 static inline int
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   extern void _dl_runtime_resolve (void);
08c3a6
 
08c3a6
@@ -228,10 +229,11 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t t,
08c3a6
 
08c3a6
 #ifdef RESOLVE_MAP
08c3a6
 
08c3a6
-inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
-                  const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
                   void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   ElfW(Addr) r_info = reloc->r_info;
08c3a6
@@ -245,7 +247,8 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
   else
08c3a6
     {
08c3a6
       const ElfW(Sym) *const refsym = sym;
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       ElfW(Addr) value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       switch (r_type)
08c3a6
@@ -326,8 +329,9 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 
08c3a6
 inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map, ElfW(Addr) l_addr,
08c3a6
-                      const ElfW(Rela) *reloc, int skip_ifunc)
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
+		      int skip_ifunc)
08c3a6
 {
08c3a6
   ElfW(Addr) *const reloc_addr = (void *) (l_addr + reloc->r_offset);
08c3a6
   const unsigned int r_type = ELFW (R_TYPE) (reloc->r_info);
08c3a6
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
08c3a6
index ff5e09e207f7986b..7e6761bbe87540d5 100644
08c3a6
--- a/sysdeps/arm/dl-machine.h
08c3a6
+++ b/sysdeps/arm/dl-machine.h
08c3a6
@@ -84,7 +84,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((unused))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   Elf32_Addr *got;
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word);
08c3a6
@@ -303,7 +304,7 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
08c3a6
 
08c3a6
 #ifdef RESOLVE_MAP
08c3a6
 /* Handle a PC24 reloc, including the out-of-range case.  */
08c3a6
-auto void
08c3a6
+static void
08c3a6
 relocate_pc24 (struct link_map *map, Elf32_Addr value,
08c3a6
                Elf32_Addr *const reloc_addr, Elf32_Sword addend)
08c3a6
 {
08c3a6
@@ -357,10 +358,11 @@ relocate_pc24 (struct link_map *map, Elf32_Addr value,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
08c3a6
-		 const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+                 const Elf32_Rel *reloc, const Elf32_Sym *sym,
08c3a6
+                 const struct r_found_version *version,
08c3a6
 		 void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -391,7 +393,8 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
08c3a6
 #endif
08c3a6
     {
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       if (sym != NULL
08c3a6
@@ -535,10 +538,11 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
08c3a6
 }
08c3a6
 
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+                  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+                  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -553,7 +557,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 # ifndef RESOLVE_CONFLICT_FIND_MAP
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
 # endif
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
       Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       if (sym != NULL
08c3a6
@@ -628,7 +632,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 }
08c3a6
 # endif
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
08c3a6
 			  void *const reloc_addr_arg)
08c3a6
@@ -638,7 +642,7 @@ elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
08c3a6
 }
08c3a6
 
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -648,9 +652,9 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 }
08c3a6
 # endif
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rel *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
@@ -680,7 +684,7 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
 
08c3a6
       /* Always initialize TLS descriptors completely, because lazy
08c3a6
 	 initialization requires synchronization at every TLS access.  */
08c3a6
-      elf_machine_rel (map, reloc, sym, version, reloc_addr, skip_ifunc);
08c3a6
+      elf_machine_rel (map, scope, reloc, sym, version, reloc_addr, skip_ifunc);
08c3a6
     }
08c3a6
   else
08c3a6
     _dl_reloc_bad_type (map, r_type, 1);
08c3a6
diff --git a/sysdeps/csky/dl-machine.h b/sysdeps/csky/dl-machine.h
08c3a6
index b08f06d74ca6f8d1..ec22f875772b1291 100644
08c3a6
--- a/sysdeps/csky/dl-machine.h
08c3a6
+++ b/sysdeps/csky/dl-machine.h
08c3a6
@@ -58,7 +58,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   Elf32_Addr *got;
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word);
08c3a6
@@ -215,9 +216,10 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void __attribute__ ((unused, always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+static inline void __attribute__ ((unused, always_inline))
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -230,7 +232,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
   else
08c3a6
     {
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       ElfW(Addr) value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
       opcode16_addr = (unsigned short *)reloc_addr;
08c3a6
 
08c3a6
@@ -331,7 +334,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__ ((unused, always_inline))
08c3a6
+static inline void __attribute__ ((unused, always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
 {
08c3a6
@@ -339,8 +342,8 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
   *reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__ ((unused, always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static inline void __attribute__ ((unused, always_inline))
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
08c3a6
index 24f0f47d8f1e25cd..088931f67065250c 100644
08c3a6
--- a/sysdeps/hppa/dl-machine.h
08c3a6
+++ b/sysdeps/hppa/dl-machine.h
08c3a6
@@ -70,8 +70,8 @@ __hppa_init_bootstrap_fdesc_table (struct link_map *map)
08c3a6
   map->l_mach.fptr_table = boot_table;
08c3a6
 }
08c3a6
 
08c3a6
-#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info)		\
08c3a6
-	__hppa_init_bootstrap_fdesc_table (BOOTSTRAP_MAP);	\
08c3a6
+#define ELF_MACHINE_BEFORE_RTLD_RELOC(map, dynamic_info)	\
08c3a6
+	__hppa_init_bootstrap_fdesc_table (map);		\
08c3a6
 	_dl_fptr_init();
08c3a6
 
08c3a6
 /* Return nonzero iff ELF header is compatible with the running host.  */
08c3a6
@@ -182,7 +182,8 @@ elf_machine_main_map (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   Elf32_Addr *got = NULL;
08c3a6
   Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type, r_sym;
08c3a6
@@ -564,8 +565,8 @@ dl_platform_init (void)
08c3a6
   (  (((as14) & 0x1fff) << 1) \
08c3a6
    | (((as14) & 0x2000) >> 13))
08c3a6
 
08c3a6
-auto void __attribute__((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map,
08c3a6
+static void __attribute__((always_inline))
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		  const Elf32_Rela *reloc,
08c3a6
 		  const Elf32_Sym *sym,
08c3a6
 		  const struct r_found_version *version,
08c3a6
@@ -594,11 +595,9 @@ elf_machine_rela (struct link_map *map,
08c3a6
      zeros, and an all zero Elf32_Sym has a binding of STB_LOCAL.)
08c3a6
      See RESOLVE_MAP definition in elf/dl-reloc.c  */
08c3a6
 # ifdef RTLD_BOOTSTRAP
08c3a6
-  /* RESOLVE_MAP in rtld.c doesn't have the local sym test.  */
08c3a6
-  sym_map = (ELF32_ST_BIND (sym->st_info) != STB_LOCAL
08c3a6
-	     ? RESOLVE_MAP (&sym, version, r_type) : map);
08c3a6
+  sym_map = map;
08c3a6
 # else
08c3a6
-  sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+  sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
 # endif
08c3a6
 
08c3a6
   if (sym_map)
08c3a6
@@ -756,7 +755,7 @@ elf_machine_rela (struct link_map *map,
08c3a6
 
08c3a6
 /* hppa doesn't have an R_PARISC_RELATIVE reloc, but uses relocs with
08c3a6
    ELF32_R_SYM (info) == 0 for a similar purpose.  */
08c3a6
-auto void __attribute__((always_inline))
08c3a6
+static void __attribute__((always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr,
08c3a6
 			   const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -809,8 +808,8 @@ elf_machine_rela_relative (Elf32_Addr l_addr,
08c3a6
   *reloc_addr = value;
08c3a6
 }
08c3a6
 
08c3a6
-auto void __attribute__((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static void __attribute__((always_inline))
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
08c3a6
index 590b41d8d7e35005..78ce890c0ff333ca 100644
08c3a6
--- a/sysdeps/i386/dl-machine.h
08c3a6
+++ b/sysdeps/i386/dl-machine.h
08c3a6
@@ -61,7 +61,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((unused, always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   Elf32_Addr *got;
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word) attribute_hidden;
08c3a6
@@ -291,9 +292,10 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute ((always_inline))
08c3a6
-elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
08c3a6
+elf_machine_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		 const Elf32_Rel *reloc,
08c3a6
 		 const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
 		 void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
@@ -327,7 +329,8 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
 # endif
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       if (sym != NULL
08c3a6
@@ -498,10 +501,11 @@ and creates an unsatisfiable circular dependency.\n",
08c3a6
 }
08c3a6
 
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -514,7 +518,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 #  ifndef RESOLVE_CONFLICT_FIND_MAP
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
 #  endif
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       if (sym != NULL
08c3a6
@@ -647,7 +652,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 }
08c3a6
 # endif	/* !RTLD_BOOTSTRAP */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute ((always_inline))
08c3a6
 elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
08c3a6
 			  void *const reloc_addr_arg)
08c3a6
@@ -658,7 +663,7 @@ elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
08c3a6
 }
08c3a6
 
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -668,9 +673,9 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 }
08c3a6
 # endif	/* !RTLD_BOOTSTRAP */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rel *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
@@ -705,13 +710,13 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
 	  const ElfW(Half) *const version =
08c3a6
 	    (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
08c3a6
 	  ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)] & 0x7fff;
08c3a6
-	  elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)],
08c3a6
+	  elf_machine_rel (map, scope, r, &symtab[ELFW(R_SYM) (r->r_info)],
08c3a6
 			   &map->l_versions[ndx],
08c3a6
 			   (void *) (l_addr + r->r_offset), skip_ifunc);
08c3a6
 	}
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
       else
08c3a6
-	elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
08c3a6
+	elf_machine_rel (map, scope, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
08c3a6
 			 (void *) (l_addr + r->r_offset), skip_ifunc);
08c3a6
 # endif
08c3a6
     }
08c3a6
@@ -728,9 +733,9 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
 
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rela (struct link_map *map,
08c3a6
+elf_machine_lazy_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		       Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		       int skip_ifunc)
08c3a6
 {
08c3a6
@@ -754,7 +759,8 @@ elf_machine_lazy_rela (struct link_map *map,
08c3a6
 
08c3a6
       /* Always initialize TLS descriptors completely at load time, in
08c3a6
 	 case static TLS is allocated for it that requires locking.  */
08c3a6
-      elf_machine_rela (map, reloc, sym, version, reloc_addr, skip_ifunc);
08c3a6
+      elf_machine_rela (map, scope, reloc, sym, version, reloc_addr,
08c3a6
+			skip_ifunc);
08c3a6
     }
08c3a6
   else if (__glibc_unlikely (r_type == R_386_IRELATIVE))
08c3a6
     {
08c3a6
diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h
08c3a6
index 4403e7767af83546..2217d0b556c17683 100644
08c3a6
--- a/sysdeps/ia64/dl-machine.h
08c3a6
+++ b/sysdeps/ia64/dl-machine.h
08c3a6
@@ -44,8 +44,8 @@ __ia64_init_bootstrap_fdesc_table (struct link_map *map)
08c3a6
   map->l_mach.fptr_table = boot_table;
08c3a6
 }
08c3a6
 
08c3a6
-#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info)		\
08c3a6
-	__ia64_init_bootstrap_fdesc_table (BOOTSTRAP_MAP);
08c3a6
+#define ELF_MACHINE_BEFORE_RTLD_RELOC(map, dynamic_info)		\
08c3a6
+	__ia64_init_bootstrap_fdesc_table (map);
08c3a6
 
08c3a6
 /* Return nonzero iff ELF header is compatible with the running host.  */
08c3a6
 static inline int __attribute__ ((unused))
08c3a6
@@ -98,7 +98,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((unused, always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   extern void _dl_runtime_resolve (void);
08c3a6
   extern void _dl_runtime_profile (void);
08c3a6
@@ -371,9 +372,9 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
 
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully
08c3a6
    resolved).  MAP is the object containing the reloc.  */
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		  const Elf64_Rela *reloc,
08c3a6
 		  const Elf64_Sym *sym,
08c3a6
 		  const struct r_found_version *version,
08c3a6
@@ -414,10 +415,11 @@ elf_machine_rela (struct link_map *map,
08c3a6
       return;
08c3a6
   else
08c3a6
     {
08c3a6
-      struct link_map *sym_map;
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
 
08c3a6
       /* RESOLVE_MAP() will return NULL if it fail to locate the symbol.  */
08c3a6
-      if ((sym_map = RESOLVE_MAP (&sym, version, r_type)))
08c3a6
+      if (sym_map != NULL)
08c3a6
 	{
08c3a6
 	  value = SYMBOL_ADDRESS (sym_map, sym, true) + reloc->r_addend;
08c3a6
 
08c3a6
@@ -476,7 +478,7 @@ elf_machine_rela (struct link_map *map,
08c3a6
    can be skipped.  */
08c3a6
 #define ELF_MACHINE_REL_RELATIVE 1
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -489,9 +491,9 @@ elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 }
08c3a6
 
08c3a6
 /* Perform a RELATIVE reloc on the .got entry that transfers to the .plt.  */
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
08c3a6
index 86a8c67e2a1b9f77..5e34c4784e348b19 100644
08c3a6
--- a/sysdeps/m68k/dl-machine.h
08c3a6
+++ b/sysdeps/m68k/dl-machine.h
08c3a6
@@ -68,7 +68,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   Elf32_Addr *got;
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word);
08c3a6
@@ -215,9 +216,10 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void __attribute__ ((unused, always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+static inline void __attribute__ ((unused, always_inline))
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -228,7 +230,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
   else
08c3a6
     {
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       switch (r_type)
08c3a6
@@ -303,7 +306,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__ ((unused, always_inline))
08c3a6
+static inline void __attribute__ ((unused, always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
 {
08c3a6
@@ -311,8 +314,8 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
   *reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__ ((unused, always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static inline void __attribute__ ((unused, always_inline))
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/microblaze/dl-machine.h b/sysdeps/microblaze/dl-machine.h
08c3a6
index e460f6f195561da1..3fd4988e6093be1c 100644
08c3a6
--- a/sysdeps/microblaze/dl-machine.h
08c3a6
+++ b/sysdeps/microblaze/dl-machine.h
08c3a6
@@ -69,7 +69,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word);
08c3a6
   extern void _dl_runtime_profile (Elf32_Word);
08c3a6
@@ -207,9 +208,10 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     ((unsigned short *)(rel_addr))[3] = (val) & 0xffff; \
08c3a6
   } while (0)
08c3a6
 
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -222,7 +224,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
   else
08c3a6
     {
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       value += reloc->r_addend;
08c3a6
@@ -277,7 +280,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
 {
08c3a6
@@ -285,8 +288,8 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
   PUT_REL_64 (reloc_addr, l_addr + reloc->r_addend);
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static inline void
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
08c3a6
index d9c6d33d0cbf1f50..7a821ceb8e518cef 100644
08c3a6
--- a/sysdeps/mips/dl-machine.h
08c3a6
+++ b/sysdeps/mips/dl-machine.h
08c3a6
@@ -188,9 +188,9 @@ elf_machine_load_address (void)
08c3a6
 
08c3a6
 /* We can't rely on elf_machine_got_rel because _dl_object_relocation_scope
08c3a6
    fiddles with global data.  */
08c3a6
-#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info)			\
08c3a6
+#define ELF_MACHINE_BEFORE_RTLD_RELOC(bootstrap_map, dynamic_info)	\
08c3a6
 do {									\
08c3a6
-  struct link_map *map = BOOTSTRAP_MAP;					\
08c3a6
+  struct link_map *map = bootstrap_map;					\
08c3a6
   ElfW(Sym) *sym;							\
08c3a6
   ElfW(Addr) *got;							\
08c3a6
   int i, n;								\
08c3a6
@@ -475,11 +475,12 @@ elf_machine_plt_value (struct link_map *map, const ElfW(Rel) *reloc,
08c3a6
    by RELOC_ADDR.  SYM is the relocation symbol specified by R_INFO and
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_reloc (struct link_map *map, ElfW(Addr) r_info,
08c3a6
-		   const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
-		   void *reloc_addr, ElfW(Addr) r_addend, int inplace_p)
08c3a6
+elf_machine_reloc (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		   ElfW(Addr) r_info, const ElfW(Sym) *sym,
08c3a6
+		   const struct r_found_version *version, void *reloc_addr,
08c3a6
+		   ElfW(Addr) r_addend, int inplace_p)
08c3a6
 {
08c3a6
   const unsigned long int r_type = ELFW(R_TYPE) (r_info);
08c3a6
   ElfW(Addr) *addr_field = (ElfW(Addr) *) reloc_addr;
08c3a6
@@ -507,7 +508,8 @@ elf_machine_reloc (struct link_map *map, ElfW(Addr) r_info,
08c3a6
     case R_MIPS_TLS_TPREL32:
08c3a6
 # endif
08c3a6
       {
08c3a6
-	struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+	struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+						r_type);
08c3a6
 
08c3a6
 	switch (r_type)
08c3a6
 	  {
08c3a6
@@ -647,7 +649,7 @@ elf_machine_reloc (struct link_map *map, ElfW(Addr) r_info,
08c3a6
 	  _dl_signal_error (0, map->l_name, NULL,
08c3a6
 			    "found jump slot relocation with non-zero addend");
08c3a6
 
08c3a6
-	sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+	sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
 	value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 	*addr_field = value;
08c3a6
 
08c3a6
@@ -661,7 +663,7 @@ elf_machine_reloc (struct link_map *map, ElfW(Addr) r_info,
08c3a6
 	ElfW(Addr) value;
08c3a6
 
08c3a6
 	/* Calculate the address of the symbol.  */
08c3a6
-	sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+	sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
 	value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
 	if (__builtin_expect (sym == NULL, 0))
08c3a6
@@ -708,16 +710,17 @@ elf_machine_reloc (struct link_map *map, ElfW(Addr) r_info,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
08c3a6
-		 const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
-		 void *const reloc_addr, int skip_ifunc)
08c3a6
+elf_machine_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		 const ElfW(Rel) *reloc, const ElfW(Sym) *sym,
08c3a6
+		 const struct r_found_version *version, void *const reloc_addr,
08c3a6
+		 int skip_ifunc)
08c3a6
 {
08c3a6
-  elf_machine_reloc (map, reloc->r_info, sym, version, reloc_addr, 0, 1);
08c3a6
+  elf_machine_reloc (map, scope, reloc->r_info, sym, version, reloc_addr, 0, 1);
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__((always_inline))
08c3a6
 elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
08c3a6
 			  void *const reloc_addr)
08c3a6
@@ -725,9 +728,9 @@ elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
08c3a6
   /* XXX Nothing to do.  There is no relative relocation, right?  */
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
@@ -748,17 +751,17 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
     _dl_reloc_bad_type (map, r_type, 1);
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], const ElfW(Rela) *reloc,
08c3a6
 		  const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr, int skip_ifunc)
08c3a6
 {
08c3a6
-  elf_machine_reloc (map, reloc->r_info, sym, version, reloc_addr,
08c3a6
+  elf_machine_reloc (map, scope, reloc->r_info, sym, version, reloc_addr,
08c3a6
 		     reloc->r_addend, 0);
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__((always_inline))
08c3a6
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 			   void *const reloc_addr)
08c3a6
@@ -767,9 +770,9 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 
08c3a6
 #ifndef RTLD_BOOTSTRAP
08c3a6
 /* Relocate GOT. */
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__((always_inline))
08c3a6
-elf_machine_got_rel (struct link_map *map, int lazy)
08c3a6
+elf_machine_got_rel (struct link_map *map, struct r_scope_elem *scope[], int lazy)
08c3a6
 {
08c3a6
   ElfW(Addr) *got;
08c3a6
   ElfW(Sym) *sym;
08c3a6
@@ -782,7 +785,7 @@ elf_machine_got_rel (struct link_map *map, int lazy)
08c3a6
       const struct r_found_version *version __attribute__ ((unused))	  \
08c3a6
 	= vernum ? &map->l_versions[vernum[sym_index] & 0x7fff] : NULL;	  \
08c3a6
       struct link_map *sym_map;						  \
08c3a6
-      sym_map = RESOLVE_MAP (&ref, version, reloc);			  \
08c3a6
+      sym_map = RESOLVE_MAP (map, scope, &ref, version, reloc);		  \
08c3a6
       SYMBOL_ADDRESS (sym_map, ref, true);				  \
08c3a6
     })
08c3a6
 
08c3a6
@@ -868,9 +871,10 @@ elf_machine_got_rel (struct link_map *map, int lazy)
08c3a6
 /* Set up the loaded object described by L so its stub function
08c3a6
    will jump to the on-demand fixup code __dl_runtime_resolve.  */
08c3a6
 
08c3a6
-auto inline int
08c3a6
+static inline int
08c3a6
 __attribute__((always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
   ElfW(Addr) *got;
08c3a6
@@ -900,7 +904,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
     }
08c3a6
 
08c3a6
   /* Relocate global offset table.  */
08c3a6
-  elf_machine_got_rel (l, lazy);
08c3a6
+  elf_machine_got_rel (l, scope, lazy);
08c3a6
 
08c3a6
   /* If using PLTs, fill in the first two entries of .got.plt.  */
08c3a6
   if (l->l_info[DT_JMPREL] && lazy)
08c3a6
diff --git a/sysdeps/nios2/dl-machine.h b/sysdeps/nios2/dl-machine.h
08c3a6
index e000cd081f18a12b..4de602b13d5500f6 100644
08c3a6
--- a/sysdeps/nios2/dl-machine.h
08c3a6
+++ b/sysdeps/nios2/dl-machine.h
08c3a6
@@ -67,7 +67,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word);
08c3a6
 
08c3a6
@@ -234,10 +235,11 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
    LOADADDR is the load address of the object; INFO is an array indexed
08c3a6
    by DT_* of the .dynamic section info.  */
08c3a6
 
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
-                  const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
-                  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
+		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
   const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
08c3a6
@@ -249,7 +251,8 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
   else
08c3a6
     {
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       switch (r_type)
08c3a6
@@ -314,7 +317,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__((always_inline))
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
 {
08c3a6
@@ -322,8 +325,8 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
   *reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
08c3a6
index b93cf486b6cda5fd..cda012dc1b822254 100644
08c3a6
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
08c3a6
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
08c3a6
@@ -170,7 +170,7 @@ extern int __elf_machine_runtime_setup (struct link_map *map,
08c3a6
 					int lazy, int profile);
08c3a6
 
08c3a6
 static inline int
08c3a6
-elf_machine_runtime_setup (struct link_map *map,
08c3a6
+elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 			   int lazy, int profile)
08c3a6
 {
08c3a6
   if (map->l_info[DT_JMPREL] == 0)
08c3a6
@@ -284,9 +284,10 @@ extern void _dl_reloc_overflow (struct link_map *map,
08c3a6
    LOADADDR is the load address of the object; INFO is an array indexed
08c3a6
    by DT_* of the .dynamic section info.  */
08c3a6
 
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -315,7 +316,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
   else
08c3a6
     {
08c3a6
-      sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
       value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
     }
08c3a6
   value += reloc->r_addend;
08c3a6
@@ -439,7 +440,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
 {
08c3a6
@@ -447,8 +448,8 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
   *reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
08c3a6
index b3f3352bcf5a52b0..3f92fbb369eb5023 100644
08c3a6
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
08c3a6
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
08c3a6
@@ -343,7 +343,8 @@ dl_platform_init (void)
08c3a6
 /* Set up the loaded object described by MAP so its unrelocated PLT
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 static inline int __attribute__ ((always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *map, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   if (map->l_info[DT_JMPREL])
08c3a6
     {
08c3a6
@@ -618,7 +619,7 @@ extern void attribute_hidden _dl_reloc_overflow (struct link_map *map,
08c3a6
 						 Elf64_Addr *const reloc_addr,
08c3a6
 						 const Elf64_Sym *refsym);
08c3a6
 
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
 {
08c3a6
@@ -627,7 +628,7 @@ elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 }
08c3a6
 
08c3a6
 /* This computes the value used by TPREL* relocs.  */
08c3a6
-auto inline Elf64_Addr __attribute__ ((always_inline, const))
08c3a6
+static inline Elf64_Addr __attribute__ ((always_inline, const))
08c3a6
 elf_machine_tprel (struct link_map *map,
08c3a6
 		   struct link_map *sym_map,
08c3a6
 		   const Elf64_Sym *sym,
08c3a6
@@ -646,7 +647,7 @@ elf_machine_tprel (struct link_map *map,
08c3a6
 }
08c3a6
 
08c3a6
 /* Call function at address VALUE (an OPD entry) to resolve ifunc relocs.  */
08c3a6
-auto inline Elf64_Addr __attribute__ ((always_inline))
08c3a6
+static inline Elf64_Addr __attribute__ ((always_inline))
08c3a6
 resolve_ifunc (Elf64_Addr value,
08c3a6
 	       const struct link_map *map, const struct link_map *sym_map)
08c3a6
 {
08c3a6
@@ -676,8 +677,8 @@ resolve_ifunc (Elf64_Addr value,
08c3a6
 
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully
08c3a6
    resolved).  MAP is the object containing the reloc.  */
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map,
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		  const Elf64_Rela *reloc,
08c3a6
 		  const Elf64_Sym *sym,
08c3a6
 		  const struct r_found_version *version,
08c3a6
@@ -705,7 +706,7 @@ elf_machine_rela (struct link_map *map,
08c3a6
 
08c3a6
   /* We need SYM_MAP even in the absence of TLS, for elf_machine_fixup_plt
08c3a6
      and STT_GNU_IFUNC.  */
08c3a6
-  struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+  struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
   Elf64_Addr value = SYMBOL_ADDRESS (sym_map, sym, true) + reloc->r_addend;
08c3a6
 
08c3a6
   if (sym != NULL
08c3a6
@@ -1035,8 +1036,8 @@ elf_machine_rela (struct link_map *map,
08c3a6
   MODIFIED_CODE_NOQUEUE (reloc_addr);
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+static inline void __attribute__ ((always_inline))
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
08c3a6
index 951268923da26a37..343c0feb6b437001 100644
08c3a6
--- a/sysdeps/riscv/dl-machine.h
08c3a6
+++ b/sysdeps/riscv/dl-machine.h
08c3a6
@@ -168,17 +168,18 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t t,
08c3a6
    by RELOC_ADDR.  SYM is the relocation symbol specified by R_INFO and
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
-		  const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr, int skip_ifunc)
08c3a6
 {
08c3a6
   ElfW(Addr) r_info = reloc->r_info;
08c3a6
   const unsigned long int r_type = ELFW (R_TYPE) (r_info);
08c3a6
   ElfW(Addr) *addr_field = (ElfW(Addr) *) reloc_addr;
08c3a6
   const ElfW(Sym) *const __attribute__ ((unused)) refsym = sym;
08c3a6
-  struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+  struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
   ElfW(Addr) value = 0;
08c3a6
   if (sym_map != NULL)
08c3a6
     value = SYMBOL_ADDRESS (sym_map, sym, true) + reloc->r_addend;
08c3a6
@@ -286,7 +287,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 			  void *const reloc_addr)
08c3a6
@@ -294,10 +295,11 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
   *(ElfW(Addr) *) reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map, ElfW(Addr) l_addr,
08c3a6
-		      const ElfW(Rela) *reloc, int skip_ifunc)
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
+		      int skip_ifunc)
08c3a6
 {
08c3a6
   ElfW(Addr) *const reloc_addr = (void *) (l_addr + reloc->r_offset);
08c3a6
   const unsigned int r_type = ELFW (R_TYPE) (reloc->r_info);
08c3a6
@@ -327,9 +329,10 @@ elf_machine_lazy_rel (struct link_map *map, ElfW(Addr) l_addr,
08c3a6
 /* Set up the loaded object described by L so its stub function
08c3a6
    will jump to the on-demand fixup code __dl_runtime_resolve.  */
08c3a6
 
08c3a6
-auto inline int
08c3a6
+static inline int
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
 #ifndef RTLD_BOOTSTRAP
08c3a6
   /* If using PLTs, fill in the first two entries of .got.plt.  */
08c3a6
diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
08c3a6
index d0ccd69261c8f55b..96a5e80c846c816a 100644
08c3a6
--- a/sysdeps/s390/s390-32/dl-machine.h
08c3a6
+++ b/sysdeps/s390/s390-32/dl-machine.h
08c3a6
@@ -85,7 +85,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((unused))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word);
08c3a6
   extern void _dl_runtime_profile (Elf32_Word);
08c3a6
@@ -321,10 +322,11 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -357,7 +359,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
       /* Only needed for R_390_COPY below.  */
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
 #endif
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       if (sym != NULL
08c3a6
@@ -484,7 +487,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -493,9 +496,9 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
   *reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
08c3a6
index 543361c83637c071..c94d09b9c8512738 100644
08c3a6
--- a/sysdeps/s390/s390-64/dl-machine.h
08c3a6
+++ b/sysdeps/s390/s390-64/dl-machine.h
08c3a6
@@ -75,7 +75,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((unused))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   extern void _dl_runtime_resolve (Elf64_Word);
08c3a6
   extern void _dl_runtime_profile (Elf64_Word);
08c3a6
@@ -268,10 +269,11 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
-		  const Elf64_Sym *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf64_Rela *reloc, const Elf64_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf64_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -304,7 +306,8 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
       /* Only needed for R_390_COPY below.  */
08c3a6
       const Elf64_Sym *const refsym = sym;
08c3a6
 #endif
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       Elf64_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       if (sym != NULL
08c3a6
@@ -438,7 +441,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -447,9 +450,9 @@ elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
   *reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h
08c3a6
index 122b417a17e2ef9b..0c22dfd8487a516e 100644
08c3a6
--- a/sysdeps/sh/dl-machine.h
08c3a6
+++ b/sysdeps/sh/dl-machine.h
08c3a6
@@ -69,7 +69,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((unused, always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   Elf32_Addr *got;
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word);
08c3a6
@@ -259,10 +260,11 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -318,7 +320,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
   else
08c3a6
     {
08c3a6
       const Elf32_Sym *const refsym = sym;
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
 
08c3a6
       value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
       value += reloc->r_addend;
08c3a6
@@ -424,7 +427,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -443,9 +446,9 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 #undef COPY_UNALIGNED_WORD
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
08c3a6
index 0269e458ea2b3bca..6361cfae9eb8fa58 100644
08c3a6
--- a/sysdeps/sparc/sparc32/dl-machine.h
08c3a6
+++ b/sysdeps/sparc/sparc32/dl-machine.h
08c3a6
@@ -97,7 +97,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   Elf32_Addr *plt;
08c3a6
   extern void _dl_runtime_resolve (Elf32_Word);
08c3a6
@@ -327,10 +328,11 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
-		  const Elf32_Sym *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf32_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -381,7 +383,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
   else
08c3a6
     {
08c3a6
-      sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
       value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
     }
08c3a6
 #else
08c3a6
@@ -536,7 +538,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -545,9 +547,9 @@ elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
   *reloc_addr += l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
08c3a6
index bbd4566d8a595f93..3fd18c6e5ef21e38 100644
08c3a6
--- a/sysdeps/sparc/sparc64/dl-machine.h
08c3a6
+++ b/sysdeps/sparc/sparc64/dl-machine.h
08c3a6
@@ -126,7 +126,8 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   if (l->l_info[DT_JMPREL] && lazy)
08c3a6
     {
08c3a6
@@ -354,10 +355,11 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
-		  const Elf64_Sym *sym, const struct r_found_version *version,
08c3a6
+elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		  const Elf64_Rela *reloc, const Elf64_Sym *sym,
08c3a6
+		  const struct r_found_version *version,
08c3a6
 		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
 {
08c3a6
   Elf64_Addr *const reloc_addr = reloc_addr_arg;
08c3a6
@@ -408,7 +410,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
     }
08c3a6
   else
08c3a6
     {
08c3a6
-      sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type);
08c3a6
       value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
     }
08c3a6
 #else
08c3a6
@@ -646,7 +648,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
 elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -655,9 +657,9 @@ elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
   *reloc_addr = l_addr + reloc->r_addend;
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute__ ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      Elf64_Addr l_addr, const Elf64_Rela *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
08c3a6
index a8596aa3fa489eff..d3fcbb37bf1f4f7c 100644
08c3a6
--- a/sysdeps/x86_64/dl-machine.h
08c3a6
+++ b/sysdeps/x86_64/dl-machine.h
08c3a6
@@ -62,7 +62,8 @@ elf_machine_load_address (void)
08c3a6
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
08c3a6
 
08c3a6
 static inline int __attribute__ ((unused, always_inline))
08c3a6
-elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
08c3a6
+elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
08c3a6
+			   int lazy, int profile)
08c3a6
 {
08c3a6
   Elf64_Addr *got;
08c3a6
   extern void _dl_runtime_resolve_fxsave (ElfW(Word)) attribute_hidden;
08c3a6
@@ -258,12 +259,11 @@ elf_machine_plt_value (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
08c3a6
    MAP is the object containing the reloc.  */
08c3a6
 
08c3a6
-auto inline void
08c3a6
-__attribute__ ((always_inline))
08c3a6
-elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
-		  const ElfW(Sym) *sym, const struct r_found_version *version,
08c3a6
-		  void *const reloc_addr_arg, int skip_ifunc)
08c3a6
-{
08c3a6
+static inline void __attribute__((always_inline))
08c3a6
+elf_machine_rela(struct link_map *map, struct r_scope_elem *scope[],
08c3a6
+		 const ElfW(Rela) *reloc, const ElfW(Sym) *sym,
08c3a6
+		 const struct r_found_version *version,
08c3a6
+		 void *const reloc_addr_arg, int skip_ifunc) {
08c3a6
   ElfW(Addr) *const reloc_addr = reloc_addr_arg;
08c3a6
   const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info);
08c3a6
 
08c3a6
@@ -300,7 +300,8 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
08c3a6
 # ifndef RTLD_BOOTSTRAP
08c3a6
       const ElfW(Sym) *const refsym = sym;
08c3a6
 # endif
08c3a6
-      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
08c3a6
+      struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version,
08c3a6
+					      r_type);
08c3a6
       ElfW(Addr) value = SYMBOL_ADDRESS (sym_map, sym, true);
08c3a6
 
08c3a6
       if (sym != NULL
08c3a6
@@ -525,7 +526,7 @@ and creates an unsatisfiable circular dependency.\n",
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute ((always_inline))
08c3a6
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 			   void *const reloc_addr_arg)
08c3a6
@@ -544,9 +545,9 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
     }
08c3a6
 }
08c3a6
 
08c3a6
-auto inline void
08c3a6
+static inline void
08c3a6
 __attribute ((always_inline))
08c3a6
-elf_machine_lazy_rel (struct link_map *map,
08c3a6
+elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
08c3a6
 		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
08c3a6
 		      int skip_ifunc)
08c3a6
 {
08c3a6
@@ -580,7 +581,7 @@ elf_machine_lazy_rel (struct link_map *map,
08c3a6
 
08c3a6
       /* Always initialize TLS descriptors completely at load time, in
08c3a6
 	 case static TLS is allocated for it that requires locking.  */
08c3a6
-      elf_machine_rela (map, reloc, sym, version, reloc_addr, skip_ifunc);
08c3a6
+      elf_machine_rela (map, scope, reloc, sym, version, reloc_addr, skip_ifunc);
08c3a6
     }
08c3a6
   else if (__glibc_unlikely (r_type == R_X86_64_IRELATIVE))
08c3a6
     {