Byte-swapping S-record output in objcopy?

Ian Lance Taylor
Thu Jan 22 08:40:00 GMT 2004

"Zack Weinberg" <> writes:

> 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.  

It seems to me that you would need to compile/assemble the ROM in
big-endian mode, and the rest in little-endian mode.  Is simple byte
swapping enough?  Maybe it is if the ROM is all assembly code.

> 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.

I don't think there is a feature like that now.  It would be pretty
simple to write a program to byte-swap S-records.  You could almost do
it in sed.  But I suppose another objcopy argument would be OK too.


More information about the Binutils mailing list