[ bfd/ChangeLog ]
[deliverable/binutils-gdb.git] / gas / config / tc-mips.c
index 19e016130ea47813d83f850c50b66e68ad755164..788a34b5ba6130f9be3bd02faff5909e5d74095d 100644 (file)
@@ -1838,7 +1838,7 @@ md_begin (void)
   bfd_set_gp_size (stdoutput, g_switch_value);
 
 #ifdef OBJ_ELF
-  if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
+  if (IS_ELF)
     {
       /* On a native system other than VxWorks, sections must be aligned
         to 16 byte boundaries.  When configured for an embedded ELF
@@ -1911,7 +1911,7 @@ md_begin (void)
                                          SEC_HAS_CONTENTS | SEC_READONLY);
            (void) bfd_set_section_alignment (stdoutput, sec, 2);
          }
-       else if (OUTPUT_FLAVOR == bfd_target_elf_flavour && mips_flag_pdr)
+       else if (mips_flag_pdr)
          {
            pdr_seg = subseg_new (".pdr", (subsegT) 0);
            (void) bfd_set_section_flags (stdoutput, pdr_seg,
@@ -2138,6 +2138,28 @@ mips_move_labels (void)
     }
 }
 
+static bfd_boolean
+s_is_linkonce (symbolS *sym, segT from_seg)
+{
+  bfd_boolean linkonce = FALSE;
+  segT symseg = S_GET_SEGMENT (sym);
+
+  if (symseg != from_seg && !S_IS_LOCAL (sym))
+    {
+      if ((bfd_get_section_flags (stdoutput, symseg) & SEC_LINK_ONCE))
+       linkonce = TRUE;
+#ifdef OBJ_ELF
+      /* The GNU toolchain uses an extension for ELF: a section
+        beginning with the magic string .gnu.linkonce is a
+        linkonce section.  */
+      if (strncmp (segment_name (symseg), ".gnu.linkonce",
+                  sizeof ".gnu.linkonce" - 1) == 0)
+       linkonce = TRUE;
+#endif
+    }
+  return linkonce;
+}
+
 /* Mark instruction labels in mips16 mode.  This permits the linker to
    handle them specially, such as generating jalx instructions when
    needed.  We also make them odd for the duration of the assembly, in
@@ -2160,10 +2182,17 @@ mips16_mark_labels (void)
       symbolS *label = l->label;
 
 #if defined(OBJ_ELF) || defined(OBJ_MAYBE_ELF)
-      if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
+      if (IS_ELF)
        S_SET_OTHER (label, STO_MIPS16);
 #endif
-      if ((S_GET_VALUE (label) & 1) == 0)
+      if ((S_GET_VALUE (label) & 1) == 0
+       /* Don't adjust the address if the label is global or weak, or
+          in a link-once section, since we'll be emitting symbol reloc
+          references to it which will be patched up by the linker, and
+          the final value of the symbol may or may not be MIPS16.  */
+         && ! S_IS_WEAK (label)
+         && ! S_IS_EXTERNAL (label)
+         && ! s_is_linkonce (label, now_seg))
        S_SET_VALUE (label, S_GET_VALUE (label) | 1);
     }
 }
@@ -9399,15 +9428,14 @@ do_msbd:
                        break;
                      }
                    new_seg = subseg_new (newname, (subsegT) 0);
-                   if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
+                   if (IS_ELF)
                      bfd_set_section_flags (stdoutput, new_seg,
                                             (SEC_ALLOC
                                              | SEC_LOAD
                                              | SEC_READONLY
                                              | SEC_DATA));
                    frag_align (*args == 'l' ? 2 : 3, 0, 0);
-                   if (OUTPUT_FLAVOR == bfd_target_elf_flavour
-                       && strcmp (TARGET_OS, "elf") != 0)
+                   if (IS_ELF && strcmp (TARGET_OS, "elf") != 0)
                      record_alignment (new_seg, 4);
                    else
                      record_alignment (new_seg, *args == 'l' ? 2 : 3);
@@ -11142,7 +11170,7 @@ md_parse_option (int c, char *arg)
         select SVR4_PIC, and -non_shared to select no PIC.  This is
         intended to be compatible with Irix 5.  */
     case OPTION_CALL_SHARED:
-      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+      if (!IS_ELF)
        {
          as_bad (_("-call_shared is supported only for ELF format"));
          return 0;
@@ -11152,7 +11180,7 @@ md_parse_option (int c, char *arg)
       break;
 
     case OPTION_NON_SHARED:
-      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+      if (!IS_ELF)
        {
          as_bad (_("-non_shared is supported only for ELF format"));
          return 0;
@@ -11178,7 +11206,7 @@ md_parse_option (int c, char *arg)
       /* The -32, -n32 and -64 options are shortcuts for -mabi=32, -mabi=n32
         and -mabi=64.  */
     case OPTION_32:
-      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+      if (!IS_ELF)
        {
          as_bad (_("-32 is supported for ELF format only"));
          return 0;
@@ -11187,7 +11215,7 @@ md_parse_option (int c, char *arg)
       break;
 
     case OPTION_N32:
-      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+      if (!IS_ELF)
        {
          as_bad (_("-n32 is supported for ELF format only"));
          return 0;
@@ -11196,13 +11224,13 @@ md_parse_option (int c, char *arg)
       break;
 
     case OPTION_64:
-      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+      if (!IS_ELF)
        {
          as_bad (_("-64 is supported for ELF format only"));
          return 0;
        }
       mips_abi = N64_ABI;
-      if (! support_64bit_objects())
+      if (!support_64bit_objects())
        as_fatal (_("No compiled in support for 64 bit object file format"));
       break;
 #endif /* OBJ_ELF */
@@ -11225,7 +11253,7 @@ md_parse_option (int c, char *arg)
 
 #ifdef OBJ_ELF
     case OPTION_MABI:
-      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+      if (!IS_ELF)
        {
          as_bad (_("-mabi is supported for ELF format only"));
          return 0;
@@ -12002,7 +12030,8 @@ s_change_sec (int sec)
      as it would not be appropriate to use it in the section changing
      functions in read.c, since obj-elf.c intercepts those.  FIXME:
      This should be cleaner, somehow.  */
-  obj_elf_section_change_hook ();
+  if (IS_ELF)
+    obj_elf_section_change_hook ();
 #endif
 
   mips_emit_delays ();
@@ -12022,7 +12051,7 @@ s_change_sec (int sec)
     case 'r':
       seg = subseg_new (RDATA_SECTION_NAME,
                        (subsegT) get_absolute_expression ());
-      if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
+      if (IS_ELF)
        {
          bfd_set_section_flags (stdoutput, seg, (SEC_ALLOC | SEC_LOAD
                                                  | SEC_READONLY | SEC_RELOC
@@ -12035,7 +12064,7 @@ s_change_sec (int sec)
 
     case 's':
       seg = subseg_new (".sdata", (subsegT) get_absolute_expression ());
-      if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
+      if (IS_ELF)
        {
          bfd_set_section_flags (stdoutput, seg,
                                 SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA);
@@ -12061,7 +12090,7 @@ s_change_section (int ignore ATTRIBUTE_UNUSED)
   int section_entry_size;
   int section_alignment;
 
-  if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+  if (!IS_ELF)
     return;
 
   section_name = input_line_pointer;
@@ -13113,6 +13142,8 @@ nopic_need_relax (symbolS *sym, int before_relaxing)
          change = (strcmp (segname, ".sdata") != 0
                    && strcmp (segname, ".sbss") != 0
                    && strncmp (segname, ".sdata.", 7) != 0
+                   && strncmp (segname, ".sbss.", 6) != 0
+                   && strncmp (segname, ".gnu.linkonce.sb.", 17) != 0
                    && strncmp (segname, ".gnu.linkonce.s.", 16) != 0);
        }
       return change;
@@ -13129,15 +13160,13 @@ static bfd_boolean
 pic_need_relax (symbolS *sym, asection *segtype)
 {
   asection *symsec;
-  bfd_boolean linkonce;
 
   /* Handle the case of a symbol equated to another symbol.  */
   while (symbol_equated_reloc_p (sym))
     {
       symbolS *n;
 
-      /* It's possible to get a loop here in a badly written
-        program.  */
+      /* It's possible to get a loop here in a badly written program.  */
       n = symbol_get_value_expression (sym)->X_add_symbol;
       if (n == sym)
        break;
@@ -13146,31 +13175,14 @@ pic_need_relax (symbolS *sym, asection *segtype)
 
   symsec = S_GET_SEGMENT (sym);
 
-  /* duplicate the test for LINK_ONCE sections as in adjust_reloc_syms */
-  linkonce = FALSE;
-  if (symsec != segtype && ! S_IS_LOCAL (sym))
-    {
-      if ((bfd_get_section_flags (stdoutput, symsec) & SEC_LINK_ONCE)
-         != 0)
-       linkonce = TRUE;
-
-      /* The GNU toolchain uses an extension for ELF: a section
-        beginning with the magic string .gnu.linkonce is a linkonce
-        section.  */
-      if (strncmp (segment_name (symsec), ".gnu.linkonce",
-                  sizeof ".gnu.linkonce" - 1) == 0)
-       linkonce = TRUE;
-    }
-
   /* This must duplicate the test in adjust_reloc_syms.  */
   return (symsec != &bfd_und_section
          && symsec != &bfd_abs_section
-         && ! bfd_is_com_section (symsec)
-         && !linkonce
+         && !bfd_is_com_section (symsec)
+         && !s_is_linkonce (sym, segtype)
 #ifdef OBJ_ELF
          /* A global or weak symbol is treated as external.  */
-         && (OUTPUT_FLAVOR != bfd_target_elf_flavour
-             || (! S_IS_WEAK (sym) && ! S_IS_EXTERNAL (sym)))
+         && (!IS_ELF || (! S_IS_WEAK (sym) && ! S_IS_EXTERNAL (sym)))
 #endif
          );
 }
@@ -13486,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;
@@ -13522,7 +13529,7 @@ mips_fix_adjustable (fixS *fixp)
 #ifdef OBJ_ELF
   /* Don't adjust relocations against mips16 symbols, so that the linker
      can find them if it needs to set up a stub.  */
-  if (OUTPUT_FLAVOR == bfd_target_elf_flavour
+  if (IS_ELF
       && S_GET_OTHER (fixp->fx_addsy) == STO_MIPS16
       && fixp->fx_subsy == NULL)
     return 0;
@@ -13554,7 +13561,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
       /* 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)
+      if (!IS_ELF)
        {
          /* A gruesome hack which is a result of the gruesome gas
             reloc handling.  What's worse, for COFF (as opposed to
@@ -13566,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)
@@ -13993,7 +14004,7 @@ mips_frob_file_after_relocs (void)
   asymbol **syms;
   unsigned int count, i;
 
-  if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+  if (!IS_ELF)
     return;
 
   syms = bfd_get_outsymbols (stdoutput);
@@ -14349,8 +14360,7 @@ s_mips_end (int x ATTRIBUTE_UNUSED)
     }
 
   /* Generate a .pdr section.  */
-  if (OUTPUT_FLAVOR == bfd_target_elf_flavour && ! ECOFF_DEBUGGING
-      && mips_flag_pdr)
+  if (IS_ELF && !ECOFF_DEBUGGING && mips_flag_pdr)
     {
       segT saved_seg = now_seg;
       subsegT saved_subseg = now_subseg;
@@ -14444,7 +14454,7 @@ static void
 s_mips_frame (int ignore ATTRIBUTE_UNUSED)
 {
 #ifdef OBJ_ELF
-  if (OUTPUT_FLAVOR == bfd_target_elf_flavour && ! ECOFF_DEBUGGING)
+  if (IS_ELF && !ECOFF_DEBUGGING)
     {
       long val;
 
@@ -14487,7 +14497,7 @@ static void
 s_mips_mask (int reg_type)
 {
 #ifdef OBJ_ELF
-  if (OUTPUT_FLAVOR == bfd_target_elf_flavour && ! ECOFF_DEBUGGING)
+  if (IS_ELF && !ECOFF_DEBUGGING)
     {
       long mask, off;
 
@@ -14619,6 +14629,9 @@ static const struct mips_cpu_info mips_cpu_info_table[] =
   /* Broadcom SB-1 CPU core */
   { "sb1",            MIPS_CPU_ASE_MIPS3D | MIPS_CPU_ASE_MDMX,
                                                ISA_MIPS64,     CPU_SB1 },
+  /* Broadcom SB-1A CPU core */
+  { "sb1a",           MIPS_CPU_ASE_MIPS3D | MIPS_CPU_ASE_MDMX,
+                                               ISA_MIPS64,     CPU_SB1 },
 
   /* End marker */
   { NULL, 0, 0, 0 }
This page took 0.031984 seconds and 4 git commands to generate.