* obcopy.c (copy_object): New parameter `input_arch', architecture
authorNick Clifton <nickc@redhat.com>
Fri, 11 Sep 2009 11:16:19 +0000 (11:16 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 11 Sep 2009 11:16:19 +0000 (11:16 +0000)
       of input file, if not specified in input file itself; all callers
       updated; `binary_architecture' hack removed.
       (copy_archive, copy_file): New parameter `input_arch', for
       `copy_object' usage.
       (copy_main): Accept `-B' (`--binary-architecture') option also
       for any arch-less input ifile format, not only `binary'; remove
       bfd_external_binary_architecture hack; instead, add `input_arch'
       to calls to `copy_file'.
       * windres.c, windmc.c : Obsolete and useless external references
       to `bfd_external_binary_architecture' or `bfd_external_machine'
       removed.

       * binary.c (binary_object_p): Remove bfd_external_binary_architecture
       hack.  objcopy `-B' (`--binary-architecture') option is now handled
       in a generic way.

bfd/ChangeLog
bfd/binary.c
binutils/ChangeLog
binutils/doc/binutils.texi
binutils/objcopy.c
binutils/windmc.c
binutils/windres.c

index a4d85b9577f9203cd9fe97985515257590bda321..795f00d6f17ac9cbcc3803c4c702a417638b5140 100644 (file)
@@ -1,3 +1,9 @@
+2009-09-11  Philippe De Muyter  <phdm@macqel.be>
+
+       * binary.c (binary_object_p): Remove bfd_external_binary_architecture
+       hack.  objcopy `-B' (`--binary-architecture') option is now handled
+       in a generic way.
+
 2009-09-11  Nick Clifton  <nickc@redhat.com>
 
        * rs6000-core.c (read_hdr): Fix typo in recent C++ compatibility
index 97407567d5114da8a3be7d6c4074f30f04e98057..d264a09209e6d95a0c3f787dbc8f3b14ebe972cf 100644 (file)
    a start symbol, an end symbol, and an absolute length symbol.  */
 #define BIN_SYMS 3
 
-/* Set by external programs - specifies the BFD architecture and
-   machine number to be uses when creating binary BFDs.  */
-enum bfd_architecture  bfd_external_binary_architecture = bfd_arch_unknown;
-unsigned long          bfd_external_machine = 0;
-
 /* Create a binary object.  Invoked via bfd_set_format.  */
 
 static bfd_boolean
@@ -92,14 +87,6 @@ binary_object_p (bfd *abfd)
 
   abfd->tdata.any = (void *) sec;
 
-  if (bfd_get_arch_info (abfd) != NULL)
-    {
-      if ((bfd_get_arch_info (abfd)->arch == bfd_arch_unknown)
-          && (bfd_external_binary_architecture != bfd_arch_unknown))
-        bfd_set_arch_info (abfd, bfd_lookup_arch
-                          (bfd_external_binary_architecture, bfd_external_machine));
-    }
-
   return abfd->xvec;
 }
 
index 49e0135946311ed374a9f6e441babd5f4635169d..e7bc712729025c67c7e21a80417cbf49c95e3187 100644 (file)
@@ -1,3 +1,20 @@
+2009-09-11  Philippe De Muyter  <phdm@macqel.be>
+
+       * obcopy.c (copy_object): New parameter `input_arch', architecture
+       of input file, if not specified in input file itself; all callers
+       updated; `binary_architecture' hack removed.
+       (copy_archive, copy_file): New parameter `input_arch', for
+       `copy_object' usage.
+       (copy_main): Accept `-B' (`--binary-architecture') option also
+       for any arch-less input ifile format, not only `binary'; remove
+       bfd_external_binary_architecture hack; instead, add `input_arch'
+       to calls to `copy_file'.
+       * windres.c, windmc.c : Obsolete and useless external references
+       to `bfd_external_binary_architecture' or `bfd_external_machine'
+       removed.
+       * doc/binutils.texi: Mention that -B parameter can be used for any
+       input file type which does not have its own architecture.
+
 2009-09-10  Martin Thuresson  <martin@mtme.org>
 
        Update soruces to compile cleanly with -Wc++-compat:
index cc0154649865a83f2177498ab67a333c146d5f39..f67ad134abadc89cf5716266f60f7840be34e76a 100644 (file)
@@ -1134,9 +1134,9 @@ translation.  @xref{Target Selection}, for more information.
 
 @item -B @var{bfdarch}
 @itemx --binary-architecture=@var{bfdarch}
