[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260204124542.523567-5-daniel@thingy.jp>
Date: Wed, 4 Feb 2026 21:45:36 +0900
From: Daniel Palmer <daniel@...ngy.jp>
To: w@....eu,
linux@...ssschuh.net
Cc: linux-kernel@...r.kernel.org,
Daniel Palmer <daniel@...ngy.jp>
Subject: [RFC PATCH v2 04/10] tools/nolibc: m68k: Add relocation support
Add support for handling relocations on m68k.
This also changes the branch to _start_c to be relative.
This might break FLAT binaries so needs to be checked
and probably wrapped in some #ifdef .. magic.
Signed-off-by: Daniel Palmer <daniel@...ngy.jp>
---
tools/include/nolibc/arch-m68k.h | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/tools/include/nolibc/arch-m68k.h b/tools/include/nolibc/arch-m68k.h
index 2a4fbada5e79..e82ff48d3fb8 100644
--- a/tools/include/nolibc/arch-m68k.h
+++ b/tools/include/nolibc/arch-m68k.h
@@ -10,8 +10,16 @@
#ifndef _NOLIBC_ARCH_M68K_H
#define _NOLIBC_ARCH_M68K_H
+#include "elf.h"
+
+#ifdef R_68K_RELATIVE
+#define _NOLIBC_ARCH_HAS_RELOC
+#define _NOLIBC_ARCH_ELF32
+#endif
+
#include "compiler.h"
#include "crt.h"
+#include "reloc.h"
#define _NOLIBC_SYSCALL_CLOBBERLIST "memory"
@@ -129,12 +137,29 @@
})
#ifndef NOLIBC_NO_RUNTIME
+
+#ifdef NOLIBC_WANT_RELOC
+static __inline__ int __relocate_rela(unsigned long base, _nolibc_elf_rela *entry)
+{
+ switch (_nolibc_elf_r_type(entry->r_info)) {
+ case R_68K_RELATIVE:
+ __relocate_rela_relative(base, entry);
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+#endif /* NOLIBC_WANT_RELOC */
+
void _start(void);
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
{
__asm__ volatile (
"movel %sp, %sp@-\n"
- "jsr _start_c\n"
+ "lea _start_c(%pc), %a0\n"
+ "jsr (%a0)\n"
);
__nolibc_entrypoint_epilogue();
}
--
2.51.0
Powered by blists - more mailing lists