Byte-swapping S-record output in objcopy?
Nigel Stephens
nigel@mips.com
Thu Jan 22 11:32:00 GMT 2004
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
More information about the Binutils
mailing list