Bug 12898 - gold throws "internal error in segment_precedes" when building kvm
Summary: gold throws "internal error in segment_precedes" when building kvm
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-16 13:13 UTC by Octoploid
Modified: 2014-01-03 01:45 UTC (History)
0 users

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


Attachments
failing linker script (203 bytes, text/plain)
2011-06-16 13:13 UTC, Octoploid
Details
input files (4.65 KB, application/gzip)
2011-06-17 14:58 UTC, Octoploid
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Octoploid 2011-06-16 13:13:45 UTC
Created attachment 5796 [details]
failing linker script

gold fails to link the new kernel kvm tool.
http://article.gmane.org/gmane.linux.kernel/1155280

ld -T bios/rom.ld.S -o bios/bios.bin.elf bios/bios.o bios/e820.o bios/int10.o
ld: error: allocated section not in any segment
ld: error: allocated section not in any segment
ld: internal error in segment_precedes, at /var/tmp/portage/sys-devel/binutils-2.21.52.0.2/work/binutils-2.21.52.0.2/gold/layout.cc:2803
Comment 1 Ian Lance Taylor 2011-06-17 14:52:19 UTC
Can you attach the input files bios/bios.o bios/e820.o bios/int10.o.  Thanks.
Comment 2 Octoploid 2011-06-17 14:58:02 UTC
Created attachment 5802 [details]
input files
Comment 3 Sourceware Commits 2011-06-29 00:39:58 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2011-06-29 00:39:55

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

Log message:
	PR gold/12898
	* layout.cc (Layout::segment_precedes): Don't crash if a linker
	script create indistinguishable segments.
	(Layout::set_segment_offsets): Use stable_sort when sorting
	segments.  Pass this to Compare_segments constructor.
	* layout.h (class Layout): Make segment_precedes non-static.
	(class Compare_segments): Change from struct to class.  Add
	layout_ field.  Add constructor.
	* script-sections.cc
	(Script_sections::attach_sections_using_phdrs_clause): Rename
	local orphan to is_orphan.  Don't report failure to put empty
	section in segment.  On attachment failure, report name of
	section, and attach to first PT_LOAD segment.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.772&r2=1.773
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/layout.cc.diff?cvsroot=src&r1=1.206&r2=1.207
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/layout.h.diff?cvsroot=src&r1=1.94&r2=1.95
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/script-sections.cc.diff?cvsroot=src&r1=1.52&r2=1.53
Comment 4 Ian Lance Taylor 2011-06-29 00:41:37 UTC
This should now be fixed in the development sources.  Thanks for reporting it, and thanks for the test case.
Comment 5 Octoploid 2011-06-29 06:44:52 UTC
And thank you for the quick fix. 
KVM is linking fine now.