summaryrefslogtreecommitdiff
path: root/arch/arc/lib/relocate.c
diff options
context:
space:
mode:
authorAlexey Brodkin <Alexey.Brodkin@synopsys.com>2014-02-18 11:10:58 (GMT)
committerTom Rini <trini@ti.com>2014-02-21 12:56:42 (GMT)
commit36ae5cd2a824597b4c53b045ac0f4c1e3b4eaf65 (patch)
tree4cf723eb12132ae449c6bbee84b48779aa90454d /arch/arc/lib/relocate.c
parentc42eb7f2c76ff5553380cb0bfbfb62903194cf0c (diff)
downloadu-boot-fsl-qoriq-36ae5cd2a824597b4c53b045ac0f4c1e3b4eaf65.tar.xz
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 <abrodkin@synopsys.com> Cc: Francois Bedard <fbedard@synopsys.com> Cc: Tom Rini <trini@ti.com> cc: Noam Camus <noamc@ezchip.com>
Diffstat (limited to 'arch/arc/lib/relocate.c')
-rw-r--r--arch/arc/lib/relocate.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/arc/lib/relocate.c b/arch/arc/lib/relocate.c
index 956aa14..2482bcd 100644
--- a/arch/arc/lib/relocate.c
+++ b/arch/arc/lib/relocate.c
@@ -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",