1# SPDX-License-Identifier: GPL-2.0+ 2# 3# (C) Copyright 2000-2002 4# Wolfgang Denk, DENX Software Engineering, wd@denx.de. 5 6PLATFORM_CPPFLAGS += -fomit-frame-pointer 7PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \ 8 $(call cc-option, -fno-unit-at-a-time)) 9 10PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86) 11PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm 12 13ifdef CONFIG_XPL_BUILD 14IS_32BIT := y 15else 16ifndef CONFIG_X86_64 17IS_32BIT := y 18endif 19endif 20 21EFI_IS_32BIT := $(IS_32BIT) 22ifdef CONFIG_EFI_STUB_64BIT 23EFI_IS_32BIT := 24endif 25 26ifeq ($(IS_32BIT),y) 27PLATFORM_CPPFLAGS += -march=i386 -m32 28else 29PLATFORM_CPPFLAGS += $(if $(CONFIG_XPL_BUILD),,-fpic) -fno-common -march=core2 -m64 30 31ifndef CONFIG_X86_HARDFP 32PLATFORM_CPPFLAGS += -mno-mmx -mno-sse 33endif 34 35endif # IS_32BIT 36 37PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden 38 39KBUILD_LDFLAGS += -Bsymbolic -Bsymbolic-functions 40KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64) 41 42# This is used in the top-level Makefile which does not include 43# KBUILD_LDFLAGS 44LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \ 45 -s -zexecstack 46 47OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ 48 -j .rel -j .rela -j .reloc --strip-all 49 50# Compiler flags to be added when building UEFI applications 51CFLAGS_EFI := -fpic -fshort-wchar 52# Compiler flags to be removed when building UEFI applications 53CFLAGS_NON_EFI := -mregparm=3 -fstack-protector-strong 54 55ifeq ($(IS_32BIT),y) 56EFIPAYLOAD_BFDARCH = i386 57else 58CFLAGS_EFI += $(call cc-option, -mno-red-zone) 59EFIPAYLOAD_BFDARCH = x86_64 60endif 61 62ifeq ($(EFI_IS_32BIT),y) 63EFIARCH = ia32 64EFIPAYLOAD_BFDTARGET = elf32-i386 65else 66EFIARCH = x86_64 67EFIPAYLOAD_BFDTARGET = elf64-x86-64 68endif 69 70LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds 71EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o 72OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH) 73 74CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI) 75CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI) 76 77ifeq ($(CONFIG_EFI_APP),y) 78 79PLATFORM_CPPFLAGS += $(CFLAGS_EFI) 80LDFLAGS_FINAL += -znocombreloc -shared 81LDSCRIPT := $(LDSCRIPT_EFI) 82 83else 84 85ifeq ($(IS_32BIT),y) 86PLATFORM_CPPFLAGS += -mregparm=3 87endif 88KBUILD_LDFLAGS += --emit-relocs 89LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_XPL_BUILD),,-pie) 90 91endif 92 93ifdef CONFIG_X86_64 94ifndef CONFIG_XPL_BUILD 95PLATFORM_CPPFLAGS += -D__x86_64__ 96else 97PLATFORM_CPPFLAGS += -D__I386__ 98endif 99else 100PLATFORM_CPPFLAGS += -D__I386__ 101endif 102 103ifdef CONFIG_EFI_STUB 104 105ifdef CONFIG_EFI_STUB_64BIT 106EFI_LDS := elf_x86_64_efi.lds 107EFI_CRT0 := crt0_x86_64_efi.o 108EFI_RELOC := reloc_x86_64_efi.o 109else 110EFI_LDS := elf_ia32_efi.lds 111EFI_CRT0 := crt0_ia32_efi.o 112EFI_RELOC := reloc_ia32_efi.o 113endif 114 115else 116 117ifdef CONFIG_X86_64 118EFI_LDS := elf_x86_64_efi.lds 119EFI_CRT0 := crt0_x86_64_efi.o 120EFI_RELOC := reloc_x86_64_efi.o 121else 122EFI_LDS := elf_ia32_efi.lds 123EFI_CRT0 := crt0_ia32_efi.o 124EFI_RELOC := reloc_ia32_efi.o 125endif 126 127endif 128 129ifdef CONFIG_X86_64 130EFI_TARGET := --target=efi-app-x86_64 131else 132EFI_TARGET := --target=efi-app-ia32 133endif 134