jit: c++-ify gdb_block
[deliverable/binutils-gdb.git] / bfd / xcofflink.c
index d80e98d4a1510334aea2a68605c95344439c0b09..91e0041ea184c9d6b3ccfc31dbb7fba6165f363b 100644 (file)
@@ -1,5 +1,5 @@
 /* POWER/PowerPC XCOFF linker support.
-   Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   Copyright (C) 1995-2019 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,6 +28,7 @@
 #include "libcoff.h"
 #include "libxcoff.h"
 #include "libiberty.h"
+#include "xcofflink.h"
 
 /* This file holds the XCOFF linker code.  */
 
@@ -829,7 +830,7 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
    if (info->output_bfd->xvec != abfd->xvec)
     {
       _bfd_error_handler
-       (_("%B: XCOFF shared object when not producing XCOFF output"),
+       (_("%pB: XCOFF shared object when not producing XCOFF output"),
         abfd);
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
@@ -850,7 +851,7 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
   if (lsec == NULL)
     {
       _bfd_error_handler
-       (_("%B: dynamic object with no .loader section"),
+       (_("%pB: dynamic object with no .loader section"),
         abfd);
       bfd_set_error (bfd_error_no_symbols);
       return FALSE;
@@ -1366,7 +1367,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
          if (csect != NULL)
            *csect_cache = csect;
          else if (first_csect == NULL
-                   || sym.n_sclass == C_FILE || sym.n_sclass == C_DWARF)
+                  || sym.n_sclass == C_FILE || sym.n_sclass == C_DWARF)
            *csect_cache = coff_section_from_bfd_index (abfd, sym.n_scnum);
          else
            *csect_cache = NULL;
@@ -1410,7 +1411,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
                {
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%B: `%s' has line numbers but no enclosing section"),
+                   (_("%pB: `%s' has line numbers but no enclosing section"),
                     abfd, name);
                  bfd_set_error (bfd_error_bad_value);
                  goto error_return;
@@ -1463,7 +1464,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
        {
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B: class %d symbol `%s' has no aux entries"),
+           (_("%pB: class %d symbol `%s' has no aux entries"),
             abfd, sym.n_sclass, name);
          bfd_set_error (bfd_error_bad_value);
          goto error_return;
@@ -1486,7 +1487,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
        default:
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B: symbol `%s' has unrecognized csect type %d"),
+           (_("%pB: symbol `%s' has unrecognized csect type %d"),
             abfd, name, smtyp);
          bfd_set_error (bfd_error_bad_value);
          goto error_return;
@@ -1499,9 +1500,10 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B: bad XTY_ER symbol `%s': class %d scnum %d scnlen %Ld"),
+               (_("%pB: bad XTY_ER symbol `%s': class %d scnum %d "
+                  "scnlen %" PRId64),
                 abfd, name, sym.n_sclass, sym.n_scnum,
-                aux.x_csect.x_scnlen.l);
+                (int64_t) aux.x_csect.x_scnlen.l);
              bfd_set_error (bfd_error_bad_value);
              goto error_return;
            }
@@ -1529,8 +1531,8 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
                {
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%B: XMC_TC0 symbol `%s' is class %d scnlen %Ld"),
-                    abfd, name, sym.n_sclass, aux.x_csect.x_scnlen.l);
+                   (_("%pB: XMC_TC0 symbol `%s' is class %d scnlen %" PRId64),
+                    abfd, name, sym.n_sclass, (int64_t) aux.x_csect.x_scnlen.l);
                  bfd_set_error (bfd_error_bad_value);
                  goto error_return;
                }
