Have info_to_howto functions return a success/fail status. Check this result. Stop...
[deliverable/binutils-gdb.git] / bfd / elf32-i370.c
index 7fba4d1f4171dd1fe070f41405d24638e7edffa7..2c6a30d2abf81e38892e0f4a8e01525fa8a5292b 100644 (file)
@@ -1,5 +1,5 @@
 /* i370-specific support for 32-bit ELF
-   Copyright (C) 1994-2015 Free Software Foundation, Inc.
+   Copyright (C) 1994-2018 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
    Hacked by Linas Vepstas for i370 linas@linas.org
 
@@ -289,8 +289,8 @@ i370_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an i370 ELF reloc.  */
 
-static void
-i370_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+i370_elf_info_to_howto (bfd *abfd,
                        arelent *cache_ptr,
                        Elf_Internal_Rela *dst)
 {
@@ -303,12 +303,14 @@ i370_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
   r_type = ELF32_R_TYPE (dst->r_info);
   if (r_type >= R_I370_max)
     {
-      (*_bfd_error_handler) (_("%B: unrecognised I370 reloc number: %d"),
-                            abfd, r_type);
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_I370_NONE;
+      return FALSE;
     }
   cache_ptr->howto = i370_elf_howto_table[r_type];
+  return TRUE;
 }
 
 /* Hack alert --  the following several routines look generic to me ...
@@ -330,8 +332,9 @@ i370_elf_set_private_flags (bfd *abfd, flagword flags)
    object file when linking.  */
 
 static bfd_boolean