-Useful when transforming a raw binary input file into an object file.
-In this case the output architecture can be set to @var{bfdarch}. This
-option will be ignored if the input file has a known @var{bfdarch}. You
+Useful when transforming a architecture-less input file into an object file.
+In this case the output architecture can be set to @var{bfdarch}.  This
+option will be ignored if the input file has a known @var{bfdarch}.  You
 can access this binary data inside a program by referencing the special
 symbols that are created by the conversion process.  These symbols are
 called _binary_@var{objfile}_start, _binary_@var{objfile}_end and
index 2048827f8e17f21d9bdf06545466247f7b2b1fc2..9732b86fa8ca5436e310d1c124fb7daa04f0dbc6 100644 (file)
@@ -442,11 +442,6 @@ extern unsigned int Chunk;
    on by the --srec-forceS3 command line switch.  */
 extern bfd_boolean S3Forced;
 
-/* Defined in bfd/binary.c.  Used to set architecture and machine of input
-   binary files.  */
-extern enum bfd_architecture  bfd_external_binary_architecture;
-extern unsigned long          bfd_external_machine;
-
 /* Forward declarations.  */
 static void setup_section (bfd *, asection *, void *);
 static void setup_bfd_headers (bfd *, bfd *);
@@ -466,7 +461,7 @@ copy_usage (FILE *stream, int exit_status)
   fprintf (stream, _("\
   -I --input-target <bfdname>      Assume input file is in format <bfdname>\n\
   -O --output-target <bfdname>     Create an output file in format <bfdname>\n\
-  -B --binary-architecture <arch>  Set arch of output file, when input is binary\n\
+  -B --binary-architecture <arch>  Set output arch, when input is arch-less\n\
   -F --target <bfdname>            Set both input and output format to <bfdname>\n\
      --debugging                   Convert debugging information, if possible\n\
   -p --preserve-dates              Copy modified/access timestamps to the output\n\
@@ -1401,7 +1396,7 @@ copy_unknown_object (bfd *ibfd, bfd *obfd)
    Returns TRUE upon success, FALSE otherwise.  */
 
 static bfd_boolean
-copy_object (bfd *ibfd, bfd *obfd)
+copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 {
   bfd_vma start;
   long symcount;
@@ -1466,6 +1461,18 @@ copy_object (bfd *ibfd, bfd *obfd)
   /* Copy architecture of input file to output file.  */
   iarch = bfd_get_arch (ibfd);
   imach = bfd_get_mach (ibfd);
+  if (input_arch)
+    {
+      if (bfd_get_arch_info (ibfd) == NULL
+         || bfd_get_arch_info (ibfd)->arch == bfd_arch_unknown)
+       {
+         iarch = input_arch->arch;
+         imach = input_arch->mach;
+       }
+      else
+       non_fatal (_("Input file `%s' ignores binary architecture parameter."),
+                  bfd_get_archive_filename (ibfd));
+    }
   if (!bfd_set_arch_mach (obfd, iarch, imach)
       && (ibfd->target_defaulted
          || bfd_get_arch (ibfd) != bfd_get_arch (obfd)))
@@ -1956,7 +1963,8 @@ copy_object (bfd *ibfd, bfd *obfd)
 
 static void
 copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
-             bfd_boolean force_output_target)
+             bfd_boolean force_output_target,
+             const bfd_arch_info_type *input_arch)
 {
   struct name_list
     {
@@ -2050,7 +2058,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
              return;
            }
 
-         del = ! copy_object (this_element, output_bfd);
+         del = ! copy_object (this_element, output_bfd, input_arch);
 
          if (! del
              || bfd_get_arch (this_element) != bfd_arch_unknown)
@@ -2155,7 +2163,8 @@ set_long_section_mode (bfd *output_bfd, bfd *input_bfd, enum long_section_name_h
 
 static void
 copy_file (const char *input_filename, const char *output_filename,
-          const char *input_target,   const char *output_target)
+          const char *input_target,   const char *output_target,
+          const bfd_arch_info_type *input_arch)
 {
   bfd *ibfd;
   char **obj_matching;
@@ -2206,7 +2215,7 @@ copy_file (const char *input_filename, const char *output_filename,
       /* This is a no-op on non-Coff targets.  */
       set_long_section_mode (obfd, ibfd, long_section_names);
 
-      copy_archive (ibfd, obfd, output_target, force_output_target);
+      copy_archive (ibfd, obfd, output_target, force_output_target, input_arch);
     }
   else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching))
     {
@@ -2228,7 +2237,7 @@ copy_file (const char *input_filename, const char *output_filename,
       /* This is a no-op on non-Coff targets.  */
       set_long_section_mode (obfd, ibfd, long_section_names);
 
-      if (! copy_object (ibfd, obfd))
+      if (! copy_object (ibfd, obfd, input_arch))
        status = 1;
 
       if (!bfd_close (obfd))
@@ -3009,7 +3018,7 @@ strip_main (int argc, char *argv[])
        }
 
       status = 0;
-      copy_file (argv[i], tmpname, input_target, output_target);
+      copy_file (argv[i], tmpname, input_target, output_target, NULL);
       if (status == 0)
        {
          if (preserve_dates)
@@ -3144,7 +3153,6 @@ convert_efi_target (char *efi)
 static int
 copy_main (int argc, char *argv[])
 {
-  char * binary_architecture = NULL;
   char *input_filename = NULL;
   char *output_filename = NULL;
   char *tmpname;
@@ -3156,6 +3164,7 @@ copy_main (int argc, char *argv[])
   int c;
   struct section_list *p;
   struct stat statbuf;
+  const bfd_arch_info_type *input_arch = NULL;
 
   while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:N:s:O:d:F:L:G:R:SpgxXHhVvW:w",
                           copy_options, (int *) 0)) != EOF)
@@ -3169,7 +3178,9 @@ copy_main (int argc, char *argv[])
          break;
 
        case 'B':
-         binary_architecture = optarg;
+         input_arch = bfd_scan_arch (optarg);
+         if (input_arch == NULL)
+           fatal (_("architecture %s unknown"), optarg);
          break;
 
        case 'i':
@@ -3824,29 +3835,6 @@ copy_main (int argc, char *argv[])
       convert_efi_target (efi);
     }
 
