#include <jmpbuf-unwind.h>
#include <assert.h>
#include <stdint.h>
-
+#include <pointer_guard.h>
/* _hurd_setup_sighandler puts a link on the `active resources' chain so that
_longjmp_unwind will call this function with the `struct sigcontext *'
#include <sys/param.h>
#include <gconv_int.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
int
#include <gconv_int.h>
#include <iconvconfig.h>
#include <not-cancel.h>
+#include <pointer_guard.h>
#include "../intl/hash-string.h"
#include <dlfcn.h>
#include <gconv_int.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
/* Simple data structure for alias mapping. We have two names, `from'
#include <sys/param.h>
#include <gconv_int.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#ifdef DEBUG
#include <libc-lock.h>
#include "gconv_int.h"
#include "../locale/localeinfo.h"
+#include <pointer_guard.h>
int
# include <dlfcn.h>
#endif
-#include <sysdep.h>
+#include <pointer_guard.h>
#include <stdint.h>
#ifndef DL_CALL_FCT
#include <inet/net-internal.h>
#include <netdb.h>
#include <stdbool.h>
+#include <pointer_guard.h>
/* Use the soname and version to locate libidn2, to ensure a
compatible ABI. */
#include <stdio.h>
#include <stdlib.h>
#include <shlib-compat.h>
+#include <pointer_guard.h>
static ssize_t
_IO_cookie_read (FILE *fp, void *buf, ssize_t size)
#include <wcsmbs/wcsmbsload.h>
#include <iconv/gconv_int.h>
#include <shlib-compat.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
/* Return orientation of stream. If mode is nonzero try to change
#include "iolibio.h"
#include <shlib-compat.h>
+#include <pointer_guard.h>
/* For historical reasons this is the name of the sysdeps header that
adjusts the libio configuration. */
#include <libioP.h>
#include <stdio.h>
#include <ldsodefs.h>
+#include <pointer_guard.h>
#ifdef SHARED
#include <gnu/lib-names.h>
#include <unwind-link.h>
#include <libc-lock.h>
+#include <pointer_guard.h>
/* Statically allocate the object, so that we do not have to deal with
malloc failure. __libc_unwind_link_get must not fail if libgcc_s
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
/* Suffix after .so of NSS service modules. This is a bit of magic,
but we assume LIBNSS_FILES_SO looks like "libnss_files.so.2" and we
#include <libc-lock.h>
#include "exit.h"
-#include <sysdep.h>
+#include <pointer_guard.h>
#undef __cxa_atexit
#include <stdlib.h>
#include "exit.h"
#include <register-atfork.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#include <stdint.h>
/* If D is non-NULL, call all functions registered with `__cxa_atexit'
#include <stdio.h>
#include <stdlib.h>
#include <ldsodefs.h>
+#include <pointer_guard.h>
typedef void (*dtor_func) (void *);
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#include <libc-lock.h>
#include "exit.h"
#include <assert.h>
#include <stdlib.h>
#include "exit.h"
-#include <sysdep.h>
+#include <pointer_guard.h>
/* Register a function to be called by exit. */
int
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <stap-probe.h>
#include <setjmp.h>
#include <stdint.h>
#include <sysdep.h>
+#include <pointer_guard.h>
static inline uintptr_t __attribute__ ((unused))
_jmpbuf_sp (__jmp_buf jmpbuf)
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <stap-probe.h>
#define __ASSEMBLY__
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#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. */
#define __ASSEMBLY__
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
.ent __sigsetjmp
#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. */
<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>
#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
--- /dev/null
+/* 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 */
<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>
#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
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
ENTRY (__longjmp)
mov a2, a0
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
ENTRY (setjmp)
movi a1, 1
#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. */
--- /dev/null
+/* 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 */
#endif
#ifdef SHARED
-# include <sysdep.h>
+# include <pointer_guard.h>
# include <unwind-resume.h>
# if UNWIND_LINK_FRAME_STATE_FOR
<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>
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>
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>
#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. */
<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>
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <sys/asm.h>
ENTRY (__longjmp)
#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. */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <sys/asm.h>
ENTRY (_setjmp)
#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. */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <tcb-offsets.h>
#include <asm-syntax.h>
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <tcb-offsets.h>
#include <asm-syntax.h>
#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"
#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. */
#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. */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
/* __longjmp(jmpbuf, val) */
#include <setjmp.h>
#include <stdint.h>
#include <sysdep.h>
+#include <pointer_guard.h>
static inline uintptr_t __attribute__ ((unused))
_jmpbuf_sp (__jmp_buf jmpbuf)
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
.text
#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. */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#define _SETJMP_H
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <stap-probe.h>
#define _ASM
#ifdef __NO_VMX__
#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. */
#include <unwind.h>
#include <bits/wordsize.h>
#include <sysdep.h>
+#include <pointer_guard.h>
/* Test if longjmp to JMPBUF would unwind the frame
#include <errno.h>
#include <sysdep.h>
+#include <pointer_guard.h>
#include <setjmp.h>
#include <bits/setjmp.h>
#include <stdlib.h>
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#define _ASM
#define _SETJMP_H
#include <bits/setjmp.h>
#include <errno.h>
#include <sysdep.h>
+#include <pointer_guard.h>
#include <setjmp.h>
#include <bits/setjmp.h>
#include <stdlib.h>
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#define _ASM
#define _SETJMP_H
#include <bits/setjmp.h>
#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. */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#define _SETJMP_H
#define _ASM
#include <bits/setjmp.h>
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
ENTRY (__sigsetjmp)
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#define _SETJMP_H
#define _ASM
#include <bits/setjmp.h>
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
ENTRY (__sigsetjmp)
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#define ENV(base,reg) [%base + (reg * 4)]
#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. */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <sys/trap.h>
#include <jmpbuf-offsets.h>
--- /dev/null
+/* 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 */
#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 */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
--- /dev/null
+/* 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 */
})
#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 */
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
--- /dev/null
+/* 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 */
#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 */
#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 */
<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>
--- /dev/null
+/* 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 */
#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. */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <features.h>
LEAF(__ia64_flush_rbs)
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? */
--- /dev/null
+/* 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 */
0x1c0 f31 */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <features.h>
/* The following two entry points are the traditional entry points: */
#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 */
--- /dev/null
+/* 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 */
#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 */
#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
})
-/* 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
#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 */
#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 */
--- /dev/null
+/* 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 */
#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 */
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)
--- /dev/null
+/* 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 */
#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
#endif /* ! __ASSEMBLER__ */
-/* Pointer mangling is not supported. */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
-
#endif /* linux/riscv/sysdep.h */
--- /dev/null
+/* 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 */
#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 */
--- /dev/null
+/* 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 */
#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 */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <sigaltstack-offsets.h>
--- /dev/null
+/* 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 */
#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 */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#define ENV(base,reg) [%base + (reg * 4)]
--- /dev/null
+/* 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 */
#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 */
--- /dev/null
+/* 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 */
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 */
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
+#include <pointer_guard.h>
#include <jmpbuf-offsets.h>
#include <asm-syntax.h>
#include <stap-probe.h>
--- /dev/null
+/* 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 */
#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
<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>
#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. */
<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>
#include <wcsmbsload.h>
#include <limits.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
wint_t
#include <uchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#ifndef EILSEQ
# define EILSEQ EINVAL
#include <uchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
-
#ifndef EILSEQ
# define EILSEQ EINVAL
#endif
#include <wchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#ifndef EILSEQ
# define EILSEQ EINVAL
#include <wchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#ifndef EILSEQ
# define EILSEQ EINVAL
#include <wchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#ifndef EILSEQ
# define EILSEQ EINVAL
#include <wchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#ifndef EILSEQ
# define EILSEQ EINVAL
#include <wchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#ifndef EILSEQ
# define EILSEQ EINVAL
#include <wchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
#ifndef EILSEQ
# define EILSEQ EINVAL
#include <wchar.h>
#include <wcsmbsload.h>
-#include <sysdep.h>
+#include <pointer_guard.h>
int