arc: fix relocation for big-endian target
PATCH 1/1 arc: fix relocation for big-endian target
In case of little-endian ARC700 instructions (which may include target address) are encoded as middle-endian. That's why it's required to swap bytes after read and ten right before write back.
But in case of big-endian ARC700 instructions are encoded as a plain big-endian. Thus no need for byte swapping.
Signed-off-by Alexey Brodkin <[email protected]>
Cc Francois Bedard <[email protected]>
Cc Tom Rini <[email protected]>
cc Noam Camus <[email protected]>
--- arch/arc/lib/relocate.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arc/lib/relocate.c +4 -0
@@ -41,19 +41,23 @@ int do_elf_reloc_fixups(void)*/ memcpy (&val, offset_ptr_ram,sizeof (int )); +#ifdef __LITTLE_ENDIAN__/* If location in ".text" section swap value */ if ((unsigned int )offset_ptr_rom < (unsigned int )&__text_end) val = (val <<16 ) | (val >>16 ); +#endif /* Check that the target points into .text */ if (val >=CONFIG_SYS_TEXT_BASE && val <= (unsigned int )&__bss_end) { val += gd->reloc_off; +#ifdef __LITTLE_ENDIAN__/* If location in ".text" section swap value */ if ((unsigned int )offset_ptr_rom < (unsigned int )&__text_end) val = (val <<16 ) | (val >>16 ); +#endif memcpy (offset_ptr_ram, &val,sizeof (int )); }else { debug(" %p: rom reloc %x, ram %p, value %x, limit %x\n",
Signature · 1 line
1.8.5.3
Quoted 4 lines · Alexey Brodkin
In case of little-endian ARC700 instructions (which may include target address) are encoded as middle-endian. That's why it's required to swap bytes after read and ten right before write back.
Quoted 8 lines
But in case of big-endian ARC700 instructions are encoded as a plain big-endian. Thus no need for byte swapping.
Signed-off-by Alexey Brodkin <[email protected]>Cc Francois Bedard <[email protected]>Cc Tom Rini <[email protected]>cc Noam Camus <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140221/a61523b8/attachment.pgp>