aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2010-03-16 14:14:40 +0000
committerDaniel Jacobowitz <drow@false.org>2010-03-16 14:14:40 +0000
commitf77c3948254d0653c6957562cba846107dcb6d89 (patch)
tree1dfb5859f3769445a4327ce4df66df120775026e
parent99164030b983b819ff55debcd0c7d9e2d91e84ee (diff)
downloadgdb-f77c3948254d0653c6957562cba846107dcb6d89.zip
gdb-f77c3948254d0653c6957562cba846107dcb6d89.tar.gz
gdb-f77c3948254d0653c6957562cba846107dcb6d89.tar.bz2
* 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.
-rw-r--r--ld/ChangeLog5
-rw-r--r--ld/ldlang.c15
-rw-r--r--ld/testsuite/ChangeLog5
-rw-r--r--ld/testsuite/ld-elf/orphan-region.d16
-rw-r--r--ld/testsuite/ld-elf/orphan-region.ld10
-rw-r--r--ld/testsuite/ld-elf/orphan-region.s8
6 files changed, 58 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index db1a305..427ac44 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-15 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * ldlang.c (lang_insert_orphan): Place loadable orphans in the same
+ region and phdrs as their placement section.
+
2010-03-15 Alan Modra <amodra@gmail.com>
* emultempl/ppc64elf.em (move_input_section, sort_toc_sections): New.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 913f2b2..3d316c5 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 3ceacd4..6db73e8 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-15 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * ld-elf/orphan-region.d, ld-elf/orphan-region.ld,
+ ld-elf/orphan-region.s: New files.
+
2010-03-02 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
* 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 0000000..eb3d2cf
--- /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 0000000..e20cbaf
--- /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 0000000..0268686
--- /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