Bug 12356 - [Regression] x86_64 kernel failed to link
Summary: [Regression] x86_64 kernel failed to link
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-29 17:16 UTC by H.J. Lu
Modified: 2011-01-14 03:02 UTC (History)
2 users (show)

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


Attachments
File defined4.o (192 bytes, application/x-object)
2011-01-02 20:46 UTC, Sedat Dilek
Details
File defined4 (211 bytes, application/octet-stream)
2011-01-02 20:47 UTC, Sedat Dilek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2010-12-29 17:16:42 UTC
[hjl@gnu-6 prxx]$ cat defined4.s
	.globl	defined
	.text
	.word 0
	.section .data..cacheline_aligned
defined:
	.word 0
[hjl@gnu-6 prxx]$ cat defined4.t
defined = addr1;
SECTIONS {
	.text : { *(.text) }
	addr1  = ADDR (.text);
	.data : { *(.data) }
	.bss : { *(.bss) *(COMMON) }
}
[hjl@gnu-6 prxx]$ make
as   -o defined4.o defined4.s
./ld -T defined4.t  -o defined4 defined4.o
defined4.o: In function `defined':
(.data..cacheline_aligned+0x0): multiple definition of `defined'
make: *** [defined4] Error 1
[hjl@gnu-6 prxx]$
Comment 1 H.J. Lu 2011-01-01 18:06:58 UTC
It is caused by

http://sourceware.org/ml/binutils/2010-12/msg00557.html
Comment 2 Sedat Dilek 2011-01-02 20:45:05 UTC
I have tested the patch from [1] on top of cherry-picked commits PR ld/12001 and PR ld/12237 from trunk against binutils-2.21 on a Debian/sid i386 host.
The testcase for x86_32 runs successfully.

- Sedat -


[1] http://sourceware.org/ml/binutils/2011-01/msg00002.html
Comment 3 Sedat Dilek 2011-01-02 20:46:38 UTC
Created attachment 5177 [details]
File defined4.o
Comment 4 Sedat Dilek 2011-01-02 20:47:01 UTC
Created attachment 5178 [details]
File defined4
Comment 5 Alan Modra 2011-01-11 05:56:00 UTC
The testcase does in fact have multiple definitions of "defined", one in an object file, and one in the linker script.  While it is true that we did not previously give an error for this situation, there was a FIXME in the ld code about exactly this..

So I think the testcase (and the x86_64 kernel script) is invalid.  If we revert http://sourceware.org/ml/binutils/2010-12/msg00557.html then that will change one of the DEFINED() tests, ld-scripts/default-script2.d, which was added exactly to test the interaction between --defsym and -T scripts.

That said, I'm not completely happy with my patch so will probably revert it;  I don't like needing expld.uses_defined.
Comment 6 Sedat Dilek 2011-01-11 12:10:18 UTC
Wouldn't it be easier to just apply H.J. new patch on top of binutils trunk?

I a 2nd thought I am thinking of cherry-picking PR ld/12237 (which is in binutils/experimental, see [1]), PR ld/12001 + PR ld/12356 for binutils-2_21-branch [2]. Not sure if reverting the patch is such a good idea.

I am running here a debianized version with the 3 patches for i386 since 02-Jan-2010.

- Sedat -

[1] http://packages.debian.org/changelogs/pool/main/b/binutils/binutils_2.21-3/changelog
[2] http://sourceware.org/git/?p=binutils.git;a=shortlog;h=refs/heads/binutils-2_21-branch
Comment 7 Sedat Dilek 2011-01-11 12:15:39 UTC
When dropping PR ld/12001 patch, what's with the testcase as reference to it [1]?

- Sedat -

[1] "Add a testcase for PR ld/12001."
http://sourceware.org/git/?p=binutils.git;a=commit;h=337876745f53fc36ec4a3e667b5242938c1f21d3
Comment 8 Sourceware Commits 2011-01-13 13:06:25 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-01-13 13:06:22

