summaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorDenis Orlov <denorl2009@gmail.com>2023-06-05 23:10:34 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2023-06-09 08:43:23 +0200
commitaa2e58df034ece049f714450ab9106a8a72bf429 (patch)
treea101a284aa30d57c83f1c070ad94a400684e7d3c /arch/mips
parentbda35cd5a22b24d291864d320fc360093378c46f (diff)
downloadbarebox-aa2e58df034ece049f714450ab9106a8a72bf429.tar.gz
barebox-aa2e58df034ece049f714450ab9106a8a72bf429.tar.xz
MIPS: reloc: fix relocation with CONFIG_64BIT enabled
Use CKSEG instead of KSEG, allowing it to compile on 64BIT configurations. Also make sure that we do not truncate target relocation address by writing it into a 32-bit wide variable. Signed-off-by: Denis Orlov <denorl2009@gmail.com> Reviewd-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230605202634.42175-4-denorl2009@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/lib/reloc.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/arch/mips/lib/reloc.c b/arch/mips/lib/reloc.c
index b084a88be7..3c845a9663 100644
--- a/arch/mips/lib/reloc.c
+++ b/arch/mips/lib/reloc.c
@@ -108,8 +108,7 @@ static void apply_reloc(unsigned int type, void *addr, long off)
void relocate_code(void *fdt, u32 fdt_size, u32 ram_size)
{
- unsigned long addr, length, bss_len;
- u32 relocaddr, new_stack;
+ unsigned long addr, length, bss_len, relocaddr, new_stack;
uint8_t *buf;
unsigned int type;
long off;
@@ -121,9 +120,9 @@ void relocate_code(void *fdt, u32 fdt_size, u32 ram_size)
length = __bss_stop - __image_start;
relocaddr = ALIGN_DOWN(ram_size - length, SZ_64K);
if (IS_ENABLED(CONFIG_MMU)) {
- relocaddr = KSEG0ADDR(relocaddr);
+ relocaddr = CKSEG0ADDR(relocaddr);
} else {
- relocaddr = KSEG1ADDR(relocaddr);
+ relocaddr = CKSEG1ADDR(relocaddr);
}
new_stack = relocaddr - MALLOC_SIZE - 16;