|
|
5de29b |
commit 9188b6818a3d1a6e6d89bf10fa4aea27a591494c
|
|
|
5de29b |
Author: Venkataramanan Kumar <venkataramanan.kumar@linaro.org>
|
|
|
5de29b |
Date: Wed Jan 1 17:47:14 2014 +0000
|
|
|
5de29b |
|
|
|
5de29b |
[AArch64] Pointer mangling support for AArch64.
|
|
|
5de29b |
|
|
|
12745e |
diff --git glibc-2.17-c758a686/ports/sysdeps/aarch64/__longjmp.S glibc-2.17-c758a686/ports/sysdeps/aarch64/__longjmp.S
|
|
|
5de29b |
index 250f2af..2d38bbf 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/__longjmp.S
|
|
|
12745e |
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/__longjmp.S
|
|
|
5de29b |
@@ -50,8 +50,12 @@ ENTRY (__longjmp)
|
|
|
5de29b |
ldp x23, x24, [x0, #JB_X23<<3]
|
|
|
5de29b |
ldp x25, x26, [x0, #JB_X25<<3]
|
|
|
5de29b |
ldp x27, x28, [x0, #JB_X27<<3]
|
|
|
5de29b |
+#ifdef PTR_DEMANGLE
|
|
|
5de29b |
+ ldp x29, x4, [x0, #JB_X29<<3]
|
|
|
5de29b |
+ PTR_DEMANGLE (x30, x4, x3, x2)
|
|
|
5de29b |
+#else
|
|
|
5de29b |
ldp x29, x30, [x0, #JB_X29<<3]
|
|
|
5de29b |
-
|
|
|
5de29b |
+#endif
|
|
|
5de29b |
ldp d8, d9, [x0, #JB_D8<<3]
|
|
|
5de29b |
ldp d10, d11, [x0, #JB_D10<<3]
|
|
|
5de29b |
ldp d12, d13, [x0, #JB_D12<<3]
|
|
|
5de29b |
@@ -87,8 +91,12 @@ ENTRY (__longjmp)
|
|
|
5de29b |
cfi_same_value(d13)
|
|
|
5de29b |
cfi_same_value(d14)
|
|
|
5de29b |
cfi_same_value(d15)
|
|
|
5de29b |
-
|
|
|
5de29b |
- ldr x5, [x0, #JB_SP<<3]
|
|
|
5de29b |
+#ifdef PTR_DEMANGLE
|
|
|
5de29b |
+ ldr x4, [x0, #JB_SP<<3]
|
|
|
5de29b |
+ PTR_DEMANGLE (x5, x4, x3, x2)
|
|
|
5de29b |
+#else
|
|
|
5de29b |
+ ldr x5, [x0, #JB_SP<<3]
|
|
|
5de29b |
+#endif
|
|
|
5de29b |
mov sp, x5
|
|
|
5de29b |
cmp x1, #0
|
|
|
5de29b |
mov x0, #1
|
|
|
12745e |
diff --git glibc-2.17-c758a686/ports/sysdeps/aarch64/jmpbuf-offsets.h glibc-2.17-c758a686/ports/sysdeps/aarch64/jmpbuf-offsets.h
|
|
|
5de29b |
index 84c2ccc..bcf2afa 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/jmpbuf-offsets.h
|
|
|
12745e |
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/jmpbuf-offsets.h
|
|
|
5de29b |
@@ -39,6 +39,22 @@
|
|
|
5de29b |
#define JB_D14 20
|
|
|
5de29b |
#define JB_D15 21
|
|
|
5de29b |
|
|
|
5de29b |
+#ifndef __ASSEMBLER__
|
|
|
5de29b |
+#include <setjmp.h>
|
|
|
5de29b |
+#include <stdint.h>
|
|
|
5de29b |
+#include <sysdep.h>
|
|
|
5de29b |
+
|
|
|
5de29b |
+static inline uintptr_t __attribute__ ((unused))
|
|
|
5de29b |
+_jmpbuf_sp (__jmp_buf jmpbuf)
|
|
|
5de29b |
+{
|
|
|
5de29b |
+ uintptr_t sp = jmpbuf[JB_SP];
|
|
|
5de29b |
+#ifdef PTR_DEMANGLE
|
|
|
5de29b |
+ PTR_DEMANGLE (sp);
|
|
|
5de29b |
+#endif
|
|
|
5de29b |
+ return sp;
|
|
|
5de29b |
+}
|
|
|
5de29b |
+#endif
|
|
|
5de29b |
+
|
|
|
5de29b |
/* Helper for generic ____longjmp_chk(). */
|
|
|
5de29b |
#define JB_FRAME_ADDRESS(buf) \
|
|
|
5de29b |
- ((void *) (buf[JB_SP]))
|
|
|
5de29b |
+ ((void *) _jmpbuf_sp (buf))
|
|
|
12745e |
diff --git glibc-2.17-c758a686/ports/sysdeps/aarch64/jmpbuf-unwind.h glibc-2.17-c758a686/ports/sysdeps/aarch64/jmpbuf-unwind.h
|
|
|
5de29b |
index 22c6c2b..39a5dc2 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/jmpbuf-unwind.h
|
|
|
12745e |
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/jmpbuf-unwind.h
|
|
|
5de29b |
@@ -29,16 +29,6 @@
|
|
|
5de29b |
#define _JMPBUF_CFA_UNWINDS_ADJ(jmpbuf, context, adj) \
|
|
|
5de29b |
_JMPBUF_UNWINDS_ADJ (jmpbuf, (void *) _Unwind_GetCFA (context), adj)
|
|
|
5de29b |
|
|
|
5de29b |
-static inline uintptr_t __attribute__ ((unused))
|
|
|
5de29b |
-_jmpbuf_sp (__jmp_buf jmpbuf)
|
|
|
5de29b |
-{
|
|
|
5de29b |
- uintptr_t sp = jmpbuf[JB_SP];
|
|
|
5de29b |
-#ifdef PTR_DEMANGLE
|
|
|
5de29b |
- PTR_DEMANGLE (sp);
|
|
|
5de29b |
-#endif
|
|
|
5de29b |
- return sp;
|
|
|
5de29b |
-}
|
|
|
5de29b |
-
|
|
|
5de29b |
#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
|
|
|
5de29b |
((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
|
|
|
5de29b |
|
|
|
12745e |
diff --git glibc-2.17-c758a686/ports/sysdeps/aarch64/setjmp.S glibc-2.17-c758a686/ports/sysdeps/aarch64/setjmp.S
|
|
|
5de29b |
index cb94e01..5822abd 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/setjmp.S
|
|
|
12745e |
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/setjmp.S
|
|
|
5de29b |
@@ -39,13 +39,25 @@ ENTRY (__sigsetjmp)
|
|
|
5de29b |
stp x23, x24, [x0, #JB_X23<<3]
|
|
|
5de29b |
stp x25, x26, [x0, #JB_X25<<3]
|
|
|
5de29b |
stp x27, x28, [x0, #JB_X27<<3]
|
|
|
5de29b |
+
|
|
|
5de29b |
+#ifdef PTR_MANGLE
|
|
|
5de29b |
+ PTR_MANGLE (x4, x30, x3, x2)
|
|
|
5de29b |
+ stp x29, x4, [x0, #JB_X29<<3]
|
|
|
5de29b |
+#else
|
|
|
5de29b |
stp x29, x30, [x0, #JB_X29<<3]
|
|
|
5de29b |
+#endif
|
|
|
5de29b |
stp d8, d9, [x0, #JB_D8<<3]
|
|
|
5de29b |
stp d10, d11, [x0, #JB_D10<<3]
|
|
|
5de29b |
stp d12, d13, [x0, #JB_D12<<3]
|
|
|
5de29b |
stp d14, d15, [x0, #JB_D14<<3]
|
|
|
5de29b |
+#ifdef PTR_MANGLE
|
|
|
5de29b |
+ mov x4, sp
|
|
|
5de29b |
+ PTR_MANGLE (x5, x4, x3, x2)
|
|
|
5de29b |
+ str x5, [x0, #JB_SP<<3]
|
|
|
5de29b |
+#else
|
|
|
5de29b |
mov x2, sp
|
|
|
5de29b |
str x2, [x0, #JB_SP<<3]
|
|
|
5de29b |
+#endif
|
|
|
5de29b |
#if defined NOT_IN_libc && defined IS_IN_rtld
|
|
|
5de29b |
/* In ld.so we never save the signal mask */
|
|
|
5de29b |
mov w0, #0
|
|
|
12745e |
diff --git glibc-2.17-c758a686/ports/sysdeps/aarch64/sysdep.h glibc-2.17-c758a686/ports/sysdeps/aarch64/sysdep.h
|
|
|
5de29b |
index 0dd597a..7169ba7 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/sysdep.h
|
|
|
12745e |
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/sysdep.h
|
|
|
5de29b |
@@ -78,6 +78,17 @@
|
|
|
5de29b |
# define L(name) .L##name
|
|
|
5de29b |
#endif
|
|
|
5de29b |
|
|
|
5de29b |
+/* Load or store to/from a pc-relative EXPR into/from R, using T. */
|
|
|
5de29b |
+#define LDST_PCREL(OP, R, T, EXPR) \
|
|
|
5de29b |
+ adrp T, EXPR; \
|
|
|
5de29b |
+ OP R, [T, #:lo12:EXPR];\
|
|
|
5de29b |
+
|
|
|
5de29b |
+/* Load or store to/from a got-relative EXPR into/from R, using T. */
|
|
|
5de29b |
+#define LDST_GLOBAL(OP, R, T, EXPR) \
|
|
|
5de29b |
+ adrp T, :got:EXPR; \
|
|
|
5de29b |
+ ldr T, [T, #:got_lo12:EXPR];\
|
|
|
5de29b |
+ OP R, [T];
|
|
|
5de29b |
+
|
|
|
5de29b |
/* Since C identifiers are not normally prefixed with an underscore
|
|
|
5de29b |
on this system, the asm identifier `syscall_error' intrudes on the
|
|
|
5de29b |
C name space. Make sure we use an innocuous name. */
|
|
|
12745e |
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
|
|
|
5de29b |
index f3f0ada..5ccf1da 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
|
|
|
12745e |
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
|
|
|
5de29b |
@@ -371,8 +371,44 @@ __local_syscall_error: \
|
|
|
5de29b |
|
|
|
5de29b |
#endif /* __ASSEMBLER__ */
|
|
|
5de29b |
|
|
|
5de29b |
-/* Pointer mangling is not yet supported for AArch64. */
|
|
|
5de29b |
-#define PTR_MANGLE(var) (void) (var)
|
|
|
5de29b |
-#define PTR_DEMANGLE(var) (void) (var)
|
|
|
5de29b |
+/* Pointer mangling is supported for AArch64. */
|
|
|
5de29b |
+#if (defined NOT_IN_libc && defined IS_IN_rtld) || \
|
|
|
5de29b |
+ (!defined SHARED && (!defined NOT_IN_libc || defined IS_IN_libpthread))
|
|
|
5de29b |
+# ifdef __ASSEMBLER__
|
|
|
5de29b |
+# define PTR_MANGLE(dst, src, guard, tmp) \
|
|
|
5de29b |
+ LDST_PCREL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local)); \
|
|
|
5de29b |
+ PTR_MANGLE2 (dst, src, guard)
|
|
|
5de29b |
+/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
|
|
|
5de29b |
+# define PTR_MANGLE2(dst, src, guard)\
|
|
|
5de29b |
+ eor dst, src, guard
|
|
|
5de29b |
+# define PTR_DEMANGLE(dst, src, guard, tmp)\
|
|
|
5de29b |
+ PTR_MANGLE (dst, src, guard, tmp)
|
|
|
5de29b |
+# define PTR_DEMANGLE2(dst, src, guard)\
|
|
|
5de29b |
+ PTR_MANGLE2 (dst, src, guard)
|
|
|
5de29b |
+# else
|
|
|
5de29b |
+extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
|
|
|
5de29b |
+# define PTR_MANGLE(var) \
|
|
|
5de29b |
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
|
|
|
5de29b |
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
|
|
|
5de29b |
+# endif
|
|
|
5de29b |
+#else
|
|
|
5de29b |
+# ifdef __ASSEMBLER__
|
|
|
5de29b |
+# define PTR_MANGLE(dst, src, guard, tmp) \
|
|
|
5de29b |
+ LDST_GLOBAL (ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard)); \
|
|
|
5de29b |
+ PTR_MANGLE2 (dst, src, guard)
|
|
|
5de29b |
+/* Use PTR_MANGLE2 for efficiency if guard is already loaded. */
|
|
|
5de29b |
+# define PTR_MANGLE2(dst, src, guard)\
|
|
|
5de29b |
+ eor dst, src, guard
|
|
|
5de29b |
+# define PTR_DEMANGLE(dst, src, guard, tmp)\
|
|
|
5de29b |
+ PTR_MANGLE (dst, src, guard, tmp)
|
|
|
5de29b |
+# define PTR_DEMANGLE2(dst, src, guard)\
|
|
|
5de29b |
+ PTR_MANGLE2 (dst, src, guard)
|
|
|
5de29b |
+# else
|
|
|
5de29b |
+extern uintptr_t __pointer_chk_guard attribute_relro;
|
|
|
5de29b |
+# define PTR_MANGLE(var) \
|
|
|
5de29b |
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
|
|
|
5de29b |
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
|
|
|
5de29b |
+# endif
|
|
|
5de29b |
+#endif
|
|
|
5de29b |
|
|
|
5de29b |
#endif /* linux/aarch64/sysdep.h */
|
|
|
5de29b |
commit 0b1f8e35640f5b3f7af11764ade3ff060211c309
|
|
|
5de29b |
Author: Carlos O'Donell <carlos@redhat.com>
|
|
|
5de29b |
Date: Mon Sep 23 01:44:38 2013 -0400
|
|
|
5de29b |
|
|
|
5de29b |
BZ #15754: Fix test case for ARM.
|
|
|
5de29b |
|
|
|
5de29b |
Statically built binaries use __pointer_chk_guard_local,
|
|
|
5de29b |
while dynamically built binaries use __pointer_chk_guard.
|
|
|
5de29b |
Provide the right definition depending on the test case
|
|
|
5de29b |
we are building.
|
|
|
5de29b |
|
|
|
12745e |
diff --git glibc-2.17-c758a686/elf/Makefile glibc-2.17-c758a686/elf/Makefile
|
|
|
5de29b |
index cb8da93..27d249b 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/elf/Makefile
|
|
|
12745e |
+++ glibc-2.17-c758a686/elf/Makefile
|
|
|
5de29b |
@@ -1019,6 +1019,9 @@ tst-stackguard1-ARGS = --command "$(host-test-program-cmd) --child"
|
|
|
5de29b |
tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
|
|
|
5de29b |
|
|
|
5de29b |
tst-ptrguard1-ARGS = --command "$(host-built-program-cmd) --child"
|
|
|
5de29b |
+# When built statically, the pointer guard interface uses
|
|
|
5de29b |
+# __pointer_chk_guard_local.
|
|
|
5de29b |
+CFLAGS-tst-ptrguard1-static.c = -DPTRGUARD_LOCAL
|
|
|
5de29b |
tst-ptrguard1-static-ARGS = --command "$(objpfx)tst-ptrguard1-static --child"
|
|
|
5de29b |
|
|
|
5de29b |
$(objpfx)tst-leaks1: $(libdl)
|
|
|
12745e |
diff --git glibc-2.17-c758a686/sysdeps/generic/stackguard-macros.h glibc-2.17-c758a686/sysdeps/generic/stackguard-macros.h
|
|
|
5de29b |
index 4fa3d96..b4a6b23 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/sysdeps/generic/stackguard-macros.h
|
|
|
12745e |
+++ glibc-2.17-c758a686/sysdeps/generic/stackguard-macros.h
|
|
|
5de29b |
@@ -3,5 +3,10 @@
|
|
|
5de29b |
extern uintptr_t __stack_chk_guard;
|
|
|
5de29b |
#define STACK_CHK_GUARD __stack_chk_guard
|
|
|
5de29b |
|
|
|
5de29b |
+#ifdef PTRGUARD_LOCAL
|
|
|
5de29b |
extern uintptr_t __pointer_chk_guard_local;
|
|
|
5de29b |
-#define POINTER_CHK_GUARD __pointer_chk_guard_local
|
|
|
5de29b |
+# define POINTER_CHK_GUARD __pointer_chk_guard_local
|
|
|
5de29b |
+#else
|
|
|
5de29b |
+extern uintptr_t __pointer_chk_guard;
|
|
|
5de29b |
+# define POINTER_CHK_GUARD __pointer_chk_guard
|
|
|
5de29b |
+#endif
|