]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Consolidate the C pointer guard and align the assembly implementations
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 12 Jun 2026 16:10:14 +0000 (13:10 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 16 Jun 2026 17:53:47 +0000 (14:53 -0300)
The per-architecture pointer_guard.h files all implemented some variant
of C PTR_MANGLE/PTR_DEMANGLE: the i386 and x86_64 versions did an
exclusive-or by the guard followed by a rotate left by
2 * sizeof (uintptr_t) + 1 bits (9 on 32-bit, 17 on 64-bit), while the
other targets did the exclusive-or only.  The assembly macros likewise
rotated on i386 and x86_64 but not on the other targets.

Consolidate everything to use XOR + rotate uniformly: collapse the
per-architecture C headers into a single generic implementation, and
add the matching rotate to the assembly implementations that lacked it.

Targets with an assembly rotate instruction (aarch64, arm, loongarch,
powerpc, s390, csky) just add it.  Those without one (alpha, sparc, sh)
synthesize the rotation: alpha and sparc with a shift/shift/or sequence,
which needs an extra scratch register added to the PTR_MANGLE/PTR_DEMANGLE
macros, sh with single-bit rotates, which needs no scratch.  The s390
__longjmp and ____longjmp_chk demangle the return address and stack
pointer in C, so update those too.

Checked with setjmp, ptrguard and longjmp_chk tests for all supported
ABIs that can run under qemu (all but csky), and with builds for all
supported ABIs.

Reviewed-by: DJ Delorie <dj@redhat.com>
35 files changed:
sysdeps/alpha/__longjmp.S
sysdeps/alpha/setjmp.S
sysdeps/arm/pointer_guard-asm.h
sysdeps/arm/pointer_guard.h [deleted file]
sysdeps/generic/pointer_guard.h
sysdeps/i386/pointer_guard-asm.h [moved from sysdeps/unix/sysv/linux/i386/pointer_guard-asm.h with 100% similarity]
sysdeps/mach/hurd/i386/____longjmp_chk.S
sysdeps/mach/hurd/i386/__longjmp.S
sysdeps/s390/__longjmp.c
sysdeps/sparc/sparc32/__longjmp.S
sysdeps/sparc/sparc32/setjmp.S
sysdeps/unix/sysv/linux/aarch64/pointer_guard-asm.h
sysdeps/unix/sysv/linux/aarch64/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S
sysdeps/unix/sysv/linux/alpha/pointer_guard-asm.h
sysdeps/unix/sysv/linux/alpha/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/csky/pointer_guard-asm.h
sysdeps/unix/sysv/linux/csky/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/i386/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h
sysdeps/unix/sysv/linux/loongarch/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/powerpc/pointer_guard-asm.h
sysdeps/unix/sysv/linux/powerpc/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/s390/____longjmp_chk.c
sysdeps/unix/sysv/linux/s390/pointer_guard-asm.h
sysdeps/unix/sysv/linux/s390/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/sh/pointer_guard-asm.h
sysdeps/unix/sysv/linux/sh/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S
sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard-asm.h
sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard-asm.h
sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h [deleted file]
sysdeps/unix/sysv/linux/x86_64/pointer_guard.h [deleted file]
sysdeps/x86_64/pointer_guard-asm.h [moved from sysdeps/unix/sysv/linux/x86_64/pointer_guard-asm.h with 100% similarity]

index 0a18a37789c106d5c2f6697dd0296705e4bb2a39..f516e9ba614d5e677fefb22a09ee0e5a670520e1 100644 (file)
@@ -53,9 +53,9 @@ ENTRY(__longjmp)
        ldt     $f8, JB_F8*8(a0)
        ldt     $f9, JB_F9*8(a0)
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE(ra, t1)
-       PTR_DEMANGLE2(t0, t1)
-       PTR_DEMANGLE2(fp, t1)
+       PTR_DEMANGLE(ra, t1, t2)
+       PTR_DEMANGLE2(t0, t1, t2)
+       PTR_DEMANGLE2(fp, t1, t2)
 #endif
        cmoveq  v0, 1, v0
        mov     t0, sp
index 8dc3dacab444535d17967397d40235fb826594ae..bf228991daf60afdb5bb00c1aadc70e72f63c8cb 100644 (file)
@@ -52,22 +52,22 @@ $sigsetjmp_local:
        stq     s4, JB_S4*8(a0)
        stq     s5, JB_S5*8(a0)
 #ifdef PTR_MANGLE
-       PTR_MANGLE(t1, ra, t0)
+       PTR_MANGLE(t1, ra, t0, t2)
        stq     t1, JB_PC*8(a0)
 #else
        stq     ra, JB_PC*8(a0)
 #endif
 #if defined(PTR_MANGLE) && FRAME == 0
-       PTR_MANGLE2(t1, sp, t0)
+       PTR_MANGLE2(t1, sp, t0, t2)
 #else
        addq    sp, FRAME, t1
 # ifdef PTR_MANGLE
-       PTR_MANGLE2(t1, t1, t0)
+       PTR_MANGLE2(t1, t1, t0, t2)
 # endif
 #endif
        stq     t1, JB_SP*8(a0)
 #ifdef PTR_MANGLE
-       PTR_MANGLE2(t1, fp, t0)
+       PTR_MANGLE2(t1, fp, t0, t2)
        stq     t1, JB_FP*8(a0)
 #else
        stq     fp, JB_FP*8(a0)
index 86a9055b6172547a19ea69690fc1f60d36d795fb..e34faa40ca29e7d2582e3c87c5679f7908776639 100644 (file)
       || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
 #  define PTR_MANGLE_LOAD(guard, tmp)                                   \
   LDR_HIDDEN (guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local), 0)
