1# SPDX-License-Identifier: GPL-2.0+ 2# 3# (C) Copyright 2000-2002 4# Wolfgang Denk, DENX Software Engineering, wd@denx.de. 5 6CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000 7 8PLATFORM_CPPFLAGS += -fno-strict-aliasing 9PLATFORM_CPPFLAGS += -fomit-frame-pointer 10PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \ 11 $(call cc-option, -fno-unit-at-a-time)) 12 13PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86) 14PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm 15 16ifdef CONFIG_SPL_BUILD 17IS_32BIT := y 18else 19ifndef CONFIG_X86_64 20IS_32BIT := y 21endif 22endif 23 24ifeq ($(IS_32BIT),y) 25PLATFORM_CPPFLAGS += -march=i386 -m32 26# TODO: These break on x86_64; need to debug further 27PLATFORM_RELFLAGS += -fdata-sections 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 91ifdef CONFIG_EFI_STUB 92 93ifdef 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 97else 98EFI_LDS := elf_ia32_efi.lds 99EFI_CRT0 := crt0_ia32_efi.o 100EFI_RELOC := reloc_ia32_efi.o 101endif 102 103else 104 105ifdef CONFIG_X86_64 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 115endif 116 117ifdef CONFIG_X86_64 118EFI_TARGET := --target=efi-app-x86_64 119else 120EFI_TARGET := --target=efi-app-ia32 121endif 122