patches/glibc/2.9/490-ptr-mangling.patch
branchnewlib
changeset 1365 c4d124ed9f8e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/glibc/2.9/490-ptr-mangling.patch	Sun Apr 19 16:17:11 2009 +0000
     1.3 @@ -0,0 +1,114 @@
     1.4 +Original patch from: gentoo/src/patchsets/glibc/2.9/6018_all_glibc-ptr-mangling.patch
     1.5 +
     1.6 +-= BEGIN original header =-
     1.7 +http://bugs.gentoo.org/201910
     1.8 +
     1.9 +For every arch, PTR_MANGLE and PTR_DEMANGLE defines are in
    1.10 +sysdeps/unix/sysv/linux/<arch>/sysdep.h. But for alpha this is not true. The
    1.11 +defines are in sysdeps/unix/alpha/sysdep.h and unix/sysv/linux/alpha/sysdep.h
    1.12 +includes the first.
    1.13 +
    1.14 +This is a patch that fixes the issue and let alpha build, at the expense of
    1.15 +disabling MANGLING in the non PIC case, but googling showed that the issue is
    1.16 +known, and that nobody really cares about it. 
    1.17 +
    1.18 +Info from: http://sourceware.org/bugzilla/show_bug.cgi?id=5216
    1.19 +
    1.20 +-= END original header =-
    1.21 +
    1.22 +diff -durN glibc-2_9.orig/sysdeps/unix/alpha/sysdep.h glibc-2_9/sysdeps/unix/alpha/sysdep.h
    1.23 +--- glibc-2_9.orig/sysdeps/unix/alpha/sysdep.h	2006-03-03 12:21:28.000000000 +0100
    1.24 ++++ glibc-2_9/sysdeps/unix/alpha/sysdep.h	2009-02-02 22:01:39.000000000 +0100
    1.25 +@@ -397,42 +397,4 @@
    1.26 + 	_sc_ret = _sc_0, _sc_err = _sc_19;			\
    1.27 + }
    1.28 + 
    1.29 +-/* Pointer mangling support.  Note that tls access is slow enough that
    1.30 +-   we don't deoptimize things by placing the pointer check value there.  */
    1.31 +-
    1.32 +-#include <stdint.h>
    1.33 +-
    1.34 +-#if defined NOT_IN_libc && defined IS_IN_rtld
    1.35 +-# ifdef __ASSEMBLER__
    1.36 +-#  define PTR_MANGLE(dst, src, tmp)				\
    1.37 +-	ldah	tmp, __pointer_chk_guard_local($29) !gprelhigh;	\
    1.38 +-	ldq	tmp, __pointer_chk_guard_local(tmp) !gprellow;	\
    1.39 +-	xor	src, tmp, dst
    1.40 +-#  define PTR_MANGLE2(dst, src, tmp)				\
    1.41 +-	xor	src, tmp, dst
    1.42 +-#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
    1.43 +-#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
    1.44 +-# else
    1.45 +-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
    1.46 +-#  define PTR_MANGLE(var)	\
    1.47 +-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
    1.48 +-#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
    1.49 +-# endif
    1.50 +-#elif defined PIC
    1.51 +-# ifdef __ASSEMBLER__
    1.52 +-#  define PTR_MANGLE(dst, src, tmp)		\
    1.53 +-	ldq	tmp, __pointer_chk_guard;	\
    1.54 +-	xor	src, tmp, dst
    1.55 +-#  define PTR_MANGLE2(dst, src, tmp)		\
    1.56 +-	xor	src, tmp, dst
    1.57 +-#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
    1.58 +-#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
    1.59 +-# else
    1.60 +-extern uintptr_t __pointer_chk_guard attribute_relro;
    1.61 +-#  define PTR_MANGLE(var)	\
    1.62 +-	(var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
    1.63 +-#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
    1.64 +-# endif
    1.65 +-#endif
    1.66 +-
    1.67 + #endif /* ASSEMBLER */
    1.68 +diff -durN glibc-2_9.orig/sysdeps/unix/sysv/linux/alpha/sysdep.h glibc-2_9/sysdeps/unix/sysv/linux/alpha/sysdep.h
    1.69 +--- glibc-2_9.orig/sysdeps/unix/sysv/linux/alpha/sysdep.h	2007-08-21 10:07:28.000000000 +0200
    1.70 ++++ glibc-2_9/sysdeps/unix/sysv/linux/alpha/sysdep.h	2009-02-02 22:01:39.000000000 +0100
    1.71 +@@ -98,4 +98,46 @@
    1.72 + 	INTERNAL_SYSCALL1(name, err_out, nr, args);			\
    1.73 + })
    1.74 + 
    1.75 ++/* Pointer mangling support.  Note that tls access is slow enough that
    1.76 ++   we don't deoptimize things by placing the pointer check value there.  */
    1.77 ++
    1.78 ++#if defined NOT_IN_libc && defined IS_IN_rtld
    1.79 ++# ifdef __ASSEMBLER__
    1.80 ++#  define PTR_MANGLE(dst, src, tmp)                            \
    1.81 ++       ldah    tmp, __pointer_chk_guard_local($29) !gprelhigh; \
    1.82 ++       ldq     tmp, __pointer_chk_guard_local(tmp) !gprellow;  \
    1.83 ++       xor     src, tmp, dst
    1.84 ++#  define PTR_MANGLE2(dst, src, tmp)                           \
    1.85 ++       xor     src, tmp, dst
    1.86 ++#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
    1.87 ++#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
    1.88 ++# else
    1.89 ++extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
    1.90 ++#  define PTR_MANGLE(var)      \
    1.91 ++  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
    1.92 ++#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
    1.93 ++# endif
    1.94 ++#elif defined PIC
    1.95 ++# ifdef __ASSEMBLER__
    1.96 ++#  define PTR_MANGLE(dst, src, tmp)            \
    1.97 ++       ldq     tmp, __pointer_chk_guard;       \
    1.98 ++       xor     src, tmp, dst
    1.99 ++#  define PTR_MANGLE2(dst, src, tmp)           \
   1.100 ++       xor     src, tmp, dst
   1.101 ++#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
   1.102 ++#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
   1.103 ++# else
   1.104 ++extern uintptr_t __pointer_chk_guard attribute_relro;
   1.105 ++#  define PTR_MANGLE(var)      \
   1.106 ++       (var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
   1.107 ++#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
   1.108 ++# endif
   1.109 ++#else
   1.110 ++/* Pointer mangling is not yet supported for static libc on alpha.  */
   1.111 ++# ifndef __ASSEMBLER__
   1.112 ++#  define PTR_MANGLE(var)   (void) (var)
   1.113 ++#  define PTR_DEMANGLE(var) (void) (var)
   1.114 ++# endif
   1.115 ++#endif
   1.116 ++
   1.117 + #endif /* _LINUX_ALPHA_SYSDEP_H */