-#  define PTR_MANGLE(dst, src, guard, tmp)                              \
-  PTR_MANGLE_LOAD(guard, tmp);                                          \
-  PTR_MANGLE2(dst, src, guard)
-/* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */
-#  define PTR_MANGLE2(dst, src, guard)          \
-  eor dst, src, guard
-#  define PTR_DEMANGLE(dst, src, guard, tmp)    \
-  PTR_MANGLE (dst, src, guard, tmp)
-#  define PTR_DEMANGLE2(dst, src, guard)        \
-  PTR_MANGLE2 (dst, src, guard)
 # else
 #  define PTR_MANGLE_LOAD(guard, tmp)                                   \
-  LDR_GLOBAL (guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard), 0);
-#  define PTR_MANGLE(dst, src, guard, tmp)                              \
+  LDR_GLOBAL (guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard), 0)
+# endif
+# define PTR_MANGLE(dst, src, guard, tmp)                              \
   PTR_MANGLE_LOAD(guard, tmp);                                          \
   PTR_MANGLE2(dst, src, guard)
 /* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */
-#  define PTR_MANGLE2(dst, src, guard)          \
-  eor dst, src, guard
-#  define PTR_DEMANGLE(dst, src, guard, tmp)    \
-  PTR_MANGLE (dst, src, guard, tmp)
-#  define PTR_DEMANGLE2(dst, src, guard)        \
-  PTR_MANGLE2 (dst, src, guard)
-# endif
+# define PTR_MANGLE2(dst, src, guard)          \
+  eor dst, src, guard;                         \
+  ror dst, dst, #23
+# define PTR_DEMANGLE(dst, src, guard, tmp)    \
+  PTR_MANGLE_LOAD(guard, tmp);                  \
+  PTR_DEMANGLE2(dst, src, guard)
+# define PTR_DEMANGLE2(dst, src, guard)        \
+  ror dst, src, #9;                            \
+  eor dst, dst, guard
 #endif
 
 #endif /* POINTER_GUARD_ASM_H */
diff --git a/sysdeps/arm/pointer_guard.h b/sysdeps/arm/pointer_guard.h
deleted file mode 100644 (file)
index 9fa25c7..0000000
+++ /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 */
index 49eb5ca4ba277ac9101ac6c21f3472e1a7057931..aee84c1fa4e99a364a883124875842167f8735df 100644 (file)
@@ -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.
 
 #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 */
index 135282f9e4695153d45b148fd4dedaf77e255a9a..d7b6c4d4b1b6537ef6f82fcd88168cfdb2887268 100644 (file)
@@ -57,8 +57,8 @@ ENTRY (____longjmp_chk)
        movl    (JB_SP*4)(%eax), %ecx
        cfi_undefined(%ecx)
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE (%edx)
-       PTR_DEMANGLE (%ecx)
+       PTR_DEMANGLE (%edx, bx)
+       PTR_DEMANGLE (%ecx, bx)
 #endif
 
        movw    %ds, %si
