This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: objcopy fails silently with an empty input file
Thanks, Nick. The patch works, although it doesn't allow for this use case:
$ echo -n > empty
$ arm-elf-objcopy -I binary -O elf32-little empty empty.o; echo $?
arm-elf-objcopy: empty: empty input file
0
$ nm empty.o
00000000 D _binary_empty_end
00000000 A _binary_empty_size
00000000 D _binary_empty_start
I'd prefer this patch:
*************** copy_file (const char *input_filename, c
*** 1701,1706 ****
--- 1701,1703 ----
if (get_file_size (input_filename) < 1)
- {
+ non_fatal (_("%s: empty input file"), input_filename);
- status = 1;
- return;
- }
Perhaps this behaviour only makes sense when the input target is
binary, and this behviour could be selected only in that special case.
Cheers,
Shaun
On 4/13/05, Nick Clifton <nickc@redhat.com> wrote:
> Hi Shaun,
>
> > objcopy silently fails when the input file is empty. I'd rather it
> > didn't fail -- this used to work in previous versions -- but it
> > definitely shouldn't fail silently.
>
> Please could you try the attached patch and let me know if you have any
> problems with it ?
>
> Cheers
> Nick
>
> binutils/ChangeLog
> 2005-04-13 Nick Clifton <nickc@redhat.com>
>
> * objcopy.c (copy_file): Emit a message when skipping an empty
> input file.
>
> Index: binutils/objcopy.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/objcopy.c,v
> retrieving revision 1.77
> diff -c -3 -p -r1.77 objcopy.c
> *** binutils/objcopy.c 15 Mar 2005 17:45:18 -0000 1.77
> --- binutils/objcopy.c 13 Apr 2005 16:06:23 -0000
> *************** copy_file (const char *input_filename, c
> *** 1701,1706 ****
> --- 1701,1707 ----
>
> if (get_file_size (input_filename) < 1)
> {
> + non_fatal (_("%s: empty input file"), input_filename);
> status = 1;
> return;
> }
>