This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR binutils/10321: objcopy silently exits with empty input files
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sources dot redhat dot com
- Date: Sat, 27 Jun 2009 10:18:36 -0700
- Subject: PATCH: PR binutils/10321: objcopy silently exits with empty input files
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
Fix PR 3001 removes the empty file message. I am checking in this
patch to restore it.
Thanks.
H.J.
---
Index: objcopy.c
===================================================================
--- objcopy.c (revision 6206)
+++ objcopy.c (working copy)
@@ -2159,9 +2159,13 @@ copy_file (const char *input_filename, c
bfd *ibfd;
char **obj_matching;
char **core_matching;
+ off_t size = get_file_size (input_filename);
- if (get_file_size (input_filename) < 1)
+ if (size < 1)
{
+ if (size == 0)
+ non_fatal (_("error: the input file '%s' is empty"),
+ input_filename);
status = 1;
return;
}
Index: ChangeLog
===================================================================
--- ChangeLog (revision 6310)
+++ ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2009-06-27 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/10321
+ * bucomm.c (get_file_size): Return -1 on error.
+
+ * objcopy.c (copy_file): Report empty file.
+
2009-06-23 Nick Clifton <nickc@redhat.com>
* dwarf.c (display_debug_lines_raw): Include the name of the
Index: bucomm.c
===================================================================
--- bucomm.c (revision 6206)
+++ bucomm.c (working copy)
@@ -571,7 +571,7 @@ get_file_size (const char * file_name)
else
return statbuf.st_size;
- return 0;
+ return (off_t) -1;
}
/* Return the filename in a static buffer. */