tic4x: sign extension using shifts
[deliverable/binutils-gdb.git] / bfd / coff64-rs6000.c
index 1c80a9df8851c39c3a1459320d299f11c9e4fca2..0588567f0782ee1a1cab95262d8c773603f87614 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for IBM RS/6000 "XCOFF64" files.
-   Copyright (C) 2000-2019 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
    Written Clinton Popetz.
    Contributed by Cygnus Support.
 
@@ -959,7 +959,7 @@ xcoff64_write_object_contents (bfd *abfd)
       if (text_sec != NULL)
        {
          internal_a.o_sntext = text_sec->target_index;
-         internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec);
+         internal_a.o_algntext = bfd_section_alignment (text_sec);
        }
       else
        {
@@ -970,7 +970,7 @@ xcoff64_write_object_contents (bfd *abfd)
       if (data_sec != NULL)
        {
          internal_a.o_sndata = data_sec->target_index;
-         internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
+         internal_a.o_algndata = bfd_section_alignment (data_sec);
        }
       else
        {
@@ -1933,18 +1933,27 @@ xcoff64_slurp_armap (bfd *abfd)
     return FALSE;
 
   sz = bfd_scan_vma (hdr.size, (const char **) NULL, 10);
+  if (sz == (bfd_size_type) -1)
+    {
+      bfd_set_error (bfd_error_no_memory);
+      return FALSE;
+    }
 
   /* Read in the entire symbol table.  */
-  contents = (bfd_byte *) bfd_alloc (abfd, sz);
+  contents = (bfd_byte *) bfd_alloc (abfd, sz + 1);
   if (contents == NULL)
     return FALSE;
   if (bfd_bread (contents, sz, abfd) != sz)
     return FALSE;
 
+  /* Ensure strings are NULL terminated so we don't wander off the end
+     of the buffer.  */
+  contents[sz] = 0;
+
   /* The symbol table starts with an eight byte count.  */
   c = H_GET_64 (abfd, contents);
 
-  if (c * 8 >= sz)
+  if (c >= sz / 8)
     {
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
This page took 0.033275 seconds and 4 git commands to generate.