This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix weak handling with GCC 3.4+


As discussed yesterday, GCC 3.4 needs to be aware of weak symbols.
I'm appending a patch that solves all problems I noticed.

This warning was fixed with some rearrangement of code:
res_libc.c:95: error: weak declaration of `__res_init_weak' must precede definition

With the appended patch, glibc builds and the testsuite passes (except
some problems like test-float.out unrelated to weak functions).

Ok to commit?

Andreas

2003-01-03  Andreas Jaeger  <aj@suse.de>, Jakub Jelinek <jakub@redhat.com>

	* resolv/res_libc.c: Provode declaration for __res_init_weak and
	reorder declarations.

	* include/libc-symbols.h (weak_extern): Use weak attribute instead
	of assembler so that GCC knows about it.

linuxthreads/ChangeLog:
2003-01-03  Andreas Jaeger  <aj@suse.de>
	* sysdeps/pthread/bits/libc-tsd.h: Declare weak_extern functions.

============================================================
Index: resolv/res_libc.c
--- resolv/res_libc.c	30 Dec 2002 00:09:54 -0000	1.12
+++ resolv/res_libc.c	3 Jan 2003 10:41:09 -0000
@@ -92,7 +92,8 @@ compat_symbol (libc, _res, _res, GLIBC_2
 
 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2)
 # undef res_init
-strong_alias (__res_init, __res_init_weak);
+extern int __res_init_weak (void);
 weak_extern (__res_init_weak);
+strong_alias (__res_init, __res_init_weak);
 compat_symbol (libc, __res_init_weak, res_init, GLIBC_2_0);
 #endif
============================================================
Index: linuxthreads/sysdeps/pthread/bits/libc-tsd.h
--- linuxthreads/sysdeps/pthread/bits/libc-tsd.h	28 Dec 2002 10:13:56 -0000	1.8
+++ linuxthreads/sysdeps/pthread/bits/libc-tsd.h	3 Jan 2003 10:41:09 -0000
@@ -33,6 +33,10 @@
 # include <bits/libc-lock.h>
 
 # ifndef SHARED
+extern void ** __pthread_internal_tsd_address (int);
+extern void *__pthread_internal_tsd_get (int);
+extern int __pthread_internal_tsd_set (int, const void *);
+
 weak_extern (__pthread_internal_tsd_address)
 weak_extern (__pthread_internal_tsd_get)
 weak_extern (__pthread_internal_tsd_set)
============================================================
Index: include/libc-symbols.h
--- include/libc-symbols.h	10 Dec 2002 20:32:00 -0000	1.49
+++ include/libc-symbols.h	3 Jan 2003 10:41:09 -0000
@@ -1,6 +1,6 @@
 /* Support macros for making weak and strong aliases for symbols,
    and for using symbol sets and linker warnings with GNU ld.
-   Copyright (C) 1995-1998,2000,2001,2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998,2000,2001,2002,2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -116,24 +116,7 @@
   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
 
 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
-#  define weak_extern(symbol) _weak_extern (symbol)
-#  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
-#   ifdef HAVE_ASM_GLOBAL_DOT_NAME
-#    define _weak_extern(symbol) \
-        asm (".weakext " __SYMBOL_PREFIX #symbol "\n\t"	\
-	     ".weakext ." __SYMBOL_PREFIX #symbol);
-#   else
-#    define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
-#   endif
-#  else
-#   ifdef HAVE_ASM_GLOBAL_DOT_NAME
-#    define _weak_extern(symbol) \
-        asm (".weak " __SYMBOL_PREFIX #symbol "\n\t"	\
-	     ".weak ." __SYMBOL_PREFIX #symbol);
-#   else
-#    define _weak_extern(symbol) asm (".weak " __SYMBOL_PREFIX #symbol);
-#   endif
-#  endif
+#  define weak_extern(name) extern __typeof (name) name __attribute__((weak));
 
 # else
 

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

Attachment: msg00036/pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]