MIPS: Remove remains of IRIX OS ABI support
[deliverable/binutils-gdb.git] / bfd / elf32-microblaze.c
index e84b1b966e6eb3dda3fdcabbba8cd60346b9a628..5c66808ed423f9321ea026ba0baa0f6d708b1c24 100644 (file)
@@ -1,6 +1,6 @@
 /* Xilinx MicroBlaze-specific support for 32-bit ELF
 
-   Copyright (C) 2009-2015 Free Software Foundation, Inc.
+   Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -652,8 +652,9 @@ microblaze_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
   r_type = ELF32_R_TYPE (dst->r_info);
   if (r_type >= R_MICROBLAZE_max)
     {
-      (*_bfd_error_handler) (_("%B: unrecognised MicroBlaze reloc number: %d"),
-                            abfd, r_type);
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%B: unrecognised MicroBlaze reloc number: %d"),
+                         abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
       r_type = R_MICROBLAZE_NONE;
     }
@@ -956,8 +957,9 @@ microblaze_elf_relocate_section (bfd *output_bfd,
 
       if (r_type < 0 || r_type >= (int) R_MICROBLAZE_max)
        {
-         (*_bfd_error_handler) (_("%s: unknown relocation type %d"),
-                                bfd_get_filename (input_bfd), (int) r_type);
+         /* xgettext:c-format */
+         _bfd_error_handler (_("%s: unknown relocation type %d"),
+                             bfd_get_filename (input_bfd), (int) r_type);
          bfd_set_error (bfd_error_bad_value);
          ret = FALSE;
          continue;
@@ -966,7 +968,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
       howto = microblaze_elf_howto_table[r_type];
       r_symndx = ELF32_R_SYM (rel->r_info);
 
-      if (info->relocatable)
+      if (bfd_link_relocatable (info))
        {
          /* This is a relocatable link.  We don't have to change
             anything, unless the reloc is against a section symbol,
@@ -1082,11 +1084,14 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                      }
                    else
                      {
-                       (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
-                                              bfd_get_filename (input_bfd),
-                                              sym_name,
-                                              microblaze_elf_howto_table[(int) r_type]->name,
-                                              bfd_get_section_name (sec->owner, sec));
+                       _bfd_error_handler
+                         /* xgettext:c-format */
+                         (_("%s: The target (%s) of an %s relocation "
+                            "is in the wrong section (%s)"),
+                          bfd_get_filename (input_bfd),
+                          sym_name,
+                          microblaze_elf_howto_table[(int) r_type]->name,
+                          bfd_get_section_name (sec->owner, sec));
                        /*bfd_set_error (bfd_error_bad_value); ??? why? */
                        ret = FALSE;
                        continue;
@@ -1127,11 +1132,14 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                      }
                    else
                      {
-                       (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
-                                              bfd_get_filename (input_bfd),
-                                              sym_name,
-                                              microblaze_elf_howto_table[(int) r_type]->name,
-                                              bfd_get_section_name (sec->owner, sec));
+                       _bfd_error_handler
+                         /* xgettext:c-format */
+                         (_("%s: The target (%s) of an %s relocation "
+                            "is in the wrong section (%s)"),
+                          bfd_get_filename (input_bfd),
+                          sym_name,
+                          microblaze_elf_howto_table[(int) r_type]->name,
+                          bfd_get_section_name (sec->owner, sec));
                        /*bfd_set_error (bfd_error_bad_value); ??? why? */
                        ret = FALSE;
                        continue;
@@ -1193,6 +1201,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
              goto dogot;
            case (int) R_MICROBLAZE_TLSLD:
              tls_type = (TLS_TLS | TLS_LD);
+             /* Fall through.  */
            dogot:
            case (int) R_MICROBLAZE_GOT_64:
              {
@@ -1245,13 +1254,16 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                    bfd_boolean dyn =
                        elf_hash_table (info)->dynamic_sections_created;
 
-                   if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
-                       && (!info->shared || !SYMBOL_REFERENCES_LOCAL (info, h)))
+                   if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
+                                                        bfd_link_pic (info),
+                                                        h)
+                       && (!bfd_link_pic (info)
+                           || !SYMBOL_REFERENCES_LOCAL (info, h)))
                      indx = h->dynindx;
                  }
 
                /* Need to generate relocs ? */
