blob: 1697dca47fb2b9c78fa07ddb83c016bec6972720 [file] [log] [blame]
wdenk2262cfe2002-11-18 00:14:45 +00001#
2# (C) Copyright 2000-2002
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
Wolfgang Denk1a459662013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
wdenk2262cfe2002-11-18 00:14:45 +00006#
7
Wolfgang Denk8ae86b72011-02-04 14:25:17 +01008CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
Mike Frysinger262ae0a2009-09-03 23:12:47 -04009
Graeme Russ5c161652010-10-07 20:03:23 +110010PLATFORM_CPPFLAGS += -fno-strict-aliasing
Graeme Russ5c161652010-10-07 20:03:23 +110011PLATFORM_CPPFLAGS += -fomit-frame-pointer
Masahiro Yamadaf6941832014-02-26 14:51:01 +090012PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
Wolfgang Denkcca4e4a2011-11-01 20:54:02 +000013 $(call cc-option, -fno-unit-at-a-time)) \
Wolfgang Denkcca4e4a2011-11-01 20:54:02 +000014 $(call cc-option, -mpreferred-stack-boundary=2)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060015
Wolfgang Denkcca4e4a2011-11-01 20:54:02 +000016PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
Graeme Russa85f53c2011-02-12 15:11:21 +110017PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Vasili Galkadbb72342014-06-10 16:14:56 +030018PLATFORM_CPPFLAGS += -march=i386 -m32
Graeme Russd664adb2010-10-07 20:03:20 +110019
Graeme Russa85f53c2011-02-12 15:11:21 +110020PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
21
Ben Stoltz3f1c0462015-08-04 12:33:42 -060022PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions -m elf_i386
Graeme Russa85f53c2011-02-12 15:11:21 +110023
Gabe Black36b24092011-11-16 23:01:37 +000024LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
25LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
Ben Stoltz3f1c0462015-08-04 12:33:42 -060026
Simon Glass476476e2015-08-04 12:33:52 -060027# This is used in the top-level Makefile which does not include
28# PLATFORM_LDFLAGS
29LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
30
Ben Stoltz3f1c0462015-08-04 12:33:42 -060031OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
32 -j .rel -j .rela -j .reloc
33
34CFLAGS_NON_EFI := -mregparm=3
35CFLAGS_EFI := -fpic -fshort-wchar
36
Simon Glass96a8d402015-08-04 12:33:56 -060037ifeq ($(CONFIG_EFI_STUB_64BIT),)
38CFLAGS_EFI += $(call cc-option, -mno-red-zone)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060039EFIARCH = ia32
Simon Glass476476e2015-08-04 12:33:52 -060040EFIPAYLOAD_BFDTARGET = elf32-i386
Simon Glass96a8d402015-08-04 12:33:56 -060041else
42EFIARCH = x86_64
43EFIPAYLOAD_BFDTARGET = elf64-x86-64
44endif
Simon Glass476476e2015-08-04 12:33:52 -060045
46EFIPAYLOAD_BFDARCH = i386
Ben Stoltz3f1c0462015-08-04 12:33:42 -060047
Simon Glassd36badf2016-11-07 08:47:13 -070048LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
Simon Glass2dcd4e92016-11-07 08:47:14 -070049EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
Ben Stoltz3f1c0462015-08-04 12:33:42 -060050OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
51
Simon Glass96a8d402015-08-04 12:33:56 -060052CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
53CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
54
Ben Stoltz3f1c0462015-08-04 12:33:42 -060055ifeq ($(CONFIG_EFI_APP),y)
56
57PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
58LDFLAGS_FINAL += -znocombreloc -shared
59LDSCRIPT := $(LDSCRIPT_EFI)
60
61else
62
63PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
64PLATFORM_LDFLAGS += --emit-relocs
65LDFLAGS_FINAL += --gc-sections -pie
66
67endif
Simon Glass5bd828b2016-11-07 08:47:15 -070068
Alexander Graf95b62b22016-11-17 22:40:10 +010069ifneq ($(CONFIG_EFI_STUB)$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
Simon Glass5bd828b2016-11-07 08:47:15 -070070
71ifneq ($(CONFIG_EFI_STUB_64BIT),)
72EFI_LDS := elf_x86_64_efi.lds
73EFI_CRT0 := crt0_x86_64_efi.o
74EFI_RELOC := reloc_x86_64_efi.o
75EFI_TARGET := --target=efi-app-ia32
76else
77EFI_LDS := elf_ia32_efi.lds
78EFI_CRT0 := crt0_ia32_efi.o
79EFI_RELOC := reloc_ia32_efi.o
80EFI_TARGET := --target=efi-app-x86_64
81endif
82
83endif