[5/8] Consolidate the C pointer guard implementation into the generic header

Message ID 20260603000656.3287796-6-adhemerval.zanella@linaro.org (mailing list archive)
State Superseded
Delegated to: DJ Delorie
Headers
Series Pointer guard hardening and consolidation |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Test failed
linaro-tcwg-bot/tcwg_glibc_check--master-arm fail Test failed

Commit Message

Adhemerval Zanella Netto June 3, 2026, 12:04 a.m. UTC
  All the per-architecture pointer_guard.h files implemented the same C
PTR_MANGLE/PTR_DEMANGLE (an exclusive-or by the guard followed by a
rotate) and only differed in the assembly macros, which now live in the
separate pointer_guard-asm.h headers.  Remove the redundant per-arch C
headers and keep a single implementation in sysdeps/generic/pointer_guard.h,
which includes <pointer_guard-asm.h> for the assembly definitions.

The i386 and x86_64 assembly headers do not depend on the Linux ABI, so
move them out of sysdeps/unix/sysv/linux into the generic per-arch
directories alongside the other targets.

Checked with builds for all supported ABIs.
---
 sysdeps/arm/pointer_guard.h                   | 40 ------------
 sysdeps/generic/pointer_guard.h               | 28 +++++++-
 .../sysv/linux => }/i386/pointer_guard-asm.h  |  0
 .../unix/sysv/linux/aarch64/pointer_guard.h   | 41 ------------
 sysdeps/unix/sysv/linux/alpha/pointer_guard.h | 40 ------------
 sysdeps/unix/sysv/linux/csky/pointer_guard.h  | 40 ------------
 sysdeps/unix/sysv/linux/i386/pointer_guard.h  | 48 --------------
 .../unix/sysv/linux/loongarch/pointer_guard.h | 41 ------------
 .../unix/sysv/linux/powerpc/pointer_guard.h   | 38 -----------
 sysdeps/unix/sysv/linux/s390/pointer_guard.h  | 38 -----------
 sysdeps/unix/sysv/linux/sh/pointer_guard.h    | 38 -----------
 .../sysv/linux/sparc/sparc32/pointer_guard.h  | 38 -----------
 .../sysv/linux/sparc/sparc64/pointer_guard.h  | 38 -----------
 .../unix/sysv/linux/x86_64/pointer_guard.h    | 64 -------------------
 .../linux => }/x86_64/pointer_guard-asm.h     |  0
 15 files changed, 25 insertions(+), 507 deletions(-)
 delete mode 100644 sysdeps/arm/pointer_guard.h
 rename sysdeps/{unix/sysv/linux => }/i386/pointer_guard-asm.h (100%)
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/csky/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/i386/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/sh/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86_64/pointer_guard.h
 rename sysdeps/{unix/sysv/linux => }/x86_64/pointer_guard-asm.h (100%)
  

Comments

DJ Delorie June 10, 2026, 9:14 p.m. UTC | #1
Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> All the per-architecture pointer_guard.h files implemented the same C
> PTR_MANGLE/PTR_DEMANGLE (an exclusive-or by the guard followed by a
> rotate) and only differed in the assembly macros, which now live in the
> separate pointer_guard-asm.h headers.  Remove the redundant per-arch C
> headers and keep a single implementation in sysdeps/generic/pointer_guard.h,
> which includes <pointer_guard-asm.h> for the assembly definitions.
>
> The i386 and x86_64 assembly headers do not depend on the Linux ABI, so
> move them out of sysdeps/unix/sysv/linux into the generic per-arch
> directories alongside the other targets.

I noticed that some of the manglers had a "rot 9" included and others
did not, but the generic one does for everyone (but pointer-size
dependent).  Is there a security implication here?  Are mangled pointers
ever stored in such a way that this change might break something?

Otherwise LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
  
Adhemerval Zanella Netto June 11, 2026, 6:59 p.m. UTC | #2
On 10/06/26 18:14, DJ Delorie wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>> All the per-architecture pointer_guard.h files implemented the same C
>> PTR_MANGLE/PTR_DEMANGLE (an exclusive-or by the guard followed by a
>> rotate) and only differed in the assembly macros, which now live in the
>> separate pointer_guard-asm.h headers.  Remove the redundant per-arch C
>> headers and keep a single implementation in sysdeps/generic/pointer_guard.h,
>> which includes <pointer_guard-asm.h> for the assembly definitions.
>>
>> The i386 and x86_64 assembly headers do not depend on the Linux ABI, so
>> move them out of sysdeps/unix/sysv/linux into the generic per-arch
>> directories alongside the other targets.
> 
> I noticed that some of the manglers had a "rot 9" included and others
> did not, but the generic one does for everyone (but pointer-size
> dependent).  Is there a security implication here?  Are mangled pointers
> ever stored in such a way that this change might break something?

