This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

R_MIPS_PC16, again


This comes up a couple times a year, so here's my try at laying it to
rest...

Background: Branches to external symbols, for MIPS, have been broken for a
long time.  The definition of R_MIPS_PC16 in the ABI is pretty much useless
because it does not accomodate the two bit right shift.  There was a GNU
extension (R_MIPS_GNU_REL16_S2), which did.  It was only ever used for
embedded PIC.

Thiemo posted a patch here:
  http://sourceware.org/ml/binutils/2003-02/msg00447.html

which changed the definition of R_MIPS_PC16 to include the right shift.
There was buy-in from most of the maintainers at the time, and I recall
seeing approving noises from MIPS also.  Unfortunately the patch broke
n32/n64 branches.

Here's a refresh.  The fiddly bits dealing with the branch offset are
changed, because all this code has been cleaned up since 2003.  The refresh
appears to work fine on n64; I have not run any glibc tests using a patched
assembler, but I have linked mips-linux, mips64-linux, and mips-ecoff (ugh,
see the patch) executables and the relocations were always resolved
correctly.  The new tests all pass.  [There's lots of garbage in the MIPS
test results right now, though.  All the DSP tests fail.  So do most of the
MIPS-specific linker tests.]

OK?  If so, what additional testing do you need?

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-11-21  Daniel Jacobowitz  <dan@codesourcery.com>
	    Thiemo Seufer <ths@networkno.de>

	* elf32-mips.c (elf_mips_howto_table_rel): Use rightshift 2 for
	R_MIPS_PC16.
	(mips_reloc_map): Map BFD_RELOC_16_PCREL_S2 to R_MIPS_PC16.
	(bfd_elf32_bfd_reloc_type_lookup): Don't handle
	BFD_RELOC_16_PCREL_S2.
	* elf64-mips.c (mips_elf64_howto_table_rel): Use rightshift 2 for
	R_MIPS_PC16.
	(mips_elf64_howto_table_rela): Likewise.
	(mips_reloc_map): Map BFD_RELOC_16_PCREL_S2 to R_MIPS_PC16.
	(bfd_elf64_bfd_reloc_type_lookup): Don't handle
	BFD_RELOC_16_PCREL_S2.
	* elfn32-mips.c (elf_mips_howto_table_rel): Use rightshift 2 for
	R_MIPS_PC16.
	(elf_mips_howto_table_rela): Likewise.
	(mips_reloc_map): Map BFD_RELOC_16_PCREL_S2 to R_MIPS_PC16.
	(bfd_elf32_bfd_reloc_type_lookup): Don't handle
	BFD_RELOC_16_PCREL_S2.
	* elfxx-mips.c: Formatting fixes.
	(mips_elf_calculate_relocation): Handle R_MIPS_GNU_REL16_S2
	and R_MIPS_PC16 identically.

