Statically initialise target common sections
[deliverable/binutils-gdb.git] / bfd / elfxx-mips.c
index 2f26d7ae832a5d1f05f69af35dd1142cbe3ebf49..6d43d107428be6280356488c640a58e55e12247c 100644 (file)
@@ -462,9 +462,6 @@ struct mips_elf_link_hash_table
   /* True if we are targetting R6 compact branches.  */
   bfd_boolean compact_branches;
 
-  /* True if we're generating code for VxWorks.  */
-  bfd_boolean is_vxworks;
-
   /* True if we already reported the small-data section overflow.  */
   bfd_boolean small_data_overflow_reported;
 
@@ -530,9 +527,6 @@ struct mips_elf_link_hash_table
      returns null.  */
   asection *(*add_stub_section) (const char *, asection *, asection *);
 
-  /* Small local sym cache.  */
-  struct sym_cache sym_cache;
-
   /* Is the PLT header compressed?  */
   unsigned int plt_header_is_comp : 1;
 };
@@ -540,8 +534,9 @@ struct mips_elf_link_hash_table
 /* Get the MIPS ELF linker hash table from a link_info structure.  */
 
 #define mips_elf_hash_table(p) \
-  (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
-  == MIPS_ELF_DATA ? ((struct mips_elf_link_hash_table *) ((p)->hash)) : NULL)
+  ((is_elf_hash_table ((p)->hash)                                      \
+    && elf_hash_table_id (elf_hash_table (p)) == MIPS_ELF_DATA)                \
+   ? (struct mips_elf_link_hash_table *) (p)->hash : NULL)
 
 /* A structure used to communicate with htab_traverse callbacks.  */
 struct mips_htab_traverse_info
@@ -703,13 +698,13 @@ typedef struct
 
 /* These are the constants used to swap the bitfields in a crinfo.  */
 
-#define CRINFO_CTYPE (0x1)
+#define CRINFO_CTYPE (0x1U)
 #define CRINFO_CTYPE_SH (31)
-#define CRINFO_RTYPE (0xf)
+#define CRINFO_RTYPE (0xfU)
 #define CRINFO_RTYPE_SH (27)
-#define CRINFO_DIST2TO (0xff)
+#define CRINFO_DIST2TO (0xffU)
 #define CRINFO_DIST2TO_SH (19)
-#define CRINFO_RELVADDR (0x7ffff)
+#define CRINFO_RELVADDR (0x7ffffU)
 #define CRINFO_RELVADDR_SH (0)
 
 /* A compact relocation info has long (3 words) or short (2 words)
@@ -904,7 +899,8 @@ static bfd *reldyn_sorting_bfd;
 
 /* The name of the dynamic relocation section.  */
 #define MIPS_ELF_REL_DYN_NAME(INFO) \
-  (mips_elf_hash_table (INFO)->is_vxworks ? ".rela.dyn" : ".rel.dyn")
+  (mips_elf_hash_table (INFO)->root.target_os == is_vxworks \
+   ? ".rela.dyn" : ".rel.dyn")
 
 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
    from smaller values.  Start with zero, widen, *then* decrement.  */
@@ -919,7 +915,8 @@ static bfd *reldyn_sorting_bfd;
 
 /* The offset of $gp from the beginning of the .got section.  */
 #define ELF_MIPS_GP_OFFSET(INFO) \
-  (mips_elf_hash_table (INFO)->is_vxworks ? 0x0 : 0x7ff0)
+  (mips_elf_hash_table (INFO)->root.target_os == is_vxworks \
+   ? 0x0 : 0x7ff0)
 
 /* The maximum size of the GOT for it to be addressable using 16-bit
    offsets from $gp.  */
