From 0c19acb575193ab7506d63aca338fc4b90e45605 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 18 Jul 2025 12:56:51 +0200 Subject: gcc: enable PIE output --- Containerfile | 3 +++ Makefile | 2 -- patches/gcc-15.1.0-x86_64-pc-elf/0001-no-red-zone.patch | 4 +++- scripts/0200-build-target-binutils.sh | 3 ++- scripts/0500-build-target-gcc.sh | 2 ++ 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Containerfile b/Containerfile index 6e03bad..e840311 100644 --- a/Containerfile +++ b/Containerfile @@ -6,6 +6,9 @@ ARG GDB_VERSION ARG NEWLIB_VERSION ARG TARGET +ADD ./patches /patches +ADD ./scripts /scripts + RUN /scripts/0000-prepare-os.sh RUN /scripts/0100-download.sh RUN /scripts/0200-build-target-binutils.sh diff --git a/Makefile b/Makefile index 606f83c..ab4095c 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,6 @@ all: podman pull docker.io/archlinux:latest podman build \ --volume $(mkfile_dir)downloads:/downloads \ - --volume $(mkfile_dir)scripts:/scripts \ - --volume $(mkfile_dir)patches:/patches \ --build-arg BINUTILS_VERSION=$(BINUTILS_VERSION) \ --build-arg GCC_VERSION=$(GCC_VERSION) \ --build-arg GDB_VERSION=$(GDB_VERSION) \ diff --git a/patches/gcc-15.1.0-x86_64-pc-elf/0001-no-red-zone.patch b/patches/gcc-15.1.0-x86_64-pc-elf/0001-no-red-zone.patch index 260102d..0c468a7 100644 --- a/patches/gcc-15.1.0-x86_64-pc-elf/0001-no-red-zone.patch +++ b/patches/gcc-15.1.0-x86_64-pc-elf/0001-no-red-zone.patch @@ -1,8 +1,10 @@ --- /dev/null +++ gcc/config/i386/t-x86_64-pc-elf -@@ -0,0 +1,2 @@ +@@ -0,0 +1,4 @@ +MULTILIB_OPTIONS += mno-red-zone ++MULTILIB_EXTRA_OPTS += mcmodel=large +MULTILIB_DIRNAMES += no-red-zone ++CRTSTUFF_T_CFLAGS = -mcmodel=large --- gcc/config.gcc 2024-08-01 10:17:14.000000000 +0200 +++ gcc/config.gcc 2024-09-16 14:03:02.049140896 +0200 @@ -1960,6 +1960,7 @@ diff --git a/scripts/0200-build-target-binutils.sh b/scripts/0200-build-target-binutils.sh index a739e9d..6afcc43 100755 --- a/scripts/0200-build-target-binutils.sh +++ b/scripts/0200-build-target-binutils.sh @@ -13,7 +13,8 @@ cd .build --disable-werror \ --enable-colored-disassembly \ --prefix=/opt/toolchain \ - --target=$TARGET + --target=$TARGET \ + --with-pic make -j$(nproc) diff --git a/scripts/0500-build-target-gcc.sh b/scripts/0500-build-target-gcc.sh index 3ef2f5e..e1ca9c7 100755 --- a/scripts/0500-build-target-gcc.sh +++ b/scripts/0500-build-target-gcc.sh @@ -13,7 +13,9 @@ PATH=/opt/bootstrap/bin:/opt/toolchain/bin:$PATH --disable-nls \ --disable-wchar_t \ --enable-cxx-flags=-fno-exceptions \ + --enable-default-pie \ --enable-languages=c,c++ \ + --enable-plugin \ --prefix=/opt/toolchain \ --target=$TARGET \ --with-newlib -- cgit v1.2.3