patches/glibc/ports-2.10.1/450-alpha-ptr-mangling.patch
author Johannes Stezenbach <js@sig21.net>
Thu Jul 29 19:47:16 2010 +0200 (2010-07-29)
changeset 2045 fdaa6c7f6dea
permissions -rw-r--r--
cc/gcc: add option to compile against static libstdc++, for gcc-4.4 and newer

Idea and know-how taken from CodeSourcery build script.

Normal build:
$ ldd arm-unknown-linux-uclibcgnueabi-gcc
linux-gate.so.1 => (0xb77f3000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb76e8000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb75a1000)
libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb757a000)
/lib/ld-linux.so.2 (0xb77f4000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb755c000)

CC_STATIC_LIBSTDCXX=y:
$ ldd arm-unknown-linux-uclibcgnueabi-gcc
linux-gate.so.1 => (0xb7843000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb76e6000)
/lib/ld-linux.so.2 (0xb7844000)

I made CC_STATIC_LIBSTDCXX default=y since I think
it is always desirable.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
yann@1625
     1
http://bugs.gentoo.org/201910
yann@1625
     2
yann@1625
     3
For every arch, PTR_MANGLE and PTR_DEMANGLE defines are in
yann@1625
     4
sysdeps/unix/sysv/linux/<arch>/sysdep.h. But for alpha this is not true. The
yann@1625
     5
defines are in sysdeps/unix/alpha/sysdep.h and unix/sysv/linux/alpha/sysdep.h
yann@1625
     6
includes the first.
yann@1625
     7
yann@1625
     8
This is a patch that fixes the issue and let alpha build, at the expense of
yann@1625
     9
disabling MANGLING in the non PIC case, but googling showed that the issue is
yann@1625
    10
known, and that nobody really cares about it. 
yann@1625
    11
yann@1625
    12
Info from: http://sourceware.org/bugzilla/show_bug.cgi?id=5216
yann@1625
    13
yann@1625
    14
diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/unix/alpha/sysdep.h glibc-2.10.1/glibc-ports-2.10.1/sysdeps/unix/alpha/sysdep.h
yann@1625
    15
--- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/unix/alpha/sysdep.h	2009-05-16 10:36:20.000000000 +0200
yann@1625
    16
+++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/unix/alpha/sysdep.h	2009-11-13 00:50:55.000000000 +0100
yann@1625
    17
@@ -397,42 +397,4 @@
yann@1625
    18
 	_sc_ret = _sc_0, _sc_err = _sc_19;			\
yann@1625
    19
 }
yann@1625
    20
 
yann@1625
    21
-/* Pointer mangling support.  Note that tls access is slow enough that
yann@1625
    22
-   we don't deoptimize things by placing the pointer check value there.  */
yann@1625
    23
-
yann@1625
    24
-#include <stdint.h>
yann@1625
    25
-
yann@1625
    26
-#if defined NOT_IN_libc && defined IS_IN_rtld
yann@1625
    27
-# ifdef __ASSEMBLER__
yann@1625
    28
-#  define PTR_MANGLE(dst, src, tmp)				\
yann@1625
    29
-	ldah	tmp, __pointer_chk_guard_local($29) !gprelhigh;	\
yann@1625
    30
-	ldq	tmp, __pointer_chk_guard_local(tmp) !gprellow;	\
yann@1625
    31
-	xor	src, tmp, dst
yann@1625
    32
-#  define PTR_MANGLE2(dst, src, tmp)				\
yann@1625
    33
-	xor	src, tmp, dst
yann@1625
    34
-#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
yann@1625
    35
-#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
yann@1625
    36
-# else
yann@1625
    37
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
yann@1625
    38
-#  define PTR_MANGLE(var)	\
yann@1625
    39
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
yann@1625
    40
-#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
yann@1625
    41
-# endif
yann@1625
    42
-#elif defined PIC
yann@1625
    43
-# ifdef __ASSEMBLER__
yann@1625
    44
-#  define PTR_MANGLE(dst, src, tmp)		\
yann@1625
    45
-	ldq	tmp, __pointer_chk_guard;	\
yann@1625
    46
-	xor	src, tmp, dst
yann@1625
    47
-#  define PTR_MANGLE2(dst, src, tmp)		\
yann@1625
    48
