shithub: newlib

ref: 536cef2b2ad9ba00df99f38b8eee764297562799
dir: /patches/binutils/jinx-working-patch.patch/

View raw version
diff --git binutils-clean/bfd/config.bfd binutils-workdir/bfd/config.bfd
index bbf1244..0a996e6 100644
--- binutils-clean/bfd/config.bfd
+++ binutils-workdir/bfd/config.bfd
@@ -735,6 +735,10 @@ case "${targ}" in
     targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec"
     want64=true
     ;;
+  x86_64-*-plan9*)
+    targ_defvec=x86_64_elf64_vec
+    want64=true
+    ;;
 #endif
   i[3-7]86-*-lynxos*)
     targ_defvec=i386_elf32_vec
diff --git binutils-clean/gas/configure.tgt binutils-workdir/gas/configure.tgt
index 7c66734..ce65a06 100644
--- binutils-clean/gas/configure.tgt
+++ binutils-workdir/gas/configure.tgt
@@ -231,6 +231,7 @@ case ${generic_target} in
   i386-*-elf*)				fmt=elf ;;
   i386-*-fuchsia*)			fmt=elf ;;
   i386-*-haiku*)			fmt=elf em=haiku ;;
+  i386-*-plan9*)			fmt=elf ;;
   i386-*-genode*)			fmt=elf ;;
   i386-*-bsd*)				fmt=aout em=386bsd ;;
   i386-*-netbsd*-gnu* | \
diff --git binutils-clean/gprofng/libcollector/configure.ac binutils-workdir/gprofng/libcollector/configure.ac
index b0ef678..c1f54fe 100644
--- binutils-clean/gprofng/libcollector/configure.ac
+++ binutils-workdir/gprofng/libcollector/configure.ac
@@ -18,7 +18,6 @@ dnl <http://www.gnu.org/licenses/>.
 
 m4_include([../../bfd/version.m4])
 AC_INIT([gprofng], BFD_VERSION)
-AC_CONFIG_MACRO_DIRS([../../config ../..])
 AC_CONFIG_AUX_DIR(../..)
 AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE
diff --git binutils-clean/ld/Makefile.am binutils-workdir/ld/Makefile.am
index f9ee05b..85e681e 100644
--- binutils-clean/ld/Makefile.am
+++ binutils-workdir/ld/Makefile.am
@@ -463,6 +463,7 @@ ALL_64_EMULATION_SOURCES = \
 	eelf_x86_64.c \
 	eelf_x86_64_cloudabi.c \
 	eelf_x86_64_fbsd.c \
+	eelf_x86_64_plan9.c \
 	eelf_x86_64_haiku.c \
 	eelf_x86_64_sol2.c \
 	ehppa64linux.c \
diff --git binutils-clean/ld/configure.tgt binutils-workdir/ld/configure.tgt
index f937f78..50e27ff 100644
--- binutils-clean/ld/configure.tgt
+++ binutils-workdir/ld/configure.tgt
@@ -1023,6 +1023,8 @@ x86_64-*-linux-*)	targ_emul=elf_x86_64
 x86_64-*-redox*)	targ_emul=elf_x86_64
 			targ_extra_emuls=elf_i386
 			;;
+x86_64-*-plan9*)	targ_emul=elf_x86_64_plan9
+			;;
 x86_64-*-solaris2*)	targ_emul=elf_x86_64_sol2
 			targ_extra_emuls="elf_x86_64 elf_i386_sol2 elf_i386_ldso elf_i386 elf_iamcu"
 			targ_extra_libpath=$targ_extra_emuls
diff --git binutils-workdir/ld/emulparams/elf_x86_64_plan9.sh binutils-workdir/ld/emulparams/elf_x86_64_plan9.sh
new file mode 100644
index 0000000..2948b21
--- /dev/null
+++ binutils-workdir/ld/emulparams/elf_x86_64_plan9.sh
@@ -0,0 +1,8 @@
+source_sh ${srcdir}/emulparams/elf_x86_64.sh
+SCRIPT_NAME=plan9
+TEXT_START_ADDR=0x200000
+DATA_ADDR="ALIGN (0x200000)"
+GENERATE_RELRO_SCRIPT=
+GENERATE_COMBRELOC_SCRIPT=
+GENERATE_SHLIB_SCRIPT=
+GENERATE_PIE_SCRIPT=
diff --git binutils-workdir/ld/scripttempl/plan9.sc binutils-workdir/ld/scripttempl/plan9.sc
new file mode 100644
index 0000000..15bd83a
--- /dev/null
+++ binutils-workdir/ld/scripttempl/plan9.sc
@@ -0,0 +1,49 @@
+# Copyright (C) 2024 Plan 9 Foundation.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+cat <<EOF
+/* Copyright (C) 2024 Plan 9 Foundation.
+
+   Copying and distribution of this script, with or without modification,
+   are permitted in any medium without royalty provided the copyright
+   notice and this notice are preserved.  */
+
+OUTPUT_FORMAT("${OUTPUT_FORMAT}")
+OUTPUT_ARCH(${ARCH})
+
+PHDRS
+{
+  text  PT_LOAD FILEHDR PHDRS;
+  data  PT_LOAD;
+}
+
+SECTIONS
+{
+  . = ${TEXT_START_ADDR} + SIZEOF_HEADERS;
+
+  .text : {
+    *(.text*)
+    *(.init*)
+    *(.fini*)
+  } :text
+
+  . = ${DATA_ADDR};
+
+  .data : {
+    *(.data*)
+    *(.ctors*)
+    *(.dtors*)
+    *(.rodata*)
+    *(.eh_frame*)
+  } :data
+
+  .bss : {
+    *(.bss*)
+  } :data
+
+  end = .;
+}
+EOF