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