Every libbfd-based native tool (objdump, as, ld, ar, nm, ...) page faulted at startup: binutils 2.43 keeps BFD's error state in _Thread_local variables, and MontaukOS has no TLS runtime (no FS-base setup, no PT_TLS handling), so the %fs:0 access in bfd_init trapped at address 0. elfedit survived only because it does not link libbfd. Patch bfd/sysdep.h to define the TLS storage macro to empty under __montauk__ (binutils has no fallback of its own; ac_cv_tls=none does not even compile). Single-threaded tools lose nothing. Confirmed on the OS: objdump -S disassembles hello.elf in the terminal. Real TLS support (FS base + PT_TLS in the ELF loader) stays on the roadmap for the GCC/libstdc++ milestone. Co-Authored-By: Claude Fable 5 <[email protected]>
66 lines
2.0 KiB
Diff
66 lines
2.0 KiB
Diff
--- a/config.sub
|
|
+++ b/config.sub
|
|
@@ -1768,7 +1768,7 @@
|
|
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
|
|
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
|
|
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
|
|
- | fiwix* | mlibc* | cos* | mbr* | ironclad* )
|
|
+ | fiwix* | mlibc* | cos* | mbr* | ironclad* | montauk* )
|
|
;;
|
|
# This one is extra strict with allowed versions
|
|
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
|
|
--- a/bfd/config.bfd
|
|
+++ b/bfd/config.bfd
|
|
@@ -681,6 +681,11 @@
|
|
targ_selvecs="i386_elf32_vec iamcu_elf32_vec"
|
|
want64=true
|
|
;;
|
|
+ x86_64-*-montauk*)
|
|
+ targ_defvec=x86_64_elf64_vec
|
|
+ targ_selvecs=i386_elf32_vec
|
|
+ want64=true
|
|
+ ;;
|
|
x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia | x86_64-*-genode*)
|
|
targ_defvec=x86_64_elf64_vec
|
|
targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec"
|
|
--- a/gas/configure.tgt
|
|
+++ b/gas/configure.tgt
|
|
@@ -229,6 +229,7 @@
|
|
i386-*-beos*) fmt=elf ;;
|
|
i386-*-elfiamcu) fmt=elf arch=iamcu ;;
|
|
i386-*-elf*) fmt=elf ;;
|
|
+ i386-*-montauk*) fmt=elf ;;
|
|
i386-*-fuchsia*) fmt=elf ;;
|
|
i386-*-haiku*) fmt=elf em=haiku ;;
|
|
i386-*-genode*) fmt=elf ;;
|
|
--- a/ld/configure.tgt
|
|
+++ b/ld/configure.tgt
|
|
@@ -1036,6 +1036,9 @@
|
|
tdir_elf_i386=`echo ${targ_alias} | \
|
|
sed -e 's/x86_64/i386/' -e 's/aout//'`
|
|
;;
|
|
+x86_64-*-montauk*) targ_emul=elf_x86_64
|
|
+ targ_extra_emuls=elf_i386
|
|
+ ;;
|
|
x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia* | x86_64-*-genode*)
|
|
targ_emul=elf_x86_64
|
|
targ_extra_emuls="elf_i386 elf_iamcu elf32_x86_64"
|
|
--- a/bfd/sysdep.h
|
|
+++ b/bfd/sysdep.h
|
|
@@ -27,6 +27,15 @@
|
|
#endif
|
|
|
|
#include "config.h"
|
|
+
|
|
+/* MontaukOS provides no runtime TLS yet (no FS-base setup, no PT_TLS
|
|
+ handling in the ELF loader), so a _Thread_local access traps at
|
|
+ %fs:0. Degrade BFD's thread-local error state to plain globals;
|
|
+ the native tools are single-threaded. */
|
|
+#ifdef __montauk__
|
|
+#undef TLS
|
|
+#define TLS
|
|
+#endif
|
|
#include <stdio.h>
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|