gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / bfd / coff-ppc.c
index a8b4e47bd22f2435a7d546a299d101ddc1ae97f1..a3ad1ef8e6ce877b4c7d9bb189a5ec67475ab203 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for PowerPC Microsoft Portable Executable files.
-   Copyright (C) 1990-2017 Free Software Foundation, Inc.
+   Copyright (C) 1990-2020 Free Software Foundation, Inc.
 
    Original version pieced together by Kim Knuttila (krk@cygnus.com)
 
@@ -179,7 +179,7 @@ static struct bfd_link_hash_table *
 ppc_coff_link_hash_table_create (bfd *abfd)
 {
   struct ppc_coff_link_hash_table *ret;
-  bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table);
+  size_t amt = sizeof (struct ppc_coff_link_hash_table);
 
   ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
@@ -771,7 +771,7 @@ record_toc (asection *toc_section,
            const char *name)
 {
   /* Add this entry to our toc addr-offset-name list.  */
-  bfd_size_type amt = sizeof (struct list_ele);
+  size_t amt = sizeof (struct list_ele);
   struct list_ele *t = (struct list_ele *) bfd_malloc (amt);
 
   if (t == NULL)
@@ -1038,9 +1038,9 @@ coff_ppc_relocate_section (bfd *output_bfd,
       switch (r_type)
        {
        default:
-         _bfd_error_handler
-           /* xgettext: c-format */
-           (_("%B: unsupported relocation type 0x%02x"), input_bfd, r_type);
+         /* xgettext: c-format */
+         _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                             input_bfd, r_type);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
        case IMAGE_REL_PPC_TOCREL16:
@@ -1131,9 +1131,9 @@ coff_ppc_relocate_section (bfd *output_bfd,
                      {
                        _bfd_error_handler
                          /* xgettext: c-format */
-                         (_("%B: Relocation for %s of %#Lx exceeds "
+                         (_("%pB: Relocation for %s of %#" PRIx64 " exceeds "
                             "Toc size limit"),
-                          input_bfd, name, our_toc_offset);
+                          input_bfd, name, (uint64_t) our_toc_offset);
                        bfd_set_error (bfd_error_bad_value);
                        return FALSE;
                      }
@@ -1185,8 +1185,8 @@ coff_ppc_relocate_section (bfd *output_bfd,
              {
                _bfd_error_handler
                  /* xgettext: c-format */
-                 (_("%B: Relocation exceeds allocated TOC (%#Lx)"),
-                  input_bfd, toc_section->size);
+                 (_("%pB: Relocation exceeds allocated TOC (%#" PRIx64 ")"),
+                  input_bfd, (uint64_t) toc_section->size);
                bfd_set_error (bfd_error_bad_value);
                return FALSE;
              }
@@ -1240,10 +1240,11 @@ coff_ppc_relocate_section (bfd *output_bfd,
 
            _bfd_error_handler
              /* xgettext: c-format */
-             (_("Warning: unsupported reloc %s <file %B, section %A>\n"
-                "sym %ld (%s), r_vaddr %Ld (%#Lx)"),
+             (_("warning: unsupported reloc %s <file %pB, section %pA>\n"
+                "sym %ld (%s), r_vaddr %" PRId64 " (%#" PRIx64 ")"),
               howto->name, input_bfd, input_section,
-              rel->r_symndx, my_name, rel->r_vaddr, rel->r_vaddr);
+              rel->r_symndx, my_name,
+              (int64_t) rel->r_vaddr, (uint64_t) rel->r_vaddr);
          }
          break;
        case IMAGE_REL_PPC_IMGLUE:
@@ -1258,7 +1259,7 @@ coff_ppc_relocate_section (bfd *output_bfd,
 
            _bfd_error_handler
              /* xgettext: c-format */
-             (_("%B: Out of order IMGLUE reloc for %s"), input_bfd, my_name);
+             (_("%pB: Out of order IMGLUE reloc for %s"), input_bfd, my_name);
            bfd_set_error (bfd_error_bad_value);
            return FALSE;
          }
@@ -1512,7 +1513,6 @@ ppc_allocate_toc_section (struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   asection *s;
   bfd_byte *foo;
-  bfd_size_type amt;
   static char test_char = '1';
 
   if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble?  */
@@ -1527,8 +1527,7 @@ ppc_allocate_toc_section (struct bfd_link_info *info ATTRIBUTE_UNUSED)
     /* No toc section? Something is very wrong.  */
     abort ();
 
-  amt = global_toc_size;
-  foo = (bfd_byte *) bfd_alloc (bfd_of_toc_owner, amt);
+  foo = (bfd_byte *) bfd_alloc (bfd_of_toc_owner, global_toc_size);
   memset(foo, test_char, (size_t) global_toc_size);
 
   s->size = global_toc_size;
@@ -2259,41 +2258,20 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
   coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
   debug_merge_allocated = FALSE;
 
-  if (flaginfo.internal_syms != NULL)
-    {
-      free (flaginfo.internal_syms);
-      flaginfo.internal_syms = NULL;
-    }
-  if (flaginfo.sec_ptrs != NULL)
-    {
-      free (flaginfo.sec_ptrs);
-      flaginfo.sec_ptrs = NULL;
-    }
-  if (flaginfo.sym_indices != NULL)
-    {
-      free (flaginfo.sym_indices);
-      flaginfo.sym_indices = NULL;
-    }
-  if (flaginfo.linenos != NULL)
-    {
-      free (flaginfo.linenos);
-      flaginfo.linenos = NULL;
-    }
-  if (flaginfo.contents != NULL)
-    {
-      free (flaginfo.contents);
-      flaginfo.contents = NULL;
-    }
-  if (flaginfo.external_relocs != NULL)
-    {
-      free (flaginfo.external_relocs);
-      flaginfo.external_relocs = NULL;
-    }
-  if (flaginfo.internal_relocs != NULL)
-    {
-      free (flaginfo.internal_relocs);
-      flaginfo.internal_relocs = NULL;
-    }
+  free (flaginfo.internal_syms);
+  flaginfo.internal_syms = NULL;
+  free (flaginfo.sec_ptrs);
+  flaginfo.sec_ptrs = NULL;
+  free (flaginfo.sym_indices);
+  flaginfo.sym_indices = NULL;
+  free (flaginfo.linenos);
+  flaginfo.linenos = NULL;
+  free (flaginfo.contents);
+  flaginfo.contents = NULL;
+  free (flaginfo.external_relocs);
+  flaginfo.external_relocs = NULL;
+  free (flaginfo.internal_relocs);
+  flaginfo.internal_relocs = NULL;
 
   /* The value of the last C_FILE symbol is supposed to be the symbol
      index of the first external symbol.  Write it out again if
@@ -2319,11 +2297,8 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
     goto error_return;
 
   /* The outsyms buffer is used by _bfd_coff_write_global_sym.  */
-  if (flaginfo.outsyms != NULL)
-    {
-      free (flaginfo.outsyms);
-      flaginfo.outsyms = NULL;
-    }
+  free (flaginfo.outsyms);
+  flaginfo.outsyms = NULL;
 
   if (bfd_link_relocatable (info))
     {
@@ -2376,10 +2351,8 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
 
       for (i = 0; i < abfd->section_count; i++)
        {
-         if (flaginfo.section_info[i].relocs != NULL)
-           free (flaginfo.section_info[i].relocs);
-         if (flaginfo.section_info[i].rel_hashes != NULL)
-           free (flaginfo.section_info[i].rel_hashes);
+         free (flaginfo.section_info[i].relocs);
+         free (flaginfo.section_info[i].rel_hashes);
        }
       free (flaginfo.section_info);
       flaginfo.section_info = NULL;
@@ -2419,9 +2392,9 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
 
   _bfd_stringtab_free (flaginfo.strtab);
 
-  /* 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;
 
@@ -2436,31 +2409,20 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
 
       for (i = 0; i < abfd->section_count; i++)
        {
-         if (flaginfo.section_info[i].relocs != NULL)
-           free (flaginfo.section_info[i].relocs);
-         if (flaginfo.section_info[i].rel_hashes != NULL)
-           free (flaginfo.section_info[i].rel_hashes);
+         free (flaginfo.section_info[i].relocs);
+         free (flaginfo.section_info[i].rel_hashes);
        }
       free (flaginfo.section_info);
     }
-  if (flaginfo.internal_syms != NULL)
-    free (flaginfo.internal_syms);
-  if (flaginfo.sec_ptrs != NULL)
-    free (flaginfo.sec_ptrs);
-  if (flaginfo.sym_indices != NULL)
-    free (flaginfo.sym_indices);
-  if (flaginfo.outsyms != NULL)
-    free (flaginfo.outsyms);
-  if (flaginfo.linenos != NULL)
-    free (flaginfo.linenos);
-  if (flaginfo.contents != NULL)
-    free (flaginfo.contents);
-  if (flaginfo.external_relocs != NULL)
-    free (flaginfo.external_relocs);
-  if (flaginfo.internal_relocs != NULL)
-    free (flaginfo.internal_relocs);
-  if (external_relocs != NULL)
-    free (external_relocs);
+  free (flaginfo.internal_syms);
+  free (flaginfo.sec_ptrs);
+  free (flaginfo.sym_indices);
+  free (flaginfo.outsyms);
+  free (flaginfo.linenos);
+  free (flaginfo.contents);
+  free (flaginfo.external_relocs);
+  free (flaginfo.internal_relocs);
+  free (external_relocs);
   return FALSE;
 }
 #endif
@@ -2480,9 +2442,9 @@ const bfd_target TARGET_LITTLE_SYM =
   BFD_ENDIAN_LITTLE,           /* data byte order is little */
   BFD_ENDIAN_LITTLE,           /* header byte order is little */
 
-  (HAS_RELOC | EXEC_P |                /* FIXME: object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+  (HAS_RELOC | EXEC_P          /* FIXME: object flags */
+   | HAS_LINENO | HAS_DEBUG
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
 #ifndef COFF_WITH_PE
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
@@ -2505,12 +2467,24 @@ const bfd_target TARGET_LITTLE_SYM =
   bfd_getl32, bfd_getl_signed_32, bfd_putl32,
   bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
 
-  {_bfd_dummy_target, coff_object_p,   /* bfd_check_format */
-     bfd_generic_archive_p, /* _bfd_dummy_target */ coff_object_p },
-  {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
-     bfd_false},
-  {bfd_false, coff_write_object_contents,      /* bfd_write_contents */
-     _bfd_write_archive_contents, bfd_false},
+  {                            /* bfd_check_format */
+    _bfd_dummy_target,
+    coff_object_p,
+    bfd_generic_archive_p,
+    coff_object_p
+  },
+  {                            /* bfd_set_format */
+    _bfd_bool_bfd_false_error,
+    coff_mkobject,
+    _bfd_generic_mkarchive,
+    _bfd_bool_bfd_false_error
+  },
+  {                            /* bfd_write_contents */
+    _bfd_bool_bfd_false_error,
+    coff_write_object_contents,
+    _bfd_write_archive_contents,
+    _bfd_bool_bfd_false_error
+  },
 
   BFD_JUMP_TABLE_GENERIC (coff),
   BFD_JUMP_TABLE_COPY (coff),
@@ -2524,7 +2498,7 @@ const bfd_target TARGET_LITTLE_SYM =
 
   /* Alternative_target.  */
 #ifdef TARGET_BIG_SYM
-  & TARGET_BIG_SYM,
+  &TARGET_BIG_SYM,
 #else
   NULL,
 #endif
@@ -2541,9 +2515,9 @@ const bfd_target TARGET_BIG_SYM =
   BFD_ENDIAN_BIG,              /* data byte order is big */
   BFD_ENDIAN_BIG,              /* header byte order is big */
 
-  (HAS_RELOC | EXEC_P |                /* FIXME: object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+  (HAS_RELOC | EXEC_P          /* FIXME: object flags */
+   | HAS_LINENO | HAS_DEBUG
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
 #ifndef COFF_WITH_PE
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
@@ -2566,12 +2540,24 @@ const bfd_target TARGET_BIG_SYM =
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
 
-  {_bfd_dummy_target, coff_object_p,   /* bfd_check_format */
-     bfd_generic_archive_p, /* _bfd_dummy_target */ coff_object_p },
-  {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
-     bfd_false},
-  {bfd_false, coff_write_object_contents,      /* bfd_write_contents */
-     _bfd_write_archive_contents, bfd_false},
+  {                            /* bfd_check_format */
+    _bfd_dummy_target,
+    coff_object_p,
+    bfd_generic_archive_p,
+    coff_object_p
+  },
+  {                            /* bfd_set_format */
+    _bfd_bool_bfd_false_error,
+    coff_mkobject,
+    _bfd_generic_mkarchive,
+    _bfd_bool_bfd_false_error
+  },
+  {                            /* bfd_write_contents */
+    _bfd_bool_bfd_false_error,
+    coff_write_object_contents,
+    _bfd_write_archive_contents,
+    _bfd_bool_bfd_false_error
+  },
 
   BFD_JUMP_TABLE_GENERIC (coff),
   BFD_JUMP_TABLE_COPY (coff),
@@ -2585,7 +2571,7 @@ const bfd_target TARGET_BIG_SYM =
 
   /* Alternative_target.  */
 #ifdef TARGET_LITTLE_SYM
-  & TARGET_LITTLE_SYM,
+  &TARGET_LITTLE_SYM,
 #else
   NULL,
 #endif
This page took 0.028212 seconds and 4 git commands to generate.