2013-05-06 Richard Sandiford <rdsandiford@googlemail.com>
authorCatherine Moore <clm@redhat.com>
Mon, 6 May 2013 15:00:01 +0000 (15:00 +0000)
committerCatherine Moore <clm@redhat.com>
Mon, 6 May 2013 15:00:01 +0000 (15:00 +0000)
* config/tc-mips.c (limited_pcrel_reloc_p): New function.
(mips_fix_adjustable): Adjust pc-relative check to use
limited_pc_reloc_p.

gas/ChangeLog
gas/config/tc-mips.c

index 417e5ed..5c2c89e 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-06  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * config/tc-mips.c (limited_pcrel_reloc_p): New function.
+       (mips_fix_adjustable): Adjust pc-relative check to use
+       limited_pc_reloc_p.
+
 2013-05-02  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * config/tc-mips.c (mips_pseudo_table): Add stabd and stabs entries.
index 012935d..9014897 100644 (file)
@@ -2744,6 +2744,24 @@ jalr_reloc_p (bfd_reloc_code_real_type reloc)
   return reloc == BFD_RELOC_MIPS_JALR || reloc == BFD_RELOC_MICROMIPS_JALR;
 }
 
+/* Return true if RELOC is a PC-relative relocation that does not have
+   full address range.  */
+
+static inline bfd_boolean
+limited_pcrel_reloc_p (bfd_reloc_code_real_type reloc)
+{
+  switch (reloc)
+    {
+    case BFD_RELOC_16_PCREL_S2:
+    case BFD_RELOC_MICROMIPS_7_PCREL_S1:
+    case BFD_RELOC_MICROMIPS_10_PCREL_S1:
+    case BFD_RELOC_MICROMIPS_16_PCREL_S1:
+      return TRUE;
+
+    default:
+      return FALSE;
+    }
+}
 /* Return true if the given relocation might need a matching %lo().
    This is only "might" because SVR4 R_MIPS_GOT16 relocations only
    need a matching %lo() when applied to local symbols.  */
@@ -17814,11 +17832,12 @@ mips_fix_adjustable (fixS *fixp)
     return 0;
 
   /* There is no place to store an in-place offset for JALR relocations.
-     Likewise an in-range offset of PC-relative relocations may overflow
-     the in-place relocatable field if recalculated against the start
-     address of the symbol's containing section.  */
+     Likewise an in-range offset of limited PC-relative relocations may
+     overflow the in-place relocatable field if recalculated against the
+     start address of the symbol's containing section.  */
   if (HAVE_IN_PLACE_ADDENDS
-      && (fixp->fx_pcrel || jalr_reloc_p (fixp->fx_r_type)))
+      && (limited_pcrel_reloc_p (fixp->fx_r_type)
+         || jalr_reloc_p (fixp->fx_r_type)))
     return 0;
 
 #ifdef OBJ_ELF