index 7718d3469aa358127822901ca06dc091cad017f4..8431a7f362d273dd08bf61e80af48ce4528c952a 100644 (file)
@@ -35,8 +35,8 @@ ENTRY (__longjmp)
        movl (JB_SP*4)(%eax), %ecx
        cfi_undefined(%ecx)
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE (%edx)
-       PTR_DEMANGLE (%ecx)
+       PTR_DEMANGLE (%edx, bx)
+       PTR_DEMANGLE (%ecx, bx)
 #endif
 
        movw    %ds, %si
index 50d67bf42cc23259afbcbc1551985159720ff280..cf59686579a90d47bd59af21f87a205012aeb20d 100644 (file)
@@ -48,7 +48,9 @@ __longjmp (__jmp_buf env, int val)
                           argument and target address.  */
 #ifdef PTR_DEMANGLE
                        "lmg  %%r4,%%r5,64(%1)\n\t"
+                       "rllg %%r4,%%r4,47\n\t"
                        "xgr  %%r4,%2\n\t"
+                       "rllg %%r5,%%r5,47\n\t"
                        "xgr  %%r5,%2\n\t"
                        LIBC_PROBE_ASM (longjmp, 8@%1 -4@%0 8@%%r4)
 #else
index 732a250e4d2e449b04c747281e1872f9dad2690f..c443011996e38c66b57726b59b43864c75ac00df 100644 (file)
@@ -28,7 +28,7 @@ ENTRY(__longjmp)
 
        ld ENV(o0,JB_FP), %g3   /* Cache target FP in register %g3.  */
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE (%g3, %g3, %g4)
+       PTR_DEMANGLE (%g3, %g3, %g4, %g5)
 #endif
        mov %o0, %g1            /* ENV in %g1 */
        orcc %o1, %g0, %g2      /* VAL in %g2 */
@@ -66,8 +66,8 @@ LOC(thread):
 #ifdef PTR_DEMANGLE
        ld      ENV(g1,JB_PC), %g5 /* Set return PC. */
        ld      ENV(g1,JB_SP), %g1 /* Set saved SP on restore below. */
-       PTR_DEMANGLE2 (%i7, %g5, %g4)
-       PTR_DEMANGLE2 (%fp, %g1, %g4)
+       PTR_DEMANGLE2 (%i7, %g5, %g4, %g3)
+       PTR_DEMANGLE2 (%fp, %g1, %g4, %g3)
 #else
        ld      ENV(g1,JB_PC), %i7 /* Set return PC. */
        ld      ENV(g1,JB_SP), %fp /* Set saved SP on restore below. */
@@ -78,7 +78,7 @@ LOC(thread):
 LOC(found):
        /* We have unwound register windows so %fp matches the target.  */
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE2 (%sp, %o0, %g4)
+       PTR_DEMANGLE2 (%sp, %o0, %g4, %g3)
 #else
        mov %o0, %sp            /* OK, install new SP.  */
 #endif
@@ -86,7 +86,7 @@ LOC(found):
 LOC(sp_ok):
        ld ENV(g1,JB_PC), %o0   /* Extract target return PC.  */
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE2 (%o0, %o0, %g4)
+       PTR_DEMANGLE2 (%o0, %o0, %g4, %g3)
 #endif
        jmp %o0 + 8             /* Return there.  */
         mov %g2, %o0           /* Delay slot: set return value.  */
index 5f2aec113acd19bd8d944ad053cbe2d69eb3334e..e389c5077e5b2911c713b1a7c045f4aba5f05d89 100644 (file)
@@ -38,9 +38,9 @@ ENTRY (__sigsetjmp)
        ta      ST_FLUSH_WINDOWS
 
 #ifdef PTR_MANGLE
-       PTR_MANGLE (%g1, %o7, %g4)
-       PTR_MANGLE2 (%g2, %sp, %g4)
-       PTR_MANGLE2 (%g3, %fp, %g4)
+       PTR_MANGLE (%g1, %o7, %g4, %g5)
+       PTR_MANGLE2 (%g2, %sp, %g4, %g5)
+       PTR_MANGLE2 (%g3, %fp, %g4, %g5)
        st      %g1, [%o0 + (JB_PC * 4)]
        st      %g2, [%o0 + (JB_SP * 4)]
        st      %g3, [%o0 + (JB_FP * 4)]
