gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / binutils / elfedit.c
index 98d4fd7203a2065d12cf0e798d07c2761ebfce35..d0e4e95f4d6ebdfbb88cba87434306ccd8a420bd 100644 (file)
@@ -1,5 +1,5 @@
 /* elfedit.c -- Update the ELF header of an ELF format file
-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 
@@ -225,7 +225,7 @@ update_gnu_property (const char *file_name, FILE *file)
                        if (disable_x86_features)
                          bitmask &= ~disable_x86_features;
                        if (old_bitmask != bitmask)
-                         BYTE_PUT (ptr, bitmask);
+                         byte_put (ptr, bitmask, 4);
                        goto out;
                      }
 
@@ -238,7 +238,7 @@ update_gnu_property (const char *file_name, FILE *file)
          }
       }
 
-out:
+ out:
   if (ret != 0)
     error (_("%s: Invalid PT_NOTE segment\n"), file_name);
 
@@ -260,7 +260,10 @@ elf_x86_feature (const char *feature, int enable)
   else if (strcasecmp (feature, "shstk") == 0)
     x86_feature = GNU_PROPERTY_X86_FEATURE_1_SHSTK;
   else
-    return -1;
+    {
+      error (_("Unknown x86 feature: %s\n"), feature);
+      return -1;
+    }
 
   if (enable)
     {
@@ -538,6 +541,7 @@ process_archive (const char * file_name, FILE * file,
   struct archive_info nested_arch;
   size_t got;
   int ret;
+  struct stat statbuf;
 
   /* The ARCH structure is used to hold information about this archive.  */
   arch.file_name = NULL;
@@ -555,7 +559,9 @@ process_archive (const char * file_name, FILE * file,
   nested_arch.sym_table = NULL;
   nested_arch.longnames = NULL;
 
-  if (setup_archive (&arch, file_name, file, is_thin_archive, FALSE) != 0)
+  if (fstat (fileno (file), &statbuf) < 0
+      || setup_archive (&arch, file_name, file, statbuf.st_size,
+                       is_thin_archive, FALSE) != 0)
     {
       ret = 1;
       goto out;
@@ -613,6 +619,7 @@ process_archive (const char * file_name, FILE * file,
       if (qualified_name == NULL)
        {
          error (_("%s: bad archive file name\n"), file_name);
+         free (name);
          ret = 1;
          break;
        }
@@ -623,8 +630,10 @@ process_archive (const char * file_name, FILE * file,
           FILE *member_file;
           char *member_file_name = adjust_relative_path (file_name,
                                                         name, namelen);
+         free (name);
           if (member_file_name == NULL)
             {
+             free (qualified_name);
               ret = 1;
               break;
             }
@@ -635,6 +644,7 @@ process_archive (const char * file_name, FILE * file,
               error (_("Input file '%s' is not readable\n"),
                         member_file_name);
               free (member_file_name);
+             free (qualified_name);
               ret = 1;
               break;
             }
@@ -645,9 +655,12 @@ process_archive (const char * file_name, FILE * file,
 
           fclose (member_file);
           free (member_file_name);
+         free (qualified_name);
         }
       else if (is_thin_archive)
         {
+         free (name);
+
           /* This is a proxy for a member of a nested archive.  */
           archive_file_offset = arch.nested_member_origin + sizeof arch.arhdr;
 
@@ -658,6 +671,7 @@ process_archive (const char * file_name, FILE * file,
             {
               error (_("%s: failed to seek to archive member\n"),
                         nested_arch.file_name);
+             free (qualified_name);
               ret = 1;
               break;
             }
@@ -666,6 +680,7 @@ process_archive (const char * file_name, FILE * file,
         }
       else
         {
+         free (name);
           archive_file_offset = arch.next_arhdr_offset;
           arch.next_arhdr_offset += archive_file_size;
 
This page took 0.035149 seconds and 4 git commands to generate.