diff mbox series

[23/33] elf: Introduce GLPM accessor for the protected memory area

Message ID 1f7722a85a1a4c10e0a2bc6b0395d37b7357e1f3.1688499219.git.fweimer@redhat.com
State New
Headers show
Series RFC: RELRO link maps | expand

Commit Message

Florian Weimer July 4, 2023, 8:03 p.m. UTC
The memory area is still allocated in the data segment, so this change
is preparatory only.
---
 elf/dl-load.c              |  12 ++--
 elf/rtld.c                 | 131 +++++++++++++++++++------------------
 elf/setup-vdso.h           |   4 +-
 sysdeps/generic/ldsodefs.h |  24 +++++--
 sysdeps/x86/dl-cet.c       |   4 +-
 sysdeps/x86/dl-prop.h      |   2 +-
 6 files changed, 95 insertions(+), 82 deletions(-)
diff mbox series

Patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 136297cf46..2c9809cc6f 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -744,7 +744,7 @@  _dl_init_paths (const char *llp, const char *source,
   l = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
 #ifdef SHARED
   if (l == NULL)
-    l = &GL (dl_rtld_map);
+    l = &GLPM (dl_rtld_map);
 #endif
   assert (l->l_type != lt_loaded);
 
@@ -969,8 +969,8 @@  _dl_map_object_from_fd (const char *name, const char *origname, int fd,
   /* When loading into a namespace other than the base one we must
      avoid loading ld.so since there can only be one copy.  Ever.  */
   if (__glibc_unlikely (nsid != LM_ID_BASE)
-      && (_dl_file_id_match_p (&id, &GL(dl_rtld_map).l_file_id)
-	  || _dl_name_match_p (name, &GL(dl_rtld_map))))
+      && (_dl_file_id_match_p (&id, &GLPM(dl_rtld_map).l_file_id)
+	  || _dl_name_match_p (name, &GLPM(dl_rtld_map))))
     {
       /* This is indeed ld.so.  Create a new link_map which refers to
 	 the real one for almost everything.  */
@@ -979,7 +979,7 @@  _dl_map_object_from_fd (const char *name, const char *origname, int fd,
 	goto fail_new;
 
       /* Refer to the real descriptor.  */
-      l->l_real = &GL(dl_rtld_map);
+      l->l_real = &GLPM(dl_rtld_map);
 
       /* Copy l_addr and l_ld to avoid a GDB warning with dlmopen().  */
       l->l_public.l_addr = l->l_real->l_public.l_addr;
@@ -1284,7 +1284,7 @@  _dl_map_object_from_fd (const char *name, const char *origname, int fd,
 	  const uintptr_t p = (uintptr_t) &__stack_prot & -GLRO(dl_pagesize);
 	  const size_t s = (uintptr_t) (&__stack_prot + 1) - p;
 
-	  struct link_map_private *const m = &GL(dl_rtld_map);
+	  struct link_map_private *const m = &GLPM(dl_rtld_map);
 	  const uintptr_t relro_end = ((m->l_public.l_addr + m->l_relro_addr
 					+ m->l_relro_size)
 				       & -GLRO(dl_pagesize));
@@ -2067,7 +2067,7 @@  _dl_map_new_object (struct link_map_private *loader, const char *name,
 	      l = (loader
 		   ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded
 # ifdef SHARED
-		   ?: &GL(dl_rtld_map)
+		   ?: &GLPM(dl_rtld_map)
 # endif
 		  );
 
diff --git a/elf/rtld.c b/elf/rtld.c
index de6df9bd96..e51e1f4845 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -346,6 +346,7 @@  struct rtld_global _rtld_global =
 extern struct rtld_global _rtld_local
     __attribute__ ((alias ("_rtld_global"), visibility ("hidden")));
 
+struct rtld_protmem _rtld_protmem;
 
 /* This variable is similar to _rtld_local, but all values are
    read-only after relocation.  */
@@ -464,9 +465,9 @@  _dl_start_final (void *arg, struct dl_start_final_info *info)
     struct link_map_rw l;
     struct auditstate _dl_rtld_auditstate[DL_NNS];
   } rtld_map_rw;
-  GL (dl_rtld_map).l_rw = &rtld_map_rw.l;
+  GLPM (dl_rtld_map).l_rw = &rtld_map_rw.l;
 #if NO_TLS_OFFSET != 0
-  GL (dl_rtld_map).l_rw->l_tls_offset = NO_TLS_OFFSET;
+  GLPM (dl_rtld_map).l_rw->l_tls_offset = NO_TLS_OFFSET;
 #endif
 
   /* If it hasn't happen yet record the startup time.  */
@@ -477,19 +478,19 @@  _dl_start_final (void *arg, struct dl_start_final_info *info)
 
   /* Transfer data about ourselves to the permanent link_map structure.  */
 #ifndef DONT_USE_BOOTSTRAP_MAP
-  GL(dl_rtld_map).l_public.l_addr = info->l.l_public.l_addr;
-  GL(dl_rtld_map).l_public.l_ld = info->l.l_public.l_ld;
-  GL(dl_rtld_map).l_ld_readonly = info->l.l_ld_readonly;
-  memcpy (GL(dl_rtld_map).l_info, info->l.l_info,
-	  sizeof GL(dl_rtld_map).l_info);
-  GL(dl_rtld_map).l_mach = info->l.l_mach;
-  GL(dl_rtld_map).l_relocated = 1;
+  GLPM(dl_rtld_map).l_public.l_addr = info->l.l_public.l_addr;
+  GLPM(dl_rtld_map).l_public.l_ld = info->l.l_public.l_ld;
+  GLPM(dl_rtld_map).l_ld_readonly = info->l.l_ld_readonly;
+  memcpy (GLPM(dl_rtld_map).l_info, info->l.l_info,
+	  sizeof GLPM(dl_rtld_map).l_info);
+  GLPM(dl_rtld_map).l_mach = info->l.l_mach;
+  GLPM(dl_rtld_map).l_relocated = 1;
 #endif
-  _dl_setup_hash (&GL(dl_rtld_map));
-  GL(dl_rtld_map).l_real = &GL(dl_rtld_map);
-  GL(dl_rtld_map).l_map_start = (ElfW(Addr)) &__ehdr_start;
-  GL(dl_rtld_map).l_map_end = (ElfW(Addr)) _end;
-  GL(dl_rtld_map).l_text_end = (ElfW(Addr)) _etext;
+  _dl_setup_hash (&GLPM(dl_rtld_map));
+  GLPM(dl_rtld_map).l_real = &GLPM(dl_rtld_map);
+  GLPM(dl_rtld_map).l_map_start = (ElfW(Addr)) &__ehdr_start;
+  GLPM(dl_rtld_map).l_map_end = (ElfW(Addr)) _end;
+  GLPM(dl_rtld_map).l_text_end = (ElfW(Addr)) _etext;
 
   /* Initialize the stack end variable.  */
   __libc_stack_end = __builtin_frame_address (0);
@@ -514,7 +515,7 @@  _dl_start_final (void *arg, struct dl_start_final_info *info)
 }
 
 #ifdef DONT_USE_BOOTSTRAP_MAP
-# define bootstrap_map GL(dl_rtld_map)
+# define bootstrap_map GLPM(dl_rtld_map)
 #else
 # define bootstrap_map info.l
 #endif
@@ -1037,8 +1038,8 @@  ERROR: audit interface '%s' requires version %d (maximum supported version %d);
 
   /* The dynamic linker link map is statically allocated, so the
      cookie in _dl_new_object has not happened.  */
-  link_map_audit_state (&GL (dl_rtld_map), GLRO (dl_naudit))->cookie
-    = (intptr_t) &GL (dl_rtld_map);
+  link_map_audit_state (&GLPM (dl_rtld_map), GLRO (dl_naudit))->cookie
+    = (intptr_t) &GLPM (dl_rtld_map);
 
   ++GLRO(dl_naudit);
 
@@ -1066,7 +1067,7 @@  load_audit_modules (struct link_map_private *main_map,
   if (GLRO(dl_naudit) > 0)
     {
       _dl_audit_objopen (main_map, LM_ID_BASE);
-      _dl_audit_objopen (&GL(dl_rtld_map), LM_ID_BASE);
+      _dl_audit_objopen (&GLPM(dl_rtld_map), LM_ID_BASE);
     }
 }
 
@@ -1076,7 +1077,7 @@  static void
 rtld_chain_load (struct link_map_private *main_map, char *argv0)
 {
   /* The dynamic loader run against itself.  */
-  const char *rtld_soname = l_soname (&GL(dl_rtld_map));
+  const char *rtld_soname = l_soname (&GLPM(dl_rtld_map));
   if (l_soname (main_map) != NULL
       && strcmp (rtld_soname, l_soname (main_map)) == 0)
     _dl_fatal_printf ("%s: loader cannot load itself\n", rtld_soname);
@@ -1163,7 +1164,7 @@  rtld_setup_main_map (struct link_map_private *main_map)
 	_dl_rtld_libname.name = ((const char *) main_map->l_public.l_addr
 				 + ph->p_vaddr);
 	/* _dl_rtld_libname.next = NULL;	Already zero.  */
-	GL(dl_rtld_map).l_libname = &_dl_rtld_libname;
+	GLPM(dl_rtld_map).l_libname = &_dl_rtld_libname;
 
 	has_interp = true;
 	break;
@@ -1249,16 +1250,16 @@  rtld_setup_main_map (struct link_map_private *main_map)
     main_map->l_map_end = ~0;
   if (! main_map->l_text_end)
     main_map->l_text_end = ~0;
-  if (! GL(dl_rtld_map).l_libname && GL(dl_rtld_map).l_public.l_name)
+  if (! GLPM(dl_rtld_map).l_libname && GLPM(dl_rtld_map).l_public.l_name)
     {
       /* We were invoked directly, so the program might not have a
 	 PT_INTERP.  */
-      _dl_rtld_libname.name = GL(dl_rtld_map).l_public.l_name;
+      _dl_rtld_libname.name = GLPM(dl_rtld_map).l_public.l_name;
       /* _dl_rtld_libname.next = NULL;	Already zero.  */
-      GL(dl_rtld_map).l_libname =  &_dl_rtld_libname;
+      GLPM(dl_rtld_map).l_libname =  &_dl_rtld_libname;
     }
   else
-    assert (GL(dl_rtld_map).l_libname); /* How else did we get here?  */
+    assert (GLPM(dl_rtld_map).l_libname); /* How else did we get here?  */
 
   return has_interp;
 }
@@ -1375,7 +1376,7 @@  dl_main (const ElfW(Phdr) *phdr,
       char **orig_argv = _dl_argv;
 
       /* Note the place where the dynamic linker actually came from.  */
-      GL(dl_rtld_map).l_public.l_name = rtld_progname;
+      GLPM(dl_rtld_map).l_public.l_name = rtld_progname;
 
       while (_dl_argc > 1)
 	if (! strcmp (_dl_argv[1], "--list"))
@@ -1651,22 +1652,22 @@  dl_main (const ElfW(Phdr) *phdr,
   /* If the current libname is different from the SONAME, add the
      latter as well.  */
   {
-    const char *soname = l_soname (&GL(dl_rtld_map));
+    const char *soname = l_soname (&GLPM(dl_rtld_map));
     if (soname != NULL
-	&& strcmp (GL(dl_rtld_map).l_libname->name, soname) != 0)
+	&& strcmp (GLPM(dl_rtld_map).l_libname->name, soname) != 0)
       {
 	static struct libname_list newname;
 	newname.name = soname;
 	newname.next = NULL;
 	newname.dont_free = 1;
 
-	assert (GL(dl_rtld_map).l_libname->next == NULL);
-	GL(dl_rtld_map).l_libname->next = &newname;
+	assert (GLPM(dl_rtld_map).l_libname->next == NULL);
+	GLPM(dl_rtld_map).l_libname->next = &newname;
       }
   }
   /* The ld.so must be relocated since otherwise loading audit modules
      will fail since they reuse the very same ld.so.  */
-  assert (GL(dl_rtld_map).l_relocated);
+  assert (GLPM(dl_rtld_map).l_relocated);
 
   if (! rtld_is_main)
     {
@@ -1696,7 +1697,7 @@  dl_main (const ElfW(Phdr) *phdr,
       _exit (has_interp ? 0 : 2);
     }
 
-  struct link_map **first_preload = &GL(dl_rtld_map).l_public.l_next;
+  struct link_map **first_preload = &GLPM(dl_rtld_map).l_public.l_next;
   /* Set up the data structures for the system-supplied DSO early,
      so they can influence _dl_init_paths.  */
   setup_vdso (main_map, &first_preload);
@@ -1709,20 +1710,20 @@  dl_main (const ElfW(Phdr) *phdr,
   call_init_paths (&state);
 
   /* Initialize _r_debug_extended.  */
-  struct r_debug *r = _dl_debug_initialize (GL(dl_rtld_map).l_public.l_addr,
+  struct r_debug *r = _dl_debug_initialize (GLPM(dl_rtld_map).l_public.l_addr,
 					    LM_ID_BASE);
   r->r_state = RT_CONSISTENT;
 
   /* Put the link_map for ourselves on the chain so it can be found by
      name.  Note that at this point the global chain of link maps contains
      exactly one element, which is pointed to by dl_loaded.  */
-  if (! GL(dl_rtld_map).l_public.l_name)
+  if (! GLPM(dl_rtld_map).l_public.l_name)
     /* If not invoked directly, the dynamic linker shared object file was
        found by the PT_INTERP name.  */
-    GL(dl_rtld_map).l_public.l_name = (char *) GL(dl_rtld_map).l_libname->name;
-  GL(dl_rtld_map).l_type = lt_library;
-  main_map->l_public.l_next = &GL(dl_rtld_map).l_public;
-  GL(dl_rtld_map).l_public.l_prev = &main_map->l_public;
+    GLPM(dl_rtld_map).l_public.l_name = (char *) GLPM(dl_rtld_map).l_libname->name;
+  GLPM(dl_rtld_map).l_type = lt_library;
+  main_map->l_public.l_next = &GLPM(dl_rtld_map).l_public;
+  GLPM(dl_rtld_map).l_public.l_prev = &main_map->l_public;
   ++GL(dl_ns)[LM_ID_BASE]._ns_nloaded;
   ++GL(dl_load_adds);
 
@@ -1740,8 +1741,8 @@  dl_main (const ElfW(Phdr) *phdr,
 
   const ElfW(Phdr) *rtld_phdr = (const void *) rtld_ehdr + rtld_ehdr->e_phoff;
 
-  GL(dl_rtld_map).l_phdr = rtld_phdr;
-  GL(dl_rtld_map).l_phnum = rtld_ehdr->e_phnum;
+  GLPM(dl_rtld_map).l_phdr = rtld_phdr;
+  GLPM(dl_rtld_map).l_phnum = rtld_ehdr->e_phnum;
 
 
   /* PT_GNU_RELRO is usually the last phdr.  */
@@ -1749,15 +1750,15 @@  dl_main (const ElfW(Phdr) *phdr,
   while (cnt-- > 0)
     if (rtld_phdr[cnt].p_type == PT_GNU_RELRO)
       {
-	GL(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr;
-	GL(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz;
+	GLPM(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr;
+	GLPM(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz;
 	break;
       }
 
   /* Add the dynamic linker to the TLS list if it also uses TLS.  */
-  if (GL(dl_rtld_map).l_tls_blocksize != 0)
+  if (GLPM(dl_rtld_map).l_tls_blocksize != 0)
     /* Assign a module ID.  Do this before loading any audit modules.  */
-    _dl_assign_tls_modid (&GL(dl_rtld_map));
+    _dl_assign_tls_modid (&GLPM(dl_rtld_map));
 
   audit_list_add_dynamic_tag (&state.audit_list, main_map, DT_AUDIT);
   audit_list_add_dynamic_tag (&state.audit_list, main_map, DT_DEPAUDIT);
@@ -1951,12 +1952,12 @@  dl_main (const ElfW(Phdr) *phdr,
     main_map->l_searchlist.r_list[--i]->l_global = 1;
 
   /* Remove _dl_rtld_map from the chain.  */
-  GL(dl_rtld_map).l_public.l_prev->l_next = GL(dl_rtld_map).l_public.l_next;
-  if (GL(dl_rtld_map).l_public.l_next != NULL)
-    GL(dl_rtld_map).l_public.l_next->l_prev = GL(dl_rtld_map).l_public.l_prev;
+  GLPM(dl_rtld_map).l_public.l_prev->l_next = GLPM(dl_rtld_map).l_public.l_next;
+  if (GLPM(dl_rtld_map).l_public.l_next != NULL)
+    GLPM(dl_rtld_map).l_public.l_next->l_prev = GLPM(dl_rtld_map).l_public.l_prev;
 
   for (i = 1; i < main_map->l_searchlist.r_nlist; ++i)
-    if (main_map->l_searchlist.r_list[i] == &GL(dl_rtld_map))
+    if (main_map->l_searchlist.r_list[i] == &GLPM(dl_rtld_map))
       break;
 
   bool rtld_multiple_ref = false;
@@ -1968,21 +1969,21 @@  dl_main (const ElfW(Phdr) *phdr,
 	 its symbol search order.  */
       rtld_multiple_ref = true;
 
-      GL(dl_rtld_map).l_public.l_prev
+      GLPM(dl_rtld_map).l_public.l_prev
 	= &main_map->l_searchlist.r_list[i - 1]->l_public;
       if (__glibc_likely (state.mode == rtld_mode_normal))
 	{
-	  GL(dl_rtld_map).l_public.l_next
+	  GLPM(dl_rtld_map).l_public.l_next
 	    = (i + 1 < main_map->l_searchlist.r_nlist
 	       ? &main_map->l_searchlist.r_list[i + 1]->l_public
 	       : NULL);
 #ifdef NEED_DL_SYSINFO_DSO
 	  if (GLRO(dl_sysinfo_map) != NULL
-	      && (GL(dl_rtld_map).l_public.l_prev->l_next
+	      && (GLPM(dl_rtld_map).l_public.l_prev->l_next
 		  == &GLRO(dl_sysinfo_map)->l_public)
-	      && (GL(dl_rtld_map).l_public.l_next
+	      && (GLPM(dl_rtld_map).l_public.l_next
 		  != &GLRO(dl_sysinfo_map)->l_public))
-	    GL(dl_rtld_map).l_public.l_prev = &GLRO(dl_sysinfo_map)->l_public;
+	    GLPM(dl_rtld_map).l_public.l_prev = &GLRO(dl_sysinfo_map)->l_public;
 #endif
 	}
       else
@@ -1991,17 +1992,17 @@  dl_main (const ElfW(Phdr) *phdr,
 	   In this case it doesn't matter much where we put the
 	   interpreter object, so we just initialize the list pointer so
 	   that the assertion below holds.  */
-	GL(dl_rtld_map).l_public.l_next
-	  = GL(dl_rtld_map).l_public.l_prev->l_next;
+	GLPM(dl_rtld_map).l_public.l_next
+	  = GLPM(dl_rtld_map).l_public.l_prev->l_next;
 
-      assert (GL(dl_rtld_map).l_public.l_prev->l_next
-	      == GL(dl_rtld_map).l_public.l_next);
-      GL(dl_rtld_map).l_public.l_prev->l_next = &GL(dl_rtld_map).l_public;
-      if (GL(dl_rtld_map).l_public.l_next != NULL)
+      assert (GLPM(dl_rtld_map).l_public.l_prev->l_next
+	      == GLPM(dl_rtld_map).l_public.l_next);
+      GLPM(dl_rtld_map).l_public.l_prev->l_next = &GLPM(dl_rtld_map).l_public;
+      if (GLPM(dl_rtld_map).l_public.l_next != NULL)
 	{
-	  assert (GL(dl_rtld_map).l_public.l_next->l_prev
-		  == GL(dl_rtld_map).l_public.l_prev);
-	  GL(dl_rtld_map).l_public.l_next->l_prev = &GL(dl_rtld_map).l_public;
+	  assert (GLPM(dl_rtld_map).l_public.l_next->l_prev
+		  == GLPM(dl_rtld_map).l_public.l_prev);
+	  GLPM(dl_rtld_map).l_public.l_next->l_prev = &GLPM(dl_rtld_map).l_public;
 	}
     }
 
@@ -2144,7 +2145,7 @@  dl_main (const ElfW(Phdr) *phdr,
 	      while (i-- > 0)
 		{
 		  struct link_map_private *l = main_map->l_initfini[i];
-		  if (l != &GL(dl_rtld_map) && ! l->l_faked)
+		  if (l != &GLPM(dl_rtld_map) && ! l->l_faked)
 		    {
 		      args.l = l;
 		      _dl_receive_error (print_unresolved, relocate_doit,
@@ -2288,7 +2289,7 @@  dl_main (const ElfW(Phdr) *phdr,
 	/* Also allocated with the fake malloc().  */
 	l->l_free_initfini = 0;
 
-	if (l != &GL(dl_rtld_map))
+	if (l != &GLPM(dl_rtld_map))
 	  _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
 			       consider_profiling);
 
@@ -2349,8 +2350,8 @@  dl_main (const ElfW(Phdr) *phdr,
       rtld_timer_start (&start);
 
       /* Mark the link map as not yet relocated again.  */
-      GL(dl_rtld_map).l_relocated = 0;
-      _dl_relocate_object (&GL(dl_rtld_map), main_map->l_scope, 0, 0);
+      GLPM(dl_rtld_map).l_relocated = 0;
+      _dl_relocate_object (&GLPM(dl_rtld_map), main_map->l_scope, 0, 0);
 
       rtld_timer_accum (&relocate_time, start);
     }
diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h
index 0021cdd0cf..387cef8cb3 100644
--- a/elf/setup-vdso.h
+++ b/elf/setup-vdso.h
@@ -97,8 +97,8 @@  setup_vdso (struct link_map_private *main_map __attribute__ ((unused)),
       /* Rearrange the list so this DSO appears after rtld_map.  */
       assert (l->l_public.l_next == NULL);
       assert (l->l_public.l_prev == &main_map->l_public);
-      GL(dl_rtld_map).l_public.l_next = &l->l_public;
-      l->l_public.l_prev = &GL(dl_rtld_map).l_public;
+      GLPM(dl_rtld_map).l_public.l_next = &l->l_public;
+      l->l_public.l_prev = &GLPM(dl_rtld_map).l_public;
       *first_preload = &l->l_public.l_next;
 # else
       GL(dl_nns) = 1;
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 1800469aa6..f100551268 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -406,11 +406,6 @@  struct rtld_global
   /* List of search directories.  */
   EXTERN struct r_search_path_elem *_dl_all_dirs;
 
-#ifdef SHARED
-  /* Structure describing the dynamic linker itself.  */
-  EXTERN struct link_map_private _dl_rtld_map;
-#endif
-
 #if !PTHREAD_IN_LIBC && defined SHARED \
     && defined __rtld_lock_default_lock_recursive
   EXTERN void (*_dl_rtld_lock_recursive) (void *);
@@ -528,6 +523,23 @@  extern struct rtld_global _rtld_global __rtld_global_attribute__;
 # undef __rtld_global_attribute__
 #endif
 
+#ifdef SHARED
+/* Implementation structure for the protected memory area.  */
+struct rtld_protmem
+{
+  /* Structure describing the dynamic linker itself.  */
+  EXTERN struct link_map_private _dl_rtld_map;
+};
+extern struct rtld_protmem _rtld_protmem attribute_hidden;
+#endif /* SHARED */
+
+/* GLPM(FIELD) denotes the FIELD in the protected memory area.  */
+#ifdef SHARED
+# define GLPM(name) _rtld_protmem._##name
+#else
+# define GLPM(name) _##name
+#endif
+
 #ifndef SHARED
 # define GLRO(name) _##name
 #else
@@ -1334,7 +1346,7 @@  static inline bool
 is_rtld_link_map (const struct link_map_private *map)
 {
 #ifdef SHARED
-  return map == &GL (dl_rtld_map);
+  return map == &GLPM (dl_rtld_map);
 #else
   return false;
 #endif
diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c
index 60ea1cb558..c47b2c8f4e 100644
--- a/sysdeps/x86/dl-cet.c
+++ b/sysdeps/x86/dl-cet.c
@@ -107,8 +107,8 @@  dl_cet_check (struct link_map *m, const char *program)
 	      /* Skip CET check for ld.so since ld.so is CET-enabled.
 		 CET will be disabled later if CET isn't enabled in
 		 executable.  */
-	      if (l == &GL(dl_rtld_map)
-		  ||  l->l_real == &GL(dl_rtld_map)
+	      if (l == &GLPM(dl_rtld_map)
+		  ||  l->l_real == &GLPM(dl_rtld_map)
 		  || (program && l == m))
 		continue;
 #endif
diff --git a/sysdeps/x86/dl-prop.h b/sysdeps/x86/dl-prop.h
index f24fc1b028..64710b76cc 100644
--- a/sysdeps/x86/dl-prop.h
+++ b/sysdeps/x86/dl-prop.h
@@ -46,7 +46,7 @@  dl_isa_level_check (struct link_map_private *m, const char *program)
 #ifdef SHARED
       /* Skip ISA level check for ld.so since ld.so won't run if its ISA
 	 level is higher than CPU.  */
-      if (l == &GL(dl_rtld_map) || l->l_real == &GL(dl_rtld_map))
+      if (l == &GLPM(dl_rtld_map) || l->l_real == &GLPM(dl_rtld_map))
 	continue;
 #endif