index ed483a806a62f4ea799351f179768cfc7907ea80..0fd26973412aa2424530e0389f6a071cbfeec68f 100644 (file)
 # if (IS_IN (rtld) \
       || (!defined SHARED && (IS_IN (libc) \
                               || IS_IN (libpthread))))
-#  define PTR_MANGLE(dst, src, tmp)                                        \
+#  define PTR_GUARD_LOAD(tmp)                                              \
        adrp    tmp, C_SYMBOL_NAME(__pointer_chk_guard_local);              \
-       ldr     tmp, [tmp, :lo12:C_SYMBOL_NAME(__pointer_chk_guard_local)]; \
-       eor     dst, src, tmp
-#  define PTR_DEMANGLE(dst, src, tmp) PTR_MANGLE (dst, src, tmp)
+       ldr     tmp, [tmp, :lo12:C_SYMBOL_NAME(__pointer_chk_guard_local)]
 # else
-#  define PTR_MANGLE(dst, src, tmp)                                      \
+#  define PTR_GUARD_LOAD(tmp)                                            \
        adrp    tmp, :got:C_SYMBOL_NAME(__pointer_chk_guard);             \
        ldr     tmp, [tmp, :got_lo12:C_SYMBOL_NAME(__pointer_chk_guard)]; \
-       ldr     tmp, [tmp];                                               \
-       eor     dst, src, tmp;
-#  define PTR_DEMANGLE(dst, src, tmp) PTR_MANGLE (dst, src, tmp)
+       ldr     tmp, [tmp]
 # endif
+#  define PTR_MANGLE(dst, src, tmp)                                        \
+       PTR_GUARD_LOAD (tmp);                                               \
+       eor     dst, src, tmp;                                              \
+       ror     dst, dst, #(64 - 17)
+#  define PTR_DEMANGLE(dst, src, tmp)                                      \
+       PTR_GUARD_LOAD (tmp);                                               \
+       ror     dst, src, #17;                                              \
+       eor     dst, dst, tmp
 #endif
 
 #endif /* 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 (file)
index 7b7d8b0..0000000
+++ /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 */
index 6661db76c9bfc675b54691aa1e09c0288e16ec49..135eb10faa0411080c3ef93708ebb3399122113e 100644 (file)
@@ -54,9 +54,9 @@ ____longjmp_chk:
        cmoveq  s1, 1, s1
 
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE(s2, t1)
-       PTR_DEMANGLE2(s3, t1)
-       PTR_DEMANGLE2(fp, t1)
+       PTR_DEMANGLE(s2, t1, t2)
+       PTR_DEMANGLE2(s3, t1, t2)
+       PTR_DEMANGLE2(fp, t1, t2)
 #endif
        /* ??? While this is a proper test for detecting a longjmp to an
           invalid frame within any given stack, the main thread stack is
index 15f9e6cacef5f4d921c5217c39336d13a2879cc1..3ca56dd7aa4fa21b5ec03f9804cacb9089fb187c 100644 (file)
 
 #ifdef __ASSEMBLER__
 # if IS_IN (rtld)
-#  define PTR_MANGLE(dst, src, tmp)                             \
+#  define PTR_GUARD_LOAD(tmp)                                   \
         ldah    tmp, __pointer_chk_guard_local($29) !gprelhigh; \
-        ldq     tmp, __pointer_chk_guard_local(tmp) !gprellow;  \
-        xor     src, tmp, dst
-#  define PTR_MANGLE2(dst, src, tmp)                            \
-        xor     src, tmp, dst
+        ldq     tmp, __pointer_chk_guard_local(tmp) !gprellow
 # elif defined SHARED
-#  define PTR_MANGLE(dst, src, tmp)             \
-        ldq     tmp, __pointer_chk_guard;       \
-        xor     src, tmp, dst
+#  define PTR_GUARD_LOAD(tmp)                   \
+        ldq     tmp, __pointer_chk_guard
 # else
-#  define PTR_MANGLE(dst, src, tmp)             \
-        ldq     tmp, __pointer_chk_guard_local; \
-        xor     src, tmp, dst
+#  define PTR_GUARD_LOAD(tmp)                   \
+        ldq     tmp, __pointer_chk_guard_local
 # endif
-# define PTR_MANGLE2(dst, src, tmp)             \
-        xor     src, tmp, dst
-# define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
-# define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
+# define PTR_MANGLE(dst, src, tmp, tmp2)        \
+        PTR_GUARD_LOAD (tmp);                   \
+        PTR_MANGLE2 (dst, src, tmp, tmp2)
+# define PTR_MANGLE2(dst, src, tmp, tmp2)       \
+        xor     src, tmp, dst;                  \
+        sll     dst, 17, tmp2;                  \
+        srl     dst, 47, dst;                   \
+        bis     dst, tmp2, dst
+# define PTR_DEMANGLE(dst, tmp, tmp2)           \
+        PTR_GUARD_LOAD (tmp);                   \
+        PTR_DEMANGLE2 (dst, tmp, tmp2)
+# define PTR_DEMANGLE2(dst, tmp, tmp2)          \
+        sll     dst, 47, tmp2;                  \
+        srl     dst, 17, dst;                   \
+        bis     dst, tmp2, dst;                 \
+        xor     dst, tmp, dst
 #endif
 
 #endif /* POINTER_GUARD_ASM_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 (file)
index 0741bf7..0000000
+++ /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 */
index 8eb6d2c1d42d0ce9e9dfef97048b395699aa9c54..074251cbdf8d5e36523daf83ab7182e72a627f54 100644 (file)
 #ifdef __ASSEMBLER__
 # if (IS_IN (rtld) \
       || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