-               if ((info->shared || indx != 0)
+               if ((bfd_link_pic (info) || indx != 0)
                    && (h == NULL
                    || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
                    || h->root.type != bfd_link_hash_undefweak))
@@ -1272,7 +1284,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                    /* Process module-id */
                    if (IS_TLS_LD(tls_type))
                      {
-                       if (! info->shared)
+                       if (! bfd_link_pic (info))
                          {
                            bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
                          }
@@ -1337,7 +1349,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
 
                          /* Relocs for dyn symbols generated by
                             finish_dynamic_symbols */
-                         if (info->shared && h == NULL)
+                         if (bfd_link_pic (info) && h == NULL)
                            {
                              *offp |= 1;
                              microblaze_elf_output_dynamic_relocation (output_bfd,
@@ -1427,7 +1439,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                    break;
                  }
 
-               if ((info->shared
+               if ((bfd_link_pic (info)
                     && (h == NULL
                         || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
                         || h->root.type != bfd_link_hash_undefweak)
@@ -1436,7 +1448,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                             && h->dynindx != -1
                             && (!info->symbolic
                                 || !h->def_regular))))
-                   || (!info->shared
+                   || (!bfd_link_pic (info)
                        && h != NULL
                        && h->dynindx != -1
                        && !h->non_got_ref
@@ -1489,7 +1501,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                        else
                          {
                            BFD_FAIL ();
-                           (*_bfd_error_handler)
+                           _bfd_error_handler
                              (_("%B: probably compiled without -fPIC?"),
                               input_bfd);
                            bfd_set_error (bfd_error_bad_value);
@@ -1553,16 +1565,14 @@ microblaze_elf_relocate_section (bfd *output_bfd,
          switch (r)
            {
            case bfd_reloc_overflow:
-             if (!((*info->callbacks->reloc_overflow)
-                   (info, (h ? &h->root : NULL), name, howto->name,
-                    (bfd_vma) 0, input_bfd, input_section, offset)))
-               return FALSE;
+             (*info->callbacks->reloc_overflow)
+               (info, (h ? &h->root : NULL), name, howto->name,
+                (bfd_vma) 0, input_bfd, input_section, offset);
              break;
 
            case bfd_reloc_undefined:
-             if (!((*info->callbacks->undefined_symbol)
-                   (info, name, input_bfd, input_section, offset, TRUE)))
-               return FALSE;
+             (*info->callbacks->undefined_symbol)
+               (info, name, input_bfd, input_section, offset, TRUE);
              break;
 
            case bfd_reloc_outofrange:
@@ -1581,9 +1591,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
              errmsg = _("internal error: unknown error");
              /* Fall through.  */
            common_error:
-             if (!((*info->callbacks->warning)
-                   (info, errmsg, name, input_bfd, input_section, offset)))
-               return FALSE;
+             (*info->callbacks->warning) (info, errmsg, name, input_bfd,
+                                          input_section, offset);
              break;
            }
        }
@@ -1591,21 +1600,6 @@ microblaze_elf_relocate_section (bfd *output_bfd,
 
   return ret;
 }
-
-/* Merge backend specific data from an object file to the output
-   object file when linking.
-
-   Note: We only use this hook to catch endian mismatches.  */
-static bfd_boolean
-microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
-{
-  /* Check if we have the same endianess.  */
-  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
-    return FALSE;
-
-  return TRUE;
-}
-
 \f
 /* Calculate fixup value for reference.  */
 
@@ -1688,7 +1682,7 @@ microblaze_elf_relax_section (bfd *abfd,
   *again = FALSE;
 
   /* Only do this for a text section.  */
-  if (link_info->relocatable
+  if (bfd_link_relocatable (link_info)
       || (sec->flags & SEC_RELOC) == 0
       || (sec->reloc_count == 0)
       || (sec->flags & SEC_CODE) == 0)
@@ -2330,7 +2324,7 @@ microblaze_elf_check_relocs (bfd * abfd,
   struct elf32_mb_link_hash_table *htab;
   asection *sreloc = NULL;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   htab = elf32_mb_hash_table (info);
@@ -2397,8 +2391,10 @@ microblaze_elf_check_relocs (bfd * abfd,
           goto dogottls;
         case R_MICROBLAZE_TLSLD:
           tls_type |= (TLS_TLS | TLS_LD);
+         /* Fall through.  */
         dogottls:
           sec->has_tls_reloc = 1;
+         /* Fall through.  */
         case R_MICROBLAZE_GOT_64:
           if (htab->sgot == NULL)
             {
@@ -2423,7 +2419,7 @@ microblaze_elf_check_relocs (bfd * abfd,
         case R_MICROBLAZE_64_PCREL:
         case R_MICROBLAZE_32:
           {
-            if (h != NULL && !info->shared)
+            if (h != NULL && !bfd_link_pic (info))
              {
                /* we may need a copy reloc.  */
                h->non_got_ref = 1;
@@ -2457,14 +2453,14 @@ microblaze_elf_check_relocs (bfd * abfd,
               dynamic library if we manage to avoid copy relocs for the
               symbol.  */
 
-            if ((info->shared
+            if ((bfd_link_pic (info)
                  && (sec->flags & SEC_ALLOC) != 0
                  && (r_type != R_MICROBLAZE_64_PCREL
                      || (h != NULL
                         && (! info->symbolic
                             || h->root.type == bfd_link_hash_defweak
                             || !h->def_regular))))
-                || (!info->shared
+                || (!bfd_link_pic (info)
                     && (sec->flags & SEC_ALLOC) != 0
                     && h != NULL
                     && (h->root.type == bfd_link_hash_defweak
@@ -2563,11 +2559,11 @@ microblaze_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
   htab->splt = bfd_get_linker_section (dynobj, ".plt");
   htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
   htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
-  if (!info->shared)
+  if (!bfd_link_pic (info))
     htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
   if (!htab->splt || !htab->srelplt || !htab->sdynbss
-      || (!info->shared && !htab->srelbss))
+      || (!bfd_link_pic (info) && !htab->srelbss))
     abort ();
 
   return TRUE;
@@ -2688,7 +2684,7 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
      only references to the symbol are via the global offset table.
      For such cases we need not do anything here; the relocations will
      be handled correctly by relocate_section.  */
-  if (info->shared)
+  if (bfd_link_pic (info))
     return TRUE;
 
   /* If there are no references to this symbol that do not use the
@@ -2795,7 +2791,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
             return FALSE;
         }
 
-      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h))
+      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
         {
           asection *s = htab->splt;
 
@@ -2810,7 +2806,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
              location in the .plt.  This is required to make function
              pointers compare as equal between the normal executable and
              the shared library.  */
-          if (! info->shared
+          if (! bfd_link_pic (info)
               && !h->def_regular)
             {
               h->root.u.def.section = s;
@@ -2900,7 +2896,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
      space for pc-relative relocs that have become local due to symbol
      visibility changes.  */
 
-  if (info->shared)
+  if (bfd_link_pic (info))
     {
       if (h->def_regular
          && (h->forced_local
@@ -3055,7 +3051,7 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
                {
                  *local_got = s->size;
                  s->size += need;
-                 if (info->shared)
+                 if (bfd_link_pic (info))
                    srel->size += need * (sizeof (Elf32_External_Rela) / 4);
                }
             }
@@ -3072,7 +3068,7 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
     {
       htab->tlsld_got.offset = htab->sgot->size;
       htab->sgot->size += 8;
-      if (info->shared)
+      if (bfd_link_pic (info))
         htab->srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
@@ -3155,7 +3151,7 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 #define add_dynamic_entry(TAG, VAL)                    \
       _bfd_elf_add_dynamic_entry (info, TAG, VAL)
 
-      if (info->executable)
+      if (bfd_link_executable (info))
         {
           if (!add_dynamic_entry (DT_DEBUG, 0))
             return FALSE;
@@ -3227,13 +3223,13 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
       got_addr = got_offset;
 
       /* For non-PIC objects we need absolute address of the GOT entry.  */
-      if (!info->shared)
+      if (!bfd_link_pic (info))
         got_addr += htab->sgotplt->output_section->vma + sgotplt->output_offset;
 
       /* Fill in the entry in the procedure linkage table.  */
       bfd_put_32 (output_bfd, PLT_ENTRY_WORD_0 + ((got_addr >> 16) & 0xffff),
                   splt->contents + h->plt.offset);
-      if (info->shared)
+      if (bfd_link_pic (info))
         bfd_put_32 (output_bfd, PLT_ENTRY_WORD_1 + (got_addr & 0xffff),
                     splt->contents + h->plt.offset + 4);
       else
@@ -3285,16 +3281,16 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       offset = (sgot->output_section->vma + sgot->output_offset
-                       + (h->got.offset &~ (bfd_vma) 1));
+               + (h->got.offset &~ (bfd_vma) 1));
 
       /* If this is a -Bsymbolic link, and the symbol is defined
          locally, we just want to emit a RELATIVE reloc.  Likewise if
          the symbol was forced to be local because of a version file.
          The entry in the global offset table will already have been
          initialized in the relocate_section function.  */
-      if (info->shared
-          && (info->symbolic || h->dynindx == -1)
-          && h->def_regular)
+      if (bfd_link_pic (info)
+          && ((info->symbolic && h->def_regular)
+             || h->dynindx == -1))
         {
           asection *sec = h->root.u.def.section;
           microblaze_elf_output_dynamic_relocation (output_bfd,
@@ -3459,7 +3455,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
                                bfd_vma *valp)
 {
   if (sym->st_shndx == SHN_COMMON
-      && !info->relocatable
+      && !bfd_link_relocatable (info)
       && sym->st_size <= elf_gp_size (abfd))
     {
       /* Common symbols less than or equal to -G nn bytes are automatically
@@ -3493,7 +3489,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
 #define bfd_elf32_bfd_is_local_label_name       microblaze_elf_is_local_label_name
 #define elf_backend_relocate_section           microblaze_elf_relocate_section
 #define bfd_elf32_bfd_relax_section             microblaze_elf_relax_section
-#define bfd_elf32_bfd_merge_private_bfd_data    microblaze_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data    _bfd_generic_verify_endian_match
 #define bfd_elf32_bfd_reloc_name_lookup                microblaze_elf_reloc_name_lookup
 
 #define elf_backend_gc_mark_hook               microblaze_elf_gc_mark_hook
This page took 0.029027 seconds and 4 git commands to generate.