diff options
author | Nick Clifton <nickc@redhat.com> | 2006-02-28 16:09:01 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2006-02-28 16:09:01 +0000 |
commit | f9d4ad2a13ff24a5095d19a59784517b274c45dc (patch) | |
tree | 05b733b64cdfd1bc306ae97c00291dea9041fa56 /binutils | |
parent | 9f6f925e1e1a5aee784d0e04663e3c7a4dc76f55 (diff) | |
download | gdb-f9d4ad2a13ff24a5095d19a59784517b274c45dc.zip gdb-f9d4ad2a13ff24a5095d19a59784517b274c45dc.tar.gz gdb-f9d4ad2a13ff24a5095d19a59784517b274c45dc.tar.bz2 |
* objcopy.c (use_alt_mach_code): Change type to unsigned long.
(copy_object): If bfd_alt_mach_code fails emit a more helpful message
and if the target architecture is ELF use the alternative as replacement
value for the e_machine number.
(copy_main): Use strtoul to parse the number provided with the
--alt-mach-code switch.
* doc/binutils.texi (--alt-mach-code): Document that this switch can now
set the absolute e_machine value.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 11 | ||||
-rw-r--r-- | binutils/doc/binutils.texi | 4 | ||||
-rw-r--r-- | binutils/objcopy.c | 30 |
3 files changed, 35 insertions, 10 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 5fbcc4f..99e3569 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2006-02-28 Nick Clifton <nickc@redhat.com> + + * objcopy.c (use_alt_mach_code): Change type to unsigned long. + (copy_object): If bfd_alt_mach_code fails emit a more helpful + message and if the target architecture is ELF use the alternative + as replacement value for the e_machine number. + (copy_main): Use strtoul to parse the number provided with the + --alt-mach-code switch. + * doc/binutils.texi (--alt-mach-code): Document that this switch + can now set the absolute e_machine value. + 2006-02-27 Carlos O'Donell <carlos@codesourcery.com> * po/Make-in: Add html target. diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 828eb5d..aaa0951 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -1399,7 +1399,9 @@ If the output architecture has alternate machine codes, use the @var{index}th code instead of the default one. This is useful in case a machine is assigned an official code and the tool-chain adopts the new code, but other applications still depend on the original code -being used. +being used. For ELF based architectures if the @var{index} +alternative does not exist then the value is treated as an absolute +number to be stored in the e_machine field of the ELF header. @item --writable-text Mark the output text as writable. This option isn't meaningful for all diff --git a/binutils/objcopy.c b/binutils/objcopy.c index a9fb877..0e0cfaa 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -147,8 +147,8 @@ static bfd_byte gap_fill = 0; static bfd_boolean pad_to_set = FALSE; static bfd_vma pad_to; -/* Use alternate machine code? */ -static int use_alt_mach_code = 0; +/* Use alternative machine code? */ +static unsigned long use_alt_mach_code = 0; /* Output BFD flags user wants to set or clear */ static flagword bfd_flags_to_set; @@ -473,7 +473,7 @@ copy_usage (FILE *stream, int exit_status) --globalize-symbols <file> --globalize-symbol for all in <file>\n\ --keep-global-symbols <file> -G for all symbols listed in <file>\n\ --weaken-symbols <file> -W for all symbols listed in <file>\n\ - --alt-machine-code <index> Use alternate machine code for output\n\ + --alt-machine-code <index> Use the target's <index>'th alternative machine\n\ --writable-text Mark the output text as writable\n\ --readonly-text Make the output text write protected\n\ --pure Mark the output file as demand paged\n\ @@ -1667,9 +1667,21 @@ copy_object (bfd *ibfd, bfd *obfd) /* Switch to the alternate machine code. We have to do this at the very end, because we only initialize the header when we create the first section. */ - if (use_alt_mach_code != 0 - && ! bfd_alt_mach_code (obfd, use_alt_mach_code)) - non_fatal (_("unknown alternate machine code, ignored")); + if (use_alt_mach_code != 0) + { + if (! bfd_alt_mach_code (obfd, use_alt_mach_code)) + { + non_fatal (_("this target does not support %lu alternative machine codes"), + use_alt_mach_code); + if (bfd_get_flavour (obfd) == bfd_target_elf_flavour) + { + non_fatal (_("treating that number as an absolute e_machine value instead")); + elf_elfheader (obfd)->e_machine = use_alt_mach_code; + } + else + non_fatal (_("ignoring the alternative value")); + } + } return TRUE; } @@ -3069,9 +3081,9 @@ copy_main (int argc, char *argv[]) break; case OPTION_ALT_MACH_CODE: - use_alt_mach_code = atoi (optarg); - if (use_alt_mach_code <= 0) - fatal (_("alternate machine code index must be positive")); + use_alt_mach_code = strtoul (optarg, NULL, 0); + if (use_alt_mach_code == 0) + fatal (_("unable to parse alternative machine code")); break; case OPTION_PREFIX_SYMBOLS: |