-#  define PTR_MANGLE(dst, src, guard)                   \
+#  define PTR_MANGLE_LOAD(guard)                        \
         grs     t0, 1f;                                 \
 1:                                                      \
         lrw     guard, 1b@GOTPC;                        \
         addu    t0, guard;                              \
         lrw     guard, __pointer_chk_guard_local@GOT;   \
         ldr.w   guard, (t0, guard << 0);                \
-        ldw     guard, (guard, 0);                      \
-        xor     dst, src, guard;
-#  define PTR_DEMANGLE(dst, src, guard) PTR_MANGLE (dst, src, guard)
-#  define PTR_MANGLE2(dst, src, guard) \
-        xor     dst, src, guard
-#  define PTR_DEMANGLE2(dst, src, guard) PTR_MANGLE2 (dst, src, guard)
+        ldw     guard, (guard, 0);
 # else
-#  define PTR_MANGLE(dst, src, guard)           \
-        grs     t0, 1f;                         \
-1:                                              \
-        lrw     guard, 1b@GOTPC;                \
-        addu    t0, guard;                      \
-        lrw     guard, __pointer_chk_guard@GOT; \
-        ldr.w   guard, (t0, guard << 0);        \
-        ldw     guard, (guard, 0);              \
-        xor     dst, src, guard;
-#  define PTR_DEMANGLE(dst, src, guard) PTR_MANGLE (dst, src, guard)
-#  define PTR_MANGLE2(dst, src, guard) \
-        xor     dst, src, guard
-#  define PTR_DEMANGLE2(dst, src, guard) PTR_MANGLE2 (dst, src, guard)
+#  define PTR_MANGLE_LOAD(guard)                        \
+        grs     t0, 1f;                                 \
+1:                                                      \
+        lrw     guard, 1b@GOTPC;                        \
+        addu    t0, guard;                              \
+        lrw     guard, __pointer_chk_guard@GOT;         \
+        ldr.w   guard, (t0, guard << 0);                \
+        ldw     guard, (guard, 0);
 # endif
+# define PTR_MANGLE(dst, src, guard)                    \
+        PTR_MANGLE_LOAD (guard);                        \
+        PTR_MANGLE2 (dst, src, guard)
+# define PTR_MANGLE2(dst, src, guard)                   \
+        xor     dst, src, guard;                        \
+        rotli   dst, dst, 9
+# define PTR_DEMANGLE(dst, src, guard)                  \
+        PTR_MANGLE_LOAD (guard);                        \
+        PTR_DEMANGLE2 (dst, src, guard)
+# define PTR_DEMANGLE2(dst, src, guard)                 \
+        rotli   dst, src, 23;                           \
+        xor     dst, dst, guard
 #endif
 
 #endif /* POINTER_GUARD_ASM_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 (file)
index 2aa044b..0000000
+++ /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 (file)
index 7776c28..0000000
+++ /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 */
index ac55dd8c95cdf03bea8a43dcd7530cb98ce3eb0c..75498545cb94761f3e19c5ee49d91275c0c4fecf 100644 (file)
 # if (IS_IN (rtld) \
       || (!defined SHARED && (IS_IN (libc) \
       || IS_IN (libpthread))))
