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