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 $(call cc-option, -mpreferred-stack-boundary=2) 15 16PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86) 17PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm 18 19ifdef CONFIG_SPL_BUILD 20IS_32BIT := y 21else 22ifndef CONFIG_X86_64 23IS_32BIT := y 24endif 25endif 26 27ifeq ($(IS_32BIT),y) 28PLATFORM_CPPFLAGS += -march=i386 -m32 29else 30PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common 31endif 32 33PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden 34 35PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions 36PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64) 37 38LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3 39LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3 40 41# This is used in the top-level Makefile which does not include 42# PLATFORM_LDFLAGS 43LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined 44 45OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ 46 -j .rel -j .rela -j .reloc 47 48ifeq ($(IS_32BIT),y) 49CFLAGS_NON_EFI := -mregparm=3 50endif 51CFLAGS_EFI := -fpic -fshort-wchar 52 53ifeq ($(CONFIG_EFI_STUB_64BIT),) 54CFLAGS_EFI += $(call cc-option, -mno-red-zone) 55EFIARCH = ia32 56EFIPAYLOAD_BFDTARGET = elf32-i386 57else 58EFIARCH = x86_64 59EFIPAYLOAD_BFDTARGET = elf64-x86-64 60endif 61 62EFIPAYLOAD_BFDARCH = i386 63 64LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds 65EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o 66OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH) 67 68CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI) 69CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI) 70 71ifeq ($(CONFIG_EFI_APP),y) 72 73PLATFORM_CPPFLAGS += $(CFLAGS_EFI) 74LDFLAGS_FINAL += -znocombreloc -shared 75LDSCRIPT := $(LDSCRIPT_EFI) 76 77else 78 79PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI) 80PLATFORM_LDFLAGS += --emit-relocs 81LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie) 82 83endif 84 85ifdef CONFIG_X86_64 86ifndef CONFIG_SPL_BUILD 87PLATFORM_CPPFLAGS += -D__x86_64__ 88else 89PLATFORM_CPPFLAGS += -D__I386__ 90endif 91else 92PLATFORM_CPPFLAGS += -D__I386__ 93endif 94 95ifneq ($(CONFIG_EFI_STUB)$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) 96 97ifneq ($(CONFIG_EFI_STUB_64BIT),) 98EFI_LDS := elf_x86_64_efi.lds 99EFI_CRT0 := crt0_x86_64_efi.o 100EFI_RELOC := reloc_x86_64_efi.o 101EFI_TARGET := --target=efi-app-ia32 102else 103EFI_LDS := elf_ia32_efi.lds 104EFI_CRT0 := crt0_ia32_efi.o 105EFI_RELOC := reloc_ia32_efi.o 106EFI_TARGET := --target=efi-app-x86_64 107endif 108 109endif 110