2018-05-06 21:58:06 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2002-11-18 00:14:45 +00:00
|
|
|
#
|
|
|
|
# (C) Copyright 2000-2002
|
|
|
|
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
|
2011-02-04 13:25:17 +00:00
|
|
|
CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
|
2009-09-04 03:12:47 +00:00
|
|
|
|
2010-10-07 09:03:23 +00:00
|
|
|
PLATFORM_CPPFLAGS += -fno-strict-aliasing
|
|
|
|
PLATFORM_CPPFLAGS += -fomit-frame-pointer
|
2014-02-26 05:51:01 +00:00
|
|
|
PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
|
2017-07-27 13:12:34 +00:00
|
|
|
$(call cc-option, -fno-unit-at-a-time))
|
2015-08-04 18:33:42 +00:00
|
|
|
|
2011-11-01 20:54:02 +00:00
|
|
|
PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
|
2011-02-12 04:11:21 +00:00
|
|
|
PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
|
2017-01-16 14:04:26 +00:00
|
|
|
|
|
|
|
ifdef CONFIG_SPL_BUILD
|
|
|
|
IS_32BIT := y
|
|
|
|
else
|
|
|
|
ifndef CONFIG_X86_64
|
|
|
|
IS_32BIT := y
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(IS_32BIT),y)
|
2014-06-10 13:14:56 +00:00
|
|
|
PLATFORM_CPPFLAGS += -march=i386 -m32
|
2018-06-12 05:48:37 +00:00
|
|
|
# TODO: These break on x86_64; need to debug further
|
|
|
|
PLATFORM_RELFLAGS += -fdata-sections
|
2017-01-16 14:04:26 +00:00
|
|
|
else
|
2017-07-27 13:12:35 +00:00
|
|
|
PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
|
2017-01-16 14:04:26 +00:00
|
|
|
endif
|
2011-02-12 04:11:21 +00:00
|
|
|
|
|
|
|
PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
|
|
|
|
|
2017-01-16 14:04:26 +00:00
|
|
|
PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
|
|
|
|
PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
|
2011-02-12 04:11:21 +00:00
|
|
|
|
2015-08-04 18:33:52 +00:00
|
|
|
# This is used in the top-level Makefile which does not include
|
|
|
|
# PLATFORM_LDFLAGS
|
|
|
|
LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
|
|
|
|
|
2015-08-04 18:33:42 +00:00
|
|
|
OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
|
|
|
|
-j .rel -j .rela -j .reloc
|
|
|
|
|
2017-01-16 14:04:26 +00:00
|
|
|
ifeq ($(IS_32BIT),y)
|
2015-08-04 18:33:42 +00:00
|
|
|
CFLAGS_NON_EFI := -mregparm=3
|
2017-01-16 14:04:26 +00:00
|
|
|
endif
|
2015-08-04 18:33:42 +00:00
|
|
|
CFLAGS_EFI := -fpic -fshort-wchar
|
|
|
|
|
2015-08-04 18:33:56 +00:00
|
|
|
ifeq ($(CONFIG_EFI_STUB_64BIT),)
|
|
|
|
CFLAGS_EFI += $(call cc-option, -mno-red-zone)
|
2015-08-04 18:33:42 +00:00
|
|
|
EFIARCH = ia32
|
2015-08-04 18:33:52 +00:00
|
|
|
EFIPAYLOAD_BFDTARGET = elf32-i386
|
2015-08-04 18:33:56 +00:00
|
|
|
else
|
|
|
|
EFIARCH = x86_64
|
|
|
|
EFIPAYLOAD_BFDTARGET = elf64-x86-64
|
|
|
|
endif
|
2015-08-04 18:33:52 +00:00
|
|
|
|
|
|
|
EFIPAYLOAD_BFDARCH = i386
|
2015-08-04 18:33:42 +00:00
|
|
|
|
2016-11-07 15:47:13 +00:00
|
|
|
LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
|
2016-11-07 15:47:14 +00:00
|
|
|
EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
|
2015-08-04 18:33:42 +00:00
|
|
|
OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
|
|
|
|
|
2015-08-04 18:33:56 +00:00
|
|
|
CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
|
|
|
|
CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
|
|
|
|
|
2015-08-04 18:33:42 +00:00
|
|
|
ifeq ($(CONFIG_EFI_APP),y)
|
|
|
|
|
|
|
|
PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
|
|
|
|
LDFLAGS_FINAL += -znocombreloc -shared
|
|
|
|
LDSCRIPT := $(LDSCRIPT_EFI)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
|
|
|
|
PLATFORM_LDFLAGS += --emit-relocs
|
2017-01-16 14:04:26 +00:00
|
|
|
LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
|
|
|
|
|
|
|
|
endif
|
2015-08-04 18:33:42 +00:00
|
|
|
|
2017-01-16 14:04:26 +00:00
|
|
|
ifdef CONFIG_X86_64
|
|
|
|
ifndef CONFIG_SPL_BUILD
|
|
|
|
PLATFORM_CPPFLAGS += -D__x86_64__
|
|
|
|
else
|
|
|
|
PLATFORM_CPPFLAGS += -D__I386__
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
PLATFORM_CPPFLAGS += -D__I386__
|
2015-08-04 18:33:42 +00:00
|
|
|
endif
|
2016-11-07 15:47:15 +00:00
|
|
|
|
2018-05-18 17:12:19 +00:00
|
|
|
ifdef CONFIG_EFI_STUB
|
2016-11-07 15:47:15 +00:00
|
|
|
|
2018-05-18 17:12:19 +00:00
|
|
|
ifdef CONFIG_EFI_STUB_64BIT
|
2016-11-07 15:47:15 +00:00
|
|
|
EFI_LDS := elf_x86_64_efi.lds
|
|
|
|
EFI_CRT0 := crt0_x86_64_efi.o
|
|
|
|
EFI_RELOC := reloc_x86_64_efi.o
|
|
|
|
else
|
|
|
|
EFI_LDS := elf_ia32_efi.lds
|
|
|
|
EFI_CRT0 := crt0_ia32_efi.o
|
|
|
|
EFI_RELOC := reloc_ia32_efi.o
|
2018-04-06 13:36:31 +00:00
|
|
|
endif
|
|
|
|
|
2018-05-18 17:12:19 +00:00
|
|
|
else
|
|
|
|
|
2018-04-06 13:36:31 +00:00
|
|
|
ifdef CONFIG_X86_64
|
2018-05-18 17:12:19 +00:00
|
|
|
EFI_LDS := elf_x86_64_efi.lds
|
|
|
|
EFI_CRT0 := crt0_x86_64_efi.o
|
|
|
|
EFI_RELOC := reloc_x86_64_efi.o
|
2018-04-06 13:36:31 +00:00
|
|
|
else
|
2018-05-18 17:12:19 +00:00
|
|
|
EFI_LDS := elf_ia32_efi.lds
|
|
|
|
EFI_CRT0 := crt0_ia32_efi.o
|
|
|
|
EFI_RELOC := reloc_ia32_efi.o
|
|
|
|
endif
|
|
|
|
|
2016-11-07 15:47:15 +00:00
|
|
|
endif
|
|
|
|
|
2018-05-18 17:12:19 +00:00
|
|
|
ifdef CONFIG_X86_64
|
|
|
|
EFI_TARGET := --target=efi-app-x86_64
|
|
|
|
else
|
|
|
|
EFI_TARGET := --target=efi-app-ia32
|
2016-11-07 15:47:15 +00:00
|
|
|
endif
|