blob: 27d8412661ff8ba4ed7efa32f9ea04785c157722 [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 += -fomit-frame-pointer
Masahiro Yamadaf6941832014-02-26 14:51:01 +09009PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
Bin Meng9a95f512017-07-27 06:12:34 -070010 $(call cc-option, -fno-unit-at-a-time))
Ben Stoltz3f1c0462015-08-04 12:33:42 -060011
Wolfgang Denkcca4e4a2011-11-01 20:54:02 +000012PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
Graeme Russa85f53c2011-02-12 15:11:21 +110013PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Simon Glass3a037032017-01-16 07:04:26 -070014
15ifdef CONFIG_SPL_BUILD
16IS_32BIT := y
17else
18ifndef CONFIG_X86_64
19IS_32BIT := y
20endif
21endif
22
23ifeq ($(IS_32BIT),y)
Vasili Galkadbb72342014-06-10 16:14:56 +030024PLATFORM_CPPFLAGS += -march=i386 -m32
Simon Glass3a037032017-01-16 07:04:26 -070025else
Bin Menga139cc12018-10-13 20:52:01 -070026PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64
Bin Mengdd4611d2018-10-13 20:52:02 -070027PLATFORM_CPPFLAGS += -mno-mmx -mno-sse
Simon Glass3a037032017-01-16 07:04:26 -070028endif
Graeme Russd664adb2010-10-07 20:03:20 +110029
Alexander Graf1acbd0e2018-08-20 14:20:51 +020030PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
Graeme Russa85f53c2011-02-12 15:11:21 +110031
Tom Rini587e4a42020-03-27 11:46:27 -040032KBUILD_LDFLAGS += -Bsymbolic -Bsymbolic-functions
33KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
Graeme Russa85f53c2011-02-12 15:11:21 +110034
Simon Glass476476e2015-08-04 12:33:52 -060035# This is used in the top-level Makefile which does not include
Tom Rini587e4a42020-03-27 11:46:27 -040036# KBUILD_LDFLAGS
Bin Meng972ffcd2018-10-02 07:39:30 -070037LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined -s
Simon Glass476476e2015-08-04 12:33:52 -060038
Ben Stoltz3f1c0462015-08-04 12:33:42 -060039OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
40 -j .rel -j .rela -j .reloc
41
Simon Glass3a037032017-01-16 07:04:26 -070042ifeq ($(IS_32BIT),y)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060043CFLAGS_NON_EFI := -mregparm=3
Simon Glass3a037032017-01-16 07:04:26 -070044endif
Ben Stoltz3f1c0462015-08-04 12:33:42 -060045CFLAGS_EFI := -fpic -fshort-wchar
46
Simon Glass96a8d402015-08-04 12:33:56 -060047ifeq ($(CONFIG_EFI_STUB_64BIT),)
48CFLAGS_EFI += $(call cc-option, -mno-red-zone)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060049EFIARCH = ia32
Simon Glass476476e2015-08-04 12:33:52 -060050EFIPAYLOAD_BFDTARGET = elf32-i386
Simon Glass96a8d402015-08-04 12:33:56 -060051else
52EFIARCH = x86_64
53EFIPAYLOAD_BFDTARGET = elf64-x86-64
54endif
Simon Glass476476e2015-08-04 12:33:52 -060055
56EFIPAYLOAD_BFDARCH = i386
Ben Stoltz3f1c0462015-08-04 12:33:42 -060057
Simon Glassd36badf2016-11-07 08:47:13 -070058LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
Simon Glass2dcd4e92016-11-07 08:47:14 -070059EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
Ben Stoltz3f1c0462015-08-04 12:33:42 -060060OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
61
Simon Glass96a8d402015-08-04 12:33:56 -060062CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
63CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
64
Ben Stoltz3f1c0462015-08-04 12:33:42 -060065ifeq ($(CONFIG_EFI_APP),y)
66
67PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
Bin Mengc54ed3e2018-10-02 07:39:31 -070068LDFLAGS_FINAL += -znocombreloc -shared -s
Ben Stoltz3f1c0462015-08-04 12:33:42 -060069LDSCRIPT := $(LDSCRIPT_EFI)
70
71else
72
73PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
Tom Rini587e4a42020-03-27 11:46:27 -040074KBUILD_LDFLAGS += --emit-relocs
Simon Glass3a037032017-01-16 07:04:26 -070075LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
Ben Stoltz3f1c0462015-08-04 12:33:42 -060076
77endif
Simon Glass5bd828b2016-11-07 08:47:15 -070078
Simon Glass3a037032017-01-16 07:04:26 -070079ifdef CONFIG_X86_64
80ifndef CONFIG_SPL_BUILD
81PLATFORM_CPPFLAGS += -D__x86_64__
82else
83PLATFORM_CPPFLAGS += -D__I386__
84endif
85else
86PLATFORM_CPPFLAGS += -D__I386__
87endif
88
Heinrich Schuchardt508d8562018-05-18 19:12:19 +020089ifdef CONFIG_EFI_STUB
Simon Glass5bd828b2016-11-07 08:47:15 -070090
Heinrich Schuchardt508d8562018-05-18 19:12:19 +020091ifdef CONFIG_EFI_STUB_64BIT
Simon Glass5bd828b2016-11-07 08:47:15 -070092EFI_LDS := elf_x86_64_efi.lds
93EFI_CRT0 := crt0_x86_64_efi.o
94EFI_RELOC := reloc_x86_64_efi.o
Simon Glass5bd828b2016-11-07 08:47:15 -070095else
96EFI_LDS := elf_ia32_efi.lds
97EFI_CRT0 := crt0_ia32_efi.o
98EFI_RELOC := reloc_ia32_efi.o
Heinrich Schuchardtf4cf1532018-04-06 15:36:31 +020099endif
100
Heinrich Schuchardt508d8562018-05-18 19:12:19 +0200101else
102
103ifdef CONFIG_X86_64
104EFI_LDS := elf_x86_64_efi.lds
105EFI_CRT0 := crt0_x86_64_efi.o
106EFI_RELOC := reloc_x86_64_efi.o
107else
108EFI_LDS := elf_ia32_efi.lds
109EFI_CRT0 := crt0_ia32_efi.o
110EFI_RELOC := reloc_ia32_efi.o
111endif
112
113endif
114
Heinrich Schuchardtf4cf1532018-04-06 15:36:31 +0200115ifdef CONFIG_X86_64
Simon Glass5bd828b2016-11-07 08:47:15 -0700116EFI_TARGET := --target=efi-app-x86_64
Heinrich Schuchardtf4cf1532018-04-06 15:36:31 +0200117else
118EFI_TARGET := --target=efi-app-ia32
Simon Glass5bd828b2016-11-07 08:47:15 -0700119endif