[ bfd/ChangeLog ]
authorThiemo Seufer <ths@networkno.de>
Thu, 20 Jul 2006 16:46:30 +0000 (16:46 +0000)
committerThiemo Seufer <ths@networkno.de>
Thu, 20 Jul 2006 16:46:30 +0000 (16:46 +0000)
* elf32-mips.c (mips16_jump_reloc): Remove function.
(elf_mips16_howto_table_rel): Use _bfd_mips_elf_generic_reloc
instead of mips16_jump_reloc.
* elf64_mips.c, wlfn32-mips.c (mips16_jump_reloc): Remove function.
(elf_mips16_howto_table_rel, elf_mips16_howto_table_rela): Use
_bfd_mips_elf_generic_reloc instead of mips16_jump_reloc.

[ gas/ChangeLog ]
* config/tc-mips.c (mips_fix_adjustable): Handle BFD_RELOC_MIPS16_JMP.
(tc_gen_reloc): Handle mips16 jumps to section symbol offsets.

[ ld/testsuite/ChangeLog ]
* ld-mips-elf/mips16-call-global-1.s,
ld-mips-elf/mips16-call-global-2.s,
ld-mips-elf/mips16-call-global-3.s, ld-mips-elf/mips16-call-global.d:
Test linking of external mips16 jumps.
* ld-mips-elf/mips-elf.exp: Run new test.

12 files changed:
bfd/ChangeLog
bfd/elf32-mips.c
bfd/elf64-mips.c
bfd/elfn32-mips.c
gas/ChangeLog
gas/config/tc-mips.c
ld/testsuite/ChangeLog
ld/testsuite/ld-mips-elf/mips-elf.exp
ld/testsuite/ld-mips-elf/mips16-call-global-1.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-call-global-2.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-call-global-3.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-call-global.d [new file with mode: 0644]

index 55e6b543de4e972eebcf246580083a0e03212688..2482506ac6718f399b8c78ce68919bb8de8eaeac 100644 (file)
@@ -1,3 +1,12 @@
+2006-07-20  Thiemo Seufer  <ths@mips.com>
+
+       * elf32-mips.c (mips16_jump_reloc): Remove function.
+       (elf_mips16_howto_table_rel): Use _bfd_mips_elf_generic_reloc
+       instead of mips16_jump_reloc.
+       * elf64_mips.c, wlfn32-mips.c (mips16_jump_reloc): Remove function.
+       (elf_mips16_howto_table_rel, elf_mips16_howto_table_rela): Use
+       _bfd_mips_elf_generic_reloc instead of mips16_jump_reloc.
+
 2006-07-19  Alan Modra  <amodra@bigpond.net.au>
 
        * bfd-in.h (enum notice_asneeded_action): Define.
index 5745df5b94cf1fb5d0dd059744cef8f82d3764e4..e86d95523c9f0e8d4e1d31fcd8ac3329083515da 100644 (file)
@@ -68,8 +68,6 @@ static bfd_boolean mips_elf32_object_p
   (bfd *);
 static bfd_boolean mips_elf_is_local_label_name
   (bfd *, const char *);
-static bfd_reloc_status_type mips16_jump_reloc
-  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type mips16_gprel_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type mips_elf_final_gp
@@ -734,7 +732,7 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
                                /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC.  */
-        mips16_jump_reloc,     /* special_function */
+        _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_26",         /* name */
         TRUE,                  /* partial_inplace */
         0x3ffffff,             /* src_mask */
@@ -1112,36 +1110,6 @@ mips32_64bit_reloc (bfd *abfd, arelent *reloc_entry,
   return r;
 }
 
-/* Handle a mips16 jump.  */
-
-static bfd_reloc_status_type
-mips16_jump_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
-                  asymbol *symbol, void *data ATTRIBUTE_UNUSED,
-                  asection *input_section, bfd *output_bfd,
-                  char **error_message ATTRIBUTE_UNUSED)
-{
-  if (output_bfd != NULL
-      && (symbol->flags & BSF_SECTION_SYM) == 0
-      && reloc_entry->addend == 0)
-    {
-      reloc_entry->address += input_section->output_offset;
-      return bfd_reloc_ok;
-    }
-
-  /* FIXME.  */
-  {
-    static bfd_boolean warned;
-
-    if (! warned)
-      (*_bfd_error_handler)
-       (_("Linking mips16 objects into %s format is not supported"),
-        bfd_get_target (input_section->output_section->owner));
-    warned = TRUE;
-  }
-
-  return bfd_reloc_undefined;
-}
-
 /* Handle a mips16 GP relative reloc.  */
 
 static bfd_reloc_status_type
index ee5bce6619c698e28114f93ff9c1e84da29cfb72..aa33cf7d6cc29361c29fd7b74c2d4956ce637155 100644 (file)
@@ -112,8 +112,6 @@ static bfd_reloc_status_type mips_elf64_gprel32_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type mips_elf64_shift6_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
-static bfd_reloc_status_type mips16_jump_reloc
-  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type mips16_gprel_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_boolean mips_elf64_assign_gp
@@ -1438,7 +1436,7 @@ static reloc_howto_type mips16_elf64_howto_table_rel[] =
                                /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC.  */