-	xor	src, tmp, dst
yann@1625
    49
-#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
yann@1625
    50
-#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
yann@1625
    51
-# else
yann@1625
    52
-extern uintptr_t __pointer_chk_guard attribute_relro;
yann@1625
    53
-#  define PTR_MANGLE(var)	\
yann@1625
    54
-	(var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
yann@1625
    55
-#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
yann@1625
    56
-# endif
yann@1625
    57
-#endif
yann@1625
    58
-
yann@1625
    59
 #endif /* ASSEMBLER */
yann@1625
    60
diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/unix/sysv/linux/alpha/sysdep.h glibc-2.10.1/glibc-ports-2.10.1/sysdeps/unix/sysv/linux/alpha/sysdep.h
yann@1625
    61
--- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/unix/sysv/linux/alpha/sysdep.h	2009-05-16 10:36:20.000000000 +0200
yann@1625
    62
+++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/unix/sysv/linux/alpha/sysdep.h	2009-11-13 00:50:55.000000000 +0100
yann@1625
    63
@@ -98,4 +98,46 @@
yann@1625
    64
 	INTERNAL_SYSCALL1(name, err_out, nr, args);			\
yann@1625
    65
 })
yann@1625
    66
 
yann@1625
    67
+/* Pointer mangling support.  Note that tls access is slow enough that
yann@1625
    68
+   we don't deoptimize things by placing the pointer check value there.  */
yann@1625
    69
+
yann@1625
    70
+#if defined NOT_IN_libc && defined IS_IN_rtld
yann@1625
    71
+# ifdef __ASSEMBLER__
yann@1625
    72
+#  define PTR_MANGLE(dst, src, tmp)                            \
yann@1625
    73
+       ldah    tmp, __pointer_chk_guard_local($29) !gprelhigh; \
yann@1625
    74
+       ldq     tmp, __pointer_chk_guard_local(tmp) !gprellow;  \
yann@1625
    75
+       xor     src, tmp, dst
yann@1625
    76
+#  define PTR_MANGLE2(dst, src, tmp)                           \
yann@1625
    77
+       xor     src, tmp, dst
yann@1625
    78
+#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
yann@1625
    79
+#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
yann@1625
    80
+# else
yann@1625
    81
+extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
yann@1625
    82
+#  define PTR_MANGLE(var)      \
yann@1625
    83
+  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
yann@1625
    84
+#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
yann@1625
    85
+# endif
yann@1625
    86
+#elif defined PIC
yann@1625
    87
+# ifdef __ASSEMBLER__
yann@1625
    88
+#  define PTR_MANGLE(dst, src, tmp)            \
yann@1625
    89
+       ldq     tmp, __pointer_chk_guard;       \
yann@1625
    90
+       xor     src, tmp, dst
yann@1625
    91
+#  define PTR_MANGLE2(dst, src, tmp)           \
yann@1625
    92
+       xor     src, tmp, dst
yann@1625
    93
+#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
yann@1625
    94
+#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
yann@1625
    95
+# else
yann@1625
    96
+extern uintptr_t __pointer_chk_guard attribute_relro;
yann@1625
    97
+#  define PTR_MANGLE(var)      \
yann@1625
    98
+       (var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
yann@1625
    99
+#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
yann@1625
   100
+# endif
yann@1625
   101
+#else
yann@1625
   102
+/* Pointer mangling is not yet supported for static libc on alpha.  */
yann@1625
   103
+# ifndef __ASSEMBLER__
yann@1625
   104
+#  define PTR_MANGLE(var)   (void) (var)
yann@1625
   105
+#  define PTR_DEMANGLE(var) (void) (var)
yann@1625
   106
+# endif
yann@1625
   107
+#endif
yann@1625
   108
+
yann@1625
   109
 #endif /* _LINUX_ALPHA_SYSDEP_H */
yann@1625
   110
diff -durN glibc-2.10.1.orig/ports/sysdeps/unix/alpha/sysdep.h glibc-2.10.1/ports/sysdeps/unix/alpha/sysdep.h
yann@1625
   111
diff -durN glibc-2.10.1.orig/ports/sysdeps/unix/sysv/linux/alpha/sysdep.h glibc-2.10.1/ports/sysdeps/unix/sysv/linux/alpha/sysdep.h