* elf.c (_bfd_elf_get_dynamic_reloc_upper_bound)
authorDaniel Jacobowitz <drow@false.org>
Tue, 29 Apr 2008 11:53:45 +0000 (11:53 +0000)
committerDaniel Jacobowitz <drow@false.org>
Tue, 29 Apr 2008 11:53:45 +0000 (11:53 +0000)
(_bfd_elf_canonicalize_dynamic_reloc): Find dynamic relocations
even if they are not loaded.
* elflink.c (_bfd_elf_init_2_index_sections): Set data_index_section
first.

* ld-arm/symbian-seg1.s, ld-arm/symbian-seg1.d: New files.
* ld-arm/arm-elf.exp: Run symbian-seg1.

bfd/ChangeLog
bfd/elf.c
bfd/elflink.c
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/symbian-seg1.d [new file with mode: 0644]
ld/testsuite/ld-arm/symbian-seg1.s [new file with mode: 0644]

index d652d97e94dd5ce4acb21e6a52f1f8983702b56f..6253bb58e68ea7cbad7c9e298453c51cfc3ecbc0 100644 (file)
@@ -1,3 +1,11 @@
+2008-04-29  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * elf.c (_bfd_elf_get_dynamic_reloc_upper_bound)
+       (_bfd_elf_canonicalize_dynamic_reloc): Find dynamic relocations
+       even if they are not loaded.
+       * elflink.c (_bfd_elf_init_2_index_sections): Set data_index_section
+       first.
+
 2008-04-25  Jay Foad  <jay.foad@gmail.com>
 
        * reloc16.c (bfd_coff_reloc16_get_value): Add support for
index f1019d6b4495c8169384e543cf60f68da904a9b9..c4a88ee2db304482936d5faaf8b015116347edca 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6520,8 +6520,7 @@ _bfd_elf_get_dynamic_reloc_upper_bound (bfd *abfd)
 
   ret = sizeof (arelent *);
   for (s = abfd->sections; s != NULL; s = s->next)
-    if ((s->flags & SEC_LOAD) != 0
-       && elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
+    if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
        && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
            || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
       ret += ((s->size / elf_section_data (s)->this_hdr.sh_entsize)
@@ -6557,8 +6556,7 @@ _bfd_elf_canonicalize_dynamic_reloc (bfd *abfd,
   ret = 0;
   for (s = abfd->sections; s != NULL; s = s->next)
     {
-      if ((s->flags & SEC_LOAD) != 0
-         && elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
+      if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
          && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
              || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
        {
index 28282f6c97f0f9c2a3c52927200659275946b711..de1939ac7c8b2a6aa7c1291023becfcce3d96827 100644 (file)
@@ -6131,20 +6131,22 @@ _bfd_elf_init_2_index_sections (bfd *output_bfd, struct bfd_link_info *info)
 {
   asection *s;
 
+  /* Data first, since setting text_index_section changes
+     _bfd_elf_link_omit_section_dynsym.  */
   for (s = output_bfd->sections; s != NULL; s = s->next)
-    if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY))
-        == (SEC_ALLOC | SEC_READONLY))
+    if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
        && !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
       {
-       elf_hash_table (info)->text_index_section = s;
+       elf_hash_table (info)->data_index_section = s;
        break;
       }
 
   for (s = output_bfd->sections; s != NULL; s = s->next)
-    if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
+    if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY))
+        == (SEC_ALLOC | SEC_READONLY))
        && !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
       {
-       elf_hash_table (info)->data_index_section = s;
+       elf_hash_table (info)->text_index_section = s;
        break;
       }
 
index 5a850f3b0f7dd2897ed3c9a6a525db6392a8cb1e..275bb070bf48150d3994a42d29853c9abc1eb77b 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-29  Daniel Jacobowitz  <dan@codesourcery.com>
+       * ld-arm/symbian-seg1.s, ld-arm/symbian-seg1.d: New files.
+       * ld-arm/arm-elf.exp: Run symbian-seg1.
+
 2008-04-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        * ld-scripts/rgn-over8.s: Tweak.
index 81b9f751828170d2437e0c1213b68a3619f6f0ca..7447b7c0bc108d49a606e9ab8ccc09e2259a6b94 100644 (file)
@@ -47,6 +47,10 @@ if {[istarget "arm-*-vxworks"]} {
     run_dump_test "emit-relocs1-vxworks"
 }
 
+if { [istarget "arm*-*-symbianelf*"] } {
+    run_dump_test "symbian-seg1"
+}
+
 # Exclude non-ARM-ELF targets.
 
 if { ![is_elf_format] || ![istarget "arm*-*-*"] } {
diff --git a/ld/testsuite/ld-arm/symbian-seg1.d b/ld/testsuite/ld-arm/symbian-seg1.d
new file mode 100644 (file)
index 0000000..21d8a00
--- /dev/null
@@ -0,0 +1,8 @@
+#source: symbian-seg1.s
+#ld: -Ttext 0x10000 -Tdata 0x400000
+#objdump: -dR
+#...
+ +10000:       00400000        .word   0x00400000
+       +10000: R_ARM_RELATIVE  .data
+ +10004:       00010008        .word   0x00010008
+       +10004: R_ARM_RELATIVE  .text
diff --git a/ld/testsuite/ld-arm/symbian-seg1.s b/ld/testsuite/ld-arm/symbian-seg1.s
new file mode 100644 (file)
index 0000000..8f893a2
--- /dev/null
@@ -0,0 +1,13 @@
+        .text
+       .globl  _start
+_start:
+        .word   datavar
+        .word   rodatavar
+
+        .section ".rodata", "a"
+rodatavar:
+        .word 0
+
+        .section ".data", "aw"
+datavar:
+        .word 0