build: UEFI: Link using gcc rather than ld directly, and do not enable PIC
This commit is contained in:
parent
2bdd297c3d
commit
74ef5901a7
@ -14,7 +14,6 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
CC = $(TOOLCHAIN)-gcc
|
CC = $(TOOLCHAIN)-gcc
|
||||||
LD = $(TOOLCHAIN)-ld
|
|
||||||
OBJCOPY = $(TOOLCHAIN)-objcopy
|
OBJCOPY = $(TOOLCHAIN)-objcopy
|
||||||
OBJDUMP = $(TOOLCHAIN)-objdump
|
OBJDUMP = $(TOOLCHAIN)-objdump
|
||||||
READELF = $(TOOLCHAIN)-readelf
|
READELF = $(TOOLCHAIN)-readelf
|
||||||
@ -35,6 +34,7 @@ INTERNAL_CFLAGS := \
|
|||||||
-fno-stack-protector \
|
-fno-stack-protector \
|
||||||
-fno-omit-frame-pointer \
|
-fno-omit-frame-pointer \
|
||||||
-fno-lto \
|
-fno-lto \
|
||||||
|
-fno-pic \
|
||||||
-Wno-address-of-packed-member \
|
-Wno-address-of-packed-member \
|
||||||
-masm=intel \
|
-masm=intel \
|
||||||
-mgeneral-regs-only \
|
-mgeneral-regs-only \
|
||||||
@ -49,20 +49,21 @@ INTERNAL_CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(TARGET), bios)
|
ifeq ($(TARGET), bios)
|
||||||
INTERNAL_CFLAGS += \
|
INTERNAL_CFLAGS += \
|
||||||
-fno-pic
|
-fno-pie
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET), uefi)
|
ifeq ($(TARGET), uefi)
|
||||||
INTERNAL_CFLAGS += \
|
INTERNAL_CFLAGS += \
|
||||||
-I../gnu-efi/inc \
|
-I../gnu-efi/inc \
|
||||||
-I../gnu-efi/inc/x86_64 \
|
-I../gnu-efi/inc/x86_64 \
|
||||||
-fpic \
|
-fpie \
|
||||||
-mno-red-zone
|
-mno-red-zone
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS = -O3 -g
|
LDFLAGS = -O3 -g
|
||||||
|
|
||||||
INTERNAL_LDFLAGS := \
|
INTERNAL_LDFLAGS := \
|
||||||
|
-fno-pic \
|
||||||
-fno-lto \
|
-fno-lto \
|
||||||
-nostdlib \
|
-nostdlib \
|
||||||
-z max-page-size=0x1000
|
-z max-page-size=0x1000
|
||||||
@ -70,11 +71,21 @@ INTERNAL_LDFLAGS := \
|
|||||||
ifeq ($(TARGET), bios)
|
ifeq ($(TARGET), bios)
|
||||||
INTERNAL_LDFLAGS += \
|
INTERNAL_LDFLAGS += \
|
||||||
-static \
|
-static \
|
||||||
|
-no-pie \
|
||||||
-fno-pie \
|
-fno-pie \
|
||||||
-lgcc \
|
-lgcc \
|
||||||
-static-libgcc
|
-static-libgcc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET), uefi)
|
||||||
|
INTERNAL_LDFLAGS += \
|
||||||
|
-shared \
|
||||||
|
-Wl,-Bsymbolic \
|
||||||
|
-Wl,--noinhibit-exec \
|
||||||
|
-pie \
|
||||||
|
-fpie
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: all clean builddir
|
.PHONY: all clean builddir
|
||||||
|
|
||||||
C_FILES := $(shell find -L ./ -type f -name '*.c' | sort)
|
C_FILES := $(shell find -L ./ -type f -name '*.c' | sort)
|
||||||
@ -155,12 +166,12 @@ $(BUILDDIR)/BOOTX64.EFI: $(BUILDDIR)/limine_efi.elf
|
|||||||
$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc --target efi-app-x86_64 --subsystem=10 $< $@
|
$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc --target efi-app-x86_64 --subsystem=10 $< $@
|
||||||
|
|
||||||
$(BUILDDIR)/limine_efi.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
|
$(BUILDDIR)/limine_efi.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
|
||||||
$(LD) -shared -Bsymbolic \
|
$(CC) \
|
||||||
-T../gnu-efi/gnuefi/elf_x86_64_efi.lds \
|
-T../gnu-efi/gnuefi/elf_x86_64_efi.lds \
|
||||||
../gnu-efi/gnuefi/crt0-efi-x86_64.o \
|
../gnu-efi/gnuefi/crt0-efi-x86_64.o \
|
||||||
../gnu-efi/gnuefi/libgnuefi.a \
|
../gnu-efi/gnuefi/libgnuefi.a \
|
||||||
../gnu-efi/lib/x86_64/efi_stub.o \
|
../gnu-efi/lib/x86_64/efi_stub.o \
|
||||||
$^ -o $@
|
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user