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


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




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