From 52a476eeda8cf7a753a58991293cae95baa44797 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 27 Jun 2009 17:19:02 +0000 Subject: [PATCH] 2009-06-27 H.J. Lu PR binutils/10321 * bucomm.c (get_file_size): Return -1 on error. * objcopy.c (copy_file): Report empty file. --- binutils/ChangeLog | 7 +++++++ binutils/bucomm.c | 2 +- binutils/objcopy.c | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index c748a6a77ee..0ff041fce02 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,10 @@ +2009-06-27 H.J. Lu + + PR binutils/10321 + * bucomm.c (get_file_size): Return -1 on error. + + * objcopy.c (copy_file): Report empty file. + 2009-06-23 Nick Clifton * dwarf.c (display_debug_lines_raw): Include the name of the diff --git a/binutils/bucomm.c b/binutils/bucomm.c index 9bbdafb9061..c6786790a72 100644 --- a/binutils/bucomm.c +++ b/binutils/bucomm.c @@ -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. */ diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 83d9e1b2aac..8908b564e13 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -2159,9 +2159,13 @@ copy_file (const char *input_filename, const char *output_filename, 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; }