blob: 586e11a0dda55a62c3318cdbc036318ee5881f40 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
wdenk2262cfe2002-11-18 00:14:45 +00002#
3# (C) Copyright 2000-2002
4# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenk2262cfe2002-11-18 00:14:45 +00005
Wolfgang Denk8ae86b72011-02-04 14:25:17 +01006CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
Mike Frysinger262ae0a2009-09-03 23:12:47 -04007
Graeme Russ5c161652010-10-07 20:03:23 +11008PLATFORM_CPPFLAGS += -fno-strict-aliasing
Graeme Russ5c161652010-10-07 20:03:23 +11009PLATFORM_CPPFLAGS += -fomit-frame-pointer
Masahiro Yamadaf6941832014-02-26 14:51:01 +090010PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
Bin Meng9a95f512017-07-27 06:12:34 -070011 $(call cc-option, -fno-unit-at-a-time))
Ben Stoltz3f1c0462015-08-04 12:33:42 -060012
Wolfgang Denkcca4e4a2011-11-01 20:54:02 +000013PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
Graeme Russa85f53c2011-02-12 15:11:21 +110014PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Simon Glass3a037032017-01-16 07:04:26 -070015
16ifdef CONFIG_SPL_BUILD
17IS_32BIT := y
18else
19ifndef CONFIG_X86_64
20IS_32BIT := y
21endif
22endif
23
24ifeq ($(IS_32BIT),y)
Vasili Galkadbb72342014-06-10 16:14:56 +030025PLATFORM_CPPFLAGS += -march=i386 -m32
Alexander Graf7e21fbc2018-06-12 07:48:37 +020026# TODO: These break on x86_64; need to debug further
27PLATFORM_RELFLAGS += -fdata-sections
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
Simon Glass476476e2015-08-04 12:33:52 -060037# This is used in the top-level Makefile which does not include
38# PLATFORM_LDFLAGS
39LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
40
Ben Stoltz3f1c0462015-08-04 12:33:42 -060041OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
42 -j .rel -j .rela -j .reloc
43
Simon Glass3a037032017-01-16 07:04:26 -070044ifeq ($(IS_32BIT),y)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060045CFLAGS_NON_EFI := -mregparm=3
Simon Glass3a037032017-01-16 07:04:26 -070046endif
Ben Stoltz3f1c0462015-08-04 12:33:42 -060047CFLAGS_EFI := -fpic -fshort-wchar
48
Simon Glass96a8d402015-08-04 12:33:56 -060049ifeq ($(CONFIG_EFI_STUB_64BIT),)
50CFLAGS_EFI += $(call cc-option, -mno-red-zone)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060051EFIARCH = ia32
Simon Glass476476e2015-08-04 12:33:52 -060052EFIPAYLOAD_BFDTARGET = elf32-i386
Simon Glass96a8d402015-08-04 12:33:56 -060053else
54EFIARCH = x86_64
55EFIPAYLOAD_BFDTARGET = elf64-x86-64
56endif
Simon Glass476476e2015-08-04 12:33:52 -060057
58EFIPAYLOAD_BFDARCH = i386
Ben Stoltz3f1c0462015-08-04 12:33:42 -060059
Simon Glassd36badf2016-11-07 08:47:13 -070060LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
Simon Glass2dcd4e92016-11-07 08:47:14 -070061EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
Ben Stoltz3f1c0462015-08-04 12:33:42 -060062OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
63
Simon Glass96a8d402015-08-04 12:33:56 -060064CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
65CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
66
Ben Stoltz3f1c0462015-08-04 12:33:42 -060067ifeq ($(CONFIG_EFI_APP),y)
68
69PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
70LDFLAGS_FINAL += -znocombreloc -shared
71LDSCRIPT := $(LDSCRIPT_EFI)
72
73else
74
75PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
76PLATFORM_LDFLAGS += --emit-relocs
Simon Glass3a037032017-01-16 07:04:26 -070077LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060078
79endif
Simon Glass5bd828b2016-11-07 08:47:15 -070080
Simon Glass3a037032017-01-16 07:04:26 -070081ifdef CONFIG_X86_64
82ifndef CONFIG_SPL_BUILD
83PLATFORM_CPPFLAGS += -D__x86_64__
84else
85PLATFORM_CPPFLAGS += -D__I386__
86endif
87else
88PLATFORM_CPPFLAGS += -D__I386__
89endif
90
Heinrich Schuchardt508d8562018-05-18 19:12:19 +020091ifdef CONFIG_EFI_STUB
Simon Glass5bd828b2016-11-07 08:47:15 -070092
Heinrich Schuchardt508d8562018-05-18 19:12:19 +020093ifdef CONFIG_EFI_STUB_64BIT
Simon Glass5bd828b2016-11-07 08:47:15 -070094EFI_LDS := elf_x86_64_efi.lds
95EFI_CRT0 := crt0_x86_64_efi.o
96EFI_RELOC := reloc_x86_64_efi.o
Simon Glass5bd828b2016-11-07 08:47:15 -070097else
98EFI_LDS := elf_ia32_efi.lds
99EFI_CRT0 := crt0_ia32_efi.o
100EFI_RELOC := reloc_ia32_efi.o
Heinrich Schuchardtf4cf1532018-04-06 15:36:31 +0200101endif
102
Heinrich Schuchardt508d8562018-05-18 19:12:19 +0200103else
104
105ifdef CONFIG_X86_64
106EFI_LDS := elf_x86_64_efi.lds
107EFI_CRT0 := crt0_x86_64_efi.o
108EFI_RELOC := reloc_x86_64_efi.o
109else
110EFI_LDS := elf_ia32_efi.lds
111EFI_CRT0 := crt0_ia32_efi.o
112EFI_RELOC := reloc_ia32_efi.o
113endif
114
115endif
116
Heinrich Schuchardtf4cf1532018-04-06 15:36:31 +0200117ifdef CONFIG_X86_64
Simon Glass5bd828b2016-11-07 08:47:15 -0700118EFI_TARGET := --target=efi-app-x86_64
Heinrich Schuchardtf4cf1532018-04-06 15:36:31 +0200119else
120EFI_TARGET := --target=efi-app-ia32
Simon Glass5bd828b2016-11-07 08:47:15 -0700121endif