[glibc] Remove unused THREAD_SET_POINTER_GUARD and THREAD_COPY_POINTER_GUARD

Adhemerval Zanella via Glibc-cvs <[email protected]> Fri, 19 Jun 2026 17:25:55 +0000 (GMT)
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=da11a7d92c32d19058a9b35b5c1c0bcc75afbd12

commit da11a7d92c32d19058a9b35b5c1c0bcc75afbd12
Author: Adhemerval Zanella <[email protected]>
Date:   Fri Jun 19 14:16:34 2026 -0300

    Remove unused THREAD_SET_POINTER_GUARD and THREAD_COPY_POINTER_GUARD
    
    Commit a5ec880f808ee7268d985bed4f961799bdc0a4bf ("Consolidate pointer
    guard to use a relro variable instead of the TCB") moved the pointer
    guard to the module-local relro variable __pointer_chk_guard_local and
    dropped the THREAD_{SET,COPY}_POINTER_GUARD macros, which are no longer
    defined by any target.
    
    Checked on a build for all afftected targets.

Diff:
---
 csu/libc-start.c               | 8 --------
 elf/rtld.c                     | 7 -------
 elf/rtld_static_init.c         | 2 --
 manual/llio.texi               | 1 -
 nptl/pthread_create.c          | 5 -----
 sysdeps/mach/hurd/init-first.c | 2 +-
 6 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/csu/libc-start.c b/csu/libc-start.c
index 1614e932c2..1bd2184e46 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -51,11 +51,7 @@ extern void __libc_init_first (int argc, char **argv, char **envp);
    in thread local area.  */
 uintptr_t __stack_chk_guard attribute_relro;
 # endif
-# ifndef  THREAD_SET_POINTER_GUARD
-/* Only exported for architectures that don't store the pointer guard
-   value in thread local area.  */
 uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-# endif
 #endif
 
 #ifndef SHARED
@@ -297,11 +293,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
   /* Set up the pointer guard value.  */
   uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
 							 stack_chk_guard);
-# ifdef THREAD_SET_POINTER_GUARD
-  THREAD_SET_POINTER_GUARD (pointer_chk_guard);
-# else
   __pointer_chk_guard_local = pointer_chk_guard;
-# endif
 
   /* We do not need the _dl_random value anymore.  Scrub the AT_RANDOM
      bytes and clear the pointer; on targets with an entropy source, refill
diff --git a/elf/rtld.c b/elf/rtld.c
index ebb5446681..f2be6239b3 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -167,12 +167,8 @@ rtld_hidden_data_def (_dl_argv)
 uintptr_t __stack_chk_guard attribute_relro;
 #endif
 
-/* Only exported for architectures that don't store the pointer guard
-   value in thread local area.  */
 uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#ifndef THREAD_SET_POINTER_GUARD
 strong_alias (__pointer_chk_guard_local, __pointer_chk_guard)
-#endif
 
 /* Check that AT_SECURE=0, or that the passed name does not contain
    directories and is not overly long.  Reject empty names
@@ -828,9 +824,6 @@ security_init (void)
   /* Set up the pointer guard as well, if necessary.  */
   uintptr_t pointer_chk_guard
     = _dl_setup_pointer_guard (_dl_random, stack_chk_guard);
-#ifdef THREAD_SET_POINTER_GUARD
-  THREAD_SET_POINTER_GUARD (pointer_chk_guard);
-#endif
   __pointer_chk_guard_local = pointer_chk_guard;
 
   /* We do not need the _dl_random value anymore.  Scrub the AT_RANDOM
diff --git a/elf/rtld_static_init.c b/elf/rtld_static_init.c
index fecde95440..959a44beb4 100644
--- a/elf/rtld_static_init.c
+++ b/elf/rtld_static_init.c
@@ -81,7 +81,6 @@ __rtld_static_init (struct link_map *map)
   dl->_dl_find_object = _dl_find_object;
   dl->_dl_readonly_area = _dl_readonly_area;
 
-#ifndef THREAD_SET_POINTER_GUARD
   extern uintptr_t __pointer_chk_guard_local attribute_hidden;
   const ElfW(Sym) *guard_sym
     = _dl_lookup_direct (map, "__pointer_chk_guard",
@@ -91,7 +90,6 @@ __rtld_static_init (struct link_map *map)
   assert (guard_sym != NULL);
   *(uintptr_t *) DL_SYMBOL_ADDRESS (map, guard_sym)
     = __pointer_chk_guard_local;
-#endif
 
   __rtld_static_init_arch (map, dl);
 }
diff --git a/manual/llio.texi b/manual/llio.texi
index 7094ff4145..b5c0061b25 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -2863,7 +2863,6 @@ aiocb64}, since the LFS transparently replaces the old interface.
 @c     _dl_deallocate_tls dup
 @c     munmap ok
 @c    THREAD_COPY_STACK_GUARD ok
-@c    THREAD_COPY_POINTER_GUARD ok
 @c    atomic_exchange_acquire ok
 @c    lll_futex_wake ok
 @c    deallocate_stack @asulock @ascuheap @aculock @acsmem
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 9a0cefb0f5..fcb06c68c7 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -740,11 +740,6 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
   THREAD_COPY_STACK_GUARD (pd);
 #endif
 
-  /* Copy the pointer guard value.  */
-#ifdef THREAD_COPY_POINTER_GUARD
-  THREAD_COPY_POINTER_GUARD (pd);
-#endif
-
   /* Setup tcbhead.  */
   tls_setup_tcbhead (pd);
 
diff --git a/sysdeps/mach/hurd/init-first.c b/sysdeps/mach/hurd/init-first.c
index 74517aab67..401088b2c5 100644
--- a/sysdeps/mach/hurd/init-first.c
+++ b/sysdeps/mach/hurd/init-first.c
@@ -38,7 +38,7 @@ extern int __libc_argc attribute_hidden;
 extern char **__libc_argv attribute_hidden;
 extern char **_dl_argv;
 
-#if !defined (SHARED) && (defined (THREAD_SET_STACK_GUARD) || defined (THREAD_SET_POINTER_GUARD))
+#if !defined (SHARED) && defined (THREAD_SET_STACK_GUARD)
 /* In the static case, we need to set up TLS early so that the stack
    protection guard can be read at from TLS by the GCC-generated snippets,
    on architectures that store the guard in TLS and not globally.  */