* ldlang.c (lang_insert_orphan): Place loadable orphans in the same
authorDaniel Jacobowitz <drow@false.org>
Tue, 16 Mar 2010 14:14:40 +0000 (14:14 +0000)
committerDaniel Jacobowitz <drow@false.org>
Tue, 16 Mar 2010 14:14:40 +0000 (14:14 +0000)
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
ld/ldlang.c
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/orphan-region.d [new file with mode: 0644]
ld/testsuite/ld-elf/orphan-region.ld [new file with mode: 0644]
ld/testsuite/ld-elf/orphan-region.s [new file with mode: 0644]

index db1a3054569f5d4e8a3781edbfcc778d9b110a3c..427ac44abe724df2e0e0b3b1c158a508acbdebec 100644 (file)
@@ -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.
index 913f2b28a7e66b54bd192b5722a1444284f02e25..3d316c5f0411f845ee9aaeaae3fb14dfa946b94b 100644 (file)
@@ -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')
     {
index 3ceacd48d0c9abd9df5a84e4d91a0764a79711d5..6db73e8e4e995a5bd4bd5fee02eb94ba5e0b948b 100644 (file)
@@ -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 (file)
index 0000000..eb3d2cf
--- /dev/null
@@ -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 (file)
index 0000000..e20cbaf
--- /dev/null
@@ -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 (file)
index 0000000..0268686
--- /dev/null
@@ -0,0 +1,8 @@
+       .text
+       .long 0
+       .section ".rodata", "a", %progbits
+       .long 0
+       .section ".moredata", "a", %progbits
+       .long 0
+       .section ".notdata", "", %progbits
+       .long 0