[AArch64] Use SYMBOL_REFERENCES_LOCAL in one symbol check
[deliverable/binutils-gdb.git] / bfd / coff-rs6000.c
index 1170c7f58c12f428b859270f67063e55b886c5f3..b49e393e48f43938400985125293f64fe0086874 100644 (file)
@@ -1,7 +1,5 @@
 /* BFD back-end for IBM RS/6000 "XCOFF" files.
-   Copyright 1990-1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011, 2012
-   Free Software Foundation, Inc.
+   Copyright (C) 1990-2017 Free Software Foundation, Inc.
    Written by Metin G. Ozisik, Mimi Phuong-Thao Vo, and John Gilmore.
    Archive support from Damon A. Permezel.
    Contributed by IBM Corporation and Cygnus Support.
@@ -116,6 +114,7 @@ extern int rs6000coff_core_file_failing_signal (bfd *abfd);
 #define bfd_pe_print_pdata     NULL
 #endif
 
+#include <stdint.h>
 #include "coffcode.h"
 
 /* The main body of code is in coffcode.h.  */
@@ -403,67 +402,6 @@ _bfd_xcoff_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
 {
   return FALSE;
 }
-
-static const struct dwarf_debug_section xcoff_debug_sections[] =
-{
-  { ".dwabrev",                NULL },
-  { ".dwarnge",                NULL },
-  { NULL,      NULL }, /* .debug_frame */
-  { ".dwinfo",         NULL },
-  { ".dwline",         NULL },
-  { NULL,      NULL }, /* .debug_loc */
-  { NULL,      NULL }, /* .debug_macinfo */
-  { NULL,      NULL }, /* .debug_macro */
-  { ".dwpbnms",                NULL },
-  { ".dwpbtyp",                NULL },
-  { ".dwrnges",                NULL },
-  { NULL,      NULL }, /* .debug_static_func */
-  { NULL,      NULL }, /* .debug_static_vars */
-  { ".dwstr",  NULL },
-  { NULL,      NULL }, /* .debug_types */
-  /* GNU DWARF 1 extensions */
-  { NULL,      NULL }, /* .debug_sfnames */
-  { NULL,      NULL }, /* .debug_srcinfo */
-  /* SGI/MIPS DWARF 2 extensions */
-  { NULL,      NULL }, /* .debug_funcnames */
-  { NULL,      NULL }, /* .debug_typenames */
-  { NULL,      NULL }, /* .debug_varnames */
-  { NULL,      NULL }, /* .debug_weaknames */
-  { NULL,      NULL },
-};
-
-static bfd_boolean
-xcoff_find_nearest_line (bfd *abfd,
-                         asection *section,
-                         asymbol **symbols,
-                         bfd_vma offset,
-                         const char **filename_ptr,
-                         const char **functionname_ptr,
-                         unsigned int *line_ptr)
-{
-  return coff_find_nearest_line_with_names (abfd, xcoff_debug_sections,
-                                            section, symbols, offset,
-                                            filename_ptr, functionname_ptr,
-                                            line_ptr);
-}
-
-static bfd_boolean
-xcoff_find_nearest_line_discriminator (bfd *abfd,
-                                      asection *section,
-                                      asymbol **symbols,
-                                      bfd_vma offset,
-                                      const char **filename_ptr,
-                                      const char **functionname_ptr,
-                                      unsigned int *line_ptr,
-                                      unsigned int *discriminator)
-{
-  *discriminator = 0;
-  return coff_find_nearest_line_with_names (abfd, xcoff_debug_sections,
-                                            section, symbols, offset,
-                                            filename_ptr, functionname_ptr,
-                                            line_ptr);
-}
-
 \f
 void
 _bfd_xcoff_swap_sym_in (bfd *abfd, void * ext1, void * in1)
@@ -482,7 +420,7 @@ _bfd_xcoff_swap_sym_in (bfd *abfd, void * ext1, void * in1)
     }
 
   in->n_value = H_GET_32 (abfd, ext->e_value);
-  in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
+  in->n_scnum = (short) H_GET_16 (abfd, ext->e_scnum);
   in->n_type = H_GET_16 (abfd, ext->e_type);
   in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
   in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
@@ -2404,7 +2342,10 @@ xcoff_write_archive_contents_big (bfd *abfd)
       PRINT20 (ahdrp->nextoff, iterator.next.offset);
 
       if (!do_pad (abfd, iterator.current.leading_padding))
-       return FALSE;
+       {
+         free (offsets);
+         return FALSE;
+       }
 
       BFD_ASSERT (iterator.current.offset == bfd_tell (abfd));
       namlen = iterator.current.padded_namlen;
@@ -2414,7 +2355,10 @@ xcoff_write_archive_contents_big (bfd *abfd)
          || bfd_seek (iterator.current.member, 0, SEEK_SET) != 0
          || !do_copy (abfd, iterator.current.member)
          || !do_pad (abfd, iterator.current.trailing_padding))