-        mips16_jump_reloc,     /* special_function */
+        _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_26",         /* name */
         TRUE,                  /* partial_inplace */
         0x3ffffff,             /* src_mask */
@@ -1510,7 +1508,7 @@ static reloc_howto_type mips16_elf64_howto_table_rela[] =
                                /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC.  */
-        mips16_jump_reloc,     /* special_function */
+        _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_26",         /* name */
         FALSE,                 /* partial_inplace */
         0x3ffffff,             /* src_mask */
@@ -2044,37 +2042,6 @@ mips_elf64_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
                                      error_message);
 }
 
-/* Handle a mips16 jump.  */
-
-static bfd_reloc_status_type
-mips16_jump_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
-                  asymbol *symbol, void *data ATTRIBUTE_UNUSED,
-                  asection *input_section, bfd *output_bfd,
-                  char **error_message ATTRIBUTE_UNUSED)
-{
-  if (output_bfd != NULL
-      && (symbol->flags & BSF_SECTION_SYM) == 0
-      && (! reloc_entry->howto->partial_inplace
-         || reloc_entry->addend == 0))
-    {
-      reloc_entry->address += input_section->output_offset;
-      return bfd_reloc_ok;
-    }
-
-  /* FIXME.  */
-  {
-    static bfd_boolean warned;
-
-    if (! warned)
-      (*_bfd_error_handler)
-       (_("Linking mips16 objects into %s format is not supported"),
-        bfd_get_target (input_section->output_section->owner));
-    warned = TRUE;
-  }
-
-  return bfd_reloc_undefined;
-}
-
 /* Handle a mips16 GP relative reloc.  */
 
 static bfd_reloc_status_type
index 367bcf33fffca00d483a95797cc4152754ef627a..275e83cdc1182fd21df2e30af076efc543332c6e 100644 (file)
@@ -61,8 +61,6 @@ static bfd_reloc_status_type gprel32_with_gp
   (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
 static bfd_reloc_status_type mips_elf_shift6_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
-static bfd_reloc_status_type mips16_jump_reloc
-  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type mips16_gprel_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
@@ -1444,7 +1442,7 @@ static reloc_howto_type elf_mips16_howto_table_rel[] =
                                /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC.  */
-        mips16_jump_reloc,     /* special_function */
+        _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_26",         /* name */
         TRUE,                  /* partial_inplace */
         0x3ffffff,             /* src_mask */
@@ -1516,7 +1514,7 @@ static reloc_howto_type elf_mips16_howto_table_rela[] =
                                /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC.  */
-        mips16_jump_reloc,     /* special_function */
+        _bfd_mips_elf_generic_reloc, /* special_function */
         "R_MIPS16_26",         /* name */
         FALSE,                 /* partial_inplace */
         0x3ffffff,             /* src_mask */
@@ -1901,28 +1899,6 @@ mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
                                      error_message);
 }
 \f
-/* Handle a mips16 jump.  */
-
-static bfd_reloc_status_type
-mips16_jump_reloc (bfd *abfd ATTRIBUTE_UNUSED,
-                  arelent *reloc_entry ATTRIBUTE_UNUSED,
-                  asymbol *symbol ATTRIBUTE_UNUSED,
-                  void *data ATTRIBUTE_UNUSED,
-                  asection *input_section, bfd *output_bfd ATTRIBUTE_UNUSED,
-                  char **error_message ATTRIBUTE_UNUSED)
-{
-  static bfd_boolean warned = FALSE;
-
-  /* FIXME.  */
-  if (! warned)
-    (*_bfd_error_handler)
-      (_("Linking mips16 objects into %s format is not supported"),
-       bfd_get_target (input_section->output_section->owner));
-  warned = TRUE;
-
-  return bfd_reloc_undefined;
-}
-
 /* Handle a mips16 GP relative reloc.  */
 
 static bfd_reloc_status_type
index 999b795b2d3a138d803c850f926d0c3fb7bd73d4..dcb7a3342bf1e1f4315ea2a8d0c4f73cb8a4ee65 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-20  Thiemo Seufer  <ths@mips.com>
+
+       * config/tc-mips.c (mips_fix_adjustable): Handle BFD_RELOC_MIPS16_JMP.
+       (tc_gen_reloc): Handle mips16 jumps to section symbol offsets.
+
 2006-07-19  Paul Brook  <paul@codesourcery.com>
 
        * config/tc-arm.c (insns): Fix rbit Arm opcode.
