blob: 8835dcf36f1a3c5cba2f4eb8c7072180c6ae9e24 [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, \
Bin Meng9a95f512017-07-27 06:12:34 -070013 $(call cc-option, -fno-unit-at-a-time))
Ben Stoltz3f1c0462015-08-04 12:33:42 -060014
Wolfgang Denkcca4e4a2011-11-01 20:54:02 +000015PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
Graeme Russa85f53c2011-02-12 15:11:21 +110016PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Simon Glass3a037032017-01-16 07:04:26 -070017
18ifdef CONFIG_SPL_BUILD
19IS_32BIT := y
20else
21ifndef CONFIG_X86_64
22IS_32BIT := y
23endif
24endif
25
26ifeq ($(IS_32BIT),y)
Vasili Galkadbb72342014-06-10 16:14:56 +030027PLATFORM_CPPFLAGS += -march=i386 -m32
Simon Glass3a037032017-01-16 07:04:26 -070028else
Bin Menge719b6b2017-07-27 06:12:35 -070029PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
Simon Glass3a037032017-01-16 07:04:26 -070030endif
Graeme Russd664adb2010-10-07 20:03:20 +110031
Graeme Russa85f53c2011-02-12 15:11:21 +110032PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
33
Simon Glass3a037032017-01-16 07:04:26 -070034PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
35PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
Graeme Russa85f53c2011-02-12 15:11:21 +110036
Gabe Black36b24092011-11-16 23:01:37 +000037LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
38LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
Ben Stoltz3f1c0462015-08-04 12:33:42 -060039
Simon Glass476476e2015-08-04 12:33:52 -060040# This is used in the top-level Makefile which does not include
41# PLATFORM_LDFLAGS
42LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
43
Ben Stoltz3f1c0462015-08-04 12:33:42 -060044OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
45 -j .rel -j .rela -j .reloc
46
Simon Glass3a037032017-01-16 07:04:26 -070047ifeq ($(IS_32BIT),y)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060048CFLAGS_NON_EFI := -mregparm=3
Simon Glass3a037032017-01-16 07:04:26 -070049endif
Ben Stoltz3f1c0462015-08-04 12:33:42 -060050CFLAGS_EFI := -fpic -fshort-wchar
51
Simon Glass96a8d402015-08-04 12:33:56 -060052ifeq ($(CONFIG_EFI_STUB_64BIT),)
53CFLAGS_EFI += $(call cc-option, -mno-red-zone)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060054EFIARCH = ia32
Simon Glass476476e2015-08-04 12:33:52 -060055EFIPAYLOAD_BFDTARGET = elf32-i386
Simon Glass96a8d402015-08-04 12:33:56 -060056else
57EFIARCH = x86_64
58EFIPAYLOAD_BFDTARGET = elf64-x86-64
59endif
Simon Glass476476e2015-08-04 12:33:52 -060060
61EFIPAYLOAD_BFDARCH = i386
Ben Stoltz3f1c0462015-08-04 12:33:42 -060062
Simon Glassd36badf2016-11-07 08:47:13 -070063LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
Simon Glass2dcd4e92016-11-07 08:47:14 -070064EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
Ben Stoltz3f1c0462015-08-04 12:33:42 -060065OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
66
Simon Glass96a8d402015-08-04 12:33:56 -060067CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
68CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
69
Ben Stoltz3f1c0462015-08-04 12:33:42 -060070ifeq ($(CONFIG_EFI_APP),y)
71
72PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
73LDFLAGS_FINAL += -znocombreloc -shared
74LDSCRIPT := $(LDSCRIPT_EFI)
75
76else
77
78PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
79PLATFORM_LDFLAGS += --emit-relocs
Simon Glass3a037032017-01-16 07:04:26 -070080LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060081
82endif
Simon Glass5bd828b2016-11-07 08:47:15 -070083
Simon Glass3a037032017-01-16 07:04:26 -070084ifdef CONFIG_X86_64
85ifndef CONFIG_SPL_BUILD
86PLATFORM_CPPFLAGS += -D__x86_64__
87else
88PLATFORM_CPPFLAGS += -D__I386__
89endif
90else
91PLATFORM_CPPFLAGS += -D__I386__
92endif
93
Alexander Graf95b62b22016-11-17 22:40:10 +010094ifneq ($(CONFIG_EFI_STUB)$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
Simon Glass5bd828b2016-11-07 08:47:15 -070095
96ifneq ($(CONFIG_EFI_STUB_64BIT),)
97EFI_LDS := elf_x86_64_efi.lds
98EFI_CRT0 := crt0_x86_64_efi.o
99EFI_RELOC := reloc_x86_64_efi.o
100EFI_TARGET := --target=efi-app-ia32
101else
102EFI_LDS := elf_ia32_efi.lds
103EFI_CRT0 := crt0_ia32_efi.o
104EFI_RELOC := reloc_ia32_efi.o
105EFI_TARGET := --target=efi-app-x86_64
106endif
107
108endif