bfd/ChangeLog:
authorEric Christopher <echristo@gmail.com>
Thu, 24 Mar 2005 01:30:47 +0000 (01:30 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 24 Mar 2005 01:30:47 +0000 (01:30 +0000)
2005-03-23  Eric Christopher  <echristo@redhat.com>

* elfxx-mips.c (MIPS_ELF_READONLY_SECTION): New.
(mips_elf_calculate_relocation): Use. Define DF_TEXTREL
after emitting relocation.
(_bfd_mips_elf_adjust_dynamic_symbol): Ditto.
(_bfd_mips_elf_check_relocs): Remove code to set DF_TEXTREL
and readonly_reloc.

ld/testsuite/ChangeLog:

2005-03-23  Eric Christopher  <echristo@redhat.com>

* ld-mips-elf/textrel-1.s, ld-mips-elf/textrel-1.d: New
test.
* ld-mips-elf/mips-elf.exp: Call it.
* ld-mips-elf/rel32-n32.d: Update for DF_TEXTREL removal.
* ld-mips-elf/rel32-o32.d: Ditto.
* ld-mips-elf/rel64.d: Ditto.

bfd/ChangeLog
bfd/elfxx-mips.c
ld/testsuite/ChangeLog
ld/testsuite/ld-mips-elf/mips-elf.exp
ld/testsuite/ld-mips-elf/rel32-n32.d
ld/testsuite/ld-mips-elf/rel32-o32.d
ld/testsuite/ld-mips-elf/rel64.d
ld/testsuite/ld-mips-elf/textrel-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/textrel-1.s [new file with mode: 0644]

index 9ee10a9bf379b46b8d969779b42d5644a4e83c9d..b15a3d571bfc7b7c6786251d5a8967f4b8552acd 100644 (file)
@@ -1,3 +1,12 @@
+2005-03-23  Eric Christopher  <echristo@redhat.com>
+
+       * elfxx-mips.c (MIPS_ELF_READONLY_SECTION): New.
+       (mips_elf_calculate_relocation): Use. Define DF_TEXTREL
+       after emitting relocation.
+       (_bfd_mips_elf_adjust_dynamic_symbol): Ditto.
+       (_bfd_mips_elf_check_relocs): Remove code to set DF_TEXTREL
+       and readonly_reloc.
+
 2005-03-23  Mike Frysinger  <vapier@gentoo.org>
            Nick Clifton  <nickc@redhat.com>
 
index a4baea95138002b5ba71f9ef1100a930bf33e6ff..951d1a72f300b94e7eba4b7c94f2d1dfc653fc8c 100644 (file)
@@ -478,6 +478,11 @@ static bfd *reldyn_sorting_bfd;
 #define MIPS_ELF_OPTIONS_SECTION_NAME(abfd) \
   (NEWABI_P (abfd) ? ".MIPS.options" : ".options")
 
+/* Whether the section is readonly.  */
+#define MIPS_ELF_READONLY_SECTION(sec)                 \
+  ((sec->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))        \
+   == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
+
 /* The name of the stub section.  */
 #define MIPS_ELF_STUB_SECTION_NAME(abfd) ".MIPS.stubs"
 
@@ -4005,6 +4010,10 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
                                                   &value,
                                                   input_section))
            return bfd_reloc_undefined;
+
+         /* If we've written this we need to set DF_TEXTREL here.  */
+         if (MIPS_ELF_READONLY_SECTION (input_section))
+           info->flags |= DF_TEXTREL;
        }
       else
        {
@@ -6101,33 +6110,21 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
                  if (sreloc == NULL)
                    return FALSE;
                }
-#define MIPS_READONLY_SECTION (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
+
              if (info->shared)
