From 9e48b4c6ec74817952f7a9b8c8b3d661ddf58c59 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 23 Apr 2007 10:59:07 +0000 Subject: * objcopy.c (reverse_bytes): New variable. (command_line_switch, copy_main): Add OPTION_REVERSE_ENDIAN. (copy_options, copy_usage): Add "reverse-bytes" entry. (copy_section): Reverse bytes within output sections. * doc/binutils.texi: Document new objcopy option. * testsuite/binutils-all/objcopy.exp: Add test for --reverse-bytes. --- binutils/doc/binutils.texi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'binutils/doc') diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 04fdcc6..ec18bc8 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -987,6 +987,7 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}] [@option{--add-section} @var{sectionname}=@var{filename}] [@option{--rename-section} @var{oldname}=@var{newname}[,@var{flags}]] [@option{--change-leading-char}] [@option{--remove-leading-char}] + [@option{--reverse-bytes=}@var{num}] [@option{--srec-len=}@var{ival}] [@option{--srec-forceS3}] [@option{--redefine-sym} @var{old}=@var{new}] [@option{--redefine-syms=}@var{filename}] @@ -1052,6 +1053,7 @@ Note---@command{objcopy} is not able to change the endianness of its input files. If the input format has an endianness (some formats do not), @command{objcopy} can only copy the inputs into file formats that have the same endianness or which have no endianness (e.g., @samp{srec}). +(However, see the @option{--reverse-bytes} option.) @c man end @@ -1342,6 +1344,30 @@ different conventions for symbol names. This is different from when appropriate, regardless of the object file format of the output file. +@item --reverse-bytes=@var{num} +Reverse the bytes in a section with output contents. A section length must +be evenly divisible by the value given in order for the swap to be able to +take place. Reversing takes place before the interleaving is performed. + +This option is used typically in generating ROM images for problematic +target systems. For example, on some target boards, the 32-bit words +fetched from 8-bit ROMs are re-assembled in little-endian byte order +regardless of the CPU byte order. Depending on the programming model, the +endianness of the ROM may need to be modified. + +Consider a simple file with a section containing the following eight +bytes: @code{12345678}. + +Using @samp{--reverse-bytes=2} for the above example, the bytes in the +output file would be ordered @code{21436587}. + +Using @samp{--reverse-bytes=4} for the above example, the bytes in the +output file would be ordered @code{43218765}. + +By using @samp{--reverse-bytes=2} for the above example, followed by +@samp{--reverse-bytes=4} on the output file, the bytes in the second +output file would be ordered @code{34127856}. + @item --srec-len=@var{ival} Meaningful only for srec output. Set the maximum length of the Srecords being produced to @var{ival}. This length covers both address, data and -- cgit v1.1