to be set when the input file type is binary.
+2001-03-12 Stefan Geuken <mail@stefan-geuken.de>
+
+ * binary.c (bfd_external_binary_architecture): Declare.
+ (binary_object_p): If bfd_external_binary_architecture is defined,
+ set the architecture to this string.
+
2001-03-11 Philip Blundell <philb@gnu.org>
* elf32-arm.h (elf32_arm_finish_dynamic_symbol): Don't make PLT
2001-03-11 Philip Blundell <philb@gnu.org>
* elf32-arm.h (elf32_arm_finish_dynamic_symbol): Don't make PLT
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
static int binary_sizeof_headers PARAMS ((bfd *, boolean));
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
static int binary_sizeof_headers PARAMS ((bfd *, boolean));
+/* Set by external programs - specifies the BFD architecture
+ to use when creating binary BFDs. */
+enum bfd_architecture bfd_external_binary_architecture = bfd_arch_unknown;
+
/* Create a binary object. Invoked via bfd_set_format. */
static boolean
/* Create a binary object. Invoked via bfd_set_format. */
static boolean
abfd->tdata.any = (PTR) sec;
abfd->tdata.any = (PTR) 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, 0));
+ }
+
+2001-03-12 Stefan Geuken <mail@stefan-geuken.de>
+
+ * NEWS: Document addition of -B switch to objcopy.
+ * binutils.texi: Document addition of -B switch to objcopy.
+ * objcopy.c: (copy_options): Add --binary-architecture.
+ (copy_usage): Document -B/--binary-architecture.
+ (copy_main): Support -B/--binary-architecture. Set
+ bfd_external_binary_architecture.
+
2001-03-11 Andreas Jaeger <aj@suse.de>
* readelf.c (guess_is_rela): Handle EM_S390_OLD.
2001-03-11 Andreas Jaeger <aj@suse.de>
* readelf.c (guess_is_rela): Handle EM_S390_OLD.
+* New command line switch to objcopy -B (or --binary-architecture) which sets
+ the archiceture of the output file to the given argument. This option only
+ makes sense, if the input target is binary. Otherwise it is ignored.
+ By Stefan Geuken.
+
* Support for PDP-11 by Lars Brinkhoff.
* Add support for ARM v5t and v5te architectures and Intel's XScale ARM
* Support for PDP-11 by Lars Brinkhoff.
* Add support for ARM v5t and v5te architectures and Intel's XScale ARM
objcopy [ -F @var{bfdname} | --target=@var{bfdname} ]
[ -I @var{bfdname} | --input-target=@var{bfdname} ]
[ -O @var{bfdname} | --output-target=@var{bfdname} ]
objcopy [ -F @var{bfdname} | --target=@var{bfdname} ]
[ -I @var{bfdname} | --input-target=@var{bfdname} ]
[ -O @var{bfdname} | --output-target=@var{bfdname} ]
+ [ -B @var{bfdarch} | --binary-architecture=@var{bfdarch} ]
[ -S | --strip-all ] [ -g | --strip-debug ]
[ -K @var{symbolname} | --keep-symbol=@var{symbolname} ]
[ -N @var{symbolname} | --strip-symbol=@var{symbolname} ]
[ -S | --strip-all ] [ -g | --strip-debug ]
[ -K @var{symbolname} | --keep-symbol=@var{symbolname} ]
[ -N @var{symbolname} | --strip-symbol=@var{symbolname} ]
file; i.e., simply transfer data from source to destination with no
translation. @xref{Target Selection}, for more information.
file; i.e., simply transfer data from source to destination with no
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
+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
+_binary_@var{objfile}_size. e.g. you can transform a picture file into
+an object file and then access it in your code using these symbols.
+
@item -j @var{sectionname}
@itemx --only-section=@var{sectionname}
Copy only the named section from the input file to the output file.
@item -j @var{sectionname}
@itemx --only-section=@var{sectionname}
Copy only the named section from the input file to the output file.
{"adjust-vma", required_argument, 0, OPTION_CHANGE_ADDRESSES},
{"adjust-section-vma", required_argument, 0, OPTION_CHANGE_SECTION_ADDRESS},
{"adjust-warnings", no_argument, 0, OPTION_CHANGE_WARNINGS},
{"adjust-vma", required_argument, 0, OPTION_CHANGE_ADDRESSES},
{"adjust-section-vma", required_argument, 0, OPTION_CHANGE_SECTION_ADDRESS},
{"adjust-warnings", no_argument, 0, OPTION_CHANGE_WARNINGS},
+ {"binary-architecture", required_argument, 0, 'B'},
{"byte", required_argument, 0, 'b'},
{"change-addresses", required_argument, 0, OPTION_CHANGE_ADDRESSES},
{"change-leading-char", no_argument, 0, OPTION_CHANGE_LEADING_CHAR},
{"byte", required_argument, 0, 'b'},
{"change-addresses", required_argument, 0, OPTION_CHANGE_ADDRESSES},
{"change-leading-char", no_argument, 0, OPTION_CHANGE_LEADING_CHAR},
on by the --srec-forceS3 command line switch. */
extern boolean S3Forced;
on by the --srec-forceS3 command line switch. */
extern boolean S3Forced;
+/* Defined in bfd/binary.c. Used to set architecture of input binary files. */
+extern enum bfd_architecture bfd_external_binary_architecture;
+
static void
copy_usage (stream, exit_status)
FILE *stream;
static void
copy_usage (stream, exit_status)
FILE *stream;
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\
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\
-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\
-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\
int argc;
char *argv[];
{
int argc;
char *argv[];
{
+ char * binary_architecture = NULL;
char *input_filename = NULL, *output_filename = NULL;
char *input_target = NULL, *output_target = NULL;
boolean show_version = false;
char *input_filename = NULL, *output_filename = NULL;
char *input_target = NULL, *output_target = NULL;
boolean show_version = false;
struct section_list *p;
struct stat statbuf;
struct section_list *p;
struct stat statbuf;
- while ((c = getopt_long (argc, argv, "b:i:I:j:K:N:s:O:d:F:L:R:SpgxXVvW:",
+ while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:N:s:O:d:F:L:R:SpgxXVvW:",
copy_options, (int *) 0)) != EOF)
{
switch (c)
copy_options, (int *) 0)) != EOF)
{
switch (c)
fatal (_("byte number must be non-negative"));
break;
fatal (_("byte number must be non-negative"));
break;
+ case 'B':
+ binary_architecture = optarg;
+ break;
+
case 'i':
interleave = atoi (optarg);
if (interleave < 1)
case 'i':
interleave = atoi (optarg);
if (interleave < 1)
if (output_target == (char *) NULL)
output_target = input_target;
if (output_target == (char *) NULL)
output_target = input_target;
+ if (binary_architecture != (char *) NULL)
- if (stat (input_filename, &statbuf) < 0)
- fatal (_("Cannot stat: %s: %s"), input_filename, strerror (errno));
+ 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;
+ 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 (_("Cannot stat: %s: %s"), input_filename, strerror (errno));
+
/* If there is no destination file then create a temp and rename
the result into the input. */
/* If there is no destination file then create a temp and rename
the result into the input. */