Toolchain: Add support for building shared libraries

This commit is contained in:
Bananymous 2024-08-27 17:36:09 +03:00
parent 5121d0d934
commit 68f9dc1f8a
3 changed files with 214 additions and 6123 deletions

View File

@ -1,20 +1,7 @@
From 0c0f7c2421aa650b11ae3914200c4be153718ca8 Mon Sep 17 00:00:00 2001
From: Bananymous <bananymousosq@gmail.com>
Date: Sun, 29 Oct 2023 17:39:44 +0200
Subject: [PATCH] Add target banan_os for i386 and x86_64
---
bfd/config.bfd | 10 ++++++++++
config.sub | 2 +-
gas/configure.tgt | 1 +
ld/configure.tgt | 6 ++++++
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/bfd/config.bfd b/bfd/config.bfd
index a4c6c8e885..1f083e596f 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -602,6 +602,11 @@ case "${targ}" in
diff -ruN binutils-2.39/bfd/config.bfd binutils-2.39-banan_os/bfd/config.bfd
--- binutils-2.39/bfd/config.bfd 2022-07-08 12:46:47.000000000 +0300
+++ binutils-2.39-banan_os/bfd/config.bfd 2024-08-26 15:25:08.612615228 +0300
@@ -602,6 +602,11 @@
targ_defvec=i386_elf32_vec
targ_selvecs=iamcu_elf32_vec
;;
@ -26,7 +13,7 @@ index a4c6c8e885..1f083e596f 100644
i[3-7]86-*-dicos*)
targ_defvec=i386_elf32_vec
targ_selvecs=iamcu_elf32_vec
@@ -656,6 +661,11 @@ case "${targ}" in
@@ -656,6 +661,11 @@
targ64_selvecs=x86_64_elf64_vec
;;
#ifdef BFD64
@ -38,11 +25,10 @@ index a4c6c8e885..1f083e596f 100644
x86_64-*-cloudabi*)
targ_defvec=x86_64_elf64_cloudabi_vec
want64=true
diff --git a/config.sub b/config.sub
index dba16e84c7..9a37bb30fd 100755
--- a/config.sub
+++ b/config.sub
@@ -1754,7 +1754,7 @@ case $os in
diff -ruN binutils-2.39/config.sub binutils-2.39-banan_os/config.sub
--- binutils-2.39/config.sub 2022-07-08 12:46:47.000000000 +0300
+++ binutils-2.39-banan_os/config.sub 2024-08-26 16:01:54.868646232 +0300
@@ -1754,7 +1754,7 @@
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
@ -51,11 +37,10 @@ index dba16e84c7..9a37bb30fd 100755
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 62f806bdfe..e05db38382 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -221,6 +221,7 @@ case ${generic_target} in
diff -ruN binutils-2.39/gas/configure.tgt binutils-2.39-banan_os/gas/configure.tgt
--- binutils-2.39/gas/configure.tgt 2022-07-08 12:46:47.000000000 +0300
+++ binutils-2.39-banan_os/gas/configure.tgt 2024-08-26 15:29:24.317178187 +0300
@@ -221,6 +221,7 @@
h8300-*-elf) fmt=elf ;;
h8300-*-linux*) fmt=elf em=linux ;;
@ -63,30 +48,98 @@ index 62f806bdfe..e05db38382 100644
i386-*-beospe*) fmt=coff em=pe ;;
i386-*-beos*) fmt=elf ;;
i386-*-elfiamcu) fmt=elf arch=iamcu ;;
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 2bae9099b6..640426e81f 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -352,6 +352,9 @@ i[3-7]86-*-aros*) targ_emul=elf_i386
diff -ruN binutils-2.39/ld/configure.tgt binutils-2.39-banan_os/ld/configure.tgt
--- binutils-2.39/ld/configure.tgt 2022-07-29 10:37:48.000000000 +0300
+++ binutils-2.39-banan_os/ld/configure.tgt 2024-08-26 15:43:54.040175458 +0300
@@ -352,6 +352,10 @@
i[3-7]86-*-rdos*) targ_emul=elf_i386
targ_extra_emuls=elf_iamcu
;;
+i[3-7]86-*-banan_os*) targ_emul=elf_i386
+ targ64_extra_emuls=elf_x86_64
+i[3-7]86-*-banan_os*) targ_emul=elf_i386_banan_os
+ targ_extra_emuls=elf_i386
+ targ64_extra_emuls="elf_x86_64_banan_os elf_x86_64"
+ ;;
i[3-7]86-*-bsd) targ_emul=i386bsd
targ_extra_ofiles=
;;
@@ -988,6 +991,9 @@ visium-*-elf) targ_emul=elf32visium
@@ -988,6 +992,9 @@
;;
x86_64-*-rdos*) targ_emul=elf64rdos
;;
+x86_64-*-banan_os*) targ_emul=elf_x86_64
+ targ_extra_emuls=elf_i386
+x86_64-*-banan_os*) targ_emul=elf_x86_64_banan_os
+ targ_extra_emuls="elf_i386_banan_os elf_x86_64 elf_i386"
+ ;;
x86_64-*-cloudabi*) targ_emul=elf_x86_64_cloudabi
;;
x86_64-*-haiku*) targ_emul=elf_x86_64_haiku
--
2.42.0
diff -ruN binutils-2.39/ld/emulparams/elf_banan_os.sh binutils-2.39-banan_os/ld/emulparams/elf_banan_os.sh
--- binutils-2.39/ld/emulparams/elf_banan_os.sh 1970-01-01 02:00:00.000000000 +0200
+++ binutils-2.39-banan_os/ld/emulparams/elf_banan_os.sh 2024-08-26 15:51:32.242246455 +0300
@@ -0,0 +1 @@
+ELF_INTERPRETER_NAME=\"/usr/lib/DynamicLoader.so\"
diff -ruN binutils-2.39/ld/emulparams/elf_i386_banan_os.sh binutils-2.39-banan_os/ld/emulparams/elf_i386_banan_os.sh
--- binutils-2.39/ld/emulparams/elf_i386_banan_os.sh 1970-01-01 02:00:00.000000000 +0200
+++ binutils-2.39-banan_os/ld/emulparams/elf_i386_banan_os.sh 2024-08-26 15:51:26.431570961 +0300
@@ -0,0 +1,2 @@
+source_sh ${srcdir}/emulparams/elf_i386.sh
+source_sh ${srcdir}/emulparams/elf_banan_os.sh
diff -ruN binutils-2.39/ld/emulparams/elf_x86_64_banan_os.sh binutils-2.39-banan_os/ld/emulparams/elf_x86_64_banan_os.sh
--- binutils-2.39/ld/emulparams/elf_x86_64_banan_os.sh 1970-01-01 02:00:00.000000000 +0200
+++ binutils-2.39-banan_os/ld/emulparams/elf_x86_64_banan_os.sh 2024-08-26 15:51:21.591003274 +0300
@@ -0,0 +1,2 @@
+source_sh ${srcdir}/emulparams/elf_x86_64.sh
+source_sh ${srcdir}/emulparams/elf_banan_os.sh
diff -ruN binutils-2.39/ld/Makefile.am binutils-2.39-banan_os/ld/Makefile.am
--- binutils-2.39/ld/Makefile.am 2022-07-08 12:46:48.000000000 +0300
+++ binutils-2.39-banan_os/ld/Makefile.am 2024-08-26 15:46:27.818947949 +0300
@@ -275,6 +275,7 @@
eelf32xtensa.c \
eelf32z80.c \
eelf_i386.c \
+ eelf_i386_banan_os.c \
eelf_i386_be.c \
eelf_i386_fbsd.c \
eelf_i386_haiku.c \
@@ -453,6 +454,7 @@
eelf64tilegx_be.c \
eelf_mipsel_haiku.c \
eelf_x86_64.c \
+ eelf_x86_64_banan_os.c \
eelf_x86_64_cloudabi.c \
eelf_x86_64_fbsd.c \
eelf_x86_64_haiku.c \
diff -ruN binutils-2.39/ld/Makefile.in binutils-2.39-banan_os/ld/Makefile.in
--- binutils-2.39/ld/Makefile.in 2022-08-05 12:56:53.000000000 +0300
+++ binutils-2.39-banan_os/ld/Makefile.in 2024-08-26 15:52:12.046704200 +0300
@@ -772,6 +772,7 @@
eelf32xtensa.c \
eelf32z80.c \
eelf_i386.c \
+ eelf_i386_banan_os.c \
eelf_i386_be.c \
eelf_i386_fbsd.c \
eelf_i386_haiku.c \
@@ -949,6 +950,7 @@
eelf64tilegx_be.c \
eelf_mipsel_haiku.c \
eelf_x86_64.c \
+ eelf_x86_64_banan_os.c \
eelf_x86_64_cloudabi.c \
eelf_x86_64_fbsd.c \
eelf_x86_64_haiku.c \
@@ -1441,6 +1443,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64tilegx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64tilegx_be.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_banan_os.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_be.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_fbsd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_haiku.Po@am__quote@
@@ -1451,6 +1454,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_mipsel_haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_s390.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_banan_os.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Po@am__quote@
@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@

