This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Fix for strip/objcopy and empty archives
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Cc: "Christopher C. Chimelis" <chris at debian dot org>
- Date: Tue, 18 Dec 2001 22:19:56 +1030
- Subject: Re: Fix for strip/objcopy and empty archives
- References: <Pine.LNX.4.21.0112110155270.24927-100000@spawn.hockeyfiend.com>
Anyone know why bfd_set_format was being set inside the object copying
loop? As it was, objcopy/strip bombed on empty archives.
binutils/ChangeLog
* objcopy.c (copy_archive): Set output bfd format outside the loop.
--
Alan Modra
Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.31
diff -u -p -r1.31 objcopy.c
--- objcopy.c 2001/12/18 08:22:30 1.31
+++ objcopy.c 2001/12/18 11:43:15
@@ -1296,6 +1296,9 @@ copy_archive (ibfd, obfd, output_target)
this_element = bfd_openr_next_archived_file (ibfd, NULL);
+ if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
+ RETURN_NONFATAL (bfd_get_filename (obfd));
+
while (!status && this_element != (bfd *) NULL)
{
/* Create an output file for this member. */
@@ -1322,9 +1325,6 @@ copy_archive (ibfd, obfd, output_target)
if (output_bfd == (bfd *) NULL)
RETURN_NONFATAL (output_name);
-
- if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
- RETURN_NONFATAL (bfd_get_filename (obfd));
if (bfd_check_format (this_element, bfd_object) == true)
copy_object (this_element, output_bfd);