This is the mail archive of the binutils@sources.redhat.com 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]

Re: Fix for strip/objcopy and empty archives


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);


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