[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260131074440.732588-7-daniel@thingy.jp>
Date: Sat, 31 Jan 2026 16:44:37 +0900
From: Daniel Palmer <daniel@...ngy.jp>
To: linux@...ssschuh.net,
w@....eu
Cc: kees@...nel.org,
linux-kernel@...r.kernel.org,
Daniel Palmer <daniel@...ngy.jp>
Subject: [RFC PATCH 6/9] tools/nolibc: riscv: Add relocation support
Add relocation support for 32 and 64bit riscv.
Signed-off-by: Daniel Palmer <daniel@...ngy.jp>
---
tools/include/nolibc/arch-riscv.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h
index 1c00cacf57e1..76618d4c001d 100644
--- a/tools/include/nolibc/arch-riscv.h
+++ b/tools/include/nolibc/arch-riscv.h
@@ -7,6 +7,11 @@
#ifndef _NOLIBC_ARCH_RISCV_H
#define _NOLIBC_ARCH_RISCV_H
+#if __riscv_xlen == 32
+#define NOLIBC_ARCH_ELF32
+#endif
+#define NOLIBC_ARCH_HAS_RELOC
+
#include "compiler.h"
#include "crt.h"
@@ -140,6 +145,19 @@
})
#ifndef NOLIBC_NO_RUNTIME
+static int __relocate_rela(unsigned long base, elf_rela *entry)
+{
+ switch (elf_r_type(entry->r_info)) {
+ case R_RISCV_RELATIVE:
+ __relocate_rela_relative(base, entry);
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
/* startup code */
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
{
--
2.51.0
Powered by blists - more mailing lists