-#  define PTR_MANGLE(dst, src, guard) \
-  LOAD_LOCAL (guard, __pointer_chk_guard_local); \
-  PTR_MANGLE2 (dst, src, guard);
-#  define PTR_DEMANGLE(dst, src, guard) \
-  LOAD_LOCAL (guard, __pointer_chk_guard_local); \
-  PTR_DEMANGLE2 (dst, src, guard);
-/* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */
-#  define PTR_MANGLE2(dst, src, guard) \
-  xor  dst, src, guard;
-#  define PTR_DEMANGLE2(dst, src, guard) \
-  PTR_MANGLE2 (dst, src, guard);
+#  define PTR_MANGLE_LOAD(guard) \
+  LOAD_LOCAL (guard, __pointer_chk_guard_local);
 # else
-#  define PTR_MANGLE(dst, src, guard) \
-  LOAD_GLOBAL (guard, __pointer_chk_guard); \
+#  define PTR_MANGLE_LOAD(guard) \
+  LOAD_GLOBAL (guard, __pointer_chk_guard);
+# endif
+# define PTR_MANGLE(dst, src, guard) \
+  PTR_MANGLE_LOAD (guard); \
   PTR_MANGLE2 (dst, src, guard);
-#  define PTR_DEMANGLE(dst, src, guard) \
-  LOAD_GLOBAL (guard, __pointer_chk_guard); \
+# define PTR_DEMANGLE(dst, src, guard) \
+  PTR_MANGLE_LOAD (guard); \
   PTR_DEMANGLE2 (dst, src, guard);
 /* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */
-#  define PTR_MANGLE2(dst, src, guard) \
-  xor dst, src, guard;
-#  define PTR_DEMANGLE2(dst, src, guard) \
-  PTR_MANGLE2 (dst, src, guard);
-# endif
+# define PTR_MANGLE2(dst, src, guard) \
+  xor  dst, src, guard; \
+  rotri.d  dst, dst, 47;
+# define PTR_DEMANGLE2(dst, src, guard) \
+  rotri.d  dst, src, 17; \
+  xor  dst, dst, guard;
 #endif
 
 #endif /* POINTER_GUARD_ASM_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 (file)
index c080bdd..0000000
+++ /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 */
index ca4278cc00a31f91dc2499ef488298a411acf301..962ad10e596f5c9c5520a515267cd2e8071c2d08 100644 (file)
        lwz     tmpreg,PTR_GUARD_SYM@l(tmpreg)
 # endif
 
+# if defined(__PPC64__) || defined(__powerpc64__)
+#  define PTR_ROT_MANGLE(dst, src)     rotldi  dst,src,17
+#  define PTR_ROT_DEMANGLE(dst, src)   rotldi  dst,src,47
+# else
+#  define PTR_ROT_MANGLE(dst, src)     rotlwi  dst,src,9
+#  define PTR_ROT_DEMANGLE(dst, src)   rotlwi  dst,src,23
+# endif
+
 # define PTR_MANGLE(reg, tmpreg) \
        PTR_GUARD_LOAD (tmpreg); \
-       xor     reg,tmpreg,reg
+       xor     reg,tmpreg,reg; \
+       PTR_ROT_MANGLE (reg, reg)
 # define PTR_MANGLE2(reg, tmpreg) \
-       xor     reg,tmpreg,reg
+       xor     reg,tmpreg,reg; \
+       PTR_ROT_MANGLE (reg, reg)
 # define PTR_MANGLE3(destreg, reg, tmpreg) \
        PTR_GUARD_LOAD (tmpreg); \
-       xor     destreg,tmpreg,reg
-# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
-# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
-# define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
+       xor     destreg,tmpreg,reg; \
+       PTR_ROT_MANGLE (destreg, destreg)
+# define PTR_DEMANGLE(reg, tmpreg) \
+       PTR_GUARD_LOAD (tmpreg); \
+       PTR_ROT_DEMANGLE (reg, reg); \
+       xor     reg,tmpreg,reg
+# define PTR_DEMANGLE2(reg, tmpreg) \
+       PTR_ROT_DEMANGLE (reg, reg); \
+       xor     reg,tmpreg,reg
+# define PTR_DEMANGLE3(destreg, reg, tmpreg) \
+       PTR_GUARD_LOAD (tmpreg); \
+       PTR_ROT_DEMANGLE (destreg, reg); \
+       xor     destreg,tmpreg,destreg
 #endif
 
 #endif /* POINTER_GUARD_ASM_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 (file)
