This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
fix PR15222, excessive LMA alignment
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 5 Mar 2013 13:22:40 +1030
- Subject: fix PR15222, excessive LMA alignment
When fixing http://sourceware.org/ml/binutils/2010-11/msg00485.html, I
aligned LMAs without regard to whether the VMA and LMA regions were
the same. This even though that bug report was clearly about the case
where the load and runtime region were equal.. Now we have another bug
report about excessive alignment in the lma_region. I think we can make
both embedded users happy with the following.
ld/
PR ld/15222
* ldlang.c (lang_size_sections_1): When given an lma_region align
LMA as per VMA only if lma_region is the same as region.
ld/testsuite/
* ld-scripts/rgn-at6.s, * ld-scripts/rgn-at6.t, * ld-scripts/rgn-at6.d,
* ld-scripts/rgn-at7.t, * ld-scripts/rgn-at7.d: New tests.
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.404
diff -u -p -r1.404 ldlang.c
--- ld/ldlang.c 11 Feb 2013 02:07:20 -0000 1.404
+++ ld/ldlang.c 5 Mar 2013 00:00:56 -0000
@@ -4963,6 +4963,13 @@ lang_size_sections_1
{
bfd_vma lma = os->lma_region->current;
+ /* When LMA_REGION is the same as REGION, align the LMA
+ as we did for the VMA, possibly including alignment
+ from the bfd section. If a different region, then
+ only align according to the value in the output
+ statement. */
+ if (os->lma_region != os->region)
+ section_alignment = os->section_alignment;
if (section_alignment > 0)
lma = align_power (lma, section_alignment);
os->bfd_section->lma = lma;
Index: ld/testsuite/ld-scripts/rgn-at6.d
===================================================================
RCS file: ld/testsuite/ld-scripts/rgn-at6.d
diff -N ld/testsuite/ld-scripts/rgn-at6.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-scripts/rgn-at6.d 5 Mar 2013 00:56:25 -0000
@@ -0,0 +1,9 @@
+#source: rgn-at6.s
+#ld: -T rgn-at6.t
+#objdump: -h --wide
+#xfail: rx-*-*
+# Test that lma is aligned as for vma when lma_region==region.
+
+#...
+.* 0+10000 +0+10000 .*
+.* 0+10100 +0+10100 .*
Index: ld/testsuite/ld-scripts/rgn-at6.s
===================================================================
RCS file: ld/testsuite/ld-scripts/rgn-at6.s
diff -N ld/testsuite/ld-scripts/rgn-at6.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-scripts/rgn-at6.s 5 Mar 2013 00:56:25 -0000
@@ -0,0 +1,6 @@
+ .text
+ .long 0
+
+ .data
+ .p2align 8
+ .long 0
Index: ld/testsuite/ld-scripts/rgn-at6.t
===================================================================
RCS file: ld/testsuite/ld-scripts/rgn-at6.t
diff -N ld/testsuite/ld-scripts/rgn-at6.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-scripts/rgn-at6.t 5 Mar 2013 00:56:25 -0000
@@ -0,0 +1,11 @@
+MEMORY
+{
+ ram : ORIGIN = 0x10000, LENGTH = 0x10000
+}
+
+SECTIONS
+{
+ .text : {*(.text)} > ram AT> ram
+ .data : ALIGN (16) {*(.data)} > ram AT> ram
+ /DISCARD/ : {*(*)}
+}
Index: ld/testsuite/ld-scripts/rgn-at7.d
===================================================================
RCS file: ld/testsuite/ld-scripts/rgn-at7.d
diff -N ld/testsuite/ld-scripts/rgn-at7.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-scripts/rgn-at7.d 5 Mar 2013 00:56:25 -0000
@@ -0,0 +1,9 @@
+#source: rgn-at6.s
+#ld: -T rgn-at7.t
+#objdump: -h --wide
+#xfail: rx-*-*
+# Test that lma is only aligned by script when lma_region!=region.
+
+#...
+.* 0+10000 +0+20000 .*
+.* 0+10100 +0+20010 .*
Index: ld/testsuite/ld-scripts/rgn-at7.t
===================================================================
RCS file: ld/testsuite/ld-scripts/rgn-at7.t
diff -N ld/testsuite/ld-scripts/rgn-at7.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-scripts/rgn-at7.t 5 Mar 2013 00:56:25 -0000
@@ -0,0 +1,12 @@
+MEMORY
+{
+ ram : ORIGIN = 0x10000, LENGTH = 0x10000
+ rom : ORIGIN = 0x20000, LENGTH = 0x10000
+}
+
+SECTIONS
+{
+ .text : {*(.text)} > ram AT> rom
+ .data : ALIGN (16) {*(.data)} > ram AT> rom
+ /DISCARD/ : {*(*)}
+}
--
Alan Modra
Australia Development Lab, IBM