2005-11-21  Daniel Jacobowitz  <dan@codesourcery.com>
	    Thiemo Seufer <ths@networkno.de>

	* config/tc-mips.c (append_insn): Handle BFD_RELOC_16_PCREL_S2.
	(macro_build): Complain for invalid branch displacements.
	(mips_validate_fix): Delete.
	(md_apply_fix): Re-add pcrel support for branches.  Use consistent
	text for misaligned branch targets.
	(tc_gen_reloc: Re-add pcrel support for branches.  Handle strange
	BFD pcrel processing.  Remove error for unresolved branches.
	* config/tc-mips.h (TC_VALIDATE_FIX, mips_validate_fix): Delete.

2005-11-21  Daniel Jacobowitz  <dan@codesourcery.com>
	    Thiemo Seufer <ths@networkno.de>

	* gas/mips/bge.d, gas/mips/bge.s, gas/mips/bgeu.d, gas/mips/bgeu.s,
	gas/mips/blt.d, gas/mips/blt.s, gas/mips/bltu.d,
	gas/mips/bltu.s: Reactivate external branch tests.
	* gas/mips/branch-misc-2.d, gas/mips/branch-misc-2pic.d,
	gas/mips/branch-misc-2-64.d, gas/mips/branch-misc-2pic-64.d: New
	tests.
	* gas/mips/branch-misc-2.l, gas/mips/branch-misc-2pic.l,
	gas/testsuite/gas/mips/branch-misc-2pic.s: Remove.
	* gas/mips/mips.exp: Adjust branch-misc-2 tests.  Add 64-bit
	variants.

Index: bfd/elf32-mips.c
===================================================================
RCS file: /big/fsf/rsync/src/src/bfd/elf32-mips.c,v
retrieving revision 1.185
diff -u -p -r1.185 elf32-mips.c
--- bfd/elf32-mips.c	23 May 2005 17:44:53 -0000	1.185
+++ bfd/elf32-mips.c	21 Nov 2005 19:43:00 -0000
@@ -257,9 +257,11 @@ static reloc_howto_type elf_mips_howto_t
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit PC relative reference.  */
+  /* 16 bit PC relative reference.  Note that the ABI document has a typo
+     and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+     We do the right thing here.  */
   HOWTO (R_MIPS_PC16,		/* type */
-	 0,			/* rightshift */
+	 2,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
 	 TRUE,			/* pc_relative */
@@ -1206,7 +1208,7 @@ static const struct elf_reloc_map mips_r
   { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
   { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
   { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
-  { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+  { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
   { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
   { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
   { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
@@ -1283,8 +1285,6 @@ bfd_elf32_bfd_reloc_type_lookup (bfd *ab
       return &elf_mips_gnu_vtinherit_howto;
     case BFD_RELOC_VTABLE_ENTRY:
       return &elf_mips_gnu_vtentry_howto;
-    case BFD_RELOC_16_PCREL_S2:
-      return &elf_mips_gnu_rel16_s2;
     case BFD_RELOC_32_PCREL:
       return &elf_mips_gnu_pcrel32;
     }
Index: bfd/elf64-mips.c
===================================================================
RCS file: /big/fsf/rsync/src/src/bfd/elf64-mips.c,v
retrieving revision 1.72
diff -u -p -r1.72 elf64-mips.c
--- bfd/elf64-mips.c	23 May 2005 17:44:53 -0000	1.72
+++ bfd/elf64-mips.c	21 Nov 2005 19:43:00 -0000
@@ -299,9 +299,11 @@ static reloc_howto_type mips_elf64_howto
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit PC relative reference.  */
+  /* 16 bit PC relative reference.  Note that the ABI document has a typo
+     and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+     We do the right thing here.  */
   HOWTO (R_MIPS_PC16,		/* type */
-	 0,			/* rightshift */
+	 2,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
 	 TRUE,			/* pc_relative */
@@ -948,9 +950,11 @@ static reloc_howto_type mips_elf64_howto
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit PC relative reference.  */
+  /* 16 bit PC relative reference.  Note that the ABI document has a typo
+     and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+     We do the right thing here.  */
   HOWTO (R_MIPS_PC16,		/* type */
-	 0,			/* rightshift */
+	 2,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
 	 TRUE,			/* pc_relative */
@@ -2133,7 +2137,7 @@ static const struct elf_reloc_map mips_r
   /* There is no BFD reloc for R_MIPS_REL32.  */
   { BFD_RELOC_64, R_MIPS_64 },
   { BFD_RELOC_CTOR, R_MIPS_64 },
-  { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+  { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
   { BFD_RELOC_HI16_S, R_MIPS_HI16 },
   { BFD_RELOC_LO16, R_MIPS_LO16 },
   { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
@@ -2217,8 +2221,6 @@ bfd_elf64_bfd_reloc_type_lookup (bfd *ab
       return &elf_mips_gnu_vtinherit_howto;
     case BFD_RELOC_VTABLE_ENTRY:
       return &elf_mips_gnu_vtentry_howto;
-    case BFD_RELOC_16_PCREL_S2:
-      return &elf_mips_gnu_rela16_s2;
     default:
       bfd_set_error (bfd_error_bad_value);
       return NULL;
Index: bfd/elfn32-mips.c
===================================================================
RCS file: /big/fsf/rsync/src/src/bfd/elfn32-mips.c,v
retrieving revision 1.29
diff -u -p -r1.29 elfn32-mips.c
--- bfd/elfn32-mips.c	23 May 2005 17:44:53 -0000	1.29
+++ bfd/elfn32-mips.c	21 Nov 2005 19:43:00 -0000
@@ -262,9 +262,11 @@ static reloc_howto_type elf_mips_howto_t
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit PC relative reference.  */
+  /* 16 bit PC relative reference.  Note that the ABI document has a typo
+     and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+     We do the right thing here.  */
   HOWTO (R_MIPS_PC16,		/* type */
-	 0,			/* rightshift */
+	 2,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
 	 TRUE,			/* pc_relative */
@@ -913,9 +915,11 @@ static reloc_howto_type elf_mips_howto_t
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit PC relative reference.  */
+  /* 16 bit PC relative reference.  Note that the ABI document has a typo
+     and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+     We do the right thing here.  */
   HOWTO (R_MIPS_PC16,		/* type */
-	 0,			/* rightshift */
+	 2,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
 	 TRUE,			/* pc_relative */
@@ -1981,7 +1985,7 @@ static const struct elf_reloc_map mips_r
   /* There is no BFD reloc for R_MIPS_REL32.  */
   { BFD_RELOC_CTOR, R_MIPS_32 },
   { BFD_RELOC_64, R_MIPS_64 },
-  { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+  { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
   { BFD_RELOC_HI16_S, R_MIPS_HI16 },
   { BFD_RELOC_LO16, R_MIPS_LO16 },
   { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
@@ -2065,8 +2069,6 @@ bfd_elf32_bfd_reloc_type_lookup (bfd *ab
       return &elf_mips_gnu_vtinherit_howto;
     case BFD_RELOC_VTABLE_ENTRY:
       return &elf_mips_gnu_vtentry_howto;
-    case BFD_RELOC_16_PCREL_S2:
-      return &elf_mips_gnu_rela16_s2;
     default:
       bfd_set_error (bfd_error_bad_value);
       return NULL;
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /big/fsf/rsync/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.154
diff -u -p -r1.154 elfxx-mips.c
--- bfd/elfxx-mips.c	11 Nov 2005 11:06:33 -0000	1.154
+++ bfd/elfxx-mips.c	21 Nov 2005 19:43:00 -0000
@@ -456,7 +456,6 @@ static struct mips_got_info *mips_elf_go
 static bfd *reldyn_sorting_bfd;
 
 /* Nonzero if ABFD is using the N32 ABI.  */
-
 #define ABI_N32_P(abfd) \
   ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
 
@@ -2762,7 +2761,7 @@ mips_elf_bfd2got_entry_eq (const void *e
   return e1->bfd == e2->bfd;
 }
 
-/* In a multi-got link, determine the GOT to be used for IBDF.  G must
+/* In a multi-got link, determine the GOT to be used for IBFD.  G must
    be the master GOT data.  */
 
 static struct mips_got_info *
@@ -4035,12 +4034,6 @@ mips_elf_calculate_relocation (bfd *abfd
       value &= howto->dst_mask;
       break;
 
-    case R_MIPS_GNU_REL16_S2:
-      value = symbol + _bfd_mips_elf_sign_extend (addend, 18) - p;
-      overflowed_p = mips_elf_overflow_p (value, 18);
-      value = (value >> 2) & howto->dst_mask;
-      break;
-
     case R_MIPS16_26:
       /* The calculation for R_MIPS16_26 is just the same as for an
 	 R_MIPS_26.  It's only the storage of the relocated field into
@@ -4204,8 +4197,10 @@ mips_elf_calculate_relocation (bfd *abfd
       break;
 
     case R_MIPS_PC16:
-      value = _bfd_mips_elf_sign_extend (addend, 16) + symbol - p;
-      overflowed_p = mips_elf_overflow_p (value, 16);
+    case R_MIPS_GNU_REL16_S2:
+      value = symbol + _bfd_mips_elf_sign_extend (addend, 18) - p;
+      overflowed_p = mips_elf_overflow_p (value, 18);
+      value = (value >> 2) & howto->dst_mask;
       break;
 
     case R_MIPS_GOT_HI16:
Index: gas/config/tc-mips.c
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/config/tc-mips.c,v
retrieving revision 1.326
diff -u -p -r1.326 tc-mips.c
--- gas/config/tc-mips.c	14 Nov 2005 02:25:39 -0000	1.326
+++ gas/config/tc-mips.c	21 Nov 2005 19:43:01 -0000
@@ -2410,7 +2410,16 @@ append_insn (struct mips_cl_insn *ip, ex
 	      break;
 
 	    case BFD_RELOC_16_PCREL_S2:
-	      goto need_reloc;
+	      if ((address_expr->X_add_number & 3) != 0)
+		as_bad (_("branch to misaligned address (0x%lx)"),
+			(unsigned long) address_expr->X_add_number);
+	      if (mips_relax_branch)
+		goto need_reloc;
+	      if ((address_expr->X_add_number + 0x20000) & ~0x3ffff)
+		as_bad (_("branch address range overflow (0x%lx)"),
+			(unsigned long) address_expr->X_add_number);
+	      ip->insn_opcode |= (address_expr->X_add_number >> 2) & 0xffff;
+	      break;
 
 	    default:
 	      internalError ();
@@ -3139,15 +3148,22 @@ macro_build (expressionS *ep, const char
 
 	case 'p':
 	  assert (ep != NULL);
+
 	  /*
 	   * This allows macro() to pass an immediate expression for
 	   * creating short branches without creating a symbol.
-	   * Note that the expression still might come from the assembly
-	   * input, in which case the value is not checked for range nor
-	   * is a relocation entry generated (yuck).
+	   *
+	   * We don't allow branch relaxation for these branches, as
+	   * they should only appear in ".set nomacro" anyway.
 	   */
 	  if (ep->X_op == O_constant)
 	    {
+	      if ((ep->X_add_number & 3) != 0)
+		as_bad (_("branch to misaligned address (0x%lx)"),
+			(unsigned long) ep->X_add_number);
+	      if ((ep->X_add_number + 0x20000) & ~0x3ffff)
+		as_bad (_("branch address range overflow (0x%lx)"),
+			(unsigned long) ep->X_add_number);
 	      insn.insn_opcode |= (ep->X_add_number >> 2) & 0xffff;
 	      ep = NULL;
 	    }
@@ -11361,83 +11377,6 @@ mips_force_relocation (fixS *fixp)
   return 0;
 }
 
-/* This hook is called before a fix is simplified.  We don't really
-   decide whether to skip a fix here.  Rather, we turn global symbols
-   used as branch targets into local symbols, such that they undergo
-   simplification.  We can only do this if the symbol is defined and
-   it is in the same section as the branch.  If this doesn't hold, we
-   emit a better error message than just saying the relocation is not
-   valid for the selected object format.
-
-   FIXP is the fix-up we're going to try to simplify, SEG is the
-   segment in which the fix up occurs.  The return value should be
-   non-zero to indicate the fix-up is valid for further
-   simplifications.  */
-
-int
-mips_validate_fix (struct fix *fixP, asection *seg)
-{
-  /* There's a lot of discussion on whether it should be possible to
-     use R_MIPS_PC16 to represent branch relocations.  The outcome
-     seems to be that it can, but gas/bfd are very broken in creating
-     RELA relocations for this, so for now we only accept branches to
-     symbols in the same section.  Anything else is of dubious value,
-     since there's no guarantee that at link time the symbol would be
-     in range.  Even for branches to local symbols this is arguably
-     wrong, since it we assume the symbol is not going to be
-     overridden, which should be possible per ELF library semantics,
-     but then, there isn't a dynamic relocation that could be used to
-     this effect, and the target would likely be out of range as well.
-
-     Unfortunately, it seems that there is too much code out there
-     that relies on branches to symbols that are global to be resolved
-     as if they were local, like the IRIX tools do, so we do it as
-     well, but with a warning so that people are reminded to fix their
-     code.  If we ever get back to using R_MIPS_PC16 for branch
-     targets, this entire block should go away (and probably the
-     whole function).  */
-
-  if (fixP->fx_r_type == BFD_RELOC_16_PCREL_S2
-      && ((OUTPUT_FLAVOR == bfd_target_ecoff_flavour
-	   || OUTPUT_FLAVOR == bfd_target_elf_flavour)
-	  || bfd_reloc_type_lookup (stdoutput, BFD_RELOC_16_PCREL_S2) == NULL)
-      && fixP->fx_addsy)
-    {
-      if (! S_IS_DEFINED (fixP->fx_addsy))
-	{
-	  as_bad_where (fixP->fx_file, fixP->fx_line,
-			_("Cannot branch to undefined symbol."));
-	  /* Avoid any further errors about this fixup.  */
-	  fixP->fx_done = 1;
-	}
-      else if (S_GET_SEGMENT (fixP->fx_addsy) != seg)
-	{
-	  as_bad_where (fixP->fx_file, fixP->fx_line,
-			_("Cannot branch to symbol in another section."));
-	  fixP->fx_done = 1;
-	}
-      else if (S_IS_EXTERNAL (fixP->fx_addsy))
-	{
-	  symbolS *sym = fixP->fx_addsy;
-
-	  if (mips_pic == SVR4_PIC)
-	    as_warn_where (fixP->fx_file, fixP->fx_line,
-			   _("Pretending global symbol used as branch target is local."));
-
-	  fixP->fx_addsy = symbol_create (S_GET_NAME (sym),
-					  S_GET_SEGMENT (sym),
-					  S_GET_VALUE (sym),
-					  symbol_get_frag (sym));
-	  copy_symbol_attributes (fixP->fx_addsy, sym);
-	  S_CLEAR_EXTERNAL (fixP->fx_addsy);
-	  assert (symbol_resolved_p (sym));
-	  symbol_mark_resolved (fixP->fx_addsy);
-	}
-    }
-
-  return 1;
-}
-
 /* Apply a fixup to the object file.  */
 
 void
@@ -11462,7 +11401,7 @@ md_apply_fix (fixS *fixP, valueT *valP, 
 
   buf = (bfd_byte *) (fixP->fx_frag->fr_literal + fixP->fx_where);
 
-  assert (! fixP->fx_pcrel);
+  assert (! fixP->fx_pcrel || fixP->fx_r_type == BFD_RELOC_16_PCREL_S2);
 
   /* Don't treat parts of a composite relocation as done.  There are two
      reasons for this:
@@ -11474,7 +11413,7 @@ md_apply_fix (fixS *fixP, valueT *valP, 
 	 constants.  The easiest way of dealing with the pathological
 	 exceptions is to generate a relocation against STN_UNDEF and
 	 leave everything up to the linker.  */
-  if (fixP->fx_addsy == NULL && fixP->fx_tcbit == 0)
+  if (fixP->fx_addsy == NULL && ! fixP->fx_pcrel && fixP->fx_tcbit == 0)
     fixP->fx_done = 1;
 
   switch (fixP->fx_r_type)
@@ -11519,7 +11458,6 @@ md_apply_fix (fixS *fixP, valueT *valP, 
     case BFD_RELOC_MIPS16_GPREL:
     case BFD_RELOC_MIPS16_HI16:
     case BFD_RELOC_MIPS16_HI16_S:
-      assert (! fixP->fx_pcrel);
       /* Nothing needed to do. The value comes from the reloc entry */
       break;
 
@@ -11589,7 +11527,7 @@ md_apply_fix (fixS *fixP, valueT *valP, 
     case BFD_RELOC_16_PCREL_S2:
       if ((*valP & 0x3) != 0)
 	as_bad_where (fixP->fx_file, fixP->fx_line,
-		      _("Branch to odd address (%lx)"), (long) *valP);
+		      _("Branch to misaligned address (%lx)"), (long) *valP);
 
       /*
        * We need to save the bits in the instruction since fixup_segment()
@@ -13307,8 +13245,24 @@ tc_gen_reloc (asection *section ATTRIBUT
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
-  assert (! fixp->fx_pcrel);
-  reloc->addend = fixp->fx_addnumber;
+  if (fixp->fx_pcrel)
+    {
+      assert (fixp->fx_r_type == BFD_RELOC_16_PCREL_S2);
+
+      /* At this point, fx_addnumber is "symbol offset - pcrel address".
+	 Relocations want only the symbol offset.  */
+      reloc->addend = fixp->fx_addnumber + reloc->address;
+      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+	{
+	  /* A gruesome hack which is a result of the gruesome gas
+	     reloc handling.  What's worse, for COFF (as opposed to
+	     ECOFF), we might need yet another copy of reloc->address.
+	     See bfd_install_relocation.  */
+	  reloc->addend += reloc->address;
+	}
+    }
+  else
+    reloc->addend = fixp->fx_addnumber;
 
   /* Since the old MIPS ELF ABI uses Rel instead of Rela, encode the vtable
      entry to be used in the relocation's section offset.  */
@@ -13320,18 +13274,7 @@ tc_gen_reloc (asection *section ATTRIBUT
 
   code = fixp->fx_r_type;
 
-  /* To support a PC relative reloc, we used a Cygnus extension.
-     We check for that here to make sure that we don't let such a
-     reloc escape normally.  (FIXME: This was formerly used by
-     embedded-PIC support, but is now used by branch handling in
-     general.  That probably should be fixed.)  */
-  if ((OUTPUT_FLAVOR == bfd_target_ecoff_flavour
-       || OUTPUT_FLAVOR == bfd_target_elf_flavour)
-      && code == BFD_RELOC_16_PCREL_S2)
-    reloc->howto = NULL;
-  else
-    reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
-
+  reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
   if (reloc->howto == NULL)
     {
       as_bad_where (fixp->fx_file, fixp->fx_line,
@@ -13408,8 +13351,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	  exp.X_add_number = fragp->fr_offset;
 
 	  fixp = fix_new_exp (fragp, buf - (bfd_byte *)fragp->fr_literal,
-			      4, &exp, 1,
-			      BFD_RELOC_16_PCREL_S2);
+			      4, &exp, 1, BFD_RELOC_16_PCREL_S2);
 	  fixp->fx_file = fragp->fr_file;
 	  fixp->fx_line = fragp->fr_line;
 
Index: gas/config/tc-mips.h
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/config/tc-mips.h,v
retrieving revision 1.41
diff -u -p -r1.41 tc-mips.h
--- gas/config/tc-mips.h	7 Jun 2005 17:54:17 -0000	1.41
+++ gas/config/tc-mips.h	21 Nov 2005 19:43:01 -0000
@@ -122,15 +122,6 @@ extern int mips_force_relocation (struct
 #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
   (! SEG_NORMAL (SEG) || mips_force_relocation (FIX))
 
-/* We use this to turn branches to global symbols into branches to
-   local symbols, so that they can be simplified.  */
-#define TC_VALIDATE_FIX(fixp, this_segment, skip_label) \
-  do \
-    if (! mips_validate_fix ((fixp), (this_segment))) \
-      goto skip_label; \
-  while (0)
-extern int mips_validate_fix (struct fix *, asection *);
-
 /* Register mask variables.  These are set by the MIPS assembly code
    and used by ECOFF and possibly other object file formats.  */
 extern unsigned long mips_gprmask;
Index: gas/testsuite/gas/mips/bge.d
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/bge.d,v
retrieving revision 1.8
diff -u -p -r1.8 bge.d
--- gas/testsuite/gas/mips/bge.d	7 May 2003 05:08:20 -0000	1.8
+++ gas/testsuite/gas/mips/bge.d	21 Nov 2005 19:43:01 -0000
@@ -52,20 +52,20 @@ Disassembly of section .text:
 0+00a8 <[^>]*> slt	at,a1,a0
 0+00ac <[^>]*> bnezl	at,0+0000 <text_label>
 0+00b0 <[^>]*> nop
-#0+00b4 <[^>]*> slt	at,a0,a1
-#0+00b8 <[^>]*> beqz	at,000000b8 <text_label\+0xb8>
-#[ 	]*b8: R_MIPS_PC16	external_label
-#0+00bc <[^>]*> nop
-#0+00c0 <[^>]*> slt	at,a1,a0
-#0+00c4 <[^>]*> bnez	at,000000c4 <text_label\+0xc4>
-#[ 	]*c4: R_MIPS_PC16	external_label
-#0+00c8 <[^>]*> nop
-#0+00cc <[^>]*> slt	at,a0,a1
-#0+00d0 <[^>]*> beqzl	at,000000d0 <text_label\+0xd0>
-#[ 	]*d0: R_MIPS_PC16	external_label
-#0+00d4 <[^>]*> nop
-#0+00d8 <[^>]*> slt	at,a1,a0
-#0+00dc <[^>]*> bnezl	at,000000dc <text_label\+0xdc>
-#[ 	]*dc: R_MIPS_PC16	external_label
-#0+00e0 <[^>]*> nop
+0+00b4 <[^>]*> slt	at,a0,a1
+0+00b8 <[^>]*> beqz	at,000000b8 <text_label\+0xb8>
+[ 	]*b8: R_MIPS_PC16	external_label
+0+00bc <[^>]*> nop
+0+00c0 <[^>]*> slt	at,a1,a0
+0+00c4 <[^>]*> bnez	at,000000c4 <text_label\+0xc4>
+[ 	]*c4: R_MIPS_PC16	external_label
+0+00c8 <[^>]*> nop
+0+00cc <[^>]*> slt	at,a0,a1
+0+00d0 <[^>]*> beqzl	at,000000d0 <text_label\+0xd0>
+[ 	]*d0: R_MIPS_PC16	external_label
+0+00d4 <[^>]*> nop
+0+00d8 <[^>]*> slt	at,a1,a0
+0+00dc <[^>]*> bnezl	at,000000dc <text_label\+0xdc>
+[ 	]*dc: R_MIPS_PC16	external_label
+0+00e0 <[^>]*> nop
 	...
Index: gas/testsuite/gas/mips/bge.s
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/bge.s,v
retrieving revision 1.5
diff -u -p -r1.5 bge.s
--- gas/testsuite/gas/mips/bge.s	12 Mar 2003 23:05:31 -0000	1.5
+++ gas/testsuite/gas/mips/bge.s	21 Nov 2005 19:43:01 -0000
@@ -25,10 +25,10 @@ text_label:	
 	bgtl	$4,$5,text_label
 
 # Branch to an external label.
-#	bge	$4,$5,external_label
-#	bgt	$4,$5,external_label
-#	bgel	$4,$5,external_label
-#	bgtl	$4,$5,external_label
+	bge	$4,$5,external_label
+	bgt	$4,$5,external_label
+	bgel	$4,$5,external_label
+	bgtl	$4,$5,external_label
 
 # Round to a 16 byte boundary, for ease in testing multiple targets.
 	nop
Index: gas/testsuite/gas/mips/bgeu.d
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/bgeu.d,v
retrieving revision 1.8
diff -u -p -r1.8 bgeu.d
--- gas/testsuite/gas/mips/bgeu.d	7 May 2003 05:08:20 -0000	1.8
+++ gas/testsuite/gas/mips/bgeu.d	21 Nov 2005 19:43:01 -0000
@@ -46,20 +46,20 @@ Disassembly of section .text:
 0+0090 <[^>]*> sltu	at,a1,a0
 0+0094 <[^>]*> bnezl	at,0+0000 <text_label>
 0+0098 <[^>]*> nop
-#0+009c <[^>]*> sltu	at,a0,a1
-#0+00a0 <[^>]*> beqz	at,000000a0 <text_label\+0xa0>
-#[ 	]*a0: R_MIPS_PC16	external_label
-#0+00a4 <[^>]*> nop
-#0+00a8 <[^>]*> sltu	at,a1,a0
-#0+00ac <[^>]*> bnez	at,000000ac <text_label\+0xac>
-#[ 	]*ac: R_MIPS_PC16	external_label
-#0+00b0 <[^>]*> nop
-#0+00b4 <[^>]*> sltu	at,a0,a1
-#0+00b8 <[^>]*> beqzl	at,000000b8 <text_label\+0xb8>
-#[ 	]*b8: R_MIPS_PC16	external_label
-#0+00bc <[^>]*> nop
-#0+00c0 <[^>]*> sltu	at,a1,a0
-#0+00c4 <[^>]*> bnezl	at,000000c4 <text_label\+0xc4>
-#[ 	]*c4: R_MIPS_PC16	external_label
-#0+00c8 <[^>]*> nop
+0+009c <[^>]*> sltu	at,a0,a1
+0+00a0 <[^>]*> beqz	at,000000a0 <text_label\+0xa0>
+[ 	]*a0: R_MIPS_PC16	external_label
+0+00a4 <[^>]*> nop
+0+00a8 <[^>]*> sltu	at,a1,a0
+0+00ac <[^>]*> bnez	at,000000ac <text_label\+0xac>
+[ 	]*ac: R_MIPS_PC16	external_label
+0+00b0 <[^>]*> nop
+0+00b4 <[^>]*> sltu	at,a0,a1
+0+00b8 <[^>]*> beqzl	at,000000b8 <text_label\+0xb8>
+[ 	]*b8: R_MIPS_PC16	external_label
+0+00bc <[^>]*> nop
+0+00c0 <[^>]*> sltu	at,a1,a0
+0+00c4 <[^>]*> bnezl	at,000000c4 <text_label\+0xc4>
+[ 	]*c4: R_MIPS_PC16	external_label
+0+00c8 <[^>]*> nop
 	...
Index: gas/testsuite/gas/mips/bgeu.s
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/bgeu.s,v
retrieving revision 1.5
diff -u -p -r1.5 bgeu.s
--- gas/testsuite/gas/mips/bgeu.s	12 Mar 2003 23:05:31 -0000	1.5
+++ gas/testsuite/gas/mips/bgeu.s	21 Nov 2005 19:43:01 -0000
@@ -23,10 +23,10 @@ text_label:	
 	bgtul	$4,$5,text_label
 
 # Branch to an external label.
-#	bgeu	$4,$5,external_label
-#	bgtu	$4,$5,external_label
-#	bgeul	$4,$5,external_label
-#	bgtul	$4,$5,external_label
+	bgeu	$4,$5,external_label
+	bgtu	$4,$5,external_label
+	bgeul	$4,$5,external_label
+	bgtul	$4,$5,external_label
 
 # Round to a 16 byte boundary, for ease in testing multiple targets.
 	nop
Index: gas/testsuite/gas/mips/blt.d
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/blt.d,v
retrieving revision 1.8
diff -u -p -r1.8 blt.d
--- gas/testsuite/gas/mips/blt.d	7 May 2003 05:08:20 -0000	1.8
+++ gas/testsuite/gas/mips/blt.d	21 Nov 2005 19:43:01 -0000
@@ -52,20 +52,20 @@ Disassembly of section .text:
 0+00a8 <[^>]*> slt	at,a1,a0
 0+00ac <[^>]*> beqzl	at,0+0000 <text_label>
 0+00b0 <[^>]*> nop
-#0+00b4 <[^>]*> slt	at,a0,a1
-#0+00b8 <[^>]*> bnez	at,000000b8 <text_label\+0xb8>
-#[ 	]*b8: R_MIPS_PC16	external_label
-#0+00bc <[^>]*> nop
-#0+00c0 <[^>]*> slt	at,a1,a0
-#0+00c4 <[^>]*> beqz	at,000000c4 <text_label\+0xc4>
-#[ 	]*c4: R_MIPS_PC16	external_label
-#0+00c8 <[^>]*> nop
-#0+00cc <[^>]*> slt	at,a0,a1
-#0+00d0 <[^>]*> bnezl	at,000000d0 <text_label\+0xd0>
-#[ 	]*d0: R_MIPS_PC16	external_label
-#0+00d4 <[^>]*> nop
-#0+00d8 <[^>]*> slt	at,a1,a0
-#0+00dc <[^>]*> beqzl	at,000000dc <text_label\+0xdc>
-#[ 	]*dc: R_MIPS_PC16	external_label
-#0+00e0 <[^>]*> nop
+0+00b4 <[^>]*> slt	at,a0,a1
+0+00b8 <[^>]*> bnez	at,000000b8 <text_label\+0xb8>
+[ 	]*b8: R_MIPS_PC16	external_label
+0+00bc <[^>]*> nop
+0+00c0 <[^>]*> slt	at,a1,a0
+0+00c4 <[^>]*> beqz	at,000000c4 <text_label\+0xc4>
+[ 	]*c4: R_MIPS_PC16	external_label
+0+00c8 <[^>]*> nop
+0+00cc <[^>]*> slt	at,a0,a1
+0+00d0 <[^>]*> bnezl	at,000000d0 <text_label\+0xd0>
+[ 	]*d0: R_MIPS_PC16	external_label
+0+00d4 <[^>]*> nop
+0+00d8 <[^>]*> slt	at,a1,a0
+0+00dc <[^>]*> beqzl	at,000000dc <text_label\+0xdc>
+[ 	]*dc: R_MIPS_PC16	external_label
+0+00e0 <[^>]*> nop
 	...
Index: gas/testsuite/gas/mips/blt.s
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/blt.s,v
retrieving revision 1.5
diff -u -p -r1.5 blt.s
--- gas/testsuite/gas/mips/blt.s	12 Mar 2003 23:05:31 -0000	1.5
+++ gas/testsuite/gas/mips/blt.s	21 Nov 2005 19:43:01 -0000
@@ -25,10 +25,10 @@ text_label:	
 	blel	$4,$5,text_label
 
 # Branch to an external label.
-#	blt	$4,$5,external_label
-#	ble	$4,$5,external_label
-#	bltl	$4,$5,external_label
-#	blel	$4,$5,external_label
+	blt	$4,$5,external_label
+	ble	$4,$5,external_label
+	bltl	$4,$5,external_label
+	blel	$4,$5,external_label
 
 # Round to a 16 byte boundary, for ease in testing multiple targets.
 	nop
Index: gas/testsuite/gas/mips/bltu.d
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/bltu.d,v
retrieving revision 1.8
diff -u -p -r1.8 bltu.d
--- gas/testsuite/gas/mips/bltu.d	7 May 2003 05:08:20 -0000	1.8
+++ gas/testsuite/gas/mips/bltu.d	21 Nov 2005 19:43:01 -0000
@@ -46,20 +46,20 @@ Disassembly of section .text:
 0+0090 <[^>]*> sltu	at,a1,a0
 0+0094 <[^>]*> beqzl	at,0+0000 <text_label>
 0+0098 <[^>]*> nop
-#0+009c <[^>]*> sltu	at,a0,a1
-#0+00a0 <[^>]*> bnez	at,000000a0 <text_label\+0xa0>
-#[ 	]*a0: R_MIPS_PC16	external_label
-#0+00a4 <[^>]*> nop
-#0+00a8 <[^>]*> sltu	at,a1,a0
-#0+00ac <[^>]*> beqz	at,000000ac <text_label\+0xac>
-#[ 	]*ac: R_MIPS_PC16	external_label
-#0+00b0 <[^>]*> nop
-#0+00b4 <[^>]*> sltu	at,a0,a1
-#0+00b8 <[^>]*> bnezl	at,000000b8 <text_label\+0xb8>
-#[ 	]*b8: R_MIPS_PC16	external_label
-#0+00bc <[^>]*> nop
-#0+00c0 <[^>]*> sltu	at,a1,a0
-#0+00c4 <[^>]*> beqzl	at,000000c4 <text_label\+0xc4>
-#[ 	]*c4: R_MIPS_PC16	external_label
-#0+00c8 <[^>]*> nop
+0+009c <[^>]*> sltu	at,a0,a1
+0+00a0 <[^>]*> bnez	at,000000a0 <text_label\+0xa0>
+[ 	]*a0: R_MIPS_PC16	external_label
+0+00a4 <[^>]*> nop
+0+00a8 <[^>]*> sltu	at,a1,a0
+0+00ac <[^>]*> beqz	at,000000ac <text_label\+0xac>
+[ 	]*ac: R_MIPS_PC16	external_label
+0+00b0 <[^>]*> nop
+0+00b4 <[^>]*> sltu	at,a0,a1
+0+00b8 <[^>]*> bnezl	at,000000b8 <text_label\+0xb8>
+[ 	]*b8: R_MIPS_PC16	external_label
+0+00bc <[^>]*> nop
+0+00c0 <[^>]*> sltu	at,a1,a0
+0+00c4 <[^>]*> beqzl	at,000000c4 <text_label\+0xc4>
+[ 	]*c4: R_MIPS_PC16	external_label
+0+00c8 <[^>]*> nop
 	...
Index: gas/testsuite/gas/mips/bltu.s
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/bltu.s,v
retrieving revision 1.5
diff -u -p -r1.5 bltu.s
--- gas/testsuite/gas/mips/bltu.s	12 Mar 2003 23:05:31 -0000	1.5
+++ gas/testsuite/gas/mips/bltu.s	21 Nov 2005 19:43:01 -0000
@@ -23,10 +23,10 @@ text_label:	
 	bleul	$4,$5,text_label
 
 # Branch to an external label.
-#	bltu	$4,$5,external_label
-#	bleu	$4,$5,external_label
-#	bltul	$4,$5,external_label
-#	bleul	$4,$5,external_label
+	bltu	$4,$5,external_label
+	bleu	$4,$5,external_label
+	bltul	$4,$5,external_label
+	bleul	$4,$5,external_label
 
 # Round to a 16 byte boundary, for ease in testing multiple targets.
 	nop
Index: gas/testsuite/gas/mips/branch-misc-2-64.d
===================================================================
RCS file: gas/testsuite/gas/mips/branch-misc-2-64.d
diff -N gas/testsuite/gas/mips/branch-misc-2-64.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/branch-misc-2-64.d	21 Nov 2005 19:43:01 -0000
@@ -0,0 +1,62 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch-misc-2-64
+#source: branch-misc-2.s
+#as: -64 -non_shared
+
+# Test the backward branches to globals symbols in current file.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+	\.\.\.
+	\.\.\.
+	\.\.\.
+0+003c <[^>]*> 04110000 	bal	0000000000000040 <x\+0x4>
+[ 	]*3c: R_MIPS_PC16	g1\+0xfffffffffffffffc
+[ 	]*3c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*3c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0040 <[^>]*> 00000000 	nop
+0+0044 <[^>]*> 04110000 	bal	0000000000000048 <x\+0xc>
+[ 	]*44: R_MIPS_PC16	g2\+0xfffffffffffffffc
+[ 	]*44: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*44: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0048 <[^>]*> 00000000 	nop
+0+004c <[^>]*> 04110000 	bal	0000000000000050 <x\+0x14>
+[ 	]*4c: R_MIPS_PC16	g3\+0xfffffffffffffffc
+[ 	]*4c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*4c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0050 <[^>]*> 00000000 	nop
+0+0054 <[^>]*> 04110000 	bal	0000000000000058 <x\+0x1c>
+[ 	]*54: R_MIPS_PC16	g4\+0xfffffffffffffffc
+[ 	]*54: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*54: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0058 <[^>]*> 00000000 	nop
+0+005c <[^>]*> 04110000 	bal	0000000000000060 <x\+0x24>
+[ 	]*5c: R_MIPS_PC16	g5\+0xfffffffffffffffc
+[ 	]*5c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*5c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0060 <[^>]*> 00000000 	nop
+0+0064 <[^>]*> 04110000 	bal	0000000000000068 <x\+0x2c>
+[ 	]*64: R_MIPS_PC16	g6\+0xfffffffffffffffc
+[ 	]*64: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*64: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0068 <[^>]*> 00000000 	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+0+00a8 <[^>]*> 10000000 	b	00000000000000ac <g6\+0x4>
+[ 	]*a8: R_MIPS_PC16	x1\+0xfffffffffffffffc
+[ 	]*a8: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*a8: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+00ac <[^>]*> 00000000 	nop
+0+00b0 <[^>]*> 10000000 	b	00000000000000b4 <g6\+0xc>
+[ 	]*b0: R_MIPS_PC16	x2\+0xfffffffffffffffc
+[ 	]*b0: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*b0: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+00b4 <[^>]*> 00000000 	nop
+0+00b8 <[^>]*> 10000000 	b	00000000000000bc <g6\+0x14>
+[ 	]*b8: R_MIPS_PC16	\.data\+0xfffffffffffffffc
+[ 	]*b8: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*b8: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+00bc <[^>]*> 00000000 	nop
+	\.\.\.
Index: gas/testsuite/gas/mips/branch-misc-2.d
===================================================================
RCS file: gas/testsuite/gas/mips/branch-misc-2.d
diff -N gas/testsuite/gas/mips/branch-misc-2.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/branch-misc-2.d	21 Nov 2005 19:43:01 -0000
@@ -0,0 +1,43 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch-misc-2
+#as: -32 -non_shared
+
+# Test the backward branches to globals symbols in current file.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+	\.\.\.
+	\.\.\.
+	\.\.\.
+0+003c <[^>]*> 0411ffff 	bal	0000003c <x>
+[ 	]*3c: R_MIPS_PC16	g1
+0+0040 <[^>]*> 00000000 	nop
+0+0044 <[^>]*> 0411ffff 	bal	00000044 <x\+0x8>
+[ 	]*44: R_MIPS_PC16	g2
+0+0048 <[^>]*> 00000000 	nop
+0+004c <[^>]*> 0411ffff 	bal	0000004c <x\+0x10>
+[ 	]*4c: R_MIPS_PC16	g3
+0+0050 <[^>]*> 00000000 	nop
+0+0054 <[^>]*> 0411ffff 	bal	00000054 <x\+0x18>
+[ 	]*54: R_MIPS_PC16	g4
+0+0058 <[^>]*> 00000000 	nop
+0+005c <[^>]*> 0411ffff 	bal	0000005c <x\+0x20>
+[ 	]*5c: R_MIPS_PC16	g5
+0+0060 <[^>]*> 00000000 	nop
+0+0064 <[^>]*> 0411ffff 	bal	00000064 <x\+0x28>
+[ 	]*64: R_MIPS_PC16	g6
+0+0068 <[^>]*> 00000000 	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+0+00a8 <[^>]*> 1000ffff 	b	000000a8 <g6>
+[ 	]*a8: R_MIPS_PC16	x1
+0+00ac <[^>]*> 00000000 	nop
+0+00b0 <[^>]*> 1000ffff 	b	000000b0 <g6\+0x8>
+[ 	]*b0: R_MIPS_PC16	x2
+0+00b4 <[^>]*> 00000000 	nop
+0+00b8 <[^>]*> 1000ffff 	b	000000b8 <g6\+0x10>
+[ 	]*b8: R_MIPS_PC16	\.data
+0+00bc <[^>]*> 00000000 	nop
+	\.\.\.
Index: gas/testsuite/gas/mips/branch-misc-2.l
===================================================================
RCS file: gas/testsuite/gas/mips/branch-misc-2.l
diff -N gas/testsuite/gas/mips/branch-misc-2.l
--- gas/testsuite/gas/mips/branch-misc-2.l	9 Jul 2003 01:27:30 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,4 +0,0 @@
-.*: Assembler messages:
-.*:35: Error: Cannot branch to undefined symbol.
-.*:36: Error: Cannot branch to undefined symbol.
-.*:37: Error: Cannot branch to symbol in another section.
Index: gas/testsuite/gas/mips/branch-misc-2pic-64.d
===================================================================
RCS file: gas/testsuite/gas/mips/branch-misc-2pic-64.d
diff -N gas/testsuite/gas/mips/branch-misc-2pic-64.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/branch-misc-2pic-64.d	21 Nov 2005 19:43:01 -0000
@@ -0,0 +1,62 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch-misc-2-64
+#source: branch-misc-2.s
+#as: -64 -call_shared
+
+# Test the backward branches to globals symbols in current file.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+	\.\.\.
+	\.\.\.
+	\.\.\.
+0+003c <[^>]*> 04110000 	bal	0000000000000040 <x\+0x4>
+[ 	]*3c: R_MIPS_PC16	g1\+0xfffffffffffffffc
+[ 	]*3c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*3c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0040 <[^>]*> 00000000 	nop
+0+0044 <[^>]*> 04110000 	bal	0000000000000048 <x\+0xc>
+[ 	]*44: R_MIPS_PC16	g2\+0xfffffffffffffffc
+[ 	]*44: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*44: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0048 <[^>]*> 00000000 	nop
+0+004c <[^>]*> 04110000 	bal	0000000000000050 <x\+0x14>
+[ 	]*4c: R_MIPS_PC16	g3\+0xfffffffffffffffc
+[ 	]*4c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*4c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0050 <[^>]*> 00000000 	nop
+0+0054 <[^>]*> 04110000 	bal	0000000000000058 <x\+0x1c>
+[ 	]*54: R_MIPS_PC16	g4\+0xfffffffffffffffc
+[ 	]*54: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*54: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0058 <[^>]*> 00000000 	nop
+0+005c <[^>]*> 04110000 	bal	0000000000000060 <x\+0x24>
+[ 	]*5c: R_MIPS_PC16	g5\+0xfffffffffffffffc
+[ 	]*5c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*5c: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0060 <[^>]*> 00000000 	nop
+0+0064 <[^>]*> 04110000 	bal	0000000000000068 <x\+0x2c>
+[ 	]*64: R_MIPS_PC16	g6\+0xfffffffffffffffc
+[ 	]*64: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*64: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+0068 <[^>]*> 00000000 	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+0+00a8 <[^>]*> 10000000 	b	00000000000000ac <g6\+0x4>
+[ 	]*a8: R_MIPS_PC16	x1\+0xfffffffffffffffc
+[ 	]*a8: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*a8: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+00ac <[^>]*> 00000000 	nop
+0+00b0 <[^>]*> 10000000 	b	00000000000000b4 <g6\+0xc>
+[ 	]*b0: R_MIPS_PC16	x2\+0xfffffffffffffffc
+[ 	]*b0: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*b0: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+00b4 <[^>]*> 00000000 	nop
+0+00b8 <[^>]*> 10000000 	b	00000000000000bc <g6\+0x14>
+[ 	]*b8: R_MIPS_PC16	\.data\+0xfffffffffffffffc
+[ 	]*b8: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+[ 	]*b8: R_MIPS_NONE	\*ABS\*\+0xfffffffffffffffc
+0+00bc <[^>]*> 00000000 	nop
+	\.\.\.
Index: gas/testsuite/gas/mips/branch-misc-2pic.d
===================================================================
RCS file: gas/testsuite/gas/mips/branch-misc-2pic.d
diff -N gas/testsuite/gas/mips/branch-misc-2pic.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/branch-misc-2pic.d	21 Nov 2005 19:43:01 -0000
@@ -0,0 +1,44 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch-misc-2pic
+#source: branch-misc-2.s
+#as: -32 -call_shared
+
+# Test the backward branches to globals symbols in current file.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+	\.\.\.
+	\.\.\.
+	\.\.\.
+0+003c <[^>]*> 0411ffff 	bal	0000003c <x>
+[ 	]*3c: R_MIPS_PC16	g1
+0+0040 <[^>]*> 00000000 	nop
+0+0044 <[^>]*> 0411ffff 	bal	00000044 <x\+0x8>
+[ 	]*44: R_MIPS_PC16	g2
+0+0048 <[^>]*> 00000000 	nop
+0+004c <[^>]*> 0411ffff 	bal	0000004c <x\+0x10>
+[ 	]*4c: R_MIPS_PC16	g3
+0+0050 <[^>]*> 00000000 	nop
+0+0054 <[^>]*> 0411ffff 	bal	00000054 <x\+0x18>
+[ 	]*54: R_MIPS_PC16	g4
+0+0058 <[^>]*> 00000000 	nop
+0+005c <[^>]*> 0411ffff 	bal	0000005c <x\+0x20>
+[ 	]*5c: R_MIPS_PC16	g5
+0+0060 <[^>]*> 00000000 	nop
+0+0064 <[^>]*> 0411ffff 	bal	00000064 <x\+0x28>
+[ 	]*64: R_MIPS_PC16	g6
+0+0068 <[^>]*> 00000000 	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+0+00a8 <[^>]*> 1000ffff 	b	000000a8 <g6>
+[ 	]*a8: R_MIPS_PC16	x1
+0+00ac <[^>]*> 00000000 	nop
+0+00b0 <[^>]*> 1000ffff 	b	000000b0 <g6\+0x8>
+[ 	]*b0: R_MIPS_PC16	x2
+0+00b4 <[^>]*> 00000000 	nop
+0+00b8 <[^>]*> 1000ffff 	b	000000b8 <g6\+0x10>
+[ 	]*b8: R_MIPS_PC16	\.data
+0+00bc <[^>]*> 00000000 	nop
+	\.\.\.
Index: gas/testsuite/gas/mips/branch-misc-2pic.l
===================================================================
RCS file: gas/testsuite/gas/mips/branch-misc-2pic.l
diff -N gas/testsuite/gas/mips/branch-misc-2pic.l
--- gas/testsuite/gas/mips/branch-misc-2pic.l	9 Jul 2003 01:27:30 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,10 +0,0 @@
-.*: Assembler messages:
-.*:21: Warning: Pretending global symbol used as branch target is local.
-.*:22: Warning: Pretending global symbol used as branch target is local.
-.*:23: Warning: Pretending global symbol used as branch target is local.
-.*:24: Warning: Pretending global symbol used as branch target is local.
-.*:25: Warning: Pretending global symbol used as branch target is local.
-.*:26: Warning: Pretending global symbol used as branch target is local.
-.*:35: Error: Cannot branch to undefined symbol.
-.*:36: Error: Cannot branch to undefined symbol.
-.*:37: Error: Cannot branch to symbol in another section.
Index: gas/testsuite/gas/mips/branch-misc-2pic.s
===================================================================
RCS file: gas/testsuite/gas/mips/branch-misc-2pic.s
diff -N gas/testsuite/gas/mips/branch-misc-2pic.s
--- gas/testsuite/gas/mips/branch-misc-2pic.s	9 Jul 2003 01:27:30 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,43 +0,0 @@
-# Source file used to test the backward branches to globals in this file.
-
-	.globl g1 .text
-	.globl g2 .text
-	.globl g3 .text
-	.globl g4 .text
-	.globl g5 .text
-	.globl g6 .text
-
-	.globl x1 .text
-
-	.text
-g1:
-	.space 20
-g2:
-	.space 20
-g3:
-	.space 20
-
-x:
-	bal	g1
-	bal	g2
-	bal	g3
-	bal	g4
-	bal	g5
-	bal	g6
-
-	.space 20
-g4:
-	.space 20
-g5:
-	.space 20
-g6:
-
-	b	x1
-	b	x2
-	b	.Ldata
-
-# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
-	.space	8
-
-	.data
-.Ldata:
Index: gas/testsuite/gas/mips/mips.exp
===================================================================
RCS file: /big/fsf/rsync/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.111
diff -u -p -r1.111 mips.exp
--- gas/testsuite/gas/mips/mips.exp	14 Nov 2005 02:25:39 -0000	1.111
+++ gas/testsuite/gas/mips/mips.exp	21 Nov 2005 19:43:01 -0000
@@ -427,8 +427,10 @@ if { [istarget mips*-*-*] } then {
     run_dump_test_arches "blt"		[mips_arch_list_matching mips2]
     run_dump_test_arches "bltu"		[mips_arch_list_matching mips2]
     run_dump_test_arches "branch-misc-1" [mips_arch_list_matching mips1]
-    run_list_test_arches "branch-misc-2" "-32 -non_shared" [mips_arch_list_matching mips1]
-    run_list_test_arches "branch-misc-2pic" "-32 -call_shared" [mips_arch_list_matching mips1]
+    run_dump_test_arches "branch-misc-2" [mips_arch_list_matching mips1]
+    run_dump_test_arches "branch-misc-2pic" [mips_arch_list_matching mips1]
+    run_dump_test_arches "branch-misc-2-64" [mips_arch_list_matching mips3]
+    run_dump_test_arches "branch-misc-2pic-64" [mips_arch_list_matching mips3]
     run_dump_test "branch-misc-3"
     run_dump_test "branch-swap"
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]