about summary refs log tree commit diff
path: root/ports/sysdeps/unix
diff options
context:
space:
mode:
authorVenkataramanan Kumar <venkataramanan.kumar@linaro.org>2014-01-01 17:47:14 +0000
committerMarcus Shawcroft <marcus.shawcroft@linaro.org>2014-01-01 17:58:46 +0000
commit9188b6818a3d1a6e6d89bf10fa4aea27a591494c (patch)
treea39527a08f172d51a8e69fce1b969b0dcf5589a4 /ports/sysdeps/unix
parentb06ece6aec66e5ea973bc3c7f835ff3258dd4bb5 (diff)
downloadglibc-9188b6818a3d1a6e6d89bf10fa4aea27a591494c.tar.gz
glibc-9188b6818a3d1a6e6d89bf10fa4aea27a591494c.tar.xz
glibc-9188b6818a3d1a6e6d89bf10fa4aea27a591494c.zip
[AArch64] Pointer mangling support for AArch64.
Diffstat (limited to 'ports/sysdeps/unix')
-rw-r--r--ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h42
1 files changed, 39 insertions, 3 deletions
diff --git a/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index f3f0ada203..5ccf1da18b 100644
--- a/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -371,8 +371,44 @@ __local_syscall_error:						\
 
 #endif	/* __ASSEMBLER__ */
 
-/* Pointer mangling is not yet supported for AArch64.  */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
+/* Pointer mangling is supported for AArch64.  */
+#if (defined NOT_IN_libc && defined IS_IN_rtld) || \
+  (!defined SHARED && (!defined NOT_IN_libc || defined IS_IN_libpthread))
+# ifdef __ASSEMBLER__
+#  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 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(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 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
 
 #endif /* linux/aarch64/sysdep.h */