[PATCH v2 05/21] riscv: define generic relocate_image
Sascha Hauer
s.hauer at pengutronix.de
Tue Jan 6 04:53:08 PST 2026
For use by the ELF loader in PBL to relocate barebox proper, export a
new relocate_image capable of relocating barebox and implement
relocate_to_current_adr() in terms of it.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/riscv/lib/reloc.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/arch/riscv/lib/reloc.c b/arch/riscv/lib/reloc.c
index 0c1ec8b4880227d16ab5e7b580244f1db2e967ec..18b13a7013cff4032c12b999470f265dbda13c51 100644
--- a/arch/riscv/lib/reloc.c
+++ b/arch/riscv/lib/reloc.c
@@ -30,26 +30,15 @@ void sync_caches_for_execution(void)
local_flush_icache_all();
}
-void relocate_to_current_adr(void)
+static void relocate_image(unsigned long offset,
+ void *dstart, void *dend,
+ long *dynsym, long *dynend)
{
- unsigned long offset;
- unsigned long *dynsym;
- void *dstart, *dend;
Elf_Rela *rela;
- /* Get offset between linked address and runtime address */
- offset = get_runtime_offset();
if (!offset)
return;
- /*
- * We have yet to relocate, so using runtime_address
- * to compute the relocated address
- */
- dstart = runtime_address(__rel_dyn_start);
- dend = runtime_address(__rel_dyn_end);
- dynsym = runtime_address(__dynsym_start);
-
for (rela = dstart; (void *)rela < dend; rela++) {
unsigned long *fixup;
@@ -74,5 +63,15 @@ void relocate_to_current_adr(void)
}
}
+}
+
+void relocate_to_current_adr(void)
+{
+ relocate_image(get_runtime_offset(),
+ runtime_address(__rel_dyn_start),
+ runtime_address(__rel_dyn_end),
+ runtime_address(__dynsym_start),
+ NULL);
+
sync_caches_for_execution();
}
--
2.47.3
More information about the barebox
mailing list