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