View File

@ -79,10 +79,11 @@ build_binutils () {
cd $BANAN_BUILD_DIR/toolchain
if [ ! -d $BINUTILS_VERSION ]; then
wget $BINUTILS_URL
if [ ! -f $BINUTILS_TAR ]; then
wget $BINUTILS_URL
fi
tar xf $BINUTILS_TAR
cd $BINUTILS_VERSION
patch -s -p1 < $BANAN_TOOLCHAIN_DIR/$BINUTILS_VERSION.patch
patch -ruN -p1 -d "$BINUTILS_VERSION" < "$BANAN_TOOLCHAIN_DIR/$BINUTILS_VERSION.patch"
fi
cd $BANAN_BUILD_DIR/toolchain/$BINUTILS_VERSION
@ -93,6 +94,8 @@ build_binutils () {
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
--with-sysroot="$BANAN_SYSROOT" \
--enable-initfini-array \
--enable-shared \
--enable-lto \
--disable-nls \
--disable-werror
@ -106,10 +109,11 @@ build_gcc () {
cd $BANAN_BUILD_DIR/toolchain
if [ ! -d $GCC_VERSION ]; then
wget $GCC_URL
if [ ! -f $GCC_TAR ]; then
wget $GCC_URL
fi
tar xf $GCC_TAR
cd $GCC_VERSION
patch -s -p1 < $BANAN_TOOLCHAIN_DIR/$GCC_VERSION.patch
patch -ruN -p1 -d "$GCC_VERSION" < "$BANAN_TOOLCHAIN_DIR/$GCC_VERSION.patch"
fi
cd $BANAN_BUILD_DIR/toolchain/$GCC_VERSION
@ -120,6 +124,8 @@ build_gcc () {
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
--with-sysroot="$BANAN_SYSROOT" \
--enable-initfini-array \
--enable-shared \
--enable-lto \
--disable-nls \
--enable-languages=c,c++

File diff suppressed because it is too large Load Diff