[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260131074440.732588-5-daniel@thingy.jp>
Date: Sat, 31 Jan 2026 16:44:35 +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 4/9] 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 | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/tools/include/nolibc/arch-m68k.h b/tools/include/nolibc/arch-m68k.h
index 2a4fbada5e79..39df399a1f12 100644
--- a/tools/include/nolibc/arch-m68k.h
+++ b/tools/include/nolibc/arch-m68k.h
@@ -10,8 +10,12 @@
#ifndef _NOLIBC_ARCH_M68K_H
#define _NOLIBC_ARCH_M68K_H
+#define NOLIBC_ARCH_HAS_RELOC
+#define NOLIBC_ARCH_ELF32
+
#include "compiler.h"
#include "crt.h"
+#include "elf.h"
#define _NOLIBC_SYSCALL_CLOBBERLIST "memory"
@@ -129,12 +133,26 @@
})
#ifndef NOLIBC_NO_RUNTIME
+static int __relocate_rela(unsigned long base, Elf32_Rela *entry)
+{
+ switch (ELF32_R_TYPE(entry->r_info)) {
+ case R_68K_RELATIVE:
+ __relocate_rela_relative(base, entry);
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
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