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