2018-05-06 21:58:06 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2002-11-18 00:14:45 +00:00
|
|
|
#
|
|
|
|
# (C) Copyright 2000-2002
|
|
|
|
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
|
2011-02-04 13:25:17 +00:00
|
|
|
CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
|
2009-09-04 03:12:47 +00:00
|
|
|
|
2010-10-07 09:03:23 +00:00
|
|
|
PLATFORM_CPPFLAGS += -fomit-frame-pointer
|
2014-02-26 05:51:01 +00:00
|
|
|
PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
|
2017-07-27 13:12:34 +00:00
|
|
|
$(call cc-option, -fno-unit-at-a-time))
|
2015-08-04 18:33:42 +00:00
|
|
|
|
2011-11-01 20:54:02 +00:00
|
|
|
PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
|
2011-02-12 04:11:21 +00:00
|
|
|
PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
|
2017-01-16 14:04:26 +00:00
|
|
|
|
|
|
|
ifdef CONFIG_SPL_BUILD
|
|
|
|
IS_32BIT := y
|
|
|
|
else
|
|
|
|
ifndef CONFIG_X86_64
|
|
|
|
IS_32BIT := y
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2022-01-04 10:51:16 +00:00
|
|
|
EFI_IS_32BIT := $(IS_32BIT)
|
|
|
|
ifdef CONFIG_EFI_STUB_64BIT
|
|
|
|
EFI_IS_32BIT :=
|
|
|
|
endif
|
|
|
|
|
2017-01-16 14:04:26 +00:00
|
|
|
ifeq ($(IS_32BIT),y)
|
2014-06-10 13:14:56 +00:00
|
|
|
PLATFORM_CPPFLAGS += -march=i386 -m32
|
2017-01-16 14:04:26 +00:00
|
|
|
else
|
2018-10-14 03:52:01 +00:00
|
|
|
PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64
|
2018-10-14 03:52:02 +00:00
|
|
|
PLATFORM_CPPFLAGS += -mno-mmx -mno-sse
|
2017-01-16 14:04:26 +00:00
|
|
|
endif
|
2011-02-12 04:11:21 +00:00
|
|
|
|
2018-08-20 12:20:51 +00:00
|
|
|
PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
|
2011-02-12 04:11:21 +00:00
|
|
|
|
2020-03-27 15:46:27 +00:00
|
|
|
KBUILD_LDFLAGS += -Bsymbolic -Bsymbolic-functions
|
|
|
|
KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
|
2011-02-12 04:11:21 +00:00
|
|
|
|
2015-08-04 18:33:52 +00:00
|
|
|
# This is used in the top-level Makefile which does not include
|
2020-03-27 15:46:27 +00:00
|
|
|
# KBUILD_LDFLAGS
|
2018-10-02 14:39:30 +00:00
|
|
|
LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined -s
|
2015-08-04 18:33:52 +00:00
|
|
|
|
2015-08-04 18:33:42 +00:00
|
|
|
OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
|
2021-09-25 00:30:19 +00:00
|
|
|
-j .rel -j .rela -j .reloc --strip-all
|
2015-08-04 18:33:42 +00:00
|
|
|
|
2021-04-11 09:21:57 +00:00
|
|
|
# Compiler flags to be added when building UEFI applications
|
2015-08-04 18:33:42 +00:00
|
|
|
CFLAGS_EFI := -fpic -fshort-wchar
|
2021-04-11 09:21:57 +00:00
|
|
|
# Compiler flags to be removed when building UEFI applications
|
2021-04-11 09:21:58 +00:00
|
|
|
CFLAGS_NON_EFI := -mregparm=3 -fstack-protector-strong
|
2015-08-04 18:33:42 +00:00
|
|
|
|
2022-01-04 10:51:16 +00:00
|
|
|
ifeq ($(IS_32BIT),y)
|
|
|
|
EFIPAYLOAD_BFDARCH = i386
|
|
|
|
else
|
2015-08-04 18:33:56 +00:00
|
|
|
CFLAGS_EFI += $(call cc-option, -mno-red-zone)
|
2022-01-04 10:51:16 +00:00
|
|
|
EFIPAYLOAD_BFDARCH = x86_64
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(EFI_IS_32BIT),y)
|
2015-08-04 18:33:42 +00:00
|
|
|
EFIARCH = ia32
|
2015-08-04 18:33:52 +00:00
|
|
|
EFIPAYLOAD_BFDTARGET = elf32-i386
|
2015-08-04 18:33:56 +00:00
|
|
|
else
|
|
|
|
EFIARCH = x86_64
|
|
|
|
EFIPAYLOAD_BFDTARGET = elf64-x86-64
|
|
|
|
endif
|
2015-08-04 18:33:52 +00:00
|
|
|
|
2016-11-07 15:47:13 +00:00
|
|
|
LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
|
2016-11-07 15:47:14 +00:00
|
|
|
EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
|
2015-08-04 18:33:42 +00:00
|
|
|
OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
|
|
|
|
|
2015-08-04 18:33:56 +00:00
|
|
|
CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
|
|
|
|
CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
|
|
|
|
|
2015-08-04 18:33:42 +00:00
|
|
|
ifeq ($(CONFIG_EFI_APP),y)
|
|
|
|
|
|
|
|
PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
|
2021-09-25 00:30:19 +00:00
|
|
|
LDFLAGS_FINAL += -znocombreloc -shared
|
2015-08-04 18:33:42 +00:00
|
|
|
LDSCRIPT := $(LDSCRIPT_EFI)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
2021-04-11 09:21:57 +00:00
|
|
|
ifeq ($(IS_32BIT),y)
|
|
|
|
PLATFORM_CPPFLAGS += -mregparm=3
|
|
|
|
endif
|
2020-03-27 15:46:27 +00:00
|
|
|
KBUILD_LDFLAGS += --emit-relocs
|
2017-01-16 14:04:26 +00:00
|
|
|
LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
|
|
|
|
|
|
|
|
endif
|
2015-08-04 18:33:42 +00:00
|
|
|
|
2017-01-16 14:04:26 +00:00
|
|
|
ifdef CONFIG_X86_64
|
|
|
|
ifndef CONFIG_SPL_BUILD
|
|
|
|
PLATFORM_CPPFLAGS += -D__x86_64__
|
|
|
|
else
|
|
|
|
PLATFORM_CPPFLAGS += -D__I386__
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
PLATFORM_CPPFLAGS += -D__I386__
|
2015-08-04 18:33:42 +00:00
|
|
|
endif
|
2016-11-07 15:47:15 +00:00
|
|
|
|
2018-05-18 17:12:19 +00:00
|
|
|
ifdef CONFIG_EFI_STUB
|
2016-11-07 15:47:15 +00:00
|
|
|
|
2018-05-18 17:12:19 +00:00
|
|
|
ifdef CONFIG_EFI_STUB_64BIT
|
2016-11-07 15:47:15 +00:00
|
|
|
EFI_LDS := elf_x86_64_efi.lds
|
|
|
|
EFI_CRT0 := crt0_x86_64_efi.o
|
|
|
|
EFI_RELOC := reloc_x86_64_efi.o
|
|
|
|
else
|
|
|
|
EFI_LDS := elf_ia32_efi.lds
|
|
|
|
EFI_CRT0 := crt0_ia32_efi.o
|
|
|
|
EFI_RELOC := reloc_ia32_efi.o
|
2018-04-06 13:36:31 +00:00
|
|
|
endif
|
|
|
|
|
2018-05-18 17:12:19 +00:00
|
|
|
else
|
|
|
|
|
2018-04-06 13:36:31 +00:00
|
|
|
ifdef CONFIG_X86_64
|
2018-05-18 17:12:19 +00:00
|
|
|
EFI_LDS := elf_x86_64_efi.lds
|
|
|
|
EFI_CRT0 := crt0_x86_64_efi.o
|
|
|
|
EFI_RELOC := reloc_x86_64_efi.o
|
2018-04-06 13:36:31 +00:00
|
|
|
else
|
2018-05-18 17:12:19 +00:00
|
|
|
EFI_LDS := elf_ia32_efi.lds
|
|
|
|
EFI_CRT0 := crt0_ia32_efi.o
|
|
|
|
EFI_RELOC := reloc_ia32_efi.o
|
|
|
|
endif
|
|
|
|
|
2016-11-07 15:47:15 +00:00
|
|
|
endif
|
|
|
|
|
2018-05-18 17:12:19 +00:00
|
|
|
ifdef CONFIG_X86_64
|
|
|
|
EFI_TARGET := --target=efi-app-x86_64
|
|
|
|
else
|
|
|
|
EFI_TARGET := --target=efi-app-ia32
|
2016-11-07 15:47:15 +00:00
|
|
|
endif
|