aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-10-18 17:00:07 +0200
committerFlorian Weimer <fweimer@redhat.com>2022-10-18 17:03:55 +0200
commit88f4b6929c26f9240a4b0b7dcc62922f02544a09 (patch)
tree72acb4a359d3ec56729a910386bd1a002bd69e3c /sysdeps
parent246f37d6b1c4c6c0a6365df8783e62e3adf208e8 (diff)
downloadglibc-88f4b6929c26f9240a4b0b7dcc62922f02544a09.zip
glibc-88f4b6929c26f9240a4b0b7dcc62922f02544a09.tar.gz
glibc-88f4b6929c26f9240a4b0b7dcc62922f02544a09.tar.bz2
Introduce <pointer_guard.h>, extracted from <sysdep.h>
This allows us to define a generic no-op version of PTR_MANGLE and PTR_DEMANGLE. In the future, we can use PTR_MANGLE and PTR_DEMANGLE unconditionally in C sources, avoiding an unintended loss of hardening due to missing include files or unlucky header inclusion ordering. In i386 and x86_64, we can avoid a <tls.h> dependency in the C code by using the computed constant from <tcb-offsets.h>. <sysdep.h> no longer includes these definitions, so there is no cyclic dependency anymore when computing the <tcb-offsets.h> constants. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/aarch64/__longjmp.S1
-rw-r--r--sysdeps/aarch64/jmpbuf-offsets.h1
-rw-r--r--sysdeps/aarch64/setjmp.S1
-rw-r--r--sysdeps/alpha/__longjmp.S1
-rw-r--r--sysdeps/alpha/jmpbuf-unwind.h1
-rw-r--r--sysdeps/alpha/setjmp.S1
-rw-r--r--sysdeps/arc/jmpbuf-unwind.h1
-rw-r--r--sysdeps/arm/__longjmp.S1
-rw-r--r--sysdeps/arm/jmpbuf-unwind.h1
-rw-r--r--sysdeps/arm/pointer_guard.h67
-rw-r--r--sysdeps/arm/setjmp.S1
-rw-r--r--sysdeps/arm/sysdep.h44
-rw-r--r--sysdeps/csky/abiv2/__longjmp.S1
-rw-r--r--sysdeps/csky/abiv2/setjmp.S1
-rw-r--r--sysdeps/csky/jmpbuf-unwind.h1
-rw-r--r--sysdeps/generic/pointer_guard.h29
-rw-r--r--sysdeps/generic/unwind-link.h2
-rw-r--r--sysdeps/i386/__longjmp.S1
-rw-r--r--sysdeps/i386/bsd-_setjmp.S1
-rw-r--r--sysdeps/i386/bsd-setjmp.S1
-rw-r--r--sysdeps/i386/jmpbuf-unwind.h1
-rw-r--r--sysdeps/i386/setjmp.S1
-rw-r--r--sysdeps/loongarch/__longjmp.S1
-rw-r--r--sysdeps/loongarch/jmpbuf-unwind.h1
-rw-r--r--sysdeps/loongarch/setjmp.S1
-rw-r--r--sysdeps/m68k/jmpbuf-unwind.h1
-rw-r--r--sysdeps/mach/hurd/i386/____longjmp_chk.S1
-rw-r--r--sysdeps/mach/hurd/i386/__longjmp.S1
-rw-r--r--sysdeps/mach/hurd/jmp-unwind.c2
-rw-r--r--sysdeps/microblaze/jmpbuf-unwind.h1
-rw-r--r--sysdeps/mips/jmpbuf-unwind.h1
-rw-r--r--sysdeps/nios2/__longjmp.S1
-rw-r--r--sysdeps/nios2/jmpbuf-offsets.h1
-rw-r--r--sysdeps/nios2/setjmp.S1
-rw-r--r--sysdeps/powerpc/jmpbuf-unwind.h1
-rw-r--r--sysdeps/powerpc/powerpc32/__longjmp-common.S1
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S1
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/setjmp-common.S1
-rw-r--r--sysdeps/powerpc/powerpc32/setjmp-common.S1
-rw-r--r--sysdeps/powerpc/powerpc64/__longjmp-common.S1
-rw-r--r--sysdeps/powerpc/powerpc64/setjmp-common.S1
-rw-r--r--sysdeps/riscv/jmpbuf-unwind.h1
-rw-r--r--sysdeps/s390/jmpbuf-unwind.h1
-rw-r--r--sysdeps/s390/s390-32/__longjmp.c1
-rw-r--r--sysdeps/s390/s390-32/setjmp.S1
-rw-r--r--sysdeps/s390/s390-64/__longjmp.c1
-rw-r--r--sysdeps/s390/s390-64/setjmp.S1
-rw-r--r--sysdeps/sh/jmpbuf-unwind.h1
-rw-r--r--sysdeps/sh/sh3/__longjmp.S1
-rw-r--r--sysdeps/sh/sh3/setjmp.S1
-rw-r--r--sysdeps/sh/sh4/__longjmp.S1
-rw-r--r--sysdeps/sh/sh4/setjmp.S1
-rw-r--r--sysdeps/sparc/sparc32/__longjmp.S1
-rw-r--r--sysdeps/sparc/sparc32/jmpbuf-unwind.h1
-rw-r--r--sysdeps/sparc/sparc32/setjmp.S1
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/pointer_guard.h68
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/sysdep.h45
-rw-r--r--sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S1
-rw-r--r--sysdeps/unix/sysv/linux/alpha/pointer_guard.h62
-rw-r--r--sysdeps/unix/sysv/linux/alpha/sysdep.h40
-rw-r--r--sysdeps/unix/sysv/linux/arc/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/csky/pointer_guard.h68
-rw-r--r--sysdeps/unix/sysv/linux/csky/sysdep.h46
-rw-r--r--sysdeps/unix/sysv/linux/hppa/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/i386/____longjmp_chk.S1
-rw-r--r--sysdeps/unix/sysv/linux/i386/pointer_guard.h49
-rw-r--r--sysdeps/unix/sysv/linux/i386/sysdep.h28
-rw-r--r--sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S1
-rw-r--r--sysdeps/unix/sysv/linux/ia64/__longjmp.S1
-rw-r--r--sysdeps/unix/sysv/linux/ia64/pointer_guard.h44
-rw-r--r--sysdeps/unix/sysv/linux/ia64/setjmp.S1
-rw-r--r--sysdeps/unix/sysv/linux/ia64/sysdep.h20
-rw-r--r--sysdeps/unix/sysv/linux/loongarch/pointer_guard.h82
-rw-r--r--sysdeps/unix/sysv/linux/loongarch/sysdep.h60
-rw-r--r--sysdeps/unix/sysv/linux/m68k/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/nios2/pointer_guard.h40
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sysdep.h17
-rw-r--r--sysdeps/unix/sysv/linux/or1k/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/pointer_guard.h55
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/sysdep.h32
-rw-r--r--sysdeps/unix/sysv/linux/riscv/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/pointer_guard.h45
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h21
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/pointer_guard.h47
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h23
-rw-r--r--sysdeps/unix/sysv/linux/sh/____longjmp_chk.S1
-rw-r--r--sysdeps/unix/sysv/linux/sh/pointer_guard.h43
-rw-r--r--sysdeps/unix/sysv/linux/sh/sysdep.h19
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h44
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h20
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h44
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h20
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S1
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/pointer_guard.h61
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/sysdep.h40
-rw-r--r--sysdeps/x86_64/__longjmp.S1
-rw-r--r--sysdeps/x86_64/jmpbuf-unwind.h1
-rw-r--r--sysdeps/x86_64/setjmp.S1
102 files changed, 911 insertions, 509 deletions
diff --git a/sysdeps/aarch64/__longjmp.S b/sysdeps/aarch64/__longjmp.S
index 5f83f9f..d934e00 100644
--- a/sysdeps/aarch64/__longjmp.S
+++ b/sysdeps/aarch64/__longjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <stap-probe.h>
diff --git a/sysdeps/aarch64/jmpbuf-offsets.h b/sysdeps/aarch64/jmpbuf-offsets.h
index 6256bda..78bdd4a 100644
--- a/sysdeps/aarch64/jmpbuf-offsets.h
+++ b/sysdeps/aarch64/jmpbuf-offsets.h
@@ -43,6 +43,7 @@
#include <setjmp.h>
#include <stdint.h>
#include <sysdep.h>
+#include <pointer_guard.h>
static inline uintptr_t __attribute__ ((unused))
_jmpbuf_sp (__jmp_buf jmpbuf)
diff --git a/sysdeps/aarch64/setjmp.S b/sysdeps/aarch64/setjmp.S
index 3860f4e..2ed2feb 100644
--- a/sysdeps/aarch64/setjmp.S
+++ b/sysdeps/aarch64/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <stap-probe.h>
diff --git a/sysdeps/alpha/__longjmp.S b/sysdeps/alpha/__longjmp.S
index ec7510b..aed7a17 100644
--- a/sysdeps/alpha/__longjmp.S
+++ b/sysdeps/alpha/__longjmp.S
@@ -18,6 +18,7 @@
#define __ASSEMBLY__
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
diff --git a/sysdeps/alpha/jmpbuf-unwind.h b/sysdeps/alpha/jmpbuf-unwind.h
index 13b2799..318b73b 100644
--- a/sysdeps/alpha/jmpbuf-unwind.h
+++ b/sysdeps/alpha/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame containing a local
variable at ADDRESS. */
diff --git a/sysdeps/alpha/setjmp.S b/sysdeps/alpha/setjmp.S
index f86367a..deb888c 100644
--- a/sysdeps/alpha/setjmp.S
+++ b/sysdeps/alpha/setjmp.S
@@ -18,6 +18,7 @@
#define __ASSEMBLY__
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
.ent __sigsetjmp
diff --git a/sysdeps/arc/jmpbuf-unwind.h b/sysdeps/arc/jmpbuf-unwind.h
index 5488707..e5434a9 100644
--- a/sysdeps/arc/jmpbuf-unwind.h
+++ b/sysdeps/arc/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <jmpbuf-offsets.h>
#include <stdint.h>
#include <unwind.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/arm/__longjmp.S b/sysdeps/arm/__longjmp.S
index 5f1cf36..411055b 100644
--- a/sysdeps/arm/__longjmp.S
+++ b/sysdeps/arm/__longjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#include <bits/setjmp.h>
#include <rtld-global-offsets.h>
diff --git a/sysdeps/arm/jmpbuf-unwind.h b/sysdeps/arm/jmpbuf-unwind.h
index e6b118f..641444e 100644
--- a/sysdeps/arm/jmpbuf-unwind.h
+++ b/sysdeps/arm/jmpbuf-unwind.h
@@ -18,6 +18,7 @@
#include <setjmp.h>
#include <stdint.h>
#include <sysdep.h>
+#include <pointer_guard.h>
#include <unwind.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/sysdeps/arm/pointer_guard.h b/sysdeps/arm/pointer_guard.h
new file mode 100644
index 0000000..6b90cec
--- /dev/null
+++ b/sysdeps/arm/pointer_guard.h
@@ -0,0 +1,67 @@
+/* Pointer guard implementation. Arm version.
+ Copyright (C) 2013-2022 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
+
+/* Pointer mangling support. */
+#if (IS_IN (rtld) \
+ || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
+# ifdef __ASSEMBLER__
+# 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
+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)
+# endif
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE_LOAD(guard, tmp) \
+ LDR_GLOBAL (guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard), 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
+# 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/arm/setjmp.S b/sysdeps/arm/setjmp.S
index 1c26227..271454d 100644
--- a/sysdeps/arm/setjmp.S
+++ b/sysdeps/arm/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#include <bits/setjmp.h>
#include <rtld-global-offsets.h>
diff --git a/sysdeps/arm/sysdep.h b/sysdeps/arm/sysdep.h
index f19146b..ffd848d 100644
--- a/sysdeps/arm/sysdep.h
+++ b/sysdeps/arm/sysdep.h
@@ -293,47 +293,3 @@
#else
# define PC_OFS 8
#endif
-
-/* Pointer mangling support. */
-#if (IS_IN (rtld) \
- || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
-# ifdef __ASSEMBLER__
-# 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
-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)
-# endif
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE_LOAD(guard, tmp) \
- LDR_GLOBAL (guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard), 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
-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
diff --git a/sysdeps/csky/abiv2/__longjmp.S b/sysdeps/csky/abiv2/__longjmp.S
index 762b2cb..bb7da54 100644
--- a/sysdeps/csky/abiv2/__longjmp.S
+++ b/sysdeps/csky/abiv2/__longjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
ENTRY (__longjmp)
mov a2, a0
diff --git a/sysdeps/csky/abiv2/setjmp.S b/sysdeps/csky/abiv2/setjmp.S
index 0acf197..afef3ce 100644
--- a/sysdeps/csky/abiv2/setjmp.S
+++ b/sysdeps/csky/abiv2/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
ENTRY (setjmp)
movi a1, 1
diff --git a/sysdeps/csky/jmpbuf-unwind.h b/sysdeps/csky/jmpbuf-unwind.h
index 358e912..76fca43 100644
--- a/sysdeps/csky/jmpbuf-unwind.h
+++ b/sysdeps/csky/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/generic/pointer_guard.h b/sysdeps/generic/pointer_guard.h
new file mode 100644
index 0000000..58a624e
--- /dev/null
+++ b/sysdeps/generic/pointer_guard.h
@@ -0,0 +1,29 @@
+/* Pointer obfuscation implenentation. Generic (no-op) version.
+ Copyright (C) 2022 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
+
+/* Assembler code depends on PTR_MANGLE not being defined for
+ optimization purposes. */
+#ifndef __ASSEMBLER__
+# define PTR_MANGLE(x) (void) (x)
+# define PTR_DEMANGLE(x) (void) (x)
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/generic/unwind-link.h b/sysdeps/generic/unwind-link.h
index 93ee80f..a2076a2 100644
--- a/sysdeps/generic/unwind-link.h
+++ b/sysdeps/generic/unwind-link.h
@@ -31,7 +31,7 @@ unwind_arch_adjustment (void *prev, void *addr)
#endif
#ifdef SHARED
-# include <sysdep.h>
+# include <pointer_guard.h>
# include <unwind-resume.h>
# if UNWIND_LINK_FRAME_STATE_FOR
diff --git a/sysdeps/i386/__longjmp.S b/sysdeps/i386/__longjmp.S
index 508d370..b67781c 100644
--- a/sysdeps/i386/__longjmp.S
+++ b/sysdeps/i386/__longjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <jmp_buf-ssp.h>
#include <asm-syntax.h>
diff --git a/sysdeps/i386/bsd-_setjmp.S b/sysdeps/i386/bsd-_setjmp.S
index 190e35b..80399db 100644
--- a/sysdeps/i386/bsd-_setjmp.S
+++ b/sysdeps/i386/bsd-_setjmp.S
@@ -21,6 +21,7 @@
in setjmp doesn't clobber the state restored by longjmp. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <jmp_buf-ssp.h>
#include <stap-probe.h>
diff --git a/sysdeps/i386/bsd-setjmp.S b/sysdeps/i386/bsd-setjmp.S
index 575ac96..b367bad 100644
--- a/sysdeps/i386/bsd-setjmp.S
+++ b/sysdeps/i386/bsd-setjmp.S
@@ -21,6 +21,7 @@
in setjmp doesn't clobber the state restored by longjmp. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <jmp_buf-ssp.h>
#include <stap-probe.h>
diff --git a/sysdeps/i386/jmpbuf-unwind.h b/sysdeps/i386/jmpbuf-unwind.h
index 416c816..73d214f 100644
--- a/sysdeps/i386/jmpbuf-unwind.h
+++ b/sysdeps/i386/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/i386/setjmp.S b/sysdeps/i386/setjmp.S
index 217efbd..b528245 100644
--- a/sysdeps/i386/setjmp.S
+++ b/sysdeps/i386/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <jmp_buf-ssp.h>
#include <asm-syntax.h>
diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S
index d6a99fc..4c40ffa 100644
--- a/sysdeps/loongarch/__longjmp.S
+++ b/sysdeps/loongarch/__longjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <sys/asm.h>
ENTRY (__longjmp)
diff --git a/sysdeps/loongarch/jmpbuf-unwind.h b/sysdeps/loongarch/jmpbuf-unwind.h
index 6fa5091..458edec 100644
--- a/sysdeps/loongarch/jmpbuf-unwind.h
+++ b/sysdeps/loongarch/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/loongarch/setjmp.S b/sysdeps/loongarch/setjmp.S
index 9b1cdea..e5f480d 100644
--- a/sysdeps/loongarch/setjmp.S
+++ b/sysdeps/loongarch/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <sys/asm.h>
ENTRY (_setjmp)
diff --git a/sysdeps/m68k/jmpbuf-unwind.h b/sysdeps/m68k/jmpbuf-unwind.h
index 17e4b85..3ee46c0 100644
--- a/sysdeps/m68k/jmpbuf-unwind.h
+++ b/sysdeps/m68k/jmpbuf-unwind.h
@@ -19,6 +19,7 @@
#include <setjmp.h>
#include <stdint.h>
#include <unwind.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/mach/hurd/i386/____longjmp_chk.S b/sysdeps/mach/hurd/i386/____longjmp_chk.S
index 1a019e2..81d297d 100644
--- a/sysdeps/mach/hurd/i386/____longjmp_chk.S
+++ b/sysdeps/mach/hurd/i386/____longjmp_chk.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <tcb-offsets.h>
#include <asm-syntax.h>
diff --git a/sysdeps/mach/hurd/i386/__longjmp.S b/sysdeps/mach/hurd/i386/__longjmp.S
index 72fcc79..22915fb 100644
--- a/sysdeps/mach/hurd/i386/__longjmp.S
+++ b/sysdeps/mach/hurd/i386/__longjmp.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <tcb-offsets.h>
#include <asm-syntax.h>
diff --git a/sysdeps/mach/hurd/jmp-unwind.c b/sysdeps/mach/hurd/jmp-unwind.c
index f8938bc..2577fbf 100644
--- a/sysdeps/mach/hurd/jmp-unwind.c
+++ b/sysdeps/mach/hurd/jmp-unwind.c
@@ -22,7 +22,7 @@
#include <hurd/sigpreempt.h>
#include <assert.h>
#include <stdint.h>
-
+#include <pointer_guard.h>
#ifndef _JMPBUF_UNWINDS
#error "<jmpbuf-unwind.h> fails to define _JMPBUF_UNWINDS"
diff --git a/sysdeps/microblaze/jmpbuf-unwind.h b/sysdeps/microblaze/jmpbuf-unwind.h
index f23c758..302e950 100644
--- a/sysdeps/microblaze/jmpbuf-unwind.h
+++ b/sysdeps/microblaze/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/mips/jmpbuf-unwind.h b/sysdeps/mips/jmpbuf-unwind.h
index 813c24f..28ecffe 100644
--- a/sysdeps/mips/jmpbuf-unwind.h
+++ b/sysdeps/mips/jmpbuf-unwind.h
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/nios2/__longjmp.S b/sysdeps/nios2/__longjmp.S
index 214901d..13695e2 100644
--- a/sysdeps/nios2/__longjmp.S
+++ b/sysdeps/nios2/__longjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
/* __longjmp(jmpbuf, val) */
diff --git a/sysdeps/nios2/jmpbuf-offsets.h b/sysdeps/nios2/jmpbuf-offsets.h
index a13aa76..76fea64 100644
--- a/sysdeps/nios2/jmpbuf-offsets.h
+++ b/sysdeps/nios2/jmpbuf-offsets.h
@@ -32,6 +32,7 @@
#include <setjmp.h>
#include <stdint.h>
#include <sysdep.h>
+#include <pointer_guard.h>
static inline uintptr_t __attribute__ ((unused))
_jmpbuf_sp (__jmp_buf jmpbuf)
diff --git a/sysdeps/nios2/setjmp.S b/sysdeps/nios2/setjmp.S
index 0aa5b23..ec75108 100644
--- a/sysdeps/nios2/setjmp.S
+++ b/sysdeps/nios2/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
.text
diff --git a/sysdeps/powerpc/jmpbuf-unwind.h b/sysdeps/powerpc/jmpbuf-unwind.h
index 706ceda..93573ce 100644
--- a/sysdeps/powerpc/jmpbuf-unwind.h
+++ b/sysdeps/powerpc/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/powerpc/powerpc32/__longjmp-common.S b/sysdeps/powerpc/powerpc32/__longjmp-common.S
index 13ded20..0e0361e 100644
--- a/sysdeps/powerpc/powerpc32/__longjmp-common.S
+++ b/sysdeps/powerpc/powerpc32/__longjmp-common.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
diff --git a/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S b/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S
index e393722..de04a62 100644
--- a/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S
+++ b/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
diff --git a/sysdeps/powerpc/powerpc32/fpu/setjmp-common.S b/sysdeps/powerpc/powerpc32/fpu/setjmp-common.S
index f82196e..1943ffd 100644
--- a/sysdeps/powerpc/powerpc32/fpu/setjmp-common.S
+++ b/sysdeps/powerpc/powerpc32/fpu/setjmp-common.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
diff --git a/sysdeps/powerpc/powerpc32/setjmp-common.S b/sysdeps/powerpc/powerpc32/setjmp-common.S
index c632a3f..281dd65 100644
--- a/sysdeps/powerpc/powerpc32/setjmp-common.S
+++ b/sysdeps/powerpc/powerpc32/setjmp-common.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
diff --git a/sysdeps/powerpc/powerpc64/__longjmp-common.S b/sysdeps/powerpc/powerpc64/__longjmp-common.S
index 5f629e1..ff3e0be 100644
--- a/sysdeps/powerpc/powerpc64/__longjmp-common.S
+++ b/sysdeps/powerpc/powerpc64/__longjmp-common.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#define _SETJMP_H
diff --git a/sysdeps/powerpc/powerpc64/setjmp-common.S b/sysdeps/powerpc/powerpc64/setjmp-common.S
index 19e76d5..75389e4 100644
--- a/sysdeps/powerpc/powerpc64/setjmp-common.S
+++ b/sysdeps/powerpc/powerpc64/setjmp-common.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
diff --git a/sysdeps/riscv/jmpbuf-unwind.h b/sysdeps/riscv/jmpbuf-unwind.h
index 28e73dd..b411a24 100644
--- a/sysdeps/riscv/jmpbuf-unwind.h
+++ b/sysdeps/riscv/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/s390/jmpbuf-unwind.h b/sysdeps/s390/jmpbuf-unwind.h
index b4ff8da..10b37f0 100644
--- a/sysdeps/s390/jmpbuf-unwind.h
+++ b/sysdeps/s390/jmpbuf-unwind.h
@@ -21,6 +21,7 @@
#include <unwind.h>
#include <bits/wordsize.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/sysdeps/s390/s390-32/__longjmp.c b/sysdeps/s390/s390-32/__longjmp.c
index 09a3a2b..83d4232 100644
--- a/sysdeps/s390/s390-32/__longjmp.c
+++ b/sysdeps/s390/s390-32/__longjmp.c
@@ -17,6 +17,7 @@
#include <errno.h>
#include <sysdep.h>
+#include <pointer_guard.h>
#include <setjmp.h>
#include <bits/setjmp.h>
#include <stdlib.h>
diff --git a/sysdeps/s390/s390-32/setjmp.S b/sysdeps/s390/s390-32/setjmp.S
index c15c7bb..0870423 100644
--- a/sysdeps/s390/s390-32/setjmp.S
+++ b/sysdeps/s390/s390-32/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#define _ASM
#define _SETJMP_H
#include <bits/setjmp.h>
diff --git a/sysdeps/s390/s390-64/__longjmp.c b/sysdeps/s390/s390-64/__longjmp.c
index 2ca96e1..9fe4939 100644
--- a/sysdeps/s390/s390-64/__longjmp.c
+++ b/sysdeps/s390/s390-64/__longjmp.c
@@ -17,6 +17,7 @@
#include <errno.h>
#include <sysdep.h>
+#include <pointer_guard.h>
#include <setjmp.h>
#include <bits/setjmp.h>
#include <stdlib.h>
diff --git a/sysdeps/s390/s390-64/setjmp.S b/sysdeps/s390/s390-64/setjmp.S
index 6dcd77d..5c59f57 100644
--- a/sysdeps/s390/s390-64/setjmp.S
+++ b/sysdeps/s390/s390-64/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#define _ASM
#define _SETJMP_H
#include <bits/setjmp.h>
diff --git a/sysdeps/sh/jmpbuf-unwind.h b/sysdeps/sh/jmpbuf-unwind.h
index c667295..1957e52 100644
--- a/sysdeps/sh/jmpbuf-unwind.h
+++ b/sysdeps/sh/jmpbuf-unwind.h
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/sh/sh3/__longjmp.S b/sysdeps/sh/sh3/__longjmp.S
index 4228b5f..f10bed2 100644
--- a/sysdeps/sh/sh3/__longjmp.S
+++ b/sysdeps/sh/sh3/__longjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#define _SETJMP_H
#define _ASM
#include <bits/setjmp.h>
diff --git a/sysdeps/sh/sh3/setjmp.S b/sysdeps/sh/sh3/setjmp.S
index 0dd0003..363e16f 100644
--- a/sysdeps/sh/sh3/setjmp.S
+++ b/sysdeps/sh/sh3/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
ENTRY (__sigsetjmp)
diff --git a/sysdeps/sh/sh4/__longjmp.S b/sysdeps/sh/sh4/__longjmp.S
index 2013b71..bc179e4 100644
--- a/sysdeps/sh/sh4/__longjmp.S
+++ b/sysdeps/sh/sh4/__longjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#define _SETJMP_H
#define _ASM
#include <bits/setjmp.h>
diff --git a/sysdeps/sh/sh4/setjmp.S b/sysdeps/sh/sh4/setjmp.S
index b73aa3c1..f28ec42 100644
--- a/sysdeps/sh/sh4/setjmp.S
+++ b/sysdeps/sh/sh4/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
ENTRY (__sigsetjmp)
diff --git a/sysdeps/sparc/sparc32/__longjmp.S b/sysdeps/sparc/sparc32/__longjmp.S
index 5bed244..68b3b15 100644
--- a/sysdeps/sparc/sparc32/__longjmp.S
+++ b/sysdeps/sparc/sparc32/__longjmp.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#define ENV(base,reg) [%base + (reg * 4)]
diff --git a/sysdeps/sparc/sparc32/jmpbuf-unwind.h b/sysdeps/sparc/sparc32/jmpbuf-unwind.h
index 3ab5088..8b697ed 100644
--- a/sysdeps/sparc/sparc32/jmpbuf-unwind.h
+++ b/sysdeps/sparc/sparc32/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/sparc/sparc32/setjmp.S b/sysdeps/sparc/sparc32/setjmp.S
index 9c7531b..c4e29c4 100644
--- a/sysdeps/sparc/sparc32/setjmp.S
+++ b/sysdeps/sparc/sparc32/setjmp.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <sys/trap.h>
#include <jmpbuf-offsets.h>
diff --git a/sysdeps/unix/sysv/linux/aarch64/pointer_guard.h b/sysdeps/unix/sysv/linux/aarch64/pointer_guard.h
new file mode 100644
index 0000000..b81c907
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/pointer_guard.h
@@ -0,0 +1,68 @@
+/* Pointer guard implementation. AArch64 version.
+ Copyright (C) 2014-2022 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
+
+/* Pointer mangling is supported for AArch64. */
+#if (IS_IN (rtld) \
+ || (!defined SHARED && (IS_IN (libc) \
+ || IS_IN (libpthread))))
+# ifdef __ASSEMBLER__
+/* Note, dst, src, guard, and tmp are all register numbers rather than
+ register names so they will work with both ILP32 and LP64. */
+# define PTR_MANGLE(dst, src, guard, tmp) \
+ LDST_PCREL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local)); \
+ PTR_MANGLE2 (dst, src, guard)
+/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
+# define PTR_MANGLE2(dst, src, guard)\
+ eor x##dst, x##src, x##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
+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)
+# endif
+#else
+# ifdef __ASSEMBLER__
+/* Note, dst, src, guard, and tmp are all register numbers rather than
+ register names so they will work with both ILP32 and LP64. */
+# define PTR_MANGLE(dst, src, guard, tmp) \
+ LDST_GLOBAL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard)); \
+ PTR_MANGLE2 (dst, src, guard)
+/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
+# define PTR_MANGLE2(dst, src, guard)\
+ eor x##dst, x##src, x##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
+# 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/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index f1853e0..8ba50da 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -233,49 +233,4 @@
#endif /* __ASSEMBLER__ */
-/* Pointer mangling is supported for AArch64. */
-#if (IS_IN (rtld) \
- || (!defined SHARED && (IS_IN (libc) \
- || IS_IN (libpthread))))
-# ifdef __ASSEMBLER__
-/* Note, dst, src, guard, and tmp are all register numbers rather than
- register names so they will work with both ILP32 and LP64. */
-# define PTR_MANGLE(dst, src, guard, tmp) \
- LDST_PCREL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local)); \
- PTR_MANGLE2 (dst, src, guard)
-/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
-# define PTR_MANGLE2(dst, src, guard)\
- eor x##dst, x##src, x##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
-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)
-# endif
-#else
-# ifdef __ASSEMBLER__
-/* Note, dst, src, guard, and tmp are all register numbers rather than
- register names so they will work with both ILP32 and LP64. */
-# define PTR_MANGLE(dst, src, guard, tmp) \
- LDST_GLOBAL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard)); \
- PTR_MANGLE2 (dst, src, guard)
-/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
-# define PTR_MANGLE2(dst, src, guard)\
- eor x##dst, x##src, x##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
-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 /* linux/aarch64/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S b/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S
index 610f401..566a3b0 100644
--- a/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S
+++ b/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
diff --git a/sysdeps/unix/sysv/linux/alpha/pointer_guard.h b/sysdeps/unix/sysv/linux/alpha/pointer_guard.h
new file mode 100644
index 0000000..d4d513d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/pointer_guard.h
@@ -0,0 +1,62 @@
+/* Pointer guard implementation. Alpha version.
+ Copyright (C) 2006-2022 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
+
+/* Pointer mangling support. Note that tls access is slow enough that
+ we don't deoptimize things by placing the pointer check value there. */
+
+#ifdef __ASSEMBLER__
+# if IS_IN (rtld)
+# define PTR_MANGLE(dst, src, 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
+# elif defined SHARED
+# define PTR_MANGLE(dst, src, tmp) \
+ ldq tmp, __pointer_chk_guard; \
+ xor src, tmp, dst
+# else
+# define PTR_MANGLE(dst, src, tmp) \
+ ldq tmp, __pointer_chk_guard_local; \
+ xor src, tmp, dst
+# 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)
+#else
+# 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/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h
index 77ec2b5..0ddcb58 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h
@@ -313,44 +313,4 @@ __LABEL(name) \
})
#endif /* ASSEMBLER */
-/* Pointer mangling support. Note that tls access is slow enough that
- we don't deoptimize things by placing the pointer check value there. */
-
-#ifdef __ASSEMBLER__
-# if IS_IN (rtld)
-# define PTR_MANGLE(dst, src, 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
-# elif defined SHARED
-# define PTR_MANGLE(dst, src, tmp) \
- ldq tmp, __pointer_chk_guard; \
- xor src, tmp, dst
-# else
-# define PTR_MANGLE(dst, src, tmp) \
- ldq tmp, __pointer_chk_guard_local; \
- xor src, tmp, dst
-# 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)
-#else
-# 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 /* _LINUX_ALPHA_SYSDEP_H */
diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h b/sysdeps/unix/sysv/linux/arc/sysdep.h
index d0c1a78..512284a 100644
--- a/sysdeps/unix/sysv/linux/arc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arc/sysdep.h
@@ -215,10 +215,6 @@ hidden_proto (__syscall_error)
LOAD_ARGS_6 (nm, arg1, arg2, arg3, arg4, arg5, arg6) \
register long int _arg7 __asm__ ("r6") = _tmp7;
-/* Pointer mangling not yet supported. */
-# define PTR_MANGLE(var) (void) (var)
-# define PTR_DEMANGLE(var) (void) (var)
-
# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
diff --git a/sysdeps/unix/sysv/linux/csky/pointer_guard.h b/sysdeps/unix/sysv/linux/csky/pointer_guard.h
new file mode 100644
index 0000000..ed68322
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/pointer_guard.h
@@ -0,0 +1,68 @@
+/* Pointer obfuscation implenentation. C-SKY version.
+ Copyright (C) 2022 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
+
+#if (IS_IN (rtld) \
+ || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(dst, src, 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)
+# else
+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)
+# endif
+#else
+# ifdef __ASSEMBLER__
+# 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)
+# 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/csky/sysdep.h b/sysdeps/unix/sysv/linux/csky/sysdep.h
index 56c527f..76b09f0 100644
--- a/sysdeps/unix/sysv/linux/csky/sysdep.h
+++ b/sysdeps/unix/sysv/linux/csky/sysdep.h
@@ -466,50 +466,4 @@ __local_syscall_error: \
#endif /* __ASSEMBLER__ */
-/* Pointer mangling support. */
-#if (IS_IN (rtld) \
- || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread))))
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(dst, src, 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)
-# else
-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)
-# endif
-#else
-# ifdef __ASSEMBLER__
-# 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)
-# else
-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 /* linux/csky/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h
index 2f339a4..3aef8f5 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep.h
+++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h
@@ -470,8 +470,4 @@ L(pre_end): ASM_LINE_SEP \
#endif /* __ASSEMBLER__ */
-/* Pointer mangling is not yet supported for HPPA. */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
-
#endif /* _LINUX_HPPA_SYSDEP_H */
diff --git a/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S b/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
index a1cf9a4..f409542 100644
--- a/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
+++ b/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <jmp_buf-ssp.h>
#include <asm-syntax.h>
diff --git a/sysdeps/unix/sysv/linux/i386/pointer_guard.h b/sysdeps/unix/sysv/linux/i386/pointer_guard.h
new file mode 100644
index 0000000..a2d2a0c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/pointer_guard.h
@@ -0,0 +1,49 @@
+/* Pointer obfuscation implenentation. i386 version.
+ Copyright (C) 2005-2022 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 <tcb-offsets.h>
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. Using a global variable
+ is too complicated here since we have no PC-relative addressing mode. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg) xorl %gs:POINTER_GUARD, reg; \
+ roll $9, reg
+# define PTR_DEMANGLE(reg) rorl $9, reg; \
+ xorl %gs:POINTER_GUARD, reg
+# else
+# define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0\n" \
+ "roll $9, %0" \
+ : "=r" (var) \
+ : "0" (var), \
+ "i" (POINTER_GUARD))
+# define PTR_DEMANGLE(var) asm ("rorl $9, %0\n" \
+ "xorl %%gs:%c2, %0" \
+ : "=r" (var) \
+ : "0" (var), \
+ "i" (POINTER_GUARD))
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 7085f7e..b8be668 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -446,34 +446,6 @@ struct libc_do_syscall_args
#endif /* __ASSEMBLER__ */
-
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. Using a global variable
- is too complicated here since we have no PC-relative addressing mode. */
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(reg) xorl %gs:POINTER_GUARD, reg; \
- roll $9, reg
-# define PTR_DEMANGLE(reg) rorl $9, reg; \
- xorl %gs:POINTER_GUARD, reg
-# else
-# define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0\n" \
- "roll $9, %0" \
- : "=r" (var) \
- : "0" (var), \
- "i" (offsetof (tcbhead_t, \
- pointer_guard)))
-# define PTR_DEMANGLE(var) asm ("rorl $9, %0\n" \
- "xorl %%gs:%c2, %0" \
- : "=r" (var) \
- : "0" (var), \
- "i" (offsetof (tcbhead_t, \
- pointer_guard)))
-# endif
-#endif
-
/* Each shadow stack slot takes 4 bytes. Assuming that each stack
frame takes 128 bytes, this is used to compute shadow stack size
from stack size. */
diff --git a/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S b/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S
index 9511c15..4ef5129 100644
--- a/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S
+++ b/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S
@@ -15,6 +15,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <features.h>
LEAF(__ia64_flush_rbs)
diff --git a/sysdeps/unix/sysv/linux/ia64/__longjmp.S b/sysdeps/unix/sysv/linux/ia64/__longjmp.S
index 793dc98..da9653d 100644
--- a/sysdeps/unix/sysv/linux/ia64/__longjmp.S
+++ b/sysdeps/unix/sysv/linux/ia64/__longjmp.S
@@ -31,6 +31,7 @@
bits into ar.rnat after setting ar.bspstore. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <features.h>
# define pPos p6 /* is rotate count positive? */
diff --git a/sysdeps/unix/sysv/linux/ia64/pointer_guard.h b/sysdeps/unix/sysv/linux/ia64/pointer_guard.h
new file mode 100644
index 0000000..8631f39
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/pointer_guard.h
@@ -0,0 +1,44 @@
+/* Pointer obfuscation implenentation. ia64 version.
+ Copyright (C) 2005-2022 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
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg, tmpreg) \
+ add tmpreg=-16,r13 \
+ ;; \
+ ld8 tmpreg=[tmpreg] \
+ ;; \
+ xor reg=reg, tmpreg
+# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+# else
+# include <stdint.h>
+# include <tls.h>
+# define PTR_MANGLE(var) \
+ (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/ia64/setjmp.S b/sysdeps/unix/sysv/linux/ia64/setjmp.S
index c29a31f..a978dd4 100644
--- a/sysdeps/unix/sysv/linux/ia64/setjmp.S
+++ b/sysdeps/unix/sysv/linux/ia64/setjmp.S
@@ -63,6 +63,7 @@
0x1c0 f31 */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <features.h>
/* The following two entry points are the traditional entry points: */
diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.h b/sysdeps/unix/sysv/linux/ia64/sysdep.h
index 14adbdf..b450c6c 100644
--- a/sysdeps/unix/sysv/linux/ia64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/ia64/sysdep.h
@@ -324,24 +324,4 @@
#endif /* not __ASSEMBLER__ */
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(reg, tmpreg) \
- add tmpreg=-16,r13 \
- ;; \
- ld8 tmpreg=[tmpreg] \
- ;; \
- xor reg=reg, tmpreg
-# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
-# else
-# define PTR_MANGLE(var) \
- (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
#endif /* linux/ia64/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
new file mode 100644
index 0000000..4b2ed46
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
@@ -0,0 +1,82 @@
+/* Pointer obfuscation implenentation. LoongArch version.
+ Copyright (C) 2022 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
+
+/* Load a got-relative EXPR into G, using T.
+ Note G and T are register names. */
+#define LD_GLOBAL(G, EXPR) \
+ la.global G, EXPR; \
+ REG_L G, G, 0;
+
+/* Load a pc-relative EXPR into G, using T.
+ Note G and T are register names. */
+#define LD_PCREL(G, EXPR) \
+ la.pcrel G, EXPR; \
+ REG_L G, G, 0;
+
+#if (IS_IN (rtld) \
+ || (!defined SHARED && (IS_IN (libc) \
+ || IS_IN (libpthread))))
+
+#ifdef __ASSEMBLER__
+#define PTR_MANGLE(dst, src, guard) \
+ LD_PCREL (guard, __pointer_chk_guard_local); \
+ PTR_MANGLE2 (dst, src, guard);
+#define PTR_DEMANGLE(dst, src, guard) \
+ LD_PCREL (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);
+#else
+# include <stdint.h>
+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)
+#endif
+
+#else
+
+#ifdef __ASSEMBLER__
+#define PTR_MANGLE(dst, src, guard) \
+ LD_GLOBAL (guard, __pointer_chk_guard); \
+ PTR_MANGLE2 (dst, src, guard);
+#define PTR_DEMANGLE(dst, src, guard) \
+ LD_GLOBAL (guard, __pointer_chk_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);
+#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/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
index f4a1d23..09f8243 100644
--- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h
+++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
@@ -314,64 +314,4 @@ extern long int __syscall_error (long int neg_errno);
#endif /* ! __ASSEMBLER__ */
-/* Pointer mangling is supported for LoongArch. */
-
-/* Load a got-relative EXPR into G, using T.
- Note G and T are register names. */
-#define LD_GLOBAL(G, EXPR) \
- la.global G, EXPR; \
- REG_L G, G, 0;
-
-/* Load a pc-relative EXPR into G, using T.
- Note G and T are register names. */
-#define LD_PCREL(G, EXPR) \
- la.pcrel G, EXPR; \
- REG_L G, G, 0;
-
-#if (IS_IN (rtld) \
- || (!defined SHARED && (IS_IN (libc) \
- || IS_IN (libpthread))))
-
-#ifdef __ASSEMBLER__
-#define PTR_MANGLE(dst, src, guard) \
- LD_PCREL (guard, __pointer_chk_guard_local); \
- PTR_MANGLE2 (dst, src, guard);
-#define PTR_DEMANGLE(dst, src, guard) \
- LD_PCREL (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);
-#else
-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)
-#endif
-
-#else
-
-#ifdef __ASSEMBLER__
-#define PTR_MANGLE(dst, src, guard) \
- LD_GLOBAL (guard, __pointer_chk_guard); \
- PTR_MANGLE2 (dst, src, guard);
-#define PTR_DEMANGLE(dst, src, guard) \
- LD_GLOBAL (guard, __pointer_chk_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);
-#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 /* linux/loongarch/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h
index d87892a..0642403 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h
@@ -295,10 +295,6 @@ SYSCALL_ERROR_LABEL: \
#endif /* not __ASSEMBLER__ */
-/* Pointer mangling is not yet supported for M68K. */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
-
/* M68K needs system-supplied DSO to access TLS helpers
even when statically linked. */
#define NEED_STATIC_SYSINFO_DSO 1
diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
index fda78f6..19805f6 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
@@ -304,10 +304,6 @@ SYSCALL_ERROR_LABEL_DCL: \
})
-/* Pointer mangling is not yet supported for Microblaze. */
-# define PTR_MANGLE(var) (void) (var)
-# define PTR_DEMANGLE(var) (void) (var)
-
#undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index a2a93bc..0ef410c 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -337,8 +337,4 @@ libc_hidden_proto (__mips_syscall7, nomips16)
#endif /* __ASSEMBLER__ */
-/* Pointer mangling is not yet supported for MIPS. */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
-
#endif /* linux/mips/mips32/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
index 2c16a67..e362f15 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
@@ -300,8 +300,4 @@ typedef long int __syscall_arg_t;
#endif /* __ASSEMBLER__ */
-/* Pointer mangling is not yet supported for MIPS. */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
-
#endif /* linux/mips/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/nios2/pointer_guard.h b/sysdeps/unix/sysv/linux/nios2/pointer_guard.h
new file mode 100644
index 0000000..da17809
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/pointer_guard.h
@@ -0,0 +1,40 @@
+/* Pointer obfuscation implenentation. Nios II version.
+ Copyright (C) 2015-2022 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
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE_GUARD(guard) ldw guard, POINTER_GUARD(r23)
+# define PTR_MANGLE(dst, src, guard) xor dst, src, guard
+# define PTR_DEMANGLE(dst, src, guard) PTR_MANGLE (dst, src, guard)
+# else
+# include <stdint.h>
+# include <tls.h>
+# define PTR_MANGLE(var) \
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
index 5fe960c..46667b9 100644
--- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
@@ -220,21 +220,4 @@
#endif /* __ASSEMBLER__ */
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE_GUARD(guard) ldw guard, POINTER_GUARD(r23)
-# define PTR_MANGLE(dst, src, guard) xor dst, src, guard
-# define PTR_DEMANGLE(dst, src, guard) PTR_MANGLE (dst, src, guard)
-# else
-# define PTR_MANGLE(var) \
- (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
-
#endif /* linux/nios2/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/or1k/sysdep.h b/sysdeps/unix/sysv/linux/or1k/sysdep.h
index 941c934..b1fdf2a 100644
--- a/sysdeps/unix/sysv/linux/or1k/sysdep.h
+++ b/sysdeps/unix/sysv/linux/or1k/sysdep.h
@@ -119,10 +119,6 @@ L(pseudo_end): \
extern long int __syscall_error (long int neg_errno);
-/* Pointer mangling is not yet supported for or1k. */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
-
#undef INTERNAL_SYSCALL
#define INTERNAL_SYSCALL(name, nr, args...) \
INTERNAL_SYSCALL_NCS (SYS_ify (name), nr, args)
diff --git a/sysdeps/unix/sysv/linux/powerpc/pointer_guard.h b/sysdeps/unix/sysv/linux/powerpc/pointer_guard.h
new file mode 100644
index 0000000..5961793
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/pointer_guard.h
@@ -0,0 +1,55 @@
+/* Pointer obfuscation implenentation. PowerpC version.
+ Copyright (C) 2005-2022 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
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+# ifdef __ASSEMBLER__
+# if defined(__PPC64__) || defined(__powerpc64__)
+# define LOAD ld
+# define TPREG r13
+# else
+# define LOAD lwz
+# define TPREG r2
+# endif
+# define PTR_MANGLE(reg, tmpreg) \
+ LOAD tmpreg,POINTER_GUARD(TPREG); \
+ xor reg,tmpreg,reg
+# define PTR_MANGLE2(reg, tmpreg) \
+ xor reg,tmpreg,reg
+# define PTR_MANGLE3(destreg, reg, tmpreg) \
+ LOAD tmpreg,POINTER_GUARD(TPREG); \
+ 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)
+# else
+# include <stdint.h>
+# include <tls.h>
+# define PTR_MANGLE(var) \
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 4fb135a..9e44818 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -207,38 +207,6 @@
#define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
#define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
-
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-#else
-# ifdef __ASSEMBLER__
-# if defined(__PPC64__) || defined(__powerpc64__)
-# define LOAD ld
-# define TPREG r13
-# else
-# define LOAD lwz
-# define TPREG r2
-# endif
-# define PTR_MANGLE(reg, tmpreg) \
- LOAD tmpreg,POINTER_GUARD(TPREG); \
- xor reg,tmpreg,reg
-# define PTR_MANGLE2(reg, tmpreg) \
- xor reg,tmpreg,reg
-# define PTR_MANGLE3(destreg, reg, tmpreg) \
- LOAD tmpreg,POINTER_GUARD(TPREG); \
- 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)
-# else
-# define PTR_MANGLE(var) \
- (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
/* List of system calls which are supported as vsyscalls. */
#define VDSO_NAME "LINUX_2.6.15"
#define VDSO_HASH 123718565
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 9b03b10..c9af888 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -357,8 +357,4 @@ extern long int __syscall_error (long int neg_errno);
#endif /* ! __ASSEMBLER__ */
-/* Pointer mangling is not supported. */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
-
#endif /* linux/riscv/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/pointer_guard.h b/sysdeps/unix/sysv/linux/s390/s390-32/pointer_guard.h
new file mode 100644
index 0000000..0e85d4c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/pointer_guard.h
@@ -0,0 +1,45 @@
+/* Pointer obfuscation implenentation. s390 version.
+ Copyright (C) 2005-2022 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
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+/* For the time being just use stack_guard rather than a separate
+ pointer_guard. */
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg, tmpreg) \
+ ear tmpreg,%a0; \
+ x reg,STACK_GUARD(tmpreg)
+# define PTR_MANGLE2(reg, tmpreg) \
+ x reg,STACK_GUARD(tmpreg)
+# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+# else
+# include <stdint.h>
+# include <tls.h>
+# define PTR_MANGLE(var) \
+ (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index e41106b..a24fde7 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -177,25 +177,4 @@
#endif /* __ASSEMBLER__ */
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-#else
-/* For the time being just use stack_guard rather than a separate
- pointer_guard. */
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(reg, tmpreg) \
- ear tmpreg,%a0; \
- x reg,STACK_GUARD(tmpreg)
-# define PTR_MANGLE2(reg, tmpreg) \
- x reg,STACK_GUARD(tmpreg)
-# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
-# else
-# define PTR_MANGLE(var) \
- (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
#endif /* _LINUX_S390_SYSDEP_H */
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/pointer_guard.h b/sysdeps/unix/sysv/linux/s390/s390-64/pointer_guard.h
new file mode 100644
index 0000000..5285456
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/pointer_guard.h
@@ -0,0 +1,47 @@
+/* Pointer obfuscation implenentation. s390x version.
+ Copyright (C) 2005-2022 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
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+/* For the time being just use stack_guard rather than a separate
+ pointer_guard. */
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg, tmpreg) \
+ ear tmpreg,%a0; \
+ sllg tmpreg,tmpreg,32; \
+ ear tmpreg,%a1; \
+ xg reg,STACK_GUARD(tmpreg)
+# define PTR_MANGLE2(reg, tmpreg) \
+ xg reg,STACK_GUARD(tmpreg)
+# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+# else
+# include <stdint.h>
+# include <tls.h>
+# define PTR_MANGLE(var) \
+ (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index 150e339..79bc0fa 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -175,27 +175,4 @@
#endif /* __ASSEMBLER__ */
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-#else
-/* For the time being just use stack_guard rather than a separate
- pointer_guard. */
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(reg, tmpreg) \
- ear tmpreg,%a0; \
- sllg tmpreg,tmpreg,32; \
- ear tmpreg,%a1; \
- xg reg,STACK_GUARD(tmpreg)
-# define PTR_MANGLE2(reg, tmpreg) \
- xg reg,STACK_GUARD(tmpreg)
-# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
-# else
-# define PTR_MANGLE(var) \
- (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
#endif /* _LINUX_S390_SYSDEP_H */
diff --git a/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S b/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
index e821e15..cf69926 100644
--- a/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
+++ b/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <sigaltstack-offsets.h>
diff --git a/sysdeps/unix/sysv/linux/sh/pointer_guard.h b/sysdeps/unix/sysv/linux/sh/pointer_guard.h
new file mode 100644
index 0000000..32a571d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sh/pointer_guard.h
@@ -0,0 +1,43 @@
+/* Pointer obfuscation implenentation. Generic (no-op) version.
+ Copyright (C) 2005-2022 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
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. Using a global variable
+ is too complicated here since we have no PC-relative addressing mode. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg, tmp) \
+ stc gbr,tmp; mov.l @(POINTER_GUARD,tmp),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)
+# else
+# include <stdint.h>
+# include <tls.h>
+# define PTR_MANGLE(var) \
+ (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h
index e9e13cd..a2f43f6 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep.h
@@ -315,23 +315,4 @@
#endif /* __ASSEMBLER__ */
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. Using a global variable
- is too complicated here since we have no PC-relative addressing mode. */
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(reg, tmp) \
- stc gbr,tmp; mov.l @(POINTER_GUARD,tmp),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)
-# else
-# define PTR_MANGLE(var) \
- (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
#endif /* linux/sh/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S b/sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S
index 8e8cb4d..ad23840b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#define ENV(base,reg) [%base + (reg * 4)]
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h b/sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h
new file mode 100644
index 0000000..4063513
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/pointer_guard.h
@@ -0,0 +1,44 @@
+/* Pointer obfuscation implenentation. 32-bit SPARC version.
+ Copyright (C) 2006-2022 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
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(dreg, reg, tmpreg) \
+ ld [%g7 + POINTER_GUARD], 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)
+# else
+# include <stdint.h>
+# include <tls.h>
+# define PTR_MANGLE(var) \
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
index 032608a..1783af8 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
@@ -125,24 +125,4 @@ ENTRY(name); \
#endif /* __ASSEMBLER__ */
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(dreg, reg, tmpreg) \
- ld [%g7 + POINTER_GUARD], 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)
-# else
-# define PTR_MANGLE(var) \
- (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
#endif /* linux/sparc/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h b/sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h
new file mode 100644
index 0000000..7865e87c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/pointer_guard.h
@@ -0,0 +1,44 @@
+/* Pointer obfuscation implenentation. 64-bit SPARC version.
+ Copyright (C) 2006-2022 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
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# include <sysdeps/generic/pointer_guard.h>
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(dreg, reg, tmpreg) \
+ ldx [%g7 + POINTER_GUARD], 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)
+# else
+# include <stdint.h>
+# include <tls.h>
+# define PTR_MANGLE(var) \
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
index 4aaa291..4ae22ae 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
@@ -127,24 +127,4 @@ ENTRY(name); \
register windows. So if you poke stack memory directly you add this. */
#define STACK_BIAS 2047
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(dreg, reg, tmpreg) \
- ldx [%g7 + POINTER_GUARD], 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)
-# else
-# define PTR_MANGLE(var) \
- (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
#endif /* linux/sparc64/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
index ffdf462..5ff275c 100644
--- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
+++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <asm-syntax.h>
#include <stap-probe.h>
diff --git a/sysdeps/unix/sysv/linux/x86_64/pointer_guard.h b/sysdeps/unix/sysv/linux/x86_64/pointer_guard.h
new file mode 100644
index 0000000..2df3912
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/pointer_guard.h
@@ -0,0 +1,61 @@
+/* Pointer obfuscation implenentation. x86-64 version.
+ Copyright (C) 2005-2022 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 <x86-lp_size.h>
+#include <tcb-offsets.h>
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg) xor __pointer_chk_guard_local(%rip), reg; \
+ rol $2*LP_SIZE+1, reg
+# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
+ xor __pointer_chk_guard_local(%rip), reg
+# else
+# define PTR_MANGLE(reg) asm ("xor __pointer_chk_guard_local(%%rip), %0\n" \
+ "rol $2*" LP_SIZE "+1, %0" \
+ : "=r" (reg) : "0" (reg))
+# define PTR_DEMANGLE(reg) asm ("ror $2*" LP_SIZE "+1, %0\n" \
+ "xor __pointer_chk_guard_local(%%rip), %0" \
+ : "=r" (reg) : "0" (reg))
+# endif
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg) xor %fs:POINTER_GUARD, reg; \
+ rol $2*LP_SIZE+1, reg
+# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
+ xor %fs:POINTER_GUARD, reg
+# else
+# define PTR_MANGLE(var) asm ("xor %%fs:%c2, %0\n" \
+ "rol $2*" LP_SIZE "+1, %0" \
+ : "=r" (var) \
+ : "0" (var), \
+ "i" (POINTER_GUARD))
+# define PTR_DEMANGLE(var) asm ("ror $2*" LP_SIZE "+1, %0\n" \
+ "xor %%fs:%c2, %0" \
+ : "=r" (var) \
+ : "0" (var), \
+ "i" (POINTER_GUARD))
+# endif
+#endif
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 740abef..5e4d782 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -381,46 +381,6 @@
#endif /* __ASSEMBLER__ */
-
-/* Pointer mangling support. */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(reg) xor __pointer_chk_guard_local(%rip), reg; \
- rol $2*LP_SIZE+1, reg
-# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
- xor __pointer_chk_guard_local(%rip), reg
-# else
-# define PTR_MANGLE(reg) asm ("xor __pointer_chk_guard_local(%%rip), %0\n" \
- "rol $2*" LP_SIZE "+1, %0" \
- : "=r" (reg) : "0" (reg))
-# define PTR_DEMANGLE(reg) asm ("ror $2*" LP_SIZE "+1, %0\n" \
- "xor __pointer_chk_guard_local(%%rip), %0" \
- : "=r" (reg) : "0" (reg))
-# endif
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(reg) xor %fs:POINTER_GUARD, reg; \
- rol $2*LP_SIZE+1, reg
-# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
- xor %fs:POINTER_GUARD, reg
-# else
-# define PTR_MANGLE(var) asm ("xor %%fs:%c2, %0\n" \
- "rol $2*" LP_SIZE "+1, %0" \
- : "=r" (var) \
- : "0" (var), \
- "i" (offsetof (tcbhead_t, \
- pointer_guard)))
-# define PTR_DEMANGLE(var) asm ("ror $2*" LP_SIZE "+1, %0\n" \
- "xor %%fs:%c2, %0" \
- : "=r" (var) \
- : "0" (var), \
- "i" (offsetof (tcbhead_t, \
- pointer_guard)))
-# endif
-#endif
-
/* How to pass the off{64}_t argument on p{readv,writev}{64}. */
#undef LO_HI_LONG
#define LO_HI_LONG(val) (val), 0
diff --git a/sysdeps/x86_64/__longjmp.S b/sysdeps/x86_64/__longjmp.S
index b51d791..6fdb4cc 100644
--- a/sysdeps/x86_64/__longjmp.S
+++ b/sysdeps/x86_64/__longjmp.S
@@ -16,6 +16,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <jmp_buf-ssp.h>
#include <asm-syntax.h>
diff --git a/sysdeps/x86_64/jmpbuf-unwind.h b/sysdeps/x86_64/jmpbuf-unwind.h
index 42ea375..c92b263 100644
--- a/sysdeps/x86_64/jmpbuf-unwind.h
+++ b/sysdeps/x86_64/jmpbuf-unwind.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <unwind.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
diff --git a/sysdeps/x86_64/setjmp.S b/sysdeps/x86_64/setjmp.S
index 1b77dcd..3897e66 100644
--- a/sysdeps/x86_64/setjmp.S
+++ b/sysdeps/x86_64/setjmp.S
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <jmp_buf-ssp.h>
#include <asm-syntax.h>