gcc-3.4.X + glibc segfault

Jake Page jake@cs.stanford.edu
Wed Jul 28 06:34:00 GMT 2004


On Mon, 26 Jul 2004, Daniel Kegel wrote:
> 
> Quick question: have you tested glibc-2.3.2 yet?

Just tested it - it works find with static apps.  Actually, it seems to 
work ok with dynamically linksed apps, now, too.  May be attribute
issue mentioned below...
Here's a revised patch for the "no-unit-at-a-time" issue - the one in 
crosstool dies when building a debug library (needs "-g0" for MIPS for 
pt-initfini.c)

> If you find a fix for glibc-2.2.5, I'd be happy to include it
> (especially if it's a simple backport from glibc-2.3.2...)

I found the problem and backported from 2.3.2... patch included, though 
there may be another (much larger) one involving converting 
__attribute__ ((unused)) to __attribute_used__ to get 2.2.5 to work 
correctly... will send one vs. stock glibc-2.2.5 when I have time...

-Jake
-------------- next part --------------
Fixes errors like

mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.o(.text+0x0):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.S:20: multiple definition of `dummy'
mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crti.o(.text+0x0):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crti.S:42: first defined here
mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.o(.text+0x18):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.S:37: multiple definition of `_init'
mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crti.o(.text+0x30):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crti.S:76: first defined here
mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.o(.init+0x1c):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.S:86: multiple definition of `_fini'
mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crti.o(.init+0x10):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crti.S:48: first defined here
mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crti.o(.init+0x28):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crti.S:58: undefined reference to `i_am_not_a_leaf'
mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.o(.init+0x4c):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.S:108: undefined reference to `i_am_not_a_leaf'
mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.o(.init+0x50):build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/crtn.S:109: undefined reference to `i_am_not_a_leaf'
collect2: ld returned 1 exit status
make[2]: *** [build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/linuxthreads/libpthread.so] Error 1
make[2]: Leaving directory `build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/glibc-2.3.2/linuxthreads'
make[1]: *** [linuxthreads/others] Error 2
make[1]: Leaving directory `build/mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/glibc-2.3.2'
make: *** [all] Error 2


CVSROOT:	/cvs/glibc
Module name:	libc
Changes by:	aj@sourceware.org	2003-12-02 07:37:29

Modified files:
	.              : configure.in configure config.make.in 
	csu            : Makefile 
	locale         : Makefile 
	linuxthreads   : Makefile 
	linuxthreads/sysdeps/unix/sysv/linux/x86_64: Makefile 
	nptl           : Makefile 
	nptl/sysdeps/unix/sysv/linux/x86_64: Makefile 

Log message:
	* config.make.in (fno-unit-at-a-time): Define.
	
	* configure.in: Add test for -fno-unit-at-a-time.
	Fix text for -fpie.
	
	* csu/Makefile (CFLAGS-initfini.s): Add $(fno_unit_at_a_time).
	* locale/Makefile (CFLAGS-loadlocale.c): Likewise.
	
	For linuxthreads:
	* Makefile (CFLAGS-pt-initfini.s): Add $(fno_unit_at_a_time).
	* sysdeps/unix/sysv/linux/x86_64/Makefile (CFLAGS-pt-initfini.s):
	Likewise.
	
	For nptl:
	* Makefile (CFLAGS-pt-initfini.s): Add $(fno_unit_at_a_time).
	* sysdeps/unix/sysv/linux/x86_64/Makefile (CFLAGS-pt-initfini.s):
	Likewise.

linuxthreads change retrieved with
wget -O foo.patch 'http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/linuxthreads/Makefile.diff?r1=1.83&r2=1.84&cvsroot=glibc' \
'http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/Makefile.diff?r1=1.5&r2=1.6&cvsroot=glibc'

and then rediffed against glibc-2.3.2
And then extended to mips...

===================================================================
RCS file: /cvs/glibc/libc/linuxthreads/Makefile,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- libc/linuxthreads/Makefile	2003/10/02 18:48:48	1.83
+++ libc/linuxthreads/Makefile	2003/12/02 07:37:28	1.84
@@ -101,7 +101,7 @@
 extra-objs += $(crti-objs) $(crtn-objs)
 omit-deps += crti crtn
 
-CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions
+CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
 endif
 
 librt-tests = ex10 ex11
===================================================================
RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/Makefile	2003/04/11 23:34:02	1.5
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/Makefile	2003/12/02 07:37:28	1.6
@@ -1,3 +1,4 @@
 ifeq ($(subdir),linuxthreads)
-CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions -fno-asynchronous-unwind-tables
+CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions \
+		       -fno-asynchronous-unwind-tables $(fno-unit-at-a-time)
 endif
--- glibc-2.3.2/linuxthreads/sysdeps/unix/sysv/linux/mips/Makefile.old	2004-05-30 18:24:41.000000000 -0700
+++ glibc-2.3.2/linuxthreads/sysdeps/unix/sysv/linux/mips/Makefile	2004-05-30 18:28:03.000000000 -0700
@@ -1,2 +1,6 @@
 # pull in __syscall_error routine
 libpthread-routines += sysdep
+
+ifeq ($(subdir),linuxthreads)
+CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
+endif
-------------- next part --------------
 Fixes gcc-3.4 optimizing out comparisons to weak external symbols in code
 like:
  if (__pthread_mutex_init != NULL)
    __pthread_mutex_init(...);

 that causes segfaults during libc init when not linked to libpthread

diff -uNr glibc-2.2.5-orig/include/libc-symbols.h glibc-2.2.5/include/libc-symbols.h
--- glibc-2.2.5-orig/include/libc-symbols.h	2001-08-03 16:02:52.000000000 -0700
+++ glibc-2.2.5/include/libc-symbols.h	2004-07-27 22:54:50.000000000 -0700
@@ -109,10 +109,7 @@
 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
 #  define weak_extern(symbol) _weak_extern (symbol)
 #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
-#   define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
-#  else
-#   define _weak_extern(symbol)    asm (".weak " __SYMBOL_PREFIX #symbol);
-#  endif
+#  define _weak_extern(expr) _Pragma (#expr)
 
 # else
 
diff -uNr glibc-2.2.5-orig/resolv/res_libc.c glibc-2.2.5/resolv/res_libc.c
--- glibc-2.2.5-orig/resolv/res_libc.c	2001-02-12 12:23:34.000000000 -0800
+++ glibc-2.2.5/resolv/res_libc.c	2004-07-27 22:56:32.000000000 -0700
@@ -84,7 +84,8 @@
 
 #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
-------------- next part --------------
------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


More information about the crossgcc mailing list