diff --git a/Make.defaults b/Make.defaults index 278c80c..e33316b 100755 --- a/Make.defaults +++ b/Make.defaults @@ -192,8 +192,6 @@ GCCMACHINE := $(shell $(CC) -dumpmachine) IS_MINGW32 := $(findstring mingw32, $(GCCMACHINE)) ifeq ($(IS_MINGW32),) CFLAGS += -fPIE -else - CFLAGS += -DGNU_EFI_USE_MS_ABI endif ifeq (FreeBSD, $(findstring FreeBSD, $(OS))) @@ -203,16 +201,19 @@ CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \ else CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Wno-pointer-sign -Werror \ -funsigned-char -fshort-wchar -fno-strict-aliasing \ - -ffreestanding -fno-stack-protector -fno-stack-check \ + -ffreestanding -fno-stack-protector -fno-stack-check \ $(if $(findstring gcc,$(CC)),-fno-merge-all-constants,) endif ARFLAGS := rDv ASFLAGS += $(ARCH3264) -LDFLAGS += -nostdlib --warn-common --no-undefined --fatal-warnings \ - --build-id=sha1 +LDFLAGS += -nostdlib ifeq ($(IS_MINGW32),) - LDFLAGS += -z nocombreloc -z norelro + LDFLAGS += --warn-common --no-undefined --fatal-warnings \ + --build-id=sha1 -z nocombreloc -z norelro +else + LDFLAGS += -Wl,--warn-common -Wl,--no-undefined -Wl,--fatal-warnings \ + -Wl,--build-id=sha1 endif ifneq ($(ARCH),arm) diff --git a/Make.rules b/Make.rules index cdb7aab..9982403 100644 --- a/Make.rules +++ b/Make.rules @@ -36,6 +36,7 @@ .SECONDARY: +ifeq ($(IS_MINGW32),) %.efi: %.so $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .rodata -j .rel \ -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ @@ -49,6 +50,10 @@ %.so: %.o $(LD) $(LDFLAGS) $^ -o $@ $(LOADLIBES) +else +%.efi: %.o + $(CC) $(LDFLAGS) $< -o $@ $(LOADLIBES) +endif %.o: %.c $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ diff --git a/apps/Makefile b/apps/Makefile index 48c5bf8..48b8f43 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -68,26 +68,35 @@ LOADLIBES += $(LIBGCC) TARGET_APPS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi t7.efi t8.efi \ tcc.efi printenv.efi modelist.efi route80h.efi route80h.efi \ drv0_use.efi AllocPages.efi exit.efi FreePages.efi bltgrid.efi \ - lfbgrid.efi setdbg.efi unsetdbg.efi ctors_test.efi \ - ctors_dtors_priority_test.efi + lfbgrid.efi setdbg.efi unsetdbg.efi ifeq ($(IS_MINGW32),) -TARGET_APPS += setjmp.efi debughook.efi debughook.efi.debug +TARGET_APPS += setjmp.efi debughook.efi debughook.efi.debug \ + ctors_test.efi ctors_dtors_priority_test.efi endif TARGET_BSDRIVERS = drv0.efi TARGET_RTDRIVERS = +SUBSYSTEM := 0xa +$(TARGET_BSDRIVERS): SUBSYSTEM = 0xb +$(TARGET_RTDRIVERS): SUBSYSTEM = 0xc + ifneq ($(HAVE_EFI_OBJCOPY),) FORMAT := --target efi-app-$(ARCH) $(TARGET_BSDRIVERS): FORMAT=--target efi-bsdrv-$(ARCH) $(TARGET_RTDRIVERS): FORMAT=--target efi-rtdrv-$(ARCH) +ifneq ($(IS_MINGW32),) +LDFLAGS += -s -Wl,-dll -Wl,--subsystem,$(SUBSYSTEM) +ifeq ($(ARCH),ia32) +LDFLAGS += -e _efi_main else +LDFLAGS += -e efi_main +endif +endif -SUBSYSTEM := 0xa -$(TARGET_BSDRIVERS): SUBSYSTEM = 0xb -$(TARGET_RTDRIVERS): SUBSYSTEM = 0xc +else FORMAT := -O binary LDFLAGS += --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)