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: Tom Rix <trix at redhat dot com>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: binutils at sources dot redhat dot com, "Christopher C. Chimelis" <chris at debian dot org>
- Date: Wed, 19 Dec 2001 00:22:36 -0600
- Subject: Re: Fix for strip/objcopy and empty archives
- References: <Pine.LNX.4.21.0112110155270.24927-100000@spawn.hockeyfiend.com> <20011218221956.M29130@bubble.sa.bigpond.net.au>
Alan Modra wrote:
> Anyone know why bfd_set_format was being set inside the object copying
> loop? As it was, objcopy/strip bombed on empty archives.
This patch will break xcoff.
Aix archives can contain non object files. Doing an 'ar -t' throught the
4.3.3 system libs turned up libUMSobj.a that has UMSobj.exp which looks like
an export/import text file.
Aix also supports an achive format <bigaf> that mixes 32 and 64 bit objects.
So checking the format inside the loop is the right thing to do.
Tom
>
>
> 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);
--
Tom Rix
GCC Engineer
trix@redhat.com