patches/glibc/2.2.5/glibc-2.2.5-allow-gcc-3.4-weakextern.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
permissions -rw-r--r--
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
yann@1
     1
Suggested by Jake Page <jake at cs dot stanford dot edu>
yann@1
     2
in http://sources.redhat.com/ml/crossgcc/2004-07/msg00169.html
yann@1
     3
but the libc-symbols.h fragment has been reworked to fix typos
yann@1
     4
and to still work on gcc-2.95.3, which lacks _Pragma.
yann@1
     5
yann@1
     6
His comment was:
yann@1
     7
 Fixes gcc-3.4 optimizing out comparisons to weak external symbols in code
yann@1
     8
 like:
yann@1
     9
  if (__pthread_mutex_init != NULL)
yann@1
    10
    __pthread_mutex_init(...);
yann@1
    11
 that causes segfaults during libc init when not linked to libpthread
yann@1
    12
yann@1
    13
diff -uNr glibc-2.2.5-orig/resolv/res_libc.c glibc-2.2.5/resolv/res_libc.c
yann@1
    14
--- glibc-2.2.5-orig/resolv/res_libc.c	2001-02-12 12:23:34.000000000 -0800
yann@1
    15
+++ glibc-2.2.5/resolv/res_libc.c	2004-07-27 22:56:32.000000000 -0700
yann@1
    16
@@ -84,7 +84,8 @@
yann@1
    17
 
yann@1
    18
 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2)
yann@1
    19
 # undef res_init
yann@1
    20
-strong_alias (__res_init, __res_init_weak);
yann@1
    21
+extern int __res_init_weak (void);
yann@1
    22
 weak_extern (__res_init_weak);
yann@1
    23
+strong_alias (__res_init, __res_init_weak);
yann@1
    24
 compat_symbol (libc, __res_init_weak, res_init, GLIBC_2_0);
yann@1
    25
 #endif
yann@1
    26
--- glibc-2.2.5/include/libc-symbols.h.old	Fri Aug 13 04:20:55 2004
yann@1
    27
+++ glibc-2.2.5/include/libc-symbols.h	Fri Aug 13 04:37:06 2004
yann@1
    28
@@ -108,10 +108,16 @@
yann@1
    29
 
yann@1
    30
 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
yann@1
    31
 #  define weak_extern(symbol) _weak_extern (symbol)
yann@1
    32
-#  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
yann@1
    33
-#   define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
yann@1
    34
-#  else
yann@1
    35
-#   define _weak_extern(symbol)    asm (".weak " __SYMBOL_PREFIX #symbol);
yann@1
    36
+#  if __GNUC__ >= 3
yann@1
    37
+    /* see http://sources.redhat.com/ml/libc-alpha/2003-01/msg00043.html */
yann@1
    38
+#   define __weak_extern_1(expr) _Pragma(#expr)
yann@1
    39
+#   define _weak_extern(symbol) __weak_extern_1(weak symbol)
yann@1
    40
+#  else /* __GNUC__ == 2 */
yann@1
    41
+#   ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
yann@1
    42
+#    define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
yann@1
    43
+#   else
yann@1
    44
+#    define _weak_extern(symbol)    asm (".weak " __SYMBOL_PREFIX #symbol);
yann@1
    45
+#   endif
yann@1
    46
 #  endif
yann@1
    47
 
yann@1
    48
 # else