From 27ffa747f36aee9c1d5bbc61395a078238366070 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 11 May 2023 22:55:31 +0300 Subject: arbitrary load address and RAM base detection + Both kind of go hand in hand, made sense to do both at the same time. Some parts feel slightly hacky, the loader works by placing everything on the stack and avoiding global values. Still, seems to work? --- arch/riscv64/conf/init-link.S | 13 +++++++++---- arch/riscv64/conf/kmi.its | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'arch/riscv64/conf') diff --git a/arch/riscv64/conf/init-link.S b/arch/riscv64/conf/init-link.S index 600304f..0933fbb 100644 --- a/arch/riscv64/conf/init-link.S +++ b/arch/riscv64/conf/init-link.S @@ -5,11 +5,13 @@ OUTPUT_ARCH(riscv) ENTRY(_start) SECTIONS { - . = ABSOLUTE(PM_KERN_BASE); - __init_start = .; + /* slight hack, the binary is position independent code but technically + not a PIE, so avoid globals and just add the load address to external + addresses. */ + __init_start = 0; /* objcopy only copies these three sections (as far as I'm aware) into the - produces binary, so __init_end should point to the correct location in the + produced binary, so __init_end should point to the correct location in the final binary */ .text ALIGN(4K) : AT(0) { @@ -29,7 +31,10 @@ SECTIONS { *(.sbss*) *(.bss*) *(COMMON) } - __init_end = . ; + .top : { + *(.top*) + } + __kernel_size = ; .garbage : { diff --git a/arch/riscv64/conf/kmi.its b/arch/riscv64/conf/kmi.its index 0494030..768f98b 100644 --- a/arch/riscv64/conf/kmi.its +++ b/arch/riscv64/conf/kmi.its @@ -12,8 +12,8 @@ arch = "riscv"; os = "kmi"; compression = "none"; - load = <0x80240000>; - entry = <0x80240000>; + load = <0x80260000>; + entry = <0x80260000>; hash-1 { algo = "sha1"; }; -- cgit v1.3