Clean up x86_64 sysdeps (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 12 Sep 2016 20:15:08 +0000 (16:15 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 16 Sep 2016 18:35:09 +0000 (14:35 -0400)
Our sysdep.h was just including Linux's, which was a mild surprise when
trying to debug the PTR_MANGLE / atexit() bug.  We don't need a lot of the
stuff that is Linux dependent.

Our sysdep.h now just contains a few things copy-and-pasted from the Linux
header, and it doesn't include things like __NR_pread, LOAD_REGS, and other
syscall-ABI specific things.

Rebuild glibc.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/x86_64/sysdep.h

index d0f553b..0fc9d20 100644 (file)
 #ifndef _AKAROS_X86_64_SYSDEP_H
 #define _AKAROS_X86_64_SYSDEP_H 1
 
-#include <sysdeps/unix/sysv/linux/x86_64/sysdep.h>
+/* Various bits copied from Linux and its #included sysdep.h */
+
+#include <sysdeps/generic/sysdep.h>
+#include <sysdeps/x86_64/sysdep.h>
+#include <tls.h>
+
+#ifdef IS_IN_rtld
+# include <dl-sysdep.h>                /* Defines RTLD_PRIVATE_ERRNO.  */
+#endif
+
+/* Pointer mangling support.  */
+#if defined NOT_IN_libc && defined 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
 
 #endif /* akaros/x86_64/sysdep.h */