-  if (binary_architecture != NULL)
-    {
-      if (input_target && strcmp (input_target, "binary") == 0)
-       {
-         const bfd_arch_info_type * temp_arch_info;
-
-         temp_arch_info = bfd_scan_arch (binary_architecture);
-
-         if (temp_arch_info != NULL)
-           {
-             bfd_external_binary_architecture = temp_arch_info->arch;
-             bfd_external_machine             = temp_arch_info->mach;
-           }
-         else
-           fatal (_("architecture %s unknown"), binary_architecture);
-       }
-      else
-       {
-         non_fatal (_("Warning: input target 'binary' required for binary architecture parameter."));
-         non_fatal (_(" Argument %s ignored"), binary_architecture);
-       }
-    }
-
   if (preserve_dates)
     if (stat (input_filename, & statbuf) < 0)
       fatal (_("warning: could not locate '%s'.  System error message: %s"),
@@ -3863,7 +3851,7 @@ copy_main (int argc, char *argv[])
     fatal (_("warning: could not create temporary file whilst copying '%s', (error: %s)"),
           input_filename, strerror (errno));
 
-  copy_file (input_filename, tmpname, input_target, output_target);
+  copy_file (input_filename, tmpname, input_target, output_target, input_arch);
   if (status == 0)
     {
       if (preserve_dates)
index c7aa8f8e4e9704b237e6655251cd0adc6173059c..d02bc865a27ce1a51fa589653bfd652936d18222 100644 (file)
@@ -1,5 +1,5 @@
 /* windmc.c -- a program to compile Windows message files.
-   Copyright 2007, 2008
+   Copyright 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written by Kai Tietz, Onevision.
 
@@ -51,11 +51,6 @@ typedef struct mc_msg_item
   struct bin_messagetable_item *res;
 } mc_msg_item;
 
-/* Defined in bfd/binary.c.  Used to set architecture and machine of input
-   binary files.  */
-extern enum bfd_architecture  bfd_external_binary_architecture;
-extern unsigned long          bfd_external_machine;
-
 int target_is_bigendian = 0;
 const char *def_target_arch;
 
index c3b1f50d7e407f65488c1bac4e144c5e6a106e8c..6fbe7b5a0868bde0b2b284e79e9683d1ccbb7fc0 100644 (file)
 #include "obstack.h"
 #include "windres.h"
 
-/* Defined in bfd/binary.c.  Used to set architecture and machine of input
-   binary files.  */
-extern enum bfd_architecture  bfd_external_binary_architecture;
-extern unsigned long          bfd_external_machine;
-
 /* Used by resrc.c at least.  */
 
 int verbose = 0;
This page took 0.041903 seconds and 4 git commands to generate.