-               {
-                 /* When creating a shared object, we must copy these
-                    reloc types into the output file as R_MIPS_REL32
-                    relocs.  We make room for this reloc in the
-                    .rel.dyn reloc section.  */
-                 mips_elf_allocate_dynamic_relocations (dynobj, 1);
-                 if ((sec->flags & MIPS_READONLY_SECTION)
-                     == MIPS_READONLY_SECTION)
-                   /* We tell the dynamic linker that there are
-                      relocations against the text segment.  */
-                   info->flags |= DF_TEXTREL;
-               }
+               /* When creating a shared object, we must copy these
+                  reloc types into the output file as R_MIPS_REL32
+                  relocs.  We make room for this reloc in the
+                  .rel.dyn reloc section.  */
+               mips_elf_allocate_dynamic_relocations (dynobj, 1);
              else
                {
                  struct mips_elf_link_hash_entry *hmips;
-
+                 
                  /* We only need to copy this reloc if the symbol is
                      defined in a dynamic object.  */
                  hmips = (struct mips_elf_link_hash_entry *) h;
                  ++hmips->possibly_dynamic_relocs;
-                 if ((sec->flags & MIPS_READONLY_SECTION)
-                     == MIPS_READONLY_SECTION)
-                   /* We need it to tell the dynamic linker if there
-                      are relocations against the text segment.  */
-                   hmips->readonly_reloc = TRUE;
                }
 
              /* Even though we don't directly need a GOT entry for
@@ -6423,9 +6420,12 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       && (h->root.type == bfd_link_hash_defweak
          || !h->def_regular))
     {
+      asection *sec;
+      sec = mips_elf_rel_dyn_section (dynobj, FALSE);
       mips_elf_allocate_dynamic_relocations (dynobj,
                                             hmips->possibly_dynamic_relocs);
-      if (hmips->readonly_reloc)
+
+      if (MIPS_ELF_READONLY_SECTION (sec))
        /* We tell the dynamic linker that there are relocations
           against the text segment.  */
        info->flags |= DF_TEXTREL;
index 657c79678a0d4e9b10488499f4c37f17e3eb9ef4..8e8c09d6e3a7964ed380bd3ad3c0ac0c1c170fff 100644 (file)
@@ -1,3 +1,12 @@
+2005-03-23  Eric Christopher  <echristo@redhat.com>
+
+       * ld-mips-elf/textrel-1.s, ld-mips-elf/textrel-1.d: New
+       test.
+       * ld-mips-elf/mips-elf.exp: Call it.
+       * ld-mips-elf/rel32-n32.d: Update for DF_TEXTREL removal.
+       * ld-mips-elf/rel32-o32.d: Ditto.
+       * ld-mips-elf/rel64.d: Ditto.
+
 2005-03-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        * ld-cris/expdyn5.d: Updated for alignment change in elf.sc.
index 5413a729f0f3bed7fa37ecf69680c9b12eeded79..b07f709070f90fbb988472ab8ad1ccd3715389a2 100644 (file)
@@ -101,6 +101,10 @@ if {$has_newabi} {
     run_dump_test "mips16-hilo-n32"
 }
 
+if { $linux_gnu } {
+    run_dump_test "textrel-1"
+}
+
 # For tests which may involve multiple files, use run_ld_link_tests.
 
 # List contains test-items with 3 items followed by 2 lists:
index cff8b3627611f5e230c4c43037ea09a190e49f7a..565742a816a6c571cfec3f8875b153ec7f5c59dc 100644 (file)
@@ -4,12 +4,12 @@
 #readelf: -x 5 -r
 #ld: -shared -melf32btsmipn32
 
-Relocation section '.rel.dyn' at offset 0x304 contains 2 entries:
+Relocation section '.rel.dyn' at offset 0x2fc contains 2 entries:
  Offset     Info    Type            Sym.Value  Sym. Name
 00000000  00000000 R_MIPS_NONE      
-00000330  00000003 R_MIPS_REL32     
+00000320  00000003 R_MIPS_REL32     
 
 Hex dump of section '.text':
-  0x00000320 00000000 00000000 00000000 00000000 ................
-  0x00000330 00000330 00000000 00000000 00000000 ................
-  0x00000340 00000000 00000000 00000000 00000000 ................
+  0x00000310 00000000 00000000 00000000 00000000 ................
+  0x00000320 00000320 00000000 00000000 00000000 ................
+  0x00000330 00000000 00000000 00000000 00000000 ................
index 982758a0c7a5837d24741567ed9447c5e09ee382..d89b87a2d7a24a9de6bfc0ae6adfa478a2880baf 100644 (file)
@@ -4,7 +4,7 @@
 #readelf: -x 6 -r
 #ld: -shared -melf32btsmip
 