@@ -1450,30 +1447,18 @@ _bfd_mips_elf_read_ecoff_info (bfd *abfd, asection *section,
   return TRUE;
 
  error_return:
-  if (ext_hdr != NULL)
-    free (ext_hdr);
-  if (debug->line != NULL)
-    free (debug->line);
-  if (debug->external_dnr != NULL)
-    free (debug->external_dnr);
-  if (debug->external_pdr != NULL)
-    free (debug->external_pdr);
-  if (debug->external_sym != NULL)
-    free (debug->external_sym);
-  if (debug->external_opt != NULL)
-    free (debug->external_opt);
-  if (debug->external_aux != NULL)
-    free (debug->external_aux);
-  if (debug->ss != NULL)
-    free (debug->ss);
-  if (debug->ssext != NULL)
-    free (debug->ssext);
-  if (debug->external_fdr != NULL)
-    free (debug->external_fdr);
-  if (debug->external_rfd != NULL)
-    free (debug->external_rfd);
-  if (debug->external_ext != NULL)
-    free (debug->external_ext);
+  free (ext_hdr);
+  free (debug->line);
+  free (debug->external_dnr);
+  free (debug->external_pdr);
+  free (debug->external_sym);
+  free (debug->external_opt);
+  free (debug->external_aux);
+  free (debug->ss);
+  free (debug->ssext);
+  free (debug->external_fdr);
+  free (debug->external_rfd);
+  free (debug->external_ext);
   return FALSE;
 }
 \f
@@ -1618,30 +1603,19 @@ mips_elf_create_procedure_table (void *handle, bfd *abfd,
      matters, but someday it might).  */
   s->map_head.link_order = NULL;
 
-  if (epdr != NULL)
-    free (epdr);
-  if (rpdr != NULL)
-    free (rpdr);
-  if (esym != NULL)
-    free (esym);
-  if (ss != NULL)
-    free (ss);
-  if (sv != NULL)
-    free (sv);
-
+  free (epdr);
+  free (rpdr);
+  free (esym);
+  free (ss);
+  free (sv);
   return TRUE;
 
  error_return:
-  if (epdr != NULL)
-    free (epdr);
-  if (rpdr != NULL)
-    free (rpdr);
-  if (esym != NULL)
-    free (esym);
-  if (ss != NULL)
-    free (ss);
-  if (sv != NULL)
-    free (sv);
+  free (epdr);
+  free (rpdr);
+  free (esym);
+  free (ss);
+  free (sv);
   return FALSE;
 }
 \f
@@ -3844,7 +3818,7 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
   MIPS_ELF_PUT_WORD (abfd, value, htab->root.sgot->contents + entry->gotidx);
 
   /* These GOT entries need a dynamic relocation on VxWorks.  */