-i370_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+i370_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 {
+  bfd *obfd = info->output_bfd;
   flagword old_flags;
   flagword new_flags;
 
@@ -352,9 +355,10 @@ i370_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 
   else                                 /* Incompatible flags.  */
     {
-      (*_bfd_error_handler)
-       ("%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
-        ibfd, (long) new_flags, (long) old_flags);
+      _bfd_error_handler
+       /* xgettext:c-format */
+       (_("%pB: uses different e_flags (%#x) fields than previous modules (%#x)"),
+        ibfd, new_flags, old_flags);
 
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
@@ -475,7 +479,7 @@ i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (dynobj != NULL
              && (h->needs_plt
-                 || h->u.weakdef != NULL
+                 || h->is_weakalias
                  || (h->def_dynamic
                      && h->ref_regular
                      && !h->def_regular)));
@@ -487,12 +491,12 @@ i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
   /* If this is a weak symbol, and there is a real definition, the
      processor independent code will have arranged for us to see the
      real definition first, and we can just use the same value.  */
-  if (h->u.weakdef != NULL)
+  if (h->is_weakalias)
     {
-      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
-                 || h->u.weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->u.weakdef->root.u.def.section;
-      h->root.u.def.value = h->u.weakdef->root.u.def.value;
+      struct elf_link_hash_entry *def = weakdef (h);
+      BFD_ASSERT (def->root.type == bfd_link_hash_defined);
+      h->root.u.def.section = def->root.u.def.section;
+      h->root.u.def.value = def->root.u.def.value;
       return TRUE;
     }
 
@@ -594,7 +598,7 @@ i370_elf_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
@@ -808,7 +812,7 @@ i370_elf_check_relocs (bfd *abfd,
     return TRUE;
 
 #ifdef DEBUG
-  _bfd_error_handler ("i370_elf_check_relocs called for section %A in %B",
+  _bfd_error_handler ("i370_elf_check_relocs called for section %pA in %pB",
                      sec, abfd);
 #endif
 
@@ -833,10 +837,6 @@ i370_elf_check_relocs (bfd *abfd,
          while (h->root.type == bfd_link_hash_indirect
                 || h->root.type == bfd_link_hash_warning)
            h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-         /* PR15323, ref flags aren't set for references in the same
-            object.  */
-         h->root.non_ir_ref = 1;
        }
 
       if (bfd_link_pic (info))
@@ -881,7 +881,7 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd,
 {
   asection *sdyn;
   bfd *dynobj = elf_hash_table (info)->dynobj;
-  asection *sgot = bfd_get_linker_section (dynobj, ".got");
+  asection *sgot = elf_hash_table (info)->sgot;
 
 #ifdef DEBUG
   fprintf (stderr, "i370_elf_finish_dynamic_sections called\n");
@@ -894,7 +894,7 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd,
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -902,35 +902,39 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd,
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
-         const char *name;
+         asection *s;
          bfd_boolean size;
 
          bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
 
          switch (dyn.d_tag)
            {
-           case DT_PLTGOT:   name = ".plt";      size = FALSE; break;
-           case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE;  break;
-           case DT_JMPREL:   name = ".rela.plt"; size = FALSE; break;
-           default:          name = NULL;        size = FALSE; break;
+           case DT_PLTGOT:
+             s = elf_hash_table (info)->splt;
+             size = FALSE;
+             break;
+           case DT_PLTRELSZ:
+             s = elf_hash_table (info)->srelplt;
+             size = TRUE;
+             break;
+           case DT_JMPREL:
+             s = elf_hash_table (info)->srelplt;
+             size = FALSE;
+             break;
+           default:
+             continue;
            }
 
-         if (name != NULL)
+         if (s == NULL)
+           dyn.d_un.d_val = 0;
+         else
            {
-             asection *s;
-
-             s = bfd_get_section_by_name (output_bfd, name);
-             if (s == NULL)
-               dyn.d_un.d_val = 0;
+             if (!size)
+               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              else
-               {
-                 if (! size)
-                   dyn.d_un.d_ptr = s->vma;
-                 else
-                   dyn.d_un.d_val = s->size;
-               }
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+               dyn.d_un.d_val = s->size;
            }
+         bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
        }
     }
 
@@ -1046,9 +1050,9 @@ i370_elf_relocate_section (bfd *output_bfd,
   bfd_boolean ret = TRUE;
 
 #ifdef DEBUG
-  _bfd_error_handler ("i370_elf_relocate_section called for %B section %A, %ld relocations%s",
+  _bfd_error_handler ("i370_elf_relocate_section called for %pB section %pA, %u relocations%s",
                      input_bfd, input_section,
-                     (long) input_section->reloc_count,
+                     input_section->reloc_count,
                      (bfd_link_relocatable (info)) ? " (relocatable)" : "");
 #endif
 
@@ -1065,7 +1069,6 @@ i370_elf_relocate_section (bfd *output_bfd,
       Elf_Internal_Sym *sym         = NULL;
       asection *sec                 = NULL;
       struct elf_link_hash_entry * h = NULL;
-      const char *sym_name          = NULL;
       reloc_howto_type *howto;
       unsigned long r_symndx;
       bfd_vma relocation;
@@ -1074,9 +1077,9 @@ i370_elf_relocate_section (bfd *output_bfd,
       if ((unsigned) r_type >= (unsigned) R_I370_max
          || !i370_elf_howto_table[(int)r_type])
        {
-         (*_bfd_error_handler) ("%B: unknown relocation type %d",
-                                input_bfd,
-                                (int) r_type);
+         /* xgettext:c-format */
+         _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                             input_bfd, (int) r_type);
 
          bfd_set_error (bfd_error_bad_value);
          ret = FALSE;
@@ -1091,7 +1094,6 @@ i370_elf_relocate_section (bfd *output_bfd,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         sym_name = "<local symbol>";
 
          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, & sec, rel);
          addend = rel->r_addend;
@@ -1108,7 +1110,6 @@ i370_elf_relocate_section (bfd *output_bfd,
          while (h->root.type == bfd_link_hash_indirect
                 || h->root.type == bfd_link_hash_warning)
            h = (struct elf_link_hash_entry *) h->root.u.i.link;
-         sym_name = h->root.root.string;
          if (h->root.type == bfd_link_hash_defined
              || h->root.type == bfd_link_hash_defweak)
            {
@@ -1137,15 +1138,13 @@ i370_elf_relocate_section (bfd *output_bfd,
            ;
          else if (!bfd_link_relocatable (info))
            {
-             if ((*info->callbacks->undefined_symbol)
-                 (info, h->root.root.string, input_bfd,
-                  input_section, rel->r_offset,
-                  (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
-                   || ELF_ST_VISIBILITY (h->other))))
-               {
-                 ret = FALSE;
-                 continue;
-               }
+             (*info->callbacks->undefined_symbol)
+               (info, h->root.root.string, input_bfd,
+                input_section, rel->r_offset,
+                (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
+                 || ELF_ST_VISIBILITY (h->other)));
+             ret = FALSE;
+             continue;
            }
        }
 
@@ -1159,9 +1158,9 @@ i370_elf_relocate_section (bfd *output_bfd,
       switch ((int) r_type)
        {
        default:
-         (*_bfd_error_handler)
-           ("%B: unknown relocation type %d for symbol %s",
-            input_bfd, (int) r_type, sym_name);
+         _bfd_error_handler
+           (_("%pB: unsupported relocation type %#x"),
+            input_bfd, (int) r_type);
 
          bfd_set_error (bfd_error_bad_value);
          ret = FALSE;
@@ -1300,27 +1299,15 @@ i370_elf_relocate_section (bfd *output_bfd,
 
        case (int) R_I370_COPY:
        case (int) R_I370_RELATIVE:
-         (*_bfd_error_handler)
-           ("%B: Relocation %s is not yet supported for symbol %s.",
-            input_bfd,
-            i370_elf_howto_table[(int) r_type]->name,
-            sym_name);
-
+         /* xgettext:c-format */
+         _bfd_error_handler (_("%pB: %s unsupported"),
+                             input_bfd,
+                             i370_elf_howto_table[(int) r_type]->name);
          bfd_set_error (bfd_error_invalid_operation);
          ret = FALSE;
          continue;
        }
 
-#ifdef DEBUG
-      fprintf (stderr, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n",
-              howto->name,
-              (int)r_type,
-              sym_name,
-              r_symndx,
-              (long) offset,
-              (long) addend);
-#endif
-
       r = _bfd_final_link_relocate (howto, input_bfd, input_section, contents,
                                    offset, relocation, addend);
 
@@ -1403,10 +1390,10 @@ i370_elf_relocate_section (bfd *output_bfd,
 #define elf_backend_adjust_dynamic_symbol      i370_elf_adjust_dynamic_symbol
 #define elf_backend_check_relocs               i370_elf_check_relocs
 
-static int
-i370_noop (void)
+static bfd_boolean
+i370_noop (bfd * abfd ATTRIBUTE_UNUSED, ...)
 {
-  return 1;
+  return TRUE;
 }
 
 #define elf_backend_finish_dynamic_symbol \
This page took 0.030019 seconds and 4 git commands to generate.