-Relocation section '.rel.dyn' at offset 0x31c contains 2 entries:
+Relocation section '.rel.dyn' at offset 0x314 contains 2 entries:
  Offset     Info    Type            Sym.Value  Sym. Name
 00000000  00000000 R_MIPS_NONE      
 00000340  00000003 R_MIPS_REL32     
index ead15f044c9b0872a47a31c22335d7d899566401..8663f148d761d7204622d94f99746ce7bc5845ce 100644 (file)
@@ -4,16 +4,16 @@
 #readelf: -x 6 -r
 #ld: -shared -melf64btsmip
 
-Relocation section '.rel.dyn' at offset 0x498 contains 2 entries:
+Relocation section '.rel.dyn' at offset 0x488 contains 2 entries:
   Offset          Info           Type           Sym. Value    Sym. Name
 000000000000  000000000000 R_MIPS_NONE      
                     Type2: R_MIPS_NONE      
                     Type3: R_MIPS_NONE      
-0000000004d0  000000001203 R_MIPS_REL32     
+0000000004c0  000000001203 R_MIPS_REL32     
                     Type2: R_MIPS_64        
                     Type3: R_MIPS_NONE      
 
 Hex dump of section '.text':
-  0x000004c0 00000000 00000000 00000000 00000000 ................
-  0x000004d0 00000000 000004d0 00000000 00000000 ................
-  0x000004e0 00000000 00000000 00000000 00000000 ................
+  0x000004b0 00000000 00000000 00000000 00000000 ................
+  0x000004c0 00000000 000004c0 00000000 00000000 ................
+  0x000004d0 00000000 00000000 00000000 00000000 ................
diff --git a/ld/testsuite/ld-mips-elf/textrel-1.d b/ld/testsuite/ld-mips-elf/textrel-1.d
new file mode 100644 (file)
index 0000000..29a166d
--- /dev/null
@@ -0,0 +1,26 @@
+#name: MIPS textrel-1
+#source: textrel-1.s
+#as: -EB -n32
+#ld: -shared -melf32btsmipn32
+#readelf: -d
+
+Dynamic section at offset 0xb4 contains 18 entries:
+  Tag        Type                         Name/Value
+ 0x00000004 \(HASH\)                       0x16c
+ 0x00000005 \(STRTAB\)                     0x30c
+ 0x00000006 \(SYMTAB\)                     0x1fc
+ 0x0000000a \(STRSZ\)                      84 \(bytes\)
+ 0x0000000b \(SYMENT\)                     16 \(bytes\)
+ 0x00000015 \(DEBUG\)                      0x0
+ 0x00000003 \(PLTGOT\)                     0x1003e0
+ 0x00000011 \(REL\)                        0x360
+ 0x00000012 \(RELSZ\)                      8 \(bytes\)
+ 0x00000013 \(RELENT\)                     8 \(bytes\)
+ 0x70000001 \(MIPS_RLD_VERSION\)           1
+ 0x70000005 \(MIPS_FLAGS\)                 NOTPOT
+ 0x70000006 \(MIPS_BASE_ADDRESS\)          0
+ 0x7000000a \(MIPS_LOCAL_GOTNO\)           7
+ 0x70000011 \(MIPS_SYMTABNO\)              17
+ 0x70000012 \(MIPS_UNREFEXTNO\)            12
+ 0x70000013 \(MIPS_GOTSYM\)                0x11
+ 0x00000000 \(NULL\)                       0x0
diff --git a/ld/testsuite/ld-mips-elf/textrel-1.s b/ld/testsuite/ld-mips-elf/textrel-1.s
new file mode 100644 (file)
index 0000000..f6b4a6a
--- /dev/null
@@ -0,0 +1,9 @@
+        .globl foo
+foo:
+        .cfi_startproc
+        nop
+        .cfi_def_cfa_offset 4
+        nop
+        .cfi_register $29, $0
+        nop
+        .cfi_endproc