Modified files:
	ld             : ChangeLog ldexp.h ldexp.c ldctor.c ldgram.y 
	                 ldlang.c mri.c 
	ld/emultempl   : beos.em pe.em pep.em spuelf.em xtensaelf.em 

Log message:
	PR ld/12356
	* ldexp.h (exp_assop): Delete.
	(exp_assign, exp_defsym): Declare.
	* ldexp.c (exp_assop): Make static, handle all assignment variations.
	(exp_assign, exp_defsym): New functions.
	(exp_provide): Use exp_assop.
	* ldgram.y (defsym_expr): Use exp_defsym.
	* ldctor.c, * ldgram.y, * ldlang.c, * mri.c, * emultempl/beos.em,
	* emultempl/pe.em, * emultempl/pep.em, * emultempl/spuelf.em,
	* emultempl/xtensaelf.em: Update exp_assop -> exp_assign.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2268&r2=1.2269
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.h.diff?cvsroot=src&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.c.diff?cvsroot=src&r1=1.90&r2=1.91
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldctor.c.diff?cvsroot=src&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldgram.y.diff?cvsroot=src&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.357&r2=1.358
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/mri.c.diff?cvsroot=src&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emultempl/beos.em.diff?cvsroot=src&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emultempl/pe.em.diff?cvsroot=src&r1=1.165&r2=1.166
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emultempl/pep.em.diff?cvsroot=src&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emultempl/spuelf.em.diff?cvsroot=src&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emultempl/xtensaelf.em.diff?cvsroot=src&r1=1.27&r2=1.28
Comment 9 Sourceware Commits 2011-01-13 13:29:59 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-01-13 13:29:55

Modified files:
	ld             : ChangeLog ld.texinfo ld.h ldgram.y ldlex.l 
	                 ldemul.c ldexp.h ldexp.c ldlang.h ldlang.c 

Log message:
	PR ld/12356
	* ld.texinfo (Miscellaneous Commands): Describe LD_FEATURE.
	(Expression Section): Update.
	* ld.h (ld_config_type): Add sane_expr.
	* ldgram.y (ifile_p1): Add LD_FEATURE.
	* ldlex.l (LD_FEATYRE): New.
	* ldemul.c (after_parse_default): Delete code handling ld_compatibility.
	* ldexp.h (struct ldexp_control): Delete uses_defined.
	* ldexp.c: Remove all uses of uses_defined.
	(fold_name): Test config.sane_expr rather than ld_compatibility.
	(exp_fold_tree_1): Likewise.  Adjust handling of assignments
	during first phase.
	* ldlang.h (ld_compatibility): Delete.
	(lang_ld_feature): Declare.
	* ldlang.c (ld_compatibility): Delete.
	(open_input_bfds): Only handle assignments for --defsym.
	(lang_ld_feature): New function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2269&r2=1.2270
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ld.texinfo.diff?cvsroot=src&r1=1.269&r2=1.270
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ld.h.diff?cvsroot=src&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldgram.y.diff?cvsroot=src&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlex.l.diff?cvsroot=src&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldemul.c.diff?cvsroot=src&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.h.diff?cvsroot=src&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.c.diff?cvsroot=src&r1=1.91&r2=1.92
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.h.diff?cvsroot=src&r1=1.93&r2=1.94
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.358&r2=1.359
Comment 10 Sourceware Commits 2011-01-13 17:07:56 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-01-13 17:07:52

Modified files:
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-scripts: defined.exp 
Added files:
	ld/testsuite/ld-scripts: defined5.d defined5.s defined5.t 

Log message:
	Add a testcase for PR ld/12356.
	
	2011-01-13  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/12356
	* ld-scripts/defined.exp: Run defined5.
	
	* ld-scripts/defined5.d: New.
	* ld-scripts/defined5.s: Likewise.
	* ld-scripts/defined5.t: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1356&r2=1.1357
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-scripts/defined5.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-scripts/defined5.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-scripts/defined5.t.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-scripts/defined.exp.diff?cvsroot=src&r1=1.12&r2=1.13
Comment 11 Alan Modra 2011-01-14 03:02:48 UTC
fixed