@@ -1676,7 +1678,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
              {
                _bfd_error_handler
                  /* xgettext:c-format */
-                 (_("%B: csect `%s' not in enclosing section"),
+                 (_("%pB: csect `%s' not in enclosing section"),
                   abfd, name);
                bfd_set_error (bfd_error_bad_value);
                goto error_return;
@@ -1784,12 +1786,12 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
              {
                _bfd_error_handler
                  /* xgettext:c-format */
-                 (_("%B: misplaced XTY_LD `%s'"),
+                 (_("%pB: misplaced XTY_LD `%s'"),
                   abfd, name);
                bfd_set_error (bfd_error_bad_value);
                goto error_return;
              }
-           csect = section;
+           csect = section;
            value = sym.n_value - csect->vma;
          }
          break;
@@ -1881,7 +1883,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
 
       if (EXTERN_SYM_P (sym.n_sclass))
        {
-         bfd_boolean copy;
+         bfd_boolean copy, ok;
          flagword flags;
 
          BFD_ASSERT (section != NULL);
@@ -1926,7 +1928,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
             We also have to handle the case of statically linking a
             shared object, which will cause symbol redefinitions,
             although this is an easier case to detect.  */
-         else if (info->output_bfd->xvec == abfd->xvec)
+         else if (info->output_bfd->xvec == abfd->xvec)
            {
              if (! bfd_is_und_section (section))
                *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
@@ -2021,12 +2023,12 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
          BFD_ASSERT (last_real->next == first_csect);
          last_real->next = NULL;
          flags = (sym.n_sclass == C_EXT ? BSF_GLOBAL : BSF_WEAK);
-         if (! (_bfd_generic_link_add_one_symbol
-                (info, abfd, name, flags, section, value,
-                 NULL, copy, TRUE,
-                 (struct bfd_link_hash_entry **) sym_hash)))
-           goto error_return;
+         ok = (_bfd_generic_link_add_one_symbol
+               (info, abfd, name, flags, section, value, NULL, copy, TRUE,
+                (struct bfd_link_hash_entry **) sym_hash));
          last_real->next = first_csect;
+         if (!ok)
+           goto error_return;
 
          if (smtyp == XTY_CM)
            {
@@ -2039,7 +2041,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
                  = csect->alignment_power;
            }
 
-         if (info->output_bfd->xvec == abfd->xvec)
+         if (info->output_bfd->xvec == abfd->xvec)
            {
              int flag;
 
@@ -2079,14 +2081,14 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
   for (o = abfd->sections; o != first_csect; o = o->next)
     {
       /* Debugging sections have no csects.  */
-      if (bfd_get_section_flags (abfd, o) & SEC_DEBUGGING)
-        continue;
+      if (bfd_section_flags (o) & SEC_DEBUGGING)
+       continue;
 
       /* Reset the section size and the line number count, since the
         data is now attached to the csects.  Don't reset the size of
         the .debug section, since we need to read it below in
         bfd_xcoff_size_dynamic_sections.  */
-      if (strcmp (bfd_get_section_name (abfd, o), ".debug") != 0)
+      if (strcmp (bfd_section_name (o), ".debug") != 0)
        o->size = 0;
       o->lineno_count = 0;
 
@@ -2105,8 +2107,8 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
                {
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%B: reloc %s:%Ld not in csect"),
-                    abfd, o->name, i);
+                   (_("%pB: reloc %s:%" PRId64 " not in csect"),
+                    abfd, o->name, (int64_t) i);
                  bfd_set_error (bfd_error_bad_value);
                  goto error_return;
                }
@@ -2114,7 +2116,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
              /* We identify all function symbols that are the target
                 of a relocation, so that we can create glue code for
                 functions imported from dynamic objects.  */
-             if (info->output_bfd->xvec == abfd->xvec
+             if (info->output_bfd->xvec == abfd->xvec
                  && *rel_csect != bfd_und_section_ptr
                  && obj_xcoff_sym_hashes (abfd)[rel->r_symndx] != NULL)
                {
@@ -2366,7 +2368,7 @@ xcoff_link_check_ar_symbols (bfd *abfd,
             undefined references in shared objects.  */
          if (h != NULL
              && h->type == bfd_link_hash_undefined
-             && (info->output_bfd->xvec != abfd->xvec
+             && (info->output_bfd->xvec != abfd->xvec
                  || (((struct xcoff_link_hash_entry *) h)->flags
                      & XCOFF_DEF_DYNAMIC) == 0))
            {
@@ -2686,10 +2688,7 @@ xcoff_need_ldrel_p (struct bfd_link_info *info, struct internal_reloc *rel,
     case R_RLA:
       /* Absolute relocations against absolute symbols can be
         resolved statically.  */
-      if (h != NULL
-         && (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-         && bfd_is_abs_section (h->root.u.def.section))
+      if (h != NULL && bfd_is_abs_symbol (&h->root))
        return FALSE;
 
       return TRUE;
@@ -3021,7 +3020,7 @@ xcoff_sweep (struct bfd_link_info *info)
                  || o == xcoff_hash_table (info)->loader_section
                  || o == xcoff_hash_table (info)->linkage_section
                  || o == xcoff_hash_table (info)->descriptor_section
-                  || (bfd_get_section_flags (sub, o) & SEC_DEBUGGING)
+                 || (bfd_section_flags (o) & SEC_DEBUGGING)
                  || strcmp (o->name, ".debug") == 0)
                o->flags |= SEC_MARK;
              else
@@ -3124,7 +3123,7 @@ bfd_xcoff_import_symbol (bfd *output_bfd,
   if (val != (bfd_vma) -1)
     {
       if (h->root.type == bfd_link_hash_defined
-         && (! bfd_is_abs_section (h->root.u.def.section)
+         && (!bfd_is_abs_symbol (&h->root)
              || h->root.u.def.value != val))
        (*info->callbacks->multiple_definition) (info, &h->root, output_bfd,
                                                 bfd_abs_section_ptr, val);
@@ -4059,7 +4058,7 @@ xcoff_create_ldrel (bfd *output_bfd, struct xcoff_final_link_info *flinfo,
        {
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B: loader reloc in unrecognized section `%s'"),
+           (_("%pB: loader reloc in unrecognized section `%s'"),
             reference_bfd, secname);
          bfd_set_error (bfd_error_nonrepresentable_section);
          return FALSE;
@@ -4071,7 +4070,7 @@ xcoff_create_ldrel (bfd *output_bfd, struct xcoff_final_link_info *flinfo,
        {
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B: `%s' in loader reloc but not loader sym"),
+           (_("%pB: `%s' in loader reloc but not loader sym"),
             reference_bfd, h->root.root.string);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
@@ -4088,7 +4087,7 @@ xcoff_create_ldrel (bfd *output_bfd, struct xcoff_final_link_info *flinfo,
     {
       _bfd_error_handler
        /* xgettext:c-format */
-       (_("%B: loader reloc in read-only section %A"),
+       (_("%pB: loader reloc in read-only section %pA"),
         reference_bfd, output_section);
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
@@ -4736,8 +4735,8 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
       flinfo->last_file.n_value = output_index;
       bfd_coff_swap_sym_out (output_bfd, (void *) &flinfo->last_file,
                             (void *) (flinfo->outsyms
-                                   + ((flinfo->last_file_index - syment_base)
-                                      * osymesz)));
+                                   + ((flinfo->last_file_index - syment_base)
+                                      * osymesz)));
     }
 
   /* Write the modified symbols to the output file.  */
@@ -4943,24 +4942,24 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                             this case, but I don't think it's worth it.  */
                          is = flinfo->internal_syms + r_symndx;
 
-                          if (is->n_sclass != C_DWARF)
-                            {
-                              name = (_bfd_coff_internal_syment_name
-                                      (input_bfd, is, buf));
+                         if (is->n_sclass != C_DWARF)
+                           {
+                             name = (_bfd_coff_internal_syment_name
+                                     (input_bfd, is, buf));
 
-                              if (name == NULL)
-                                return FALSE;
+                             if (name == NULL)
+                               return FALSE;
 
                              (*flinfo->info->callbacks->unattached_reloc)
                                (flinfo->info, name,
                                 input_bfd, o, irel->r_vaddr);
-                            }
+                           }
                        }
                    }
                }
 
              if ((o->flags & SEC_DEBUGGING) == 0
-                  && xcoff_need_ldrel_p (flinfo->info, irel, h))
+                 && xcoff_need_ldrel_p (flinfo->info, irel, h))
                {
                  asection *sec;
 
@@ -5112,9 +5111,9 @@ xcoff_find_tc0 (bfd *output_bfd, struct xcoff_final_link_info *flinfo)
       if (best_address > toc_start + 0x8000)
        {
          _bfd_error_handler
-           (_("TOC overflow: %#Lx > 0x10000; try -mminimal-toc "
+           (_("TOC overflow: %#" PRIx64 " > 0x10000; try -mminimal-toc "
               "when compiling"),
-            toc_end - toc_start);
+            (uint64_t) (toc_end - toc_start));
          bfd_set_error (bfd_error_file_too_big);
          return FALSE;
        }
@@ -5310,7 +5309,7 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
        tocoff += h->descriptor->u.toc_offset;
 
       /* The first instruction in the glink code needs to be
-        cooked to to hold the correct offset in the toc.  The
+        cooked to hold the correct offset in the toc.  The
         rest are just output raw.  */
       bfd_put_32 (output_bfd,
                  bfd_xcoff_glink_code(output_bfd, 0) | (tocoff & 0xffff), p);
@@ -5588,10 +5587,10 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
            || h->root.type == bfd_link_hash_defweak)
           && h->smclas == XMC_XO)
     {
-      BFD_ASSERT (bfd_is_abs_section (h->root.u.def.section));
+      BFD_ASSERT (bfd_is_abs_symbol (&h->root));
       isym.n_value = h->root.u.def.value;
       isym.n_scnum = N_UNDEF;
-      if (h->root.type == bfd_link_hash_undefweak
+      if (h->root.type == bfd_link_hash_defweak
          && C_WEAKEXT == C_AIX_WEAKEXT)
        isym.n_sclass = C_WEAKEXT;
       else
@@ -5657,7 +5656,7 @@ xcoff_write_global_symbol (struct bfd_hash_entry *bh, void * inf)
       /* We just output an SD symbol.  Now output an LD symbol.  */
       h->indx += 2;
 
-      if (h->root.type == bfd_link_hash_undefweak
+      if (h->root.type == bfd_link_hash_defweak
          && C_WEAKEXT == C_AIX_WEAKEXT)
        isym.n_sclass = C_WEAKEXT;
       else
@@ -6414,9 +6413,9 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
        goto error_return;
     }
 
-  /* Setting bfd_get_symcount to 0 will cause write_object_contents to
+  /* Setting symcount to 0 will cause write_object_contents to
      not try to write out the symbols.  */
-  bfd_get_symcount (abfd) = 0;
+  abfd->symcount = 0;
 
   return TRUE;
 
This page took 0.034339 seconds and 4 git commands to generate.