index 621784a..0000000
+++ /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 */
index 4186114844d9cf7d204fde81fad9620d2f5cdeeb..7ee7bf71cfff47df510908dfc89a1a04631ed20a 100644 (file)
@@ -23,6 +23,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <stdbit.h>
 #include <signal.h>
 #include <sys/syscall.h>
 
@@ -34,7 +35,8 @@
       uintptr_t cur_sp;                                                        \
       uintptr_t new_sp = env->__gregs[9];                              \
       __asm__ ("lgr %0, %%r15" : "=r" (cur_sp));                       \
-      new_sp ^= guard;                                                 \
+      new_sp = stdc_rotate_right (new_sp, 2 * sizeof (uintptr_t) + 1)  \
+              ^ guard;                                                 \
       if (new_sp < cur_sp)                                             \
        {                                                               \
          stack_t oss;                                                  \
index 71cc0465d13261b3254f95bd4a8619208113e4af..44c9a2a156bd4ac64b3ff2231c60f059612152de 100644 (file)
 # endif
 # define PTR_MANGLE(reg, tmpreg) \
        PTR_GUARD_LOAD (tmpreg);                                        \
-       xgr     reg,tmpreg
+       xgr     reg,tmpreg;                                             \
+       rllg    reg,reg,17
 # define PTR_MANGLE2(reg, tmpreg) \
+       xgr     reg,tmpreg;                                             \
+       rllg    reg,reg,17
+# define PTR_DEMANGLE(reg, tmpreg) \
+       PTR_GUARD_LOAD (tmpreg);                                        \
+       rllg    reg,reg,47;                                             \
+       xgr     reg,tmpreg
+# define PTR_DEMANGLE2(reg, tmpreg) \
+       rllg    reg,reg,47;                                             \
        xgr     reg,tmpreg
-# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
-# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
 #endif
 
 #endif /* POINTER_GUARD_ASM_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 (file)
index 403eff6..0000000
+++ /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 */
index 64e6f6153e81549d381da0b2f74c82ca07d935e8..f6002efdeadaf495ed275318f0271090f971e4f9 100644 (file)
 .Lptrg_end:
 # endif
 # define PTR_MANGLE(reg, tmp) \
-     PTR_GUARD_LOAD (tmp); xor tmp,reg
-# define PTR_MANGLE2(reg, tmp) xor tmp,reg
-# define PTR_DEMANGLE(reg, tmp)        PTR_MANGLE (reg, tmp)
-# define PTR_DEMANGLE2(reg, tmp)       PTR_MANGLE2 (reg, tmp)
+     PTR_GUARD_LOAD (tmp); PTR_MANGLE2 (reg, tmp)
+# define PTR_MANGLE2(reg, tmp) \
+     xor tmp,reg;                                                      \
+     rotl reg; rotl reg; rotl reg; rotl reg; rotl reg;                 \
+     rotl reg; rotl reg; rotl reg; rotl reg
+# define PTR_DEMANGLE(reg, tmp)        PTR_GUARD_LOAD (tmp); PTR_DEMANGLE2 (reg, tmp)
+# define PTR_DEMANGLE2(reg, tmp) \
+     rotr reg; rotr reg; rotr reg; rotr reg; rotr reg;                 \
+     rotr reg; rotr reg; rotr reg; rotr reg;                           \
+     xor tmp,reg
 #endif
 
 #endif /* POINTER_GUARD_ASM_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 (file)
index 42340fa..0000000
+++ /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 */
index b0c6160bd28083fcf541285307f9343ca854dad5..07baa0c9ed2f176ec94c09209a372d3b4663631f 100644 (file)
@@ -32,7 +32,7 @@ longjmp_msg:
 ENTRY (____longjmp_chk)
        ld      ENV(o0,JB_SP), %g5
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE (%g5, %g5, %g4)
+       PTR_DEMANGLE (%g5, %g5, %g4, %g3)
 #endif
 
        cmp     %sp, %g5
@@ -82,7 +82,7 @@ ENTRY (____longjmp_chk)
 .Lok_norestore:
        ld      ENV(o0,JB_FP), %g3      /* Cache target FP in register %g3.  */
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE2 (%g3, %g3, %g4)
+       PTR_DEMANGLE2 (%g3, %g3, %g4, %g1)
 #endif
 
        mov %o0, %g1            /* ENV in %g1 */
@@ -103,7 +103,7 @@ ENTRY (____longjmp_chk)
        ta      ST_FLUSH_WINDOWS
 #ifdef PTR_DEMANGLE
        ld      ENV(g1,JB_PC), %g1 /* Set return PC. */
-       PTR_DEMANGLE2 (%i7, %g1, %g4)
+       PTR_DEMANGLE2 (%i7, %g1, %g4, %g3)
 #else
        ld      ENV(g1,JB_PC), %i7 /* Set return PC. */
 #endif
index e1e42f8087ac3cd7090249143b5a716864c5b837..aa2b7609c92010e8a4756114ef71eb5603d6a1ec 100644 (file)
        sethi   %hi(PTR_GUARD_SYM), tmpreg;                             \
        ld      [tmpreg + %lo(PTR_GUARD_SYM)], tmpreg
 # endif
-# define PTR_MANGLE(dreg, reg, tmpreg) \
+# define PTR_MANGLE(dreg, reg, tmpreg, tmp2) \
        PTR_GUARD_LOAD (tmpreg);                                        \
-       xor     reg, tmpreg, dreg
-# define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
-# define PTR_MANGLE2(dreg, reg, tmpreg) \
-       xor     reg, tmpreg, dreg
-# define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
+       PTR_MANGLE2 (dreg, reg, tmpreg, tmp2)
+# define PTR_MANGLE2(dreg, reg, tmpreg, tmp2) \
+       xor     reg, tmpreg, dreg;                                      \
+       sll     dreg, 9, tmp2;                                          \
+       srl     dreg, 23, dreg;                                         \
+       or      dreg, tmp2, dreg
+# define PTR_DEMANGLE(dreg, reg, tmpreg, tmp2) \
+       PTR_GUARD_LOAD (tmpreg);                                        \
+       PTR_DEMANGLE2 (dreg, reg, tmpreg, tmp2)
+# define PTR_DEMANGLE2(dreg, reg, tmpreg, tmp2) \
+       srl     reg, 9, tmp2;                                           \
+       sll     reg, 23, dreg;                                          \
+       or      dreg, tmp2, dreg;                                       \
+       xor     dreg, tmpreg, dreg
 #endif
 
 #endif /* POINTER_GUARD_ASM_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 (file)
index 86d3fbb..0000000
+++ /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 */
index f378c88e58c8867ee903c0c7fd2848aeee6ac5dc..ef5b38f541bd801cbe3d964c48788ef13fe1685d 100644 (file)
        sethi   %hi(PTR_GUARD_SYM), tmpreg;                             \
        ldx     [tmpreg + %lo(PTR_GUARD_SYM)], tmpreg
 # endif
-# define PTR_MANGLE(dreg, reg, tmpreg) \
+# define PTR_MANGLE(dreg, reg, tmpreg, tmp2) \
        PTR_GUARD_LOAD (tmpreg);                                        \
-       xor     reg, tmpreg, dreg
-# define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
-# define PTR_MANGLE2(dreg, reg, tmpreg) \
-       xor     reg, tmpreg, dreg
-# define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
+       PTR_MANGLE2 (dreg, reg, tmpreg, tmp2)
+# define PTR_MANGLE2(dreg, reg, tmpreg, tmp2) \
+       xor     reg, tmpreg, dreg;                                      \
+       sllx    dreg, 17, tmp2;                                         \
+       srlx    dreg, 47, dreg;                                         \
+       or      dreg, tmp2, dreg
+# define PTR_DEMANGLE(dreg, reg, tmpreg, tmp2) \
+       PTR_GUARD_LOAD (tmpreg);                                        \
+       PTR_DEMANGLE2 (dreg, reg, tmpreg, tmp2)
+# define PTR_DEMANGLE2(dreg, reg, tmpreg, tmp2) \
+       srlx    reg, 17, tmp2;                                          \
+       sllx    reg, 47, dreg;                                          \
+       or      dreg, tmp2, dreg;                                       \
+       xor     dreg, tmpreg, dreg
 #endif
 
 #endif /* POINTER_GUARD_ASM_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 (file)
index fc0a723..0000000
+++ /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 (file)
index dd3a975..0000000
+++ /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 */