Patch to remove confusing warning generated by objcopy -I binary

Matthew Hiller hiller@redhat.com
Wed Nov 1 17:13:00 GMT 2000


	There are somewhat uncommon instances where one will want to use a
raw binary file as the input to objcopy; this patch adjusts objcopy such
that it does not output a confusing warning message when one attempts to
do so.

2000-11-01  Matthew Hiller   <hiller@redhat.com>

	* binutils/objcopy.c (copy_object): Output "output file cannot
	represent architecture" warning only when appropriate.

	* bfd/binary.c: Adjusted opening comment.

Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 objcopy.c
*** objcopy.c	2000/08/14 19:47:01	1.13
--- objcopy.c	2000/11/02 00:52:26
*************** copy_object (ibfd, obfd)
*** 750,757 ****
    bfd_size_type max_gap = 0;
    long symsize;
    PTR dhandle;
  
- 
    if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
      RETURN_NONFATAL (bfd_get_filename (obfd));
  
--- 750,758 ----
    bfd_size_type max_gap = 0;
    long symsize;
    PTR dhandle;
+   enum bfd_architecture arch;
+   unsigned long mach;
  
    if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
      RETURN_NONFATAL (bfd_get_filename (obfd));
  
*************** copy_object (ibfd, obfd)
*** 771,783 ****
  			      (bfd_get_file_flags (ibfd)
  			       & bfd_applicable_file_flags (obfd))))
      RETURN_NONFATAL (bfd_get_filename (ibfd));
  
!   /* Copy architecture of input file to output file */
!   if (!bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
! 			  bfd_get_mach (ibfd)))
      non_fatal (_("Warning: Output file cannot represent architecture %s"),
! 	       bfd_printable_arch_mach (bfd_get_arch (ibfd),
! 					bfd_get_mach (ibfd)));
  
    if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
      RETURN_NONFATAL (bfd_get_filename (ibfd));
--- 772,789 ----
  			      (bfd_get_file_flags (ibfd)
  			       & bfd_applicable_file_flags (obfd))))
      RETURN_NONFATAL (bfd_get_filename (ibfd));
+ 
  
!   /* Copy architecture of input file to output file.  Output a warning
!      if this can't be done, but don't issue the warning if the input
!      format does not have an architecture associated with it (e.g.,
!      the "binary" format.) */
!   arch = bfd_get_arch (ibfd);
!   mach = bfd_get_mach (ibfd);
!   if (!bfd_set_arch_mach (obfd, arch, mach)
!       && bfd_lookup_arch (arch, mach))
      non_fatal (_("Warning: Output file cannot represent architecture %s"),
! 	       bfd_printable_arch_mach (arch, mach)); 
  
    if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
      RETURN_NONFATAL (bfd_get_filename (ibfd));
Index: bfd/binary.c
===================================================================
RCS file: /cvs/src/src/bfd/binary.c,v
retrieving revision 1.3
diff -c -3 -p -r1.3 binary.c
*** binary.c	1999/07/19 14:55:15	1.3
--- binary.c	2000/11/02 00:52:26
*************** along with this program; if not, write t
*** 19,27 ****
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
  /* This is a BFD backend which may be used to write binary objects.
!    It may only be used for output, not input.  The intention is that
!    this may be used as an output format for objcopy in order to
!    generate raw binary data.
  
     This is very simple.  The only complication is that the real data
     will start at some address X, and in some cases we will not want to
--- 19,28 ----
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
  /* This is a BFD backend which may be used to write binary objects.
!    The primary intention is that this may be used as an output format
!    for objcopy in order to generate raw binary data.  There are some
!    situations, though, in which users will want to use raw binary data
!    as an input format.
  
     This is very simple.  The only complication is that the real data
     will start at some address X, and in some cases we will not want to



More information about the Binutils mailing list