-  if (htab->is_vxworks)
+  if (htab->root.target_os == is_vxworks)
     {
       Elf_Internal_Rela outrel;
       asection *s;
@@ -4189,7 +4163,7 @@ mips_elf_allocate_dynamic_relocations (bfd *abfd, struct bfd_link_info *info,
   s = mips_elf_rel_dyn_section (info, FALSE);
   BFD_ASSERT (s != NULL);
 
-  if (htab->is_vxworks)
+  if (htab->root.target_os == is_vxworks)
     s->size += n * MIPS_ELF_RELA_SIZE (abfd);
   else
     {
@@ -4425,7 +4399,7 @@ mips_elf_resolve_got_page_ref (void **refp, void *data)
       Elf_Internal_Sym *isym;
 
       /* Read in the symbol.  */
-      isym = bfd_sym_from_r_symndx (&htab->sym_cache, ref->u.abfd,
+      isym = bfd_sym_from_r_symndx (&htab->root.sym_cache, ref->u.abfd,
                                    ref->symndx);
       if (isym == NULL)
        {
@@ -4575,7 +4549,7 @@ mips_elf_count_got_symbols (struct mips_elf_link_hash_entry *h, void *data)
           entry if it was only used for relocations; those relocations
           will be against the null or section symbol instead of H.  */
        h->global_got_area = GGA_NONE;
-      else if (htab->is_vxworks
+      else if (htab->root.target_os == is_vxworks
               && h->got_only_for_calls
               && h->root.plt.plist->mips_offset != MINUS_ONE)
        /* On VxWorks, calls can refer directly to the .got.plt entry;
@@ -5289,7 +5263,7 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
 static bfd_boolean
 is_gott_symbol (struct bfd_link_info *info, struct elf_link_hash_entry *h)
 {
-  return (mips_elf_hash_table (info)->is_vxworks
+  return (mips_elf_hash_table (info)->root.target_os == is_vxworks
          && bfd_link_pic (info)
          && (strcmp (h->root.root.string, "__GOTT_BASE__") == 0
              || strcmp (h->root.root.string, "__GOTT_INDEX__") == 0));
@@ -5393,7 +5367,7 @@ mips_elf_nullify_got_load (bfd *input_bfd, bfd_byte *contents,
   if (mips16_reloc_p (r_type)
       && (((x >> 22) & 0x3ff) == 0x3d3                         /* LW */
          || ((x >> 22) & 0x3ff) == 0x3c7))                     /* LD */
-    x = (0x3cd << 22) | (x & (7 << 16)) << 3;                  /* LI */
+    x = (0x3cdU << 22) | (x & (7 << 16)) << 3;                 /* LI */
   else if (micromips_reloc_p (r_type)
           && ((x >> 26) & 0x37) == 0x37)                       /* LW/LD */
     x = (0xc << 26) | (x & (0x1f << 21));                      /* ADDIU */
@@ -5927,7 +5901,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
        {
          /* On VxWorks, CALL relocations should refer to the .got.plt
             entry, which is initialized to point at the PLT stub.  */
-         if (htab->is_vxworks
+         if (htab->root.target_os == is_vxworks
              && (call_hi16_reloc_p (r_type)
                  || call_lo16_reloc_p (r_type)
                  || call16_reloc_p (r_type)))
@@ -5947,7 +5921,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
                MIPS_ELF_PUT_WORD (dynobj, symbol, htab->root.sgot->contents + g);
            }
        }
-      else if (!htab->is_vxworks
+      else if (htab->root.target_os != is_vxworks
               && (call16_reloc_p (r_type) || got16_reloc_p (r_type)))
        /* The calculation below does not involve "g".  */
        break;
@@ -6229,7 +6203,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
     case R_MICROMIPS_CALL16:
       /* VxWorks does not have separate local and global semantics for
         R_MIPS*_GOT16; every relocation evaluates to "G".  */
-      if (!htab->is_vxworks && local_p)
+      if (htab->root.target_os != is_vxworks && local_p)
        {
          value = mips_elf_got16_entry (abfd, input_bfd, info,
                                        symbol + addend, !was_local_p);
@@ -6768,7 +6742,8 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd,
      in the relocation.  */
   if (h != NULL && ! SYMBOL_REFERENCES_LOCAL (info, &h->root))
     {
-      BFD_ASSERT (htab->is_vxworks || h->global_got_area != GGA_NONE);
+      BFD_ASSERT (htab->root.target_os == is_vxworks
+                 || h->global_got_area != GGA_NONE);
       indx = h->root.dynindx;
       if (SGI_COMPAT (output_bfd))
        defined_p = h->root.def_regular;
@@ -6827,7 +6802,7 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd,
   if (defined_p && r_type != R_MIPS_REL32)
     *addendp += symbol;
 
-  if (htab->is_vxworks)
+  if (htab->root.target_os == is_vxworks)
     /* VxWorks uses non-relative relocations for this.  */
     outrel[0].r_info = ELF32_R_INFO (indx, R_MIPS_32);
   else
@@ -6873,7 +6848,7 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd,
         (sreloc->contents
          + sreloc->reloc_count * sizeof (Elf64_Mips_External_Rel)));
     }
-  else if (htab->is_vxworks)
+  else if (htab->root.target_os == is_vxworks)
     {
       /* VxWorks uses RELA rather than REL dynamic relocations.  */
       outrel[0].r_addend = *addendp;
@@ -7083,15 +7058,21 @@ elf_mips_abi_name (bfd *abfd)
    faster assembler code.  This is what we use for the small common
    section.  This approach is copied from ecoff.c.  */
 static asection mips_elf_scom_section;
-static asymbol mips_elf_scom_symbol;
-static asymbol *mips_elf_scom_symbol_ptr;
+static const asymbol mips_elf_scom_symbol =
+  GLOBAL_SYM_INIT (".scommon", &mips_elf_scom_section);
+static asection mips_elf_scom_section =
+  BFD_FAKE_SECTION (mips_elf_scom_section, &mips_elf_scom_symbol,
+                   ".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
 
 /* MIPS ELF also uses an acommon section, which represents an
    allocated common symbol which may be overridden by a
    definition in a shared library.  */
 static asection mips_elf_acom_section;
-static asymbol mips_elf_acom_symbol;
-static asymbol *mips_elf_acom_symbol_ptr;
+static const asymbol mips_elf_acom_symbol =
+  GLOBAL_SYM_INIT (".acommon", &mips_elf_acom_section);
+static asection mips_elf_acom_section =
+  BFD_FAKE_SECTION (mips_elf_acom_section, &mips_elf_acom_symbol,
+                   ".acommon", 0, SEC_ALLOC);
 
 /* This is used for both the 32-bit and the 64-bit ABI.  */
 
@@ -7110,19 +7091,6 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym)
         either resolve these symbols to something in a shared
         library, or it can just leave them here.  For our purposes,
         we can consider these symbols to be in a new section.  */
-      if (mips_elf_acom_section.name == NULL)
-       {
-         /* Initialize the acommon section.  */
-         mips_elf_acom_section.name = ".acommon";
-         mips_elf_acom_section.flags = SEC_ALLOC;
-         mips_elf_acom_section.output_section = &mips_elf_acom_section;
-         mips_elf_acom_section.symbol = &mips_elf_acom_symbol;
-         mips_elf_acom_section.symbol_ptr_ptr = &mips_elf_acom_symbol_ptr;
-         mips_elf_acom_symbol.name = ".acommon";
-         mips_elf_acom_symbol.flags = BSF_SECTION_SYM;
-         mips_elf_acom_symbol.section = &mips_elf_acom_section;
-         mips_elf_acom_symbol_ptr = &mips_elf_acom_symbol;
-       }
       asym->section = &mips_elf_acom_section;
       break;
 
@@ -7135,19 +7103,6 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym)
        break;
       /* Fall through.  */
     case SHN_MIPS_SCOMMON:
-      if (mips_elf_scom_section.name == NULL)
-       {
-         /* Initialize the small common section.  */
-         mips_elf_scom_section.name = ".scommon";
-         mips_elf_scom_section.flags = SEC_IS_COMMON;
-         mips_elf_scom_section.output_section = &mips_elf_scom_section;
-         mips_elf_scom_section.symbol = &mips_elf_scom_symbol;
-         mips_elf_scom_section.symbol_ptr_ptr = &mips_elf_scom_symbol_ptr;
-         mips_elf_scom_symbol.name = ".scommon";
-         mips_elf_scom_symbol.flags = BSF_SECTION_SYM;
-         mips_elf_scom_symbol.section = &mips_elf_scom_section;
-         mips_elf_scom_symbol_ptr = &mips_elf_scom_symbol;
-       }
       asym->section = &mips_elf_scom_section;
       asym->value = elfsym->internal_elf_sym.st_size;
       break;
@@ -7285,7 +7240,7 @@ _bfd_mips_elf_eh_frame_address_size (bfd *abfd, const asection *sec)
 bfd_boolean
 _bfd_mips_elf_name_local_section_symbols (bfd *abfd)
 {
-  return SGI_COMPAT (abfd);
+  return elf_elfheader (abfd)->e_type == ET_REL && SGI_COMPAT (abfd);
 }
 \f
 /* Work over a section just before writing it out.  This routine is
@@ -7826,7 +7781,7 @@ _bfd_mips_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
       /* Fall through.  */
     case SHN_MIPS_SCOMMON:
       *secp = bfd_make_section_old_way (abfd, ".scommon");
-      (*secp)->flags |= SEC_IS_COMMON;
+      (*secp)->flags |= SEC_IS_COMMON | SEC_SMALL_DATA;
       *valp = sym->st_size;
       break;
 
@@ -7996,7 +7951,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 
   /* The psABI requires a read-only .dynamic section, but the VxWorks
      EABI doesn't.  */
-  if (!htab->is_vxworks)
+  if (htab->root.target_os != is_vxworks)
     {
       s = bfd_get_linker_section (abfd, ".dynamic");
       if (s != NULL)
@@ -8144,7 +8099,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     return FALSE;
 
   /* Do the usual VxWorks handling.  */
-  if (htab->is_vxworks
+  if (htab->root.target_os == is_vxworks
       && !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
     return FALSE;
 
@@ -8677,10 +8632,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
       call_reloc_p = FALSE;
 
       /* Set CONSTRAIN_SYMBOL_P if we need to take the relocation
-        into account when deciding how to define the symbol.
-        Relocations in nonallocatable sections such as .pdr and
-        .debug* should have no effect.  */
-      constrain_symbol_p = ((sec->flags & SEC_ALLOC) != 0);
+        into account when deciding how to define the symbol.  */
+      constrain_symbol_p = TRUE;
 
       switch (r_type)
        {
@@ -8748,7 +8701,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
            elf_hash_table (info)->dynobj = dynobj = abfd;
          if (!mips_elf_create_got_section (dynobj, info))
            return FALSE;
-         if (htab->is_vxworks && !bfd_link_pic (info))
+         if (htab->root.target_os == is_vxworks
+             && !bfd_link_pic (info))
            {
              _bfd_error_handler
                /* xgettext:c-format */
@@ -8794,7 +8748,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
             against a read-only section.  */
          if ((bfd_link_pic (info)
               || (h != NULL
-                  && !htab->is_vxworks
+                  && htab->root.target_os != is_vxworks
                   && strcmp (h->root.root.string, "__gnu_local_gp") != 0
                   && !(!info->nocopyreloc
                        && !PIC_OBJECT_P (abfd)
@@ -8836,7 +8790,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
                 relocations related to taking the function's address.
                 This doesn't apply to VxWorks, where CALL relocs refer
                 to a .got.plt entry instead of a normal .got entry.  */
-             if (!htab->is_vxworks && (!can_make_dynamic_p || !call_reloc_p))
+             if (htab->root.target_os != is_vxworks
+                 && (!can_make_dynamic_p || !call_reloc_p))
                ((struct mips_elf_link_hash_entry *) h)->no_fn_stub = TRUE;
            }
 
@@ -8861,7 +8816,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
       else if (call_lo16_reloc_p (r_type)
               || got_lo16_reloc_p (r_type)
               || got_disp_reloc_p (r_type)
-              || (got16_reloc_p (r_type) && htab->is_vxworks))
+              || (got16_reloc_p (r_type)
+                  && htab->root.target_os == is_vxworks))
        {
          /* We may need a local GOT entry for this relocation.  We
             don't count R_MIPS_GOT_PAGE because we can estimate the
@@ -9225,7 +9181,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
   /* VxWorks executables are handled elsewhere; we only need to
      allocate relocations in shared objects.  */
-  if (htab->is_vxworks && !bfd_link_pic (info))
+  if (htab->root.target_os == is_vxworks && !bfd_link_pic (info))
     return TRUE;
 
   /* Ignore indirect symbols.  All relocations against such symbols
@@ -9270,7 +9226,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
             VxWorks does not enforce the same mapping between the GOT
             and the symbol table, so the same requirement does not
             apply there.  */
-         if (!htab->is_vxworks)
+         if (htab->root.target_os != is_vxworks)
            {
              if (hmips->global_got_area > GGA_RELOC_ONLY)
                hmips->global_got_area = GGA_RELOC_ONLY;
@@ -9337,7 +9293,9 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
 
      Traditional stubs are only available on SVR4 psABI-based systems;
      VxWorks always uses PLTs instead.  */
-  if (!htab->is_vxworks && h->needs_plt && !hmips->no_fn_stub)
+  if (htab->root.target_os != is_vxworks
+      && h->needs_plt
+      && !hmips->no_fn_stub)
     {
       if (! elf_hash_table (info)->dynamic_sections_created)
        return TRUE;
@@ -9386,7 +9344,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
             entry is 16 bytes and the PLT0 entry is 32 bytes.
             Encourage better cache usage by aligning.  We do this
             lazily to avoid pessimizing traditional objects.  */
-         if (!htab->is_vxworks
+         if (htab->root.target_os != is_vxworks
              && !bfd_set_section_alignment (htab->root.splt, 5))
            return FALSE;
 
@@ -9398,21 +9356,23 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
 
          /* On non-VxWorks targets, the first two entries in .got.plt
             are reserved.  */
-         if (!htab->is_vxworks)
+         if (htab->root.target_os != is_vxworks)
            htab->plt_got_index
              += (get_elf_backend_data (dynobj)->got_header_size
                  / MIPS_ELF_GOT_SIZE (dynobj));
 
          /* On VxWorks, also allocate room for the header's
             .rela.plt.unloaded entries.  */
-         if (htab->is_vxworks && !bfd_link_pic (info))
+         if (htab->root.target_os == is_vxworks
+             && !bfd_link_pic (info))
            htab->srelplt2->size += 2 * sizeof (Elf32_External_Rela);
 
          /* Now work out the sizes of individual PLT entries.  */
-         if (htab->is_vxworks && bfd_link_pic (info))
+         if (htab->root.target_os == is_vxworks
+             && bfd_link_pic (info))
            htab->plt_mips_entry_size
              = 4 * ARRAY_SIZE (mips_vxworks_shared_plt_entry);
-         else if (htab->is_vxworks)
+         else if (htab->root.target_os == is_vxworks)
            htab->plt_mips_entry_size
              = 4 * ARRAY_SIZE (mips_vxworks_exec_plt_entry);
          else if (newabi_p)
@@ -9455,7 +9415,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
         standard entry actually has to be used as the stub ends with a J
         instruction.  */
       if (newabi_p
-         || htab->is_vxworks
+         || htab->root.target_os == is_vxworks
          || hmips->call_stub
          || hmips->call_fp_stub)
        {
@@ -9497,12 +9457,12 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
        hmips->use_plt_entry = TRUE;
 
       /* Make room for the R_MIPS_JUMP_SLOT relocation.  */
-      htab->root.srelplt->size += (htab->is_vxworks
+      htab->root.srelplt->size += (htab->root.target_os == is_vxworks
                                   ? MIPS_ELF_RELA_SIZE (dynobj)
                                   : MIPS_ELF_REL_SIZE (dynobj));
 
       /* Make room for the .rela.plt.unloaded relocations.  */
-      if (htab->is_vxworks && !bfd_link_pic (info))
+      if (htab->root.target_os == is_vxworks && !bfd_link_pic (info))
        htab->srelplt2->size += 3 * sizeof (Elf32_External_Rela);
 
       /* All relocations against this symbol that could have been made
@@ -9567,7 +9527,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
     }
   if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
     {
-      if (htab->is_vxworks)
+      if (htab->root.target_os == is_vxworks)
        srel->size += sizeof (Elf32_External_Rela);
       else
        mips_elf_allocate_dynamic_relocations (dynobj, info, 1);
@@ -9650,7 +9610,7 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info)
   /* Allocate room for the reserved entries.  VxWorks always reserves
      3 entries; other objects only reserve 2 entries.  */
   BFD_ASSERT (g->assigned_low_gotno == 0);
-  if (htab->is_vxworks)
+  if (htab->root.target_os == is_vxworks)
     htab->reserved_gotno = 3;
   else
     htab->reserved_gotno = 2;
@@ -9682,7 +9642,7 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info)
        }
     }
 
-  if (htab->is_vxworks)
+  if (htab->root.target_os == is_vxworks)
     /* There's no need to allocate page entries for VxWorks; R_MIPS*_GOT16
        relocations against local symbols evaluate to "G", and the EABI does
        not include R_MIPS_GOT_PAGE.  */
@@ -9707,7 +9667,8 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info)
   /* VxWorks does not support multiple GOTs.  It initializes $gp to
      __GOTT_BASE__[__GOTT_INDEX__], the value of which is set by the
      dynamic loader.  */
-  if (!htab->is_vxworks && s->size > MIPS_ELF_GOT_MAX_SIZE (info))
+  if (htab->root.target_os != is_vxworks
+      && s->size > MIPS_ELF_GOT_MAX_SIZE (info))
     {
       if (!mips_elf_multi_got (output_bfd, info, s, page_gotno))
        return FALSE;
@@ -9733,7 +9694,7 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info)
                  == g->global_gotno + g->local_gotno + g->tls_gotno);
 
       /* Each VxWorks GOT entry needs an explicit relocation.  */
-      if (htab->is_vxworks && bfd_link_pic (info))
+      if (htab->root.target_os == is_vxworks && bfd_link_pic (info))
        g->relocs += g->global_gotno + g->local_gotno - htab->reserved_gotno;
 
       /* Allocate room for the TLS relocations.  */
@@ -9915,7 +9876,7 @@ mips_elf_set_plt_sym_value (struct mips_elf_link_hash_entry *h, void *data)
       /* For VxWorks, point at the PLT load stub rather than the lazy
         resolution stub; this stub will become the canonical function
         address.  */
-      if (htab->is_vxworks)
+      if (htab->root.target_os == is_vxworks)
        val += 8;
 
       h->root.root.u.def.section = htab->root.splt;
@@ -9980,9 +9941,9 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
          BFD_ASSERT (htab->root.sgotplt->size == 0);
          BFD_ASSERT (htab->root.splt->size == 0);
 
-         if (htab->is_vxworks && bfd_link_pic (info))
+         if (htab->root.target_os == is_vxworks && bfd_link_pic (info))
            size = 4 * ARRAY_SIZE (mips_vxworks_shared_plt0_entry);
-         else if (htab->is_vxworks)
+         else if (htab->root.target_os == is_vxworks)
            size = 4 * ARRAY_SIZE (mips_vxworks_exec_plt0_entry);
          else if (ABI_64_P (output_bfd))
            size = 4 * ARRAY_SIZE (mips_n64_exec_plt0_entry);
@@ -10098,7 +10059,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
             room for an extra nop to fill the delay slot.  This is
             for CPUs without load interlocking.  */
          if (! LOAD_INTERLOCKS_P (output_bfd)
-             && ! htab->is_vxworks && s->size > 0)
+             && htab->root.target_os != is_vxworks
+             && s->size > 0)
            s->size += 4;
        }
       else if (! CONST_STRNEQ (name, ".init")
@@ -10156,7 +10118,9 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
          && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
        return FALSE;
 
-      if (reltext && (SGI_COMPAT (output_bfd) || htab->is_vxworks))
+      if (reltext
+         && (SGI_COMPAT (output_bfd)
+             || htab->root.target_os == is_vxworks))
        info->flags |= DF_TEXTREL;
 
       if ((info->flags & DF_TEXTREL) != 0)
@@ -10175,7 +10139,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
        return FALSE;
 
       sreldyn = mips_elf_rel_dyn_section (info, FALSE);
-      if (htab->is_vxworks)
+      if (htab->root.target_os == is_vxworks)
        {
          /* VxWorks uses .rela.dyn instead of .rel.dyn.  It does not
             use any of the DT_MIPS_* tags.  */
@@ -10255,7 +10219,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
          if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_PLTGOT, 0))
            return FALSE;
        }
-      if (htab->is_vxworks
+      if (htab->root.target_os == is_vxworks
          && !elf_vxworks_add_dynamic_entries (output_bfd, info))
        return FALSE;
     }
@@ -10897,7 +10861,7 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
   dynobj = elf_hash_table (info)->dynobj;
   hmips = (struct mips_elf_link_hash_entry *) h;
 
-  BFD_ASSERT (!htab->is_vxworks);
+  BFD_ASSERT (htab->root.target_os != is_vxworks);
 
   if (h->plt.plist != NULL
       && (h->plt.plist->mips_offset != MINUS_ONE
@@ -11833,7 +11797,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
              break;
 
            case DT_RELAENT:
-             BFD_ASSERT (htab->is_vxworks);
+             BFD_ASSERT (htab->root.target_os == is_vxworks);
              dyn.d_un.d_val = MIPS_ELF_RELA_SIZE (dynobj);
              break;
 
@@ -11972,7 +11936,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
 
            case DT_PLTREL:
              BFD_ASSERT (htab->use_plts_and_copy_relocs);
-             if (htab->is_vxworks)
+             if (htab->root.target_os == is_vxworks)
                dyn.d_un.d_val = DT_RELA;
              else
                dyn.d_un.d_val = DT_REL;
@@ -12016,7 +11980,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
 
            default:
              swap_out_p = FALSE;
-             if (htab->is_vxworks
+             if (htab->root.target_os == is_vxworks
                  && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
                swap_out_p = TRUE;
              break;
@@ -12041,7 +12005,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
   if (sgot != NULL && sgot->size > 0
       && !bfd_is_abs_section (sgot->output_section))
     {
-      if (htab->is_vxworks)
+      if (htab->root.target_os == is_vxworks)
        {
          /* The first entry of the global offset table points to the
             ".dynamic" section.  The second is initialized by the
@@ -12188,7 +12152,8 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
                                             s->contents));
 
            /* Clean up a dummy stub function entry in .text.  */
-           if (htab->sstubs != NULL)
+           if (htab->sstubs != NULL
+               && htab->sstubs->contents != NULL)
              {
                file_ptr dummy_offset;
 
@@ -12204,7 +12169,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
        increasing order of r_symndx.  The VxWorks EABI doesn't require
        this, and because the code below handles REL rather than RELA
        relocations, using it for VxWorks would be outright harmful.  */
-    if (!htab->is_vxworks)
+    if (htab->root.target_os != is_vxworks)
       {
        s = mips_elf_rel_dyn_section (info, FALSE);
        if (s != NULL
@@ -12226,7 +12191,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
 
   if (htab->root.splt && htab->root.splt->size > 0)
     {
-      if (htab->is_vxworks)
+      if (htab->root.target_os == is_vxworks)
        {
          if (bfd_link_pic (info))
            mips_vxworks_finish_shared_plt (output_bfd, info);
@@ -13391,13 +13356,11 @@ _bfd_elf_mips_get_relocated_section_contents
            }
        }
     }
-  if (reloc_vector != NULL)
-    free (reloc_vector);
+  free (reloc_vector);
   return data;
 
  error_return:
-  if (reloc_vector != NULL)
-    free (reloc_vector);
+  free (reloc_vector);
   return NULL;
 }
 \f
@@ -14274,21 +14237,17 @@ _bfd_mips_elf_relax_section (bfd *abfd, asection *sec,
        }
     }
 
-  if (internal_relocs != NULL
-      && elf_section_data (sec)->relocs != internal_relocs)
+  if (elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
 
   return TRUE;
 
  error_return:
-  if (isymbuf != NULL
-      && symtab_hdr->contents != (unsigned char *) isymbuf)
+  if (symtab_hdr->contents != (unsigned char *) isymbuf)
     free (isymbuf);
-  if (contents != NULL
-      && elf_section_data (sec)->this_hdr.contents != contents)
+  if (elf_section_data (sec)->this_hdr.contents != contents)
     free (contents);
-  if (internal_relocs != NULL
-      && elf_section_data (sec)->relocs != internal_relocs)
+  if (elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
 
   return FALSE;
@@ -14334,7 +14293,6 @@ _bfd_mips_vxworks_link_hash_table_create (bfd *abfd)
 
       htab = (struct mips_elf_link_hash_table *) ret;
       htab->use_plts_and_copy_relocs = TRUE;
-      htab->is_vxworks = TRUE;
     }
   return ret;
 }
@@ -14713,7 +14671,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info)
        elf_gp (abfd) = (h->u.def.value
                         + h->u.def.section->output_section->vma
                         + h->u.def.section->output_offset);
-      else if (htab->is_vxworks
+      else if (htab->root.target_os == is_vxworks
               && (h = bfd_link_hash_lookup (info->hash,
                                             "_GLOBAL_OFFSET_TABLE_",
                                             FALSE, FALSE, TRUE))
@@ -15767,6 +15725,7 @@ _bfd_mips_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   /* Check to see if the input BFD actually contains any sections.  If not,
      then it has no attributes, and its flags may not have been initialized
      either, but it cannot actually cause any incompatibility.  */
+  /* FIXME: This excludes any input shared library from consideration.  */
   for (sec = ibfd->sections; sec != NULL; sec = sec->next)
     {
       /* Ignore synthetic sections and empty .text, .data and .bss sections
@@ -16341,21 +16300,21 @@ const struct bfd_elf_special_section _bfd_mips_elf_special_sections[] =
    definiton of the symbol.  */
 void
 _bfd_mips_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
-                                     const Elf_Internal_Sym *isym,
+                                     unsigned int st_other,
                                      bfd_boolean definition,
                                      bfd_boolean dynamic ATTRIBUTE_UNUSED)
 {
-  if ((isym->st_other & ~ELF_ST_VISIBILITY (-1)) != 0)
+  if ((st_other & ~ELF_ST_VISIBILITY (-1)) != 0)
     {
       unsigned char other;
 
-      other = (definition ? isym->st_other : h->other);
+      other = (definition ? st_other : h->other);
       other &= ~ELF_ST_VISIBILITY (-1);
       h->other = other | ELF_ST_VISIBILITY (h->other);
     }
 
   if (!definition
-      && ELF_MIPS_IS_OPTIONAL (isym->st_other))
+      && ELF_MIPS_IS_OPTIONAL (st_other))
     h->other |= STO_OPTIONAL;
 }
 
@@ -16667,7 +16626,9 @@ _bfd_mips_init_file_header (bfd *abfd, struct bfd_link_info *link_info)
       BFD_ASSERT (htab != NULL);
     }
 
-  if (htab != NULL && htab->use_plts_and_copy_relocs && !htab->is_vxworks)
+  if (htab != NULL
+      && htab->use_plts_and_copy_relocs
+      && htab->root.target_os != is_vxworks)
     i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_MIPS_PLT;
 
   if (mips_elf_tdata (abfd)->abiflags.fp_abi == Val_GNU_MIPS_ABI_FP_64
This page took 0.037486 seconds and 4 git commands to generate.