This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fixes a problem with objcopy leaving temporary files and directories around if it encounters a probl


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cfad873011d6399aa88bc6ddcb4c93dda5dad9b0

commit cfad873011d6399aa88bc6ddcb4c93dda5dad9b0
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Mar 10 13:38:24 2015 +0000

    Fixes a problem with objcopy leaving temporary files and directories around if it encounters a problem during a copy.
    
    	PR binutils/17636
    	* objcopy.c (copy_object): Avoid calling fatal as that does not
    	allow the parent to clean up temporary files.

Diff:
---
 binutils/ChangeLog |  6 ++++++
 binutils/objcopy.c | 24 ++++++++++++++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index d10dd23..550111b 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-10  Nick Clifton  <nickc@redhat.com>
+
+	PR binutils/17636
+	* objcopy.c (copy_object): Avoid calling fatal as that does not
+	allow the parent to clean up temporary files.
+
 2015-03-10  Yuri Gribov  <y.gribov@samsung.arm>
 
 	PR ld/16572
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index f340c8a..128044c 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1640,7 +1640,12 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
   if (ibfd->xvec->byteorder != obfd->xvec->byteorder
       && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
       && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
-    fatal (_("Unable to change endianness of input file(s)"));
+    {
+      /* PR 17636: Call non-fatal so that we return to our parent who
+	 may need to tidy temporary files.  */
+      non_fatal (_("Unable to change endianness of input file(s)"));
+      return FALSE;
+    }
 
   if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
     {
@@ -1909,7 +1914,10 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 
 	  pupdate->section = bfd_get_section_by_name (ibfd, pupdate->name);
 	  if (pupdate->section == NULL)
-	    fatal (_("error: %s not found, can't be updated"), pupdate->name);
+	    {
+	      non_fatal (_("error: %s not found, can't be updated"), pupdate->name);
+	      return FALSE;
+	    }
 
 	  osec = pupdate->section->output_section;
 	  if (! bfd_set_section_size (obfd, osec, pupdate->size))
@@ -1965,9 +1973,12 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 	  if (bfd_get_section_contents (ibfd, sec, contents, 0, size))
 	    {
 	      if (fwrite (contents, 1, size, f) != size)
-		fatal (_("error writing section contents to %s (error: %s)"),
-		       pdump->filename,
-		       strerror (errno));
+		{
+		  non_fatal (_("error writing section contents to %s (error: %s)"),
+			     pdump->filename,
+			     strerror (errno));
+		  return FALSE;
+		}
 	    }
 	  else
 	    bfd_nonfatal_message (NULL, ibfd, sec,
@@ -2365,7 +2376,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
     {
       status = 1;
       bfd_nonfatal_message (NULL, obfd, NULL, NULL);
-      return;
+      goto cleanup_and_exit;
     }
 
   while (!status && this_element != NULL)
@@ -2526,6 +2537,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
 	  unlink (l->name);
 	}
     }
+
   rmdir (dir);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]