-       return FALSE;
+       {
+         free (offsets);
+         return FALSE;
+       }
 
       offsets[i] = iterator.current.offset;
       prevoff = iterator.current.offset;
@@ -2459,7 +2403,10 @@ xcoff_write_archive_contents_big (bfd *abfd)
   member_table_size += member_table_size & 1;
   member_table = bfd_zmalloc (member_table_size);
   if (member_table == NULL)
-    return FALSE;
+    {
+      free (offsets);
+      return FALSE;
+    }
 
   hdr = (struct xcoff_ar_hdr_big *) member_table;
 
@@ -2581,7 +2528,7 @@ _bfd_xcoff_sizeof_headers (bfd *abfd,
       };
       struct nbr_reloc_lineno *n_rl;
       bfd *sub;
-      int max_index;
+      unsigned int max_index;
       asection *s;
 
       /* Although the number of sections is known, the maximum value of
@@ -2600,7 +2547,7 @@ _bfd_xcoff_sizeof_headers (bfd *abfd,
        return -1;
 
       /* Sum.  */
-      for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+      for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
        for (s = sub->sections; s != NULL; s = s->next)
          {
            struct nbr_reloc_lineno *e = &n_rl[s->output_section->index];
@@ -2789,9 +2736,10 @@ xcoff_reloc_type_fail (bfd *input_bfd,
                        bfd_vma *relocation ATTRIBUTE_UNUSED,
                        bfd_byte *contents ATTRIBUTE_UNUSED)
 {
-  (*_bfd_error_handler)
-    (_("%s: unsupported relocation type 0x%02x"),
-     bfd_get_filename (input_bfd), (unsigned int) rel->r_type);
+  _bfd_error_handler
+    /* xgettext: c-format */
+    (_("%B: unsupported relocation type 0x%02x"),
+     input_bfd, (unsigned int) rel->r_type);
   bfd_set_error (bfd_error_bad_value);
   return FALSE;
 }
@@ -2874,10 +2822,10 @@ xcoff_reloc_type_toc (bfd *input_bfd,
     {
       if (h->toc_section == NULL)
        {
-         (*_bfd_error_handler)
-           (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
-            bfd_get_filename (input_bfd), rel->r_vaddr,
-            h->root.root.string);
+         _bfd_error_handler
+           /* xgettext: c-format */
+           (_("%B: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
+            input_bfd, rel->r_vaddr, h->root.root.string);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
        }
@@ -3420,15 +3368,12 @@ xcoff_ppc_relocate_section (bfd *output_bfd,
            {
              if (info->unresolved_syms_in_objects != RM_IGNORE
                  && (h->flags & XCOFF_WAS_UNDEFINED) != 0)
-               {
-                 if (! ((*info->callbacks->undefined_symbol)
-                        (info, h->root.root.string,
-                         input_bfd, input_section,
-                         rel->r_vaddr - input_section->vma,
-                         (info->unresolved_syms_in_objects
-                          == RM_GENERATE_ERROR))))
-                   return FALSE;
-               }
+               (*info->callbacks->undefined_symbol)
+                 (info, h->root.root.string,
+                  input_bfd, input_section,
+                  rel->r_vaddr - input_section->vma,
+                  info->unresolved_syms_in_objects == RM_GENERATE_ERROR);
+
              if (h->root.type == bfd_link_hash_defined
                  || h->root.type == bfd_link_hash_defweak)
                {
@@ -3446,7 +3391,7 @@ xcoff_ppc_relocate_section (bfd *output_bfd,
                }
              else
                {
-                 BFD_ASSERT (info->relocatable
+                 BFD_ASSERT (bfd_link_relocatable (info)
                              || (info->static_link
                                  && (h->flags & XCOFF_WAS_UNDEFINED) != 0)
                              || (h->flags & XCOFF_DEF_DYNAMIC) != 0
@@ -3508,11 +3453,10 @@ xcoff_ppc_relocate_section (bfd *output_bfd,
            }
          sprintf (reloc_type_name, "0x%02x", rel->r_type);
 
-         if (! ((*info->callbacks->reloc_overflow)
-                (info, (h ? &h->root : NULL), name, reloc_type_name,
-                 (bfd_vma) 0, input_bfd, input_section,
-                 rel->r_vaddr - input_section->vma)))
-           return FALSE;
+         (*info->callbacks->reloc_overflow)
+           (info, (h ? &h->root : NULL), name, reloc_type_name,
+            (bfd_vma) 0, input_bfd, input_section,
+            rel->r_vaddr - input_section->vma);
        }
 
       /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE.  */
@@ -3576,7 +3520,8 @@ _bfd_xcoff_put_ldsymbol_name (bfd *abfd ATTRIBUTE_UNUSED,
 }
 
 static bfd_boolean
-_bfd_xcoff_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,
+_bfd_xcoff_put_symbol_name (struct bfd_link_info *info,
+                           struct bfd_strtab_hash *strtab,
                            struct internal_syment *sym,
                            const char *name)
 {
@@ -3589,9 +3534,7 @@ _bfd_xcoff_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,
       bfd_boolean hash;
       bfd_size_type indx;
 
-      hash = TRUE;
-      if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
-       hash = FALSE;
+      hash = !info->traditional_format;
       indx = _bfd_stringtab_add (strtab, name, hash, FALSE);
       if (indx == (bfd_size_type) -1)
        return FALSE;
@@ -3616,7 +3559,7 @@ xcoff_create_csect_from_smclas (bfd *abfd,
       ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0", /* 8 - 15 */
       ".td", NULL, ".sv3264", NULL, ".tl", ".ul", ".te"
     };
-  
+
   if ((aux->x_csect.x_smclas < ARRAY_SIZE (names))
       && (NULL != names[aux->x_csect.x_smclas]))
     {
@@ -3625,7 +3568,8 @@ xcoff_create_csect_from_smclas (bfd *abfd,
     }
   else
     {
-      (*_bfd_error_handler)
+      _bfd_error_handler
+       /* xgettext: c-format */
        (_("%B: symbol `%s' has unrecognized smclas %d"),
         abfd, symbol_name, aux->x_csect.x_smclas);
       bfd_set_error (bfd_error_bad_value);
@@ -4033,13 +3977,14 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 #define _bfd_xcoff_make_empty_symbol coff_make_empty_symbol
 #define _bfd_xcoff_print_symbol coff_print_symbol
 #define _bfd_xcoff_get_symbol_info coff_get_symbol_info
+#define _bfd_xcoff_get_symbol_version_string \
+  _bfd_nosymbols_get_symbol_version_string
 #define _bfd_xcoff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
 #define _bfd_xcoff_bfd_is_target_special_symbol \
   coff_bfd_is_target_special_symbol
 #define _bfd_xcoff_get_lineno coff_get_lineno
-#define _bfd_xcoff_find_nearest_line xcoff_find_nearest_line
-#define _bfd_generic_find_nearest_line_discriminator \
-  xcoff_find_nearest_line_discriminator
+#define _bfd_xcoff_find_nearest_line coff_find_nearest_line
+#define _bfd_xcoff_find_line coff_find_line
 #define _bfd_xcoff_find_inliner_info coff_find_inliner_info
 #define _bfd_xcoff_bfd_make_debug_symbol coff_bfd_make_debug_symbol
 #define _bfd_xcoff_read_minisymbols _bfd_generic_read_minisymbols
@@ -4048,6 +3993,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 /* For reloc entry points.  */
 #define _bfd_xcoff_get_reloc_upper_bound coff_get_reloc_upper_bound
 #define _bfd_xcoff_canonicalize_reloc coff_canonicalize_reloc
+#define _bfd_xcoff_set_reloc _bfd_generic_set_reloc
 #define _bfd_xcoff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
 #define _bfd_xcoff_bfd_reloc_name_lookup _bfd_xcoff_reloc_name_lookup
 
@@ -4067,6 +4013,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 #define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
 #define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked
 #define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol
+#define _bfd_xcoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
 /* For dynamic symbols and relocs entry points.  */
 #define _bfd_xcoff_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
@@ -4097,6 +4044,7 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
       3,                       /* _bfd_coff_default_section_alignment_power */
       FALSE,                   /* _bfd_coff_force_symnames_in_strings */
       2,                       /* _bfd_coff_debug_string_prefix_length */
+      32768,                   /* _bfd_coff_max_nscns */
       coff_swap_filehdr_in,
       coff_swap_aouthdr_in,
       coff_swap_scnhdr_in,
@@ -4168,7 +4116,7 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
   };
 
 /* The transfer vector that leads the outside world to all of the above.  */
-const bfd_target rs6000coff_vec =
+const bfd_target rs6000_xcoff_vec =
   {
     "aixcoff-rs6000",
     bfd_target_xcoff_flavour,
@@ -4277,6 +4225,7 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data =
       3,                       /* _bfd_coff_default_section_alignment_power */
       FALSE,                   /* _bfd_coff_force_symnames_in_strings */
       2,                       /* _bfd_coff_debug_string_prefix_length */
+      32768,                   /* _bfd_coff_max_nscns */
       coff_swap_filehdr_in,
       coff_swap_aouthdr_in,
       coff_swap_scnhdr_in,
@@ -4348,7 +4297,7 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data =
   };
 
 /* The transfer vector that leads the outside world to all of the above.  */
-const bfd_target pmac_xcoff_vec =
+const bfd_target powerpc_xcoff_vec =
   {
     "xcoff-powermac",
     bfd_target_xcoff_flavour,
This page took 0.033519 seconds and 4 git commands to generate.