index abe4630a14df679cc5fc8511bfe304b70b9bb1ad..788a34b5ba6130f9be3bd02faff5909e5d74095d 100644 (file)
@@ -13498,11 +13498,6 @@ md_estimate_size_before_relax (fragS *fragp, asection *segtype)
 int
 mips_fix_adjustable (fixS *fixp)
 {
-  /* Don't adjust MIPS16 jump relocations, so we don't have to worry
-     about the format of the offset in the .o file. */
-  if (fixp->fx_r_type == BFD_RELOC_MIPS16_JMP)
-    return 0;
-
   if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT
       || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
     return 0;
@@ -13578,6 +13573,10 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   else
     reloc->addend = fixp->fx_addnumber;
 
+  /* Handle relocs adjusted against a section symbol.  */
+  if (fixp->fx_r_type == BFD_RELOC_MIPS16_JMP)
+    reloc->addend += fixp->fx_offset;
+
   /* Since the old MIPS ELF ABI uses Rel instead of Rela, encode the vtable
      entry to be used in the relocation's section offset.  */
   if (! HAVE_NEWABI && fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
index ad6b44c57723311f7d8b4abe900ff2fb3526ef1f..395ae65c372775a570409149071d4996715b0afe 100644 (file)
@@ -1,3 +1,11 @@
+2006-07-20  Thiemo Seufer  <ths@mips.com>
+
+       * ld-mips-elf/mips16-call-global-1.s,
+       ld-mips-elf/mips16-call-global-2.s,
+       ld-mips-elf/mips16-call-global-3.s, ld-mips-elf/mips16-call-global.d:
+       Test linking of external mips16 jumps.
+       * ld-mips-elf/mips-elf.exp: Run new test.
+
 2006-07-19  Thiemo Seufer  <ths@mips.com>
 
        * ld-selective/selective.exp: Fix selective testcases for MIPS.
index b5ddaefd58f5f806a7ee14dcd886eb0627637967..aba416f56aba94815bf9730542c5d97dfc5ccc7b 100644 (file)
@@ -243,3 +243,12 @@ if {[istarget mips*-*-linux*]} {
     run_ld_link_tests $mips_tls_tests
 }
 
+set mips16_call_global_test {
+    {"Global calls from mips16"
+     ""
+     "-mips32r2" {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s}
+     {{objdump -dr mips16-call-global.d}}
+     "mips16-call-global"}
+}
+
+run_ld_link_tests $mips16_call_global_test
diff --git a/ld/testsuite/ld-mips-elf/mips16-call-global-1.s b/ld/testsuite/ld-mips-elf/mips16-call-global-1.s
new file mode 100644 (file)
index 0000000..1e60bcc
--- /dev/null
@@ -0,0 +1,12 @@
+       .set    mips16
+
+       .globl  __start
+       .ent    __start
+__start:
+       .frame  $sp,24,$31
+       save    24,$31
+       jal     x+8
+       jal     y+8
+       restore 24,$31
+       j       $31
+       .end    __start
diff --git a/ld/testsuite/ld-mips-elf/mips16-call-global-2.s b/ld/testsuite/ld-mips-elf/mips16-call-global-2.s
new file mode 100644 (file)
index 0000000..bae3195
--- /dev/null
@@ -0,0 +1,8 @@
+       .set mips16
+
+       .globl  x
+       .ent    x
+       .type   x,@function
+x:
+       jr      $31
+       .end    x
diff --git a/ld/testsuite/ld-mips-elf/mips16-call-global-3.s b/ld/testsuite/ld-mips-elf/mips16-call-global-3.s
new file mode 100644 (file)
index 0000000..e776b3d
--- /dev/null
@@ -0,0 +1,6 @@
+       .globl  y
+       .ent    y
+       .type   y,@function
+y:
+       jr      $31
+       .end    y
diff --git a/ld/testsuite/ld-mips-elf/mips16-call-global.d b/ld/testsuite/ld-mips-elf/mips16-call-global.d
new file mode 100644 (file)
index 0000000..bd5095e
--- /dev/null
@@ -0,0 +1,37 @@
+#as: -mips32r2
+#source: mips16-call-global-1.S mips16-call-global-2.S mips16-call-global-3.S
+
+.*:     file format elf.*mips
+
+Disassembly of section .text:
+
+00400090 <__start>:
+  400090:      64c3            save    24,ra
+  400092:      1a00 002e       jal     4000b8 <x\+0x8>
+  400096:      6500            nop
+  400098:      1e00 0032       jalx    4000c8 <y\+0x8>
+  40009c:      6500            nop
+  40009e:      6443            restore 24,ra
+  4000a0:      e8a0            jrc     ra
+  4000a2:      6500            nop
+  4000a4:      6500            nop
+  4000a6:      6500            nop
+  4000a8:      6500            nop
+  4000aa:      6500            nop
+  4000ac:      6500            nop
+  4000ae:      6500            nop
+
+004000b0 <x>:
+  4000b0:      e8a0            jrc     ra
+  4000b2:      6500            nop
+  4000b4:      6500            nop
+  4000b6:      6500            nop
+  4000b8:      6500            nop
+  4000ba:      6500            nop
+  4000bc:      6500            nop
+  4000be:      6500            nop
+
+004000c0 <y>:
+  4000c0:      03e00008        jr      ra
+  4000c4:      00000000        nop
+       \.\.\.