From 13762d2ee43b8b49d5d26a87c5496439d829bc6a Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 5 Mar 2013 02:55:27 +0000 Subject: [PATCH] PR ld/15222 ld/ * 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. --- ld/ChangeLog | 6 ++++++ ld/ldlang.c | 7 +++++++ ld/testsuite/ChangeLog | 5 +++++ ld/testsuite/ld-scripts/rgn-at6.d | 9 +++++++++ ld/testsuite/ld-scripts/rgn-at6.s | 6 ++++++ ld/testsuite/ld-scripts/rgn-at6.t | 11 +++++++++++ ld/testsuite/ld-scripts/rgn-at7.d | 9 +++++++++ ld/testsuite/ld-scripts/rgn-at7.t | 12 ++++++++++++ 8 files changed, 65 insertions(+) create mode 100644 ld/testsuite/ld-scripts/rgn-at6.d create mode 100644 ld/testsuite/ld-scripts/rgn-at6.s create mode 100644 ld/testsuite/ld-scripts/rgn-at6.t create mode 100644 ld/testsuite/ld-scripts/rgn-at7.d create mode 100644 ld/testsuite/ld-scripts/rgn-at7.t diff --git a/ld/ChangeLog b/ld/ChangeLog index 8b15d2a63be..d24b2661ed1 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2013-03-05 Alan Modra + + 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. + 2013-02-27 Nick Clifton * scripttempl/elf32msp430.sc: Add placement of .data.* sections. diff --git a/ld/ldlang.c b/ld/ldlang.c index 65d8bbdfb6d..08aa32aa0c4 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -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; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 0db8fe702ad..dd4ded2fc11 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-03-05 Alan Modra + + * 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. + 2013-02-28 Nathan Sidwell * ld-arm/tls-local-static.s: New test. diff --git a/ld/testsuite/ld-scripts/rgn-at6.d b/ld/testsuite/ld-scripts/rgn-at6.d new file mode 100644 index 00000000000..80f9b8adba3 --- /dev/null +++ b/ld/testsuite/ld-scripts/rgn-at6.d @@ -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 .* diff --git a/ld/testsuite/ld-scripts/rgn-at6.s b/ld/testsuite/ld-scripts/rgn-at6.s new file mode 100644 index 00000000000..20571bc1a23 --- /dev/null +++ b/ld/testsuite/ld-scripts/rgn-at6.s @@ -0,0 +1,6 @@ + .text + .long 0 + + .data + .p2align 8 + .long 0 diff --git a/ld/testsuite/ld-scripts/rgn-at6.t b/ld/testsuite/ld-scripts/rgn-at6.t new file mode 100644 index 00000000000..0408dcdf3f9 --- /dev/null +++ b/ld/testsuite/ld-scripts/rgn-at6.t @@ -0,0 +1,11 @@ +MEMORY +{ + ram : ORIGIN = 0x10000, LENGTH = 0x10000 +} + +SECTIONS +{ + .text : {*(.text)} > ram AT> ram + .data : ALIGN (16) {*(.data)} > ram AT> ram + /DISCARD/ : {*(*)} +} diff --git a/ld/testsuite/ld-scripts/rgn-at7.d b/ld/testsuite/ld-scripts/rgn-at7.d new file mode 100644 index 00000000000..a12ca17bde5 --- /dev/null +++ b/ld/testsuite/ld-scripts/rgn-at7.d @@ -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 .* diff --git a/ld/testsuite/ld-scripts/rgn-at7.t b/ld/testsuite/ld-scripts/rgn-at7.t new file mode 100644 index 00000000000..c1f278975c8 --- /dev/null +++ b/ld/testsuite/ld-scripts/rgn-at7.t @@ -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/ : {*(*)} +} -- 2.30.2