From b401d07f8f9a7c015ea1ac907f93a880098539e0 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Mon, 3 May 2021 01:08:31 +0200 Subject: [PATCH] build: Work around GCC issue where -static-pie does not seem to work with -elf cross compilers --- stage23/Makefile | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/stage23/Makefile b/stage23/Makefile index 4124165d..5d82f335 100644 --- a/stage23/Makefile +++ b/stage23/Makefile @@ -71,6 +71,12 @@ ifeq ($(TARGET), bios) endif ifeq ($(TARGET), uefi) + INTERNAL_CFLAGS32 := \ + $(INTERNAL_CFLAGS) \ + -m32 \ + -march=i386 \ + -fpie + INTERNAL_CFLAGS += \ -m64 \ -march=x86-64 \ @@ -78,12 +84,6 @@ ifeq ($(TARGET), uefi) -I../gnu-efi/inc/x86_64 \ -fpie \ -mno-red-zone - - INTERNAL_CFLAGS32 := \ - $(INTERNAL_CFLAGS) \ - -m32 \ - -march=i386 \ - -fpie endif LDFLAGS = -O3 -g @@ -98,19 +98,23 @@ ifeq ($(TARGET), bios) INTERNAL_LDFLAGS += \ -m32 \ -march=i386 \ + -fno-pie \ -Wl,-melf_i386 \ -static \ - -no-pie \ - -fno-pie + -no-pie endif ifeq ($(TARGET), uefi) INTERNAL_LDFLAGS += \ -m64 \ -march=x86-64 \ + -fpie \ -Wl,-melf_x86_64 \ - -static-pie \ - -fpie + -Wl,-static \ + -Wl,-pie \ + -Wl,--no-dynamic-linker \ + -z text \ + -static-pie endif .PHONY: all clean builddir