It was an overlook from my part. I first consolidate the implementations, and
then enabled them for all ABIs. Later I figured out why x86 did the rotate (it 
is an security improvement, the rotate makes recover/guess harder); and decided
to make it the generic implementations. But I forgot to also update some assembly
macros.

But the C and asm PTR_MANGLE/PTR_DEMANGLE must agree at all times, because they 
interoperate. I will implement the rotate on all assemble macros.

> 
> Otherwise LGTM
> Reviewed-by: DJ Delorie <dj@redhat.com>
>
  

Patch

diff --git a/sysdeps/arm/pointer_guard.h b/sysdeps/arm/pointer_guard.h
deleted file mode 100644
index 9fa25c708a9..00000000000
--- a/sysdeps/arm/pointer_guard.h
+++ /dev/null
@@ -1,40 +0,0 @@ 
-/* Pointer guard implementation.  Arm version.
-   Copyright (C) 2013-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# if (IS_IN (rtld) \
-      || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-#  define PTR_DEMANGLE(var)     PTR_MANGLE (var)
-# else
-#  include <stdint.h>
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-#  define PTR_DEMANGLE(var)     PTR_MANGLE (var)
-# endif
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/generic/pointer_guard.h b/sysdeps/generic/pointer_guard.h
index 49eb5ca4ba2..aee84c1fa4e 100644
--- a/sysdeps/generic/pointer_guard.h
+++ b/sysdeps/generic/pointer_guard.h
@@ -1,4 +1,4 @@ 
-/* Pointer obfuscation implenentation.  Generic (no-op) version.
+/* Pointer obfuscation implenentation.  Generic version.
    Copyright (C) 2022-2026 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -22,8 +22,30 @@ 
 #include <pointer_guard-asm.h>
 
 #ifndef __ASSEMBLER__
-# define PTR_MANGLE(x) (void) (x)
-# define PTR_DEMANGLE(x) (void) (x)
+# include <stdbit.h>
+# include <stdint.h>
+
+# if (IS_IN (rtld) \
+      || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
+extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
+#  define PTR_GUARD_VALUE	__pointer_chk_guard_local
+# else
+extern uintptr_t __pointer_chk_guard attribute_relro;
+#  define PTR_GUARD_VALUE	__pointer_chk_guard
+# endif
+
+# define PTR_MANGLE(var)						      \
+    do {								      \
+      (var) = (__typeof (var)) ((uintptr_t) (var) ^ PTR_GUARD_VALUE);	      \
+      (var) = (__typeof (var)) stdc_rotate_left ((uintptr_t) (var),	      \
+						 2 * sizeof (uintptr_t) + 1); \
+    } while (0)
+# define PTR_DEMANGLE(var)						      \
+    do {								      \
+      (var) = (__typeof (var)) stdc_rotate_right ((uintptr_t) (var),	      \
+						  2 * sizeof (uintptr_t) + 1); \
+      (var) = (__typeof (var)) ((uintptr_t) (var) ^ PTR_GUARD_VALUE);	      \
+    } while (0)
 #endif
 
 #endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/i386/pointer_guard-asm.h b/sysdeps/i386/pointer_guard-asm.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/i386/pointer_guard-asm.h
rename to sysdeps/i386/pointer_guard-asm.h
diff --git a/sysdeps/unix/sysv/linux/aarch64/pointer_guard.h b/sysdeps/unix/sysv/linux/aarch64/pointer_guard.h
deleted file mode 100644
index 7b7d8b0b714..00000000000
--- a/sysdeps/unix/sysv/linux/aarch64/pointer_guard.h
+++ /dev/null
@@ -1,41 +0,0 @@ 
-/* Pointer guard implementation.  AArch64 version.
-   Copyright (C) 2014-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# if (IS_IN (rtld) \
-      || (!defined SHARED && (IS_IN (libc) \
-                              || IS_IN (libpthread))))
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-#  define PTR_DEMANGLE(var)     PTR_MANGLE (var)
-# else
-#  include <stdint.h>
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-#  define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/alpha/pointer_guard.h b/sysdeps/unix/sysv/linux/alpha/pointer_guard.h
deleted file mode 100644
index 0741bf7a183..00000000000
--- a/sysdeps/unix/sysv/linux/alpha/pointer_guard.h
+++ /dev/null
@@ -1,40 +0,0 @@ 
-/* Pointer guard implementation.  Alpha version.
-   Copyright (C) 2006-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdint.h>
-# if (IS_IN (rtld) \
-      || (!defined SHARED && (IS_IN (libc) \
-                              || IS_IN (libpthread))))
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-        (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-        (var) = (__typeof(var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-# endif
-# define PTR_DEMANGLE(var)  PTR_MANGLE(var)
-#endif /* ASSEMBLER */
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/csky/pointer_guard.h b/sysdeps/unix/sysv/linux/csky/pointer_guard.h
deleted file mode 100644
index 2aa044bdc42..00000000000
--- a/sysdeps/unix/sysv/linux/csky/pointer_guard.h
+++ /dev/null
@@ -1,40 +0,0 @@ 
-/* Pointer obfuscation implenentation.  C-SKY version.
-   Copyright (C) 2022-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# if (IS_IN (rtld) \
-      || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
-extern uintptr_t __pointer_chk_guard_local;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-#  define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# else
-# include <stdint.h>
-extern uintptr_t __pointer_chk_guard;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-#  define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/i386/pointer_guard.h b/sysdeps/unix/sysv/linux/i386/pointer_guard.h
deleted file mode 100644
index 7776c282d81..00000000000
--- a/sysdeps/unix/sysv/linux/i386/pointer_guard.h
+++ /dev/null
@@ -1,48 +0,0 @@ 
-/* Pointer obfuscation implenentation.  i386 version.
-   Copyright (C) 2005-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdbit.h>
-# include <stdint.h>
-# if IS_IN (rtld) || !defined SHARED
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_GUARD_VALUE	__pointer_chk_guard_local
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_GUARD_VALUE	__pointer_chk_guard
-# endif
-# define PTR_MANGLE(var)						      \
-    do {								      \
-      (var) = (__typeof (var)) ((uintptr_t) (var) ^ PTR_GUARD_VALUE);	      \
-      (var) = (__typeof (var)) stdc_rotate_left ((uintptr_t) (var),	      \
-						 2 * sizeof (uintptr_t) + 1); \
-    } while (0)
-# define PTR_DEMANGLE(var)						      \
-    do {								      \
-      (var) = (__typeof (var)) stdc_rotate_right ((uintptr_t) (var),	      \
-						  2 * sizeof (uintptr_t) + 1); \
-      (var) = (__typeof (var)) ((uintptr_t) (var) ^ PTR_GUARD_VALUE);	      \
-    } while (0)
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
deleted file mode 100644
index c080bdd0a9d..00000000000
--- a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
+++ /dev/null
@@ -1,41 +0,0 @@ 
-/* Pointer obfuscation implenentation.  LoongArch version.
-   Copyright (C) 2022-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdint.h>
-# if (IS_IN (rtld) \
-      || (!defined SHARED && (IS_IN (libc) \
-      || IS_IN (libpthread))))
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-#  define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-#  define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/powerpc/pointer_guard.h b/sysdeps/unix/sysv/linux/powerpc/pointer_guard.h
deleted file mode 100644
index 51f588ec11c..00000000000
--- a/sysdeps/unix/sysv/linux/powerpc/pointer_guard.h
+++ /dev/null
@@ -1,38 +0,0 @@ 
-/* Pointer obfuscation implenentation.  PowerPC version.
-   Copyright (C) 2005-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdint.h>
-# if IS_IN (rtld) || !defined SHARED
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-# endif
-# define PTR_DEMANGLE(var)     PTR_MANGLE (var)
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/s390/pointer_guard.h b/sysdeps/unix/sysv/linux/s390/pointer_guard.h
deleted file mode 100644
index 403eff63282..00000000000
--- a/sysdeps/unix/sysv/linux/s390/pointer_guard.h
+++ /dev/null
@@ -1,38 +0,0 @@ 
-/* Pointer obfuscation implenentation.  s390x version.
-   Copyright (C) 2005-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdint.h>
-# if IS_IN (rtld) || !defined SHARED
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_GUARD_VALUE	__pointer_chk_guard_local
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_GUARD_VALUE	__pointer_chk_guard
-# endif
-# define PTR_MANGLE(var) \
-  (var) = (void *) ((uintptr_t) (var) ^ PTR_GUARD_VALUE)
-# define PTR_DEMANGLE(var)	PTR_MANGLE (var)
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/sh/pointer_guard.h b/sysdeps/unix/sysv/linux/sh/pointer_guard.h
deleted file mode 100644
index 42340faca83..00000000000
--- a/sysdeps/unix/sysv/linux/sh/pointer_guard.h
+++ /dev/null
@@ -1,38 +0,0 @@ 
-/* Pointer obfuscation implenentation.  SH version.
-   Copyright (C) 2005-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdint.h>
-# if IS_IN (rtld) || !defined SHARED
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-     (var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-     (var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
-# endif
-# define PTR_DEMANGLE(var)     PTR_MANGLE (var)
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h b/sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h
deleted file mode 100644
index 86d3fbb7d27..00000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h
+++ /dev/null
@@ -1,38 +0,0 @@ 
-/* Pointer obfuscation implenentation.  32-bit SPARC version.
-   Copyright (C) 2006-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdint.h>
-# if IS_IN (rtld) || !defined SHARED
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-# endif
-# define PTR_DEMANGLE(var)     PTR_MANGLE (var)
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h b/sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h
deleted file mode 100644
index fc0a723905e..00000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h
+++ /dev/null
@@ -1,38 +0,0 @@ 
-/* Pointer obfuscation implenentation.  64-bit SPARC version.
-   Copyright (C) 2006-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdint.h>
-# if IS_IN (rtld) || !defined SHARED
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-# endif
-# define PTR_DEMANGLE(var)     PTR_MANGLE (var)
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/x86_64/pointer_guard.h b/sysdeps/unix/sysv/linux/x86_64/pointer_guard.h
deleted file mode 100644
index dd3a9752b2a..00000000000
--- a/sysdeps/unix/sysv/linux/x86_64/pointer_guard.h
+++ /dev/null
@@ -1,64 +0,0 @@ 
-/* Pointer obfuscation implenentation.  x86-64 version.
-   Copyright (C) 2005-2026 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef POINTER_GUARD_H
-#define POINTER_GUARD_H
-
-#include <pointer_guard-asm.h>
-
-#ifndef __ASSEMBLER__
-# include <stdbit.h>
-# include <stdint.h>
-
-# if (IS_IN (rtld) \
-      || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var)						      \
-    do {								      \
-      (var) = (__typeof (var)) ((uintptr_t) (var)			      \
-				^ __pointer_chk_guard_local);		      \
-      (var) = (__typeof (var)) stdc_rotate_left ((uintptr_t) (var),	      \
-						 2 * sizeof (uintptr_t) + 1); \
-    } while (0)
-#  define PTR_DEMANGLE(var)						      \
-    do {								      \
-      (var) = (__typeof (var)) stdc_rotate_right ((uintptr_t) (var),	      \
-						  2 * sizeof (uintptr_t) + 1); \
-      (var) = (__typeof (var)) ((uintptr_t) (var)			      \
-				^ __pointer_chk_guard_local);		      \
-    } while (0)
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var)						      \
-    do {								      \
-      (var) = (__typeof (var)) ((uintptr_t) (var)			      \
-				^ __pointer_chk_guard);			      \
-      (var) = (__typeof (var)) stdc_rotate_left ((uintptr_t) (var),	      \
-						 2 * sizeof (uintptr_t) + 1); \
-    } while (0)
-#  define PTR_DEMANGLE(var)						      \
-    do {								      \
-      (var) = (__typeof (var)) stdc_rotate_right ((uintptr_t) (var),	      \
-						  2 * sizeof (uintptr_t) + 1); \
-      (var) = (__typeof (var)) ((uintptr_t) (var)			      \
-				^ __pointer_chk_guard);			      \
-    } while (0)
-# endif
-#endif
-
-#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/x86_64/pointer_guard-asm.h b/sysdeps/x86_64/pointer_guard-asm.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/x86_64/pointer_guard-asm.h
rename to sysdeps/x86_64/pointer_guard-asm.h