From f77c3948254d0653c6957562cba846107dcb6d89 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Tue, 16 Mar 2010 14:14:40 +0000 Subject: [PATCH] * ldlang.c (lang_insert_orphan): Place loadable orphans in the same region and phdrs as their placement section. testsuite/ * ld-elf/orphan-region.d, ld-elf/orphan-region.ld, ld-elf/orphan-region.s: New files. --- ld/ChangeLog | 5 +++++ ld/ldlang.c | 15 ++++++++++++++- ld/testsuite/ChangeLog | 5 +++++ ld/testsuite/ld-elf/orphan-region.d | 16 ++++++++++++++++ ld/testsuite/ld-elf/orphan-region.ld | 10 ++++++++++ ld/testsuite/ld-elf/orphan-region.s | 8 ++++++++ 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-elf/orphan-region.d create mode 100644 ld/testsuite/ld-elf/orphan-region.ld create mode 100644 ld/testsuite/ld-elf/orphan-region.s diff --git a/ld/ChangeLog b/ld/ChangeLog index db1a3054569..427ac44abe7 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2010-03-15 Daniel Jacobowitz + + * ldlang.c (lang_insert_orphan): Place loadable orphans in the same + region and phdrs as their placement section. + 2010-03-15 Alan Modra * emultempl/ppc64elf.em (move_input_section, sort_toc_sections): New. diff --git a/ld/ldlang.c b/ld/ldlang.c index 913f2b28a7e..3d316c5f041 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1761,7 +1761,20 @@ lang_insert_orphan (asection *s, add_child = &os->children; lang_add_section (add_child, s, os); - lang_leave_output_section_statement (0, "*default*", NULL, NULL); + if (after && (s->flags & (SEC_LOAD | SEC_ALLOC)) != 0) + { + const char *region = (after->region + ? after->region->name_list.name + : DEFAULT_MEMORY_REGION); + const char *lma_region = (after->lma_region + ? after->lma_region->name_list.name + : NULL); + lang_leave_output_section_statement (NULL, region, after->phdrs, + lma_region); + } + else + lang_leave_output_section_statement (NULL, DEFAULT_MEMORY_REGION, NULL, + NULL); if (ps != NULL && *ps == '\0') { diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 3ceacd48d0c..6db73e8e4e9 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-03-15 Daniel Jacobowitz + + * ld-elf/orphan-region.d, ld-elf/orphan-region.ld, + ld-elf/orphan-region.s: New files. + 2010-03-02 Matthew Gretton-Dann * ld-arm/arm-merge-incompatible.d: New test. diff --git a/ld/testsuite/ld-elf/orphan-region.d b/ld/testsuite/ld-elf/orphan-region.d new file mode 100644 index 00000000000..eb3d2cfb684 --- /dev/null +++ b/ld/testsuite/ld-elf/orphan-region.d @@ -0,0 +1,16 @@ +#source: orphan-region.s +#ld: -T orphan-region.ld +#readelf: -S -l --wide + +#... + \[[ 0-9]+\] \.text[ \t]+PROGBITS[ \t]+0*40000000[ \t]+.* + \[[ 0-9]+\] \.rodata[ \t]+PROGBITS[ \t]+0*400000[0-9a-f]+[ \t]+.* + \[[ 0-9]+\] \.moredata[ \t]+PROGBITS[ \t]+0*400000[0-9a-f]+[ \t]+.* +#... +Program Headers: + Type.* + LOAD[ \t]+0x[0-9a-f]+ 0x0*40000000 0x0*40000000 0x[0-9a-f]+ 0x[0-9a-f]+ R E 0x[0-9a-f]+ + + Section to Segment mapping: + Segment Sections... + 00 .text .rodata .moredata * diff --git a/ld/testsuite/ld-elf/orphan-region.ld b/ld/testsuite/ld-elf/orphan-region.ld new file mode 100644 index 00000000000..e20cbafc131 --- /dev/null +++ b/ld/testsuite/ld-elf/orphan-region.ld @@ -0,0 +1,10 @@ +MEMORY +{ + region : ORIGIN = 0x40000000, LENGTH = 8M +} + +SECTIONS +{ + .text : ALIGN (4) { *(.text) } > region + .rodata : ALIGN (4) { *(.rodata) } > region +} \ No newline at end of file diff --git a/ld/testsuite/ld-elf/orphan-region.s b/ld/testsuite/ld-elf/orphan-region.s new file mode 100644 index 00000000000..0268686ab7a --- /dev/null +++ b/ld/testsuite/ld-elf/orphan-region.s @@ -0,0 +1,8 @@ + .text + .long 0 + .section ".rodata", "a", %progbits + .long 0 + .section ".moredata", "a", %progbits + .long 0 + .section ".notdata", "", %progbits + .long 0 -- 2.30.2