This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Byte-swapping S-record output in objcopy?
- From: Nigel Stephens <nigel at mips dot com>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: binutils <binutils at sources dot redhat dot com>
- Date: Thu, 22 Jan 2004 11:32:45 +0000
- Subject: Re: Byte-swapping S-record output in objcopy?
- Organization: MIPS Technologies
- References: <87wu7kjs7v.fsf@egil.codesourcery.com>
Zack Weinberg wrote:
One of CodeSourcery's customers has asked us for ideas about how to
handle a fairly peculiar situation, to wit: There are ARM embedded
systems where the initial boot (from ROM) is in big-endian mode, but
after everything comes up the operating system runs in little-endian
mode. To handle this properly, the ROM image needs to be generated
little-endian and then byte-swapped before the ROM is burnt.
The image is compiled to ELF, the ROM burner takes S-records, so one
obvious approach is to add a byte-swapping mode to objcopy -O srec. I
was wondering, first, whether there is already a way to do something
like that, and second, if there isn't, whether a patch to add such a
feature would be accepted.
But how big is the word that you're going to swap - 16, 32 or 64 bits?
Maybe --interleave could be reused for that purpose. But a more flexible
approach might be an argument which explicitly listed the order in which
bytes should be output, for example:
--select-bytes=0,1,2,3 normal byte order
--select-bytes=3,2,1,0 byte swap 32-bit word
--select-bytes=7,6,5,4,3,2,1,0 byte swap 64-bit word
--select-bytes=1,0 byte swap 16-bit words
--select-bytes=2,3,0,1 halfword swap 32-bit word
etc.
Nigel