Bug 12726 - cannot move location counter backwards, assignment related regression
Summary: cannot move location counter backwards, assignment related regression
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-03 10:46 UTC by Richard Guenther
Modified: 2011-05-03 15:18 UTC (History)
1 user (show)

See Also:
Host:
Target: i?86-*-*
Build:
Last reconfirmed:


Attachments
testcase (17.82 KB, application/x-bzip)
2011-05-03 10:46 UTC, Richard Guenther
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Guenther 2011-05-03 10:46:36 UTC
Created attachment 5702 [details]
testcase

While the 2.21 release links the attached testcase just fine, the 2.21 branch
taken at Apr 19th fails to link it with

> ld -T romlayout32seg.lds code32seg.o -o rom32seg.o
romlayout32seg.lds:66 cannot move location counter backwards (from 00000000000067b0 to 00000000000067a0)

If one changes the linker script to add 0x4 more room for the sections
(which corresponds to their alignment) like

*(.rodata.__func__.10274)
. = ( 0x6782 - code32seg_start ) ;
*(.rodata.__func__.8035)
. = ( 0x6796 - code32seg_start ) ;
*(.rodata.__func__.8048)
. = ( 0x67aa - code32seg_start ) ;
*(.rodata.__func__.8075)
. = ( 0x67c0 - code32seg_start ) ;
*(.rodata.__func__.8115)

then the link succeeds.  This looks like a bogus alignment calculation
as with the size of 0xe for the section 0x10 should be enough space
to properly align the data.
Comment 1 Richard Guenther 2011-05-03 10:54:15 UTC
Similar issue happens on 64bit.
Comment 2 Richard Guenther 2011-05-03 11:23:27 UTC
Confirmed also with the current 2.21 branch head and also with

2010-12-04  Alan Modra  <amodra@gmail.com>

        * ldlang.c (lang_size_sections_1): Align lma using same alignment
        as for vma.

reverted (that just looked maybe related).
Comment 3 Alan Modra 2011-05-03 13:24:52 UTC
Mine.  Looks to be caused by the fix for PR12380.  That delayed setting expld.phase = lang_final_phase_enum until just before the final lang_do_assignments, breaking the assignments done in lang_relax_sections.
Comment 4 cvs-commit@gcc.gnu.org 2011-05-03 14:56:18 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-05-03 14:56:14

Modified files:
	ld             : ChangeLog ldexp.c ldexp.h ldlang.c ldlang.h 
	                 pe-dll.c 

Log message:
	PR ld/12726
	* ldexp.h (lang_phase_type): Add lang_assigning_phase_enum.
	* ldexp.c (exp_fold_tree_1): Correct assign to dot comment.  Don't
	assign to dot when lang_assigning_phase_enum.
	* ldlang.h (lang_do_assignments): Update prototype.
	* ldlang.c (lang_do_assignments): Add phase parameter.  Update all
	callers.
	* pe-dll.c (pe_dll_fill_sections, pe_exe_fill_sections): Update
	lang_do_assignments calls.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2324&r2=1.2325
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.c.diff?cvsroot=src&r1=1.93&r2=1.94
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.h.diff?cvsroot=src&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.366&r2=1.367
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.h.diff?cvsroot=src&r1=1.96&r2=1.97
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/pe-dll.c.diff?cvsroot=src&r1=1.136&r2=1.137
Comment 5 cvs-commit@gcc.gnu.org 2011-05-03 15:16:51 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_21-branch
Changes by:	amodra@sourceware.org	2011-05-03 15:16:40

Modified files:
	ld             : ChangeLog ldexp.c ldexp.h ldlang.c ldlang.h 
	                 pe-dll.c 

Log message:
	PR ld/12726
	* ldexp.h (lang_phase_type): Add lang_assigning_phase_enum.
	* ldexp.c (exp_fold_tree_1): Correct assign to dot comment.  Don't
	assign to dot when lang_assigning_phase_enum.
	* ldlang.h (lang_do_assignments): Update prototype.
	* ldlang.c (lang_do_assignments): Add phase parameter.  Update all
	callers.
	* pe-dll.c (pe_dll_fill_sections, pe_exe_fill_sections): Update
	lang_do_assignments calls.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.2222.2.20&r2=1.2222.2.21
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.87.2.1&r2=1.87.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldexp.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.23.2.1&r2=1.23.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.347.2.3&r2=1.347.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.91.2.2&r2=1.91.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/pe-dll.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.133&r2=1.133.2.1
Comment 6 Alan Modra 2011-05-03 15:18:26 UTC
Fixed