sortix-mirror/ports/binutils/binutils.patch
2024-09-07 11:25:24 +02:00

446 lines
16 KiB
Diff

diff -Paur --no-dereference -- binutils.upstream/bfd/config.bfd binutils/bfd/config.bfd
--- binutils.upstream/bfd/config.bfd
+++ binutils/bfd/config.bfd
@@ -665,6 +665,11 @@
targ_selvecs=
targ64_selvecs=x86_64_elf64_vec
;;
+ i[3-7]86-*-sortix*)
+ targ_defvec=i386_elf32_sortix_vec
+ targ_selvecs="i386_elf32_vec"
+ targ64_selvecs="x86_64_elf64_sortix_vec x86_64_elf64_vec"
+ ;;
#ifdef BFD64
x86_64-*-cloudabi*)
targ_defvec=x86_64_elf64_cloudabi_vec
@@ -715,6 +720,11 @@
targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec"
want64=true
;;
+ x86_64-*-sortix*)
+ targ_defvec=x86_64_elf64_sortix_vec
+ targ_selvecs="x86_64_elf64_vec i386_elf32_sortix_vec i386_elf32_vec"
+ want64=true
+ ;;
x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin)
targ_defvec=x86_64_pe_vec
targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec pdb_vec"
diff -Paur --no-dereference -- binutils.upstream/bfd/configure binutils/bfd/configure
--- binutils.upstream/bfd/configure
+++ binutils/bfd/configure
@@ -15894,6 +15894,7 @@
i386_elf32_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
i386_elf32_fbsd_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
i386_elf32_sol2_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
+ i386_elf32_sortix_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
i386_elf32_vxworks_vec) tb="$tb elf32-i386.lo $elfxx_x86 elf32.lo $elf" ;;
i386_mach_o_vec) tb="$tb mach-o-i386.lo" ;;
i386_msdos_vec) tb="$tb i386msdos.lo" ;;
@@ -16079,6 +16080,7 @@
x86_64_elf64_cloudabi_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_elf64_fbsd_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_elf64_sol2_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
+ x86_64_elf64_sortix_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_mach_o_vec) tb="$tb mach-o-x86-64.lo" ;;
x86_64_pe_vec) tb="$tb pe-x86_64.lo pex64igen.lo $coff"; target_size=64 ;;
x86_64_pe_big_vec) tb="$tb pe-x86_64.lo pex64igen.lo $coff"; target_size=64 ;;
diff -Paur --no-dereference -- binutils.upstream/bfd/elf32-i386.c binutils/bfd/elf32-i386.c
--- binutils.upstream/bfd/elf32-i386.c
+++ binutils/bfd/elf32-i386.c
@@ -4529,6 +4529,21 @@
#undef elf_backend_init_file_header
+/* Sortix support. */
+
+#undef TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM i386_elf32_sortix_vec
+#undef TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME "elf32-i386-sortix"
+
+#undef ELF_OSABI
+#define ELF_OSABI ELFOSABI_SORTIX
+
+#undef elf32_bed
+#define elf32_bed elf32_i386_sortix_bed
+
+#include "elf32-target.h"
+
/* Solaris 2. */
#undef TARGET_LITTLE_SYM
diff -Paur --no-dereference -- binutils.upstream/bfd/elf64-x86-64.c binutils/bfd/elf64-x86-64.c
--- binutils.upstream/bfd/elf64-x86-64.c
+++ binutils/bfd/elf64-x86-64.c
@@ -5831,6 +5831,21 @@
#define elf64_bed elf64_x86_64_fbsd_bed
#include "elf64-target.h"
+
+/* Sortix support. */
+
+#undef TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM x86_64_elf64_sortix_vec
+#undef TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME "elf64-x86-64-sortix"
+
+#undef ELF_OSABI
+#define ELF_OSABI ELFOSABI_SORTIX
+
+#undef elf64_bed
+#define elf64_bed elf64_x86_64_sortix_bed
+
+#include "elf64-target.h"
/* Solaris 2 support. */
diff -Paur --no-dereference -- binutils.upstream/bfd/targets.c binutils/bfd/targets.c
--- binutils.upstream/bfd/targets.c
+++ binutils/bfd/targets.c
@@ -749,6 +749,7 @@
extern const bfd_target i386_coff_lynx_vec;
extern const bfd_target i386_elf32_vec;
extern const bfd_target i386_elf32_fbsd_vec;
+extern const bfd_target i386_elf32_sortix_vec;
extern const bfd_target i386_elf32_sol2_vec;
extern const bfd_target i386_elf32_vxworks_vec;
extern const bfd_target i386_mach_o_vec;
@@ -935,6 +936,7 @@
extern const bfd_target x86_64_elf64_vec;
extern const bfd_target x86_64_elf64_cloudabi_vec;
extern const bfd_target x86_64_elf64_fbsd_vec;
+extern const bfd_target x86_64_elf64_sortix_vec;
extern const bfd_target x86_64_elf64_sol2_vec;
extern const bfd_target x86_64_mach_o_vec;
extern const bfd_target x86_64_pe_vec;
diff -Paur --no-dereference -- binutils.upstream/binutils/elfedit.c binutils/binutils/elfedit.c
--- binutils.upstream/binutils/elfedit.c
+++ binutils/binutils/elfedit.c
@@ -831,7 +831,8 @@
{ ELFOSABI_OPENVMS, "OpenVMS" },
{ ELFOSABI_NSK, "NSK" },
{ ELFOSABI_AROS, "AROS" },
- { ELFOSABI_FENIXOS, "FenixOS" }
+ { ELFOSABI_FENIXOS, "FenixOS" },
+ { ELFOSABI_SORTIX, "Sortix" },
};
/* Return ELFOSABI_XXX for an OSABI string, OSABI. */
diff -Paur --no-dereference -- binutils.upstream/binutils/readelf.c binutils/binutils/readelf.c
--- binutils.upstream/binutils/readelf.c
+++ binutils/binutils/readelf.c
@@ -5224,6 +5224,7 @@
case ELFOSABI_CLOUDABI: return "Nuxi CloudABI";
case ELFOSABI_OPENVOS: return "Stratus Technologies OpenVOS";
case ELFOSABI_CUDA: return "CUDA";
+ case ELFOSABI_SORTIX: return "UNIX - Sortix";
default:
if (osabi >= 64)
switch (filedata->file_header.e_machine)
diff -Paur --no-dereference -- binutils.upstream/binutils/testsuite/gentestdlls.c binutils/binutils/testsuite/gentestdlls.c
--- binutils.upstream/binutils/testsuite/gentestdlls.c
+++ binutils/binutils/testsuite/gentestdlls.c
@@ -25,7 +25,6 @@
See:
https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-335.pdf */
-#include <memory.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff -Paur --no-dereference -- binutils.upstream/elfcpp/elfcpp.h binutils/elfcpp/elfcpp.h
--- binutils.upstream/elfcpp/elfcpp.h
+++ binutils/elfcpp/elfcpp.h
@@ -142,6 +142,7 @@
ELFOSABI_OPENVMS = 13,
ELFOSABI_NSK = 14,
ELFOSABI_AROS = 15,
+ ELFOSABI_SORTIX = 83,
// A GNU extension for the ARM.
ELFOSABI_ARM = 97,
// A GNU extension for the MSP.
diff -Paur --no-dereference -- binutils.upstream/gas/Makefile.in binutils/gas/Makefile.in
--- binutils.upstream/gas/Makefile.in
+++ binutils/gas/Makefile.in
@@ -849,6 +849,7 @@
config/te-pc532mach.h \
config/te-pe.h \
config/te-solaris.h \
+ config/te-sortix.h \
config/te-tmips.h \
config/te-vxworks.h \
config/te-wince-pe.h
diff -Paur --no-dereference -- binutils.upstream/gas/config/tc-i386.h binutils/gas/config/tc-i386.h
--- binutils.upstream/gas/config/tc-i386.h
+++ binutils/gas/config/tc-i386.h
@@ -68,6 +68,11 @@
#define ELF_TARGET_FORMAT64 "elf64-x86-64-sol2"
#endif
+#ifdef TE_Sortix
+#define ELF_TARGET_FORMAT "elf32-i386-sortix"
+#define ELF_TARGET_FORMAT64 "elf64-x86-64-sortix"
+#endif
+
#ifndef ELF_TARGET_FORMAT
#define ELF_TARGET_FORMAT "elf32-i386"
#endif
diff -Paur --no-dereference -- binutils.upstream/gas/config/te-sortix.h binutils/gas/config/te-sortix.h
--- binutils.upstream/gas/config/te-sortix.h
+++ binutils/gas/config/te-sortix.h
@@ -0,0 +1,30 @@
+/* te-sortix.h -- Sortix target environment declarations.
+ Copyright 2000, 2005, 2007 Free Software Foundation, Inc.
+
+ This file is part of GAS, the GNU Assembler.
+
+ GAS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GAS is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GAS; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+/* Target environment for Sortix. It is the same as the generic
+ target, except that it arranges via the TE_Sortix define to
+ suppress the use of "/" as a comment character. Some code in the
+ Sortix kernel uses "/" to mean division. (What a concept!) */
+#define TE_Sortix 1
+
+#define LOCAL_LABELS_DOLLAR 1
+#define LOCAL_LABELS_FB 1
+
+#include "obj-format.h"
diff -Paur --no-dereference -- binutils.upstream/gas/configure.tgt binutils/gas/configure.tgt
--- binutils.upstream/gas/configure.tgt
+++ binutils/gas/configure.tgt
@@ -244,6 +244,7 @@
i386-*-lynxos*) fmt=elf em=lynx ;;
i386-*-redox*) fmt=elf ;;
i386-*-solaris*) fmt=elf em=solaris ;;
+ i386-*-sortix*) fmt=elf em=sortix ;;
i386-*-freebsd* \
| i386-*-kfreebsd*-gnu) fmt=elf em=freebsd ;;
i386-*-msdosdjgpp* \
@@ -446,6 +447,7 @@
*-*-sim) fmt=coff ;;
*-*-elf | *-*-rtems* | *-*-sysv4*) fmt=elf ;;
*-*-solaris*) fmt=elf em=solaris ;;
+ *-*-sortix*) fmt=elf em=sortix ;;
*-*-aros*) fmt=elf em=linux ;;
*-*-vxworks* | *-*-windiss) fmt=elf em=vxworks ;;
esac
diff -Paur --no-dereference -- binutils.upstream/include/elf/common.h binutils/include/elf/common.h
--- binutils.upstream/include/elf/common.h
+++ binutils/include/elf/common.h
@@ -83,6 +83,7 @@
#define ELFOSABI_AMDGPU_PAL 65 /* AMD PAL Runtime */
#define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC */
#define ELFOSABI_AMDGPU_MESA3D 66 /* AMD Mesa3D Runtime */
+#define ELFOSABI_SORTIX 83 /* Sortix */
#define ELFOSABI_ARM 97 /* ARM */
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
diff -Paur --no-dereference -- binutils.upstream/ld/Makefile.in binutils/ld/Makefile.in
--- binutils.upstream/ld/Makefile.in
+++ binutils/ld/Makefile.in
@@ -793,6 +793,7 @@
eelf_i386_haiku.c \
eelf_i386_ldso.c \
eelf_i386_sol2.c \
+ eelf_i386_sortix.c \
eelf_i386_vxworks.c \
eelf_iamcu.c \
eelf_s390.c \
@@ -904,6 +905,7 @@
eaarch64pe.c \
earm64pe.c \
eelf32_x86_64.c \
+ eelf32_x86_64_sortix.c \
eelf32b4300.c \
eelf32bmip.c \
eelf32bmipn32.c \
@@ -975,6 +977,7 @@
eelf_x86_64_fbsd.c \
eelf_x86_64_haiku.c \
eelf_x86_64_sol2.c \
+ eelf_x86_64_sortix.c \
ehppa64linux.c \
ei386pep.c \
emmo.c
@@ -1361,6 +1364,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32_tic6x_linux_be.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32_tic6x_linux_le.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32_x86_64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32_x86_64_sortix.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32am33lin.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32b4300.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32bfin.Po@am__quote@
@@ -1483,6 +1487,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_ldso.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_sol2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_sortix.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_vxworks.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_iamcu.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_mipsel_haiku.Po@am__quote@
@@ -1492,6 +1497,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sol2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sortix.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eh8300elf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eh8300elf_linux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eh8300helf.Po@am__quote@
diff -Paur --no-dereference -- binutils.upstream/ld/configure.tgt binutils/ld/configure.tgt
--- binutils.upstream/ld/configure.tgt
+++ binutils/ld/configure.tgt
@@ -392,6 +392,9 @@
targ_extra_emuls="elf_i386"
targ_extra_libpath=$targ_extra_emuls
;;
+i[3-7]86-*-sortix*) targ_emul=elf_i386_sortix
+ targ_extra_emuls=elf_i386
+ ;;
i[3-7]86-*-netbsd* | \
i[3-7]86-*-netbsd*-gnu* | \
i[3-7]86-*-knetbsd*-gnu | \
@@ -1028,6 +1031,9 @@
targ_extra_libpath=$targ_extra_emuls
tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
;;
+x86_64-*-sortix*) targ_emul=elf_x86_64_sortix
+ targ_extra_emuls="elf_x86_64 elf32_x86_64_sortix elf32_x86_64 elf_i386_sortix elf_i386"
+ ;;
x86_64-*-netbsd* | x86_64-*-openbsd*)
targ_emul=elf_x86_64
targ_extra_emuls="elf_i386 elf_iamcu"
@@ -1159,6 +1165,10 @@
NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
;;
+*-*-sortix*)
+ NATIVE_LIB_DIRS='/lib /local/lib'
+ ;;
+
esac
case "${target}" in
diff -Paur --no-dereference -- binutils.upstream/ld/emulparams/elf32_x86_64_sortix.sh binutils/ld/emulparams/elf32_x86_64_sortix.sh
--- binutils.upstream/ld/emulparams/elf32_x86_64_sortix.sh
+++ binutils/ld/emulparams/elf32_x86_64_sortix.sh
@@ -0,0 +1,43 @@
+source_sh ${srcdir}/emulparams/plt_unwind.sh
+source_sh ${srcdir}/emulparams/extern_protected_data.sh
+source_sh ${srcdir}/emulparams/dynamic_undefined_weak.sh
+source_sh ${srcdir}/emulparams/reloc_overflow.sh
+source_sh ${srcdir}/emulparams/call_nop.sh
+source_sh ${srcdir}/emulparams/cet.sh
+source_sh ${srcdir}/emulparams/x86-report-relative.sh
+source_sh ${srcdir}/emulparams/x86-64-level.sh
+source_sh ${srcdir}/emulparams/x86-64-level-report.sh
+source_sh ${srcdir}/emulparams/x86-64-plt.sh
+source_sh ${srcdir}/emulparams/static.sh
+source_sh ${srcdir}/emulparams/dt-relr.sh
+SCRIPT_NAME=elf
+ELFSIZE=32
+OUTPUT_FORMAT="elf32-x86-64-sortix"
+NO_REL_RELOCS=yes
+TEXT_START_ADDR=0x400000
+MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
+COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
+ARCH="i386:x64-32"
+MACHINE=
+NOP=0x90909090
+TEMPLATE_NAME=elf
+EXTRA_EM_FILE="elf-x86"
+GENERATE_SHLIB_SCRIPT=no
+GENERATE_PIE_SCRIPT=no
+NO_SMALL_DATA=yes
+LARGE_SECTIONS=yes
+SEPARATE_GOTPLT=24
+IREL_IN_PLT=
+ENABLE_INITFINI_ARRAY=no
+# These sections are placed right after .plt section.
+OTHER_PLT_SECTIONS="
+.plt.got ${RELOCATING-0} : { *(.plt.got) }
+.plt.sec ${RELOCATING-0} : { *(.plt.sec) }
+"
+
+if [ "x${host}" = "x${target}" ]; then
+ case " $EMULATION_LIBPATH " in
+ *" ${EMULATION_NAME} "*)
+ NATIVE=yes
+ esac
+fi
diff -Paur --no-dereference -- binutils.upstream/ld/emulparams/elf_i386_sortix.sh binutils/ld/emulparams/elf_i386_sortix.sh
--- binutils.upstream/ld/emulparams/elf_i386_sortix.sh
+++ binutils/ld/emulparams/elf_i386_sortix.sh
@@ -0,0 +1,5 @@
+source_sh ${srcdir}/emulparams/elf_i386.sh
+OUTPUT_FORMAT="elf32-i386-sortix"
+GENERATE_SHLIB_SCRIPT=yes
+GENERATE_PIE_SCRIPT=yes
+ENABLE_INITFINI_ARRAY=no
diff -Paur --no-dereference -- binutils.upstream/ld/emulparams/elf_x86_64_sortix.sh binutils/ld/emulparams/elf_x86_64_sortix.sh
--- binutils.upstream/ld/emulparams/elf_x86_64_sortix.sh
+++ binutils/ld/emulparams/elf_x86_64_sortix.sh
@@ -0,0 +1,3 @@
+source_sh ${srcdir}/emulparams/elf_x86_64.sh
+OUTPUT_FORMAT="elf64-x86-64-sortix"
+ENABLE_INITFINI_ARRAY=no
diff -Paur --no-dereference -- binutils.upstream/libctf/ctf-create.c binutils/libctf/ctf-create.c
--- binutils.upstream/libctf/ctf-create.c
+++ binutils/libctf/ctf-create.c
@@ -18,7 +18,6 @@
<http://www.gnu.org/licenses/>. */
#include <ctf-impl.h>
-#include <sys/param.h>
#include <string.h>
#include <unistd.h>
diff -Paur --no-dereference -- binutils.upstream/libctf/ctf-impl.h binutils/libctf/ctf-impl.h
--- binutils.upstream/libctf/ctf-impl.h
+++ binutils/libctf/ctf-impl.h
@@ -22,7 +22,6 @@
#include "config.h"
#include <errno.h>
-#include <sys/param.h>
#include "ctf-decls.h"
#include <ctf-api.h>
#include "ctf-sha1.h"
diff -Paur --no-dereference -- binutils.upstream/libiberty/choose-temp.c binutils/libiberty/choose-temp.c
--- binutils.upstream/libiberty/choose-temp.c
+++ binutils/libiberty/choose-temp.c
@@ -68,7 +68,8 @@
strcpy (temp_filename, base);
strcpy (temp_filename + len, TEMP_FILE);
- if (mktemp (temp_filename) == 0)
+ if (mkdtemp (temp_filename) == 0)
abort ();
+ remove (temp_filename);
return temp_filename;
}
diff -Paur --no-dereference -- binutils.upstream/libiberty/vfork.c binutils/libiberty/vfork.c
--- binutils.upstream/libiberty/vfork.c
+++ binutils/libiberty/vfork.c
@@ -13,7 +13,7 @@
#include "ansidecl.h"
-extern int fork (void);
+#include <unistd.h>
int
vfork (void)