Bug 10979 - Crashes during linking of program
Summary: Crashes during linking of program
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
: 10669 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-11-18 17:19 UTC by robert.wohlrab
Modified: 2009-12-31 05:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description robert.wohlrab 2009-11-18 17:19:14 UTC
I tried to recompile all packages in Debian and found different packages which
dont work with binutils-gold. Interesting for you are currently arj, idjc, klibc
and libtirpc because they create internal crashes which get caught by it (so no
segfaults but still crashes):

Output of each lin:
cc -DLOCALE=LANG_en -DLOCALE_DESC="\"en\"" -DPKGLIBDIR="\"/usr/lib/arj\""
-D_UNIX -Wall -g -O2 -s gnu/stripgcc.lnk -o linux-
gnu/en/rs/tools/today ./linux-gnu/en/rs/tools/filemode.o
./linux-gnu/en/rs/tools/today.o 
/usr/bin/ld: internal error in write_sections, at ../../gold/reloc.cc:747
collect2: ld returned 1 exit status

cc  -g -O2 -g -Wall -O2   -o idjcmixer -rdynamic idjcmixer-idjcmixer.o
idjcmixer-kvpdict.o idjcmixer-kvpparse.o idjcmixer-
dbconvert.o idjcmixer-ialloc.o idjcmixer-xlplayer.o idjcmixer-mp4tag.o
idjcmixer-compressor.o idjcmixer-sndfileinfo.o 
idjcmixer-flacdecode.o idjcmixer-mp3dec.o idjcmixer-sndfiledecode.o
idjcmixer-avcodecdecode.o idjcmixer-mp3tagread.o idjcmixer-
oggdec.o idjcmixer-ogg_vorbis_dec.o idjcmixer-ogg_flac_dec.o
idjcmixer-ogg_speex_dec.o idjcmixer-speextag.o idjcmixer-
bsdcompat.o idjcmixer-agc.o idjcmixer-dyn_mad.o -lpthread -ldl -lm -ljack
-lpthread -lrt   -lvorbisfile -lvorbis -lm -logg   -
lsamplerate   -lFLAC -lm    -lsndfile    -lmad   -lavcodec   -lavformat  
-lspeex    
/usr/bin/ld: internal error in allocate_base_common, at ../../gold/symtab.cc:196

usr/klibc/socketcalls/sendmsg.o usr/klibc/socketcalls/recvmsg.o
/usr/lib/gcc/x86_64-linux-gnu/4.3.4/libgcc.a --end-group
ld: internal error in do_write, at ../../gold/output.cc:383

gcc -shared  .libs/libtirpc_la-auth_none.o .libs/libtirpc_la-auth_unix.o
.libs/libtirpc_la-authunix_prot.o .libs/libtirpc_la-
bindresvport.o .libs/libtirpc_la-clnt_bcast.o .libs/libtirpc_la-clnt_dg.o
.libs/libtirpc_la-clnt_generic.o .libs/libtirpc_la-
clnt_perror.o .libs/libtirpc_la-clnt_raw.o .libs/libtirpc_la-clnt_simple.o
.libs/libtirpc_la-clnt_vc.o .libs/libtirpc_la-
rpc_dtablesize.o .libs/libtirpc_la-getnetconfig.o .libs/libtirpc_la-getnetpath.o
.libs/libtirpc_la-getrpcent.o 
.libs/libtirpc_la-getrpcport.o .libs/libtirpc_la-mt_misc.o
.libs/libtirpc_la-pmap_clnt.o .libs/libtirpc_la-pmap_getmaps.o 
.libs/libtirpc_la-pmap_getport.o .libs/libtirpc_la-pmap_prot.o
.libs/libtirpc_la-pmap_prot2.o .libs/libtirpc_la-pmap_rmt.o 
.libs/libtirpc_la-rpc_prot.o .libs/libtirpc_la-rpc_commondata.o
.libs/libtirpc_la-rpc_callmsg.o .libs/libtirpc_la-rpc_generic.o 
.libs/libtirpc_la-rpc_soc.o .libs/libtirpc_la-rpcb_clnt.o
.libs/libtirpc_la-rpcb_prot.o .libs/libtirpc_la-rpcb_st_xdr.o 
.libs/libtirpc_la-svc.o .libs/libtirpc_la-svc_auth.o .libs/libtirpc_la-svc_dg.o
.libs/libtirpc_la-svc_auth_unix.o 
.libs/libtirpc_la-svc_generic.o .libs/libtirpc_la-svc_raw.o
.libs/libtirpc_la-svc_run.o .libs/libtirpc_la-svc_simple.o 
.libs/libtirpc_la-svc_vc.o .libs/libtirpc_la-getpeereid.o
.libs/libtirpc_la-auth_time.o .libs/libtirpc_la-auth_des.o 
.libs/libtirpc_la-authdes_prot.o .libs/libtirpc_la-xdr.o
.libs/libtirpc_la-xdr_rec.o .libs/libtirpc_la-xdr_array.o 
.libs/libtirpc_la-xdr_float.o .libs/libtirpc_la-xdr_mem.o
.libs/libtirpc_la-xdr_reference.o .libs/libtirpc_la-xdr_stdio.o 
.libs/libtirpc_la-auth_gss.o .libs/libtirpc_la-authgss_prot.o
.libs/libtirpc_la-svc_auth_gss.o .libs/libtirpc_la-
svc_auth_none.o  -lnsl -lgssglue -ldl -lpthread  -Wl,-z -Wl,defs -Wl,-soname
-Wl,libtirpc.so.1 -o .libs/libtirpc.so.1.0.10
/usr/bin/ld: internal error in allocate_base_common, at ../../gold/symtab.cc:196
collect2: ld returned 1 exit status

Downstream bugreport can be found at http://bugs.debian.org/553916
Comment 1 Sourceware Commits 2009-12-31 03:48:58 UTC
Subject: Bug 10979

CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2009-12-31 03:48:46

Modified files:
	gold           : ChangeLog layout.cc layout.h script.cc 

Log message:
	PR 10979
	* script.cc (read_input_script): If we see a new SECTIONS clause,
	and we have added an input section, give an error.
	* layout.h (class Layout): Add have_added_input_section function.
	Add have_added_input_section_ field.
	* layout.cc (Layout::Layout): Initialize
	have_added_input_section_.
	(Layout::layout): Set have_added_input_section_.
	(Layout::layout_eh_frame): Likewise.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.414&r2=1.415
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/layout.cc.diff?cvsroot=src&r1=1.153&r2=1.154
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/layout.h.diff?cvsroot=src&r1=1.75&r2=1.76
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/script.cc.diff?cvsroot=src&r1=1.63&r2=1.64

Comment 2 Ian Lance Taylor 2009-12-31 03:51:44 UTC
The problem with arj is that it passes in a linker script as an input file.  The 
linker script is just

SECTIONS
{
 /DISCARD/ : { *(.comment) *(.note) *(.stab) *(.stabstr) }
}

The problem is that once gold sees a SECTIONS clause, it more or less has to go 
through the linker script processing.  When it sees a SECTIONS clause in an 
input file, it has already handled crt1.o and friends.  That fails, because they 
require special handling when using a linker script.

I thought about different ways to tackle this, but I finally decided to simply 
forbid it.  I committed this patch to give a sensible error for this case, 
rather than simply crashing.
Comment 3 Sourceware Commits 2009-12-31 05:07:36 UTC
Subject: Bug 10979

CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2009-12-31 05:07:22

Modified files:
	gold           : ChangeLog common.cc symtab.h 
	gold/testsuite : Makefile.am Makefile.in 
Added files:
	gold/testsuite : common_test_2.c common_test_3.c 

Log message:
	PR 10979
	* common.cc (Sort_commons::operator()): Stabilize sort when both
	entries are NULL.
	(Symbol_table::do_allocate_commons_list): When allocating common
	symbols, skip a symbol which is no longer common.
	* symtab.h (Symbol::is_common): Test whether the symbol comes from
	an object before checking its type.
	* testsuite/common_test_2.c: New file.
	* testsuite/common_test_3.c: New file.
	* testsuite/Makefile.am (check_PROGRAMS): Add common_test_2.
	(common_test_2_SOURCES, common_test_2_DEPENDENCIES): Define.
	(common_test_2_LDFLAGS, common_test_2_LDADD): Define.
	(common_test_2_pic.o, common_test_2.so): New targets.
	(common_test_3_pic.o, common_test_3.so): New targets.
	* testsuite/Makefile.in: Rebuild.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.415&r2=1.416
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/common.cc.diff?cvsroot=src&r1=1.21&r2=1.22
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/symtab.h.diff?cvsroot=src&r1=1.102&r2=1.103
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/testsuite/common_test_2.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/testsuite/common_test_3.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.am.diff?cvsroot=src&r1=1.114&r2=1.115
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.in.diff?cvsroot=src&r1=1.120&r2=1.121

Comment 4 Ian Lance Taylor 2009-12-31 05:14:02 UTC
The problem with idjc is a complicated case which arises because it defines a 
common symbol named "shutdown", then links against a shared library which refers 
to "shutdown" with a glibc version, and then sees from libc that that version is 
the default.  This leads it to allocate the common symbol twice, which gives an 
error.  I committed a patch to fix it.  I assume that this will also fix the 
problem with libtirpc which fails in the same way.
Comment 5 Ian Lance Taylor 2009-12-31 05:15:16 UTC
*** Bug 10669 has been marked as a duplicate of this bug. ***
Comment 6 Sourceware Commits 2009-12-31 05:43:43 UTC
Subject: Bug 10979

CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2009-12-31 05:43:29

Modified files:
	gold           : ChangeLog layout.cc 

Log message:
	PR 10979
	* layout.cc (Layout::relaxation_loop_body): If -Ttext was used,
	don't put the file header and segment headers in the text
	segment.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.416&r2=1.417
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/layout.cc.diff?cvsroot=src&r1=1.154&r2=1.155

Comment 7 Ian Lance Taylor 2009-12-31 05:46:27 UTC
The klibc problem is due to -Ttext.  gold was trying to put the file header and 
segment header in the text segment, but it was in the wrong place due to -Ttext.  
I've committed a patch.

I believe that fixes all of the cases pointed out in this bug report.  Thanks for 
filing it.