lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260204124542.523567-6-daniel@thingy.jp>
Date: Wed,  4 Feb 2026 21:45:37 +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 05/10] tools/nolibc: x86: Add relocation support

Add relocation support for x86, both 32bit and 64bit (including x32).

Signed-off-by: Daniel Palmer <daniel@...ngy.jp>
---
 tools/include/nolibc/arch-x86.h | 53 +++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/tools/include/nolibc/arch-x86.h b/tools/include/nolibc/arch-x86.h
index f6c43ac5377b..263734c56537 100644
--- a/tools/include/nolibc/arch-x86.h
+++ b/tools/include/nolibc/arch-x86.h
@@ -7,8 +7,29 @@
 #ifndef _NOLIBC_ARCH_X86_H
 #define _NOLIBC_ARCH_X86_H
 
+#include "elf.h"
+
+/* x86_64 and x32 */
+#if defined(__x86_64__)
+#if defined(R_AMD64_RELATIVE)
+#define _NOLIBC_ARCH_HAS_RELOC
+#endif
+/* x32 uses ELF32 */
+#if defined(__ILP32__)
+#define _NOLIBC_ARCH_ELF32
+#endif
+/* i386 */
+#else
+#if defined(R_386_RELATIVE)
+#define _NOLIBC_ARCH_HAS_RELOC
+#define _NOLIBC_ARCH_ELF32
+#define _NOLIBC_ARCH_ELF_REL
+#endif
+#endif
+
 #include "compiler.h"
 #include "crt.h"
+#include "reloc.h"
 
 #if !defined(__x86_64__)
 
@@ -158,6 +179,22 @@
 })
 
 #ifndef NOLIBC_NO_RUNTIME
+
+#ifdef NOLIBC_WANT_RELOC
+static __inline__ int __relocate_rel(unsigned long base, _nolibc_elf_rel *entry)
+{
+	switch (_nolibc_elf_r_type(entry->r_info)) {
+	case R_386_RELATIVE:
+		__relocate_rel_relative(base, entry);
+		break;
+	default:
+		return -1;
+	}
+
+	return 0;
+}
+#endif /* NOLIBC_WANT_RELOC */
+
 /* startup code */
 /*
  * i386 System V ABI mandates:
@@ -326,6 +363,22 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
 })
 
 #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_AMD64_RELATIVE:
+		__relocate_rela_relative(base, entry);
+		break;
+	default:
+		return -1;
+	}
+
+	return 0;
+}
+#endif /* NOLIBC_WANT_RELOC */
+
 /* startup code */
 /*
  * x86-64 System V ABI mandates:
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