blob: 5f77f98e60a453676058a9726c0e357243b41689 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
wdenk591dda52002-11-18 00:14:45 +00002#
3# (C) Copyright 2000-2002
4# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenk591dda52002-11-18 00:14:45 +00005
Wolfgang Denk33a57342011-02-04 14:25:17 +01006CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
Mike Frysinger5b660442009-09-03 23:12:47 -04007
Graeme Russbed10fa2010-10-07 20:03:23 +11008PLATFORM_CPPFLAGS += -fno-strict-aliasing
Graeme Russbed10fa2010-10-07 20:03:23 +11009PLATFORM_CPPFLAGS += -fomit-frame-pointer
Masahiro Yamada4fad1492014-02-26 14:51:01 +090010PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
Bin Meng20358f62017-07-27 06:12:34 -070011 $(call cc-option, -fno-unit-at-a-time))
Ben Stoltzc24aae52015-08-04 12:33:42 -060012
Wolfgang Denk9209ed52011-11-01 20:54:02 +000013PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
Graeme Russ9381c8a2011-02-12 15:11:21 +110014PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Simon Glass5aa58752017-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 Galka37215b72014-06-10 16:14:56 +030025PLATFORM_CPPFLAGS += -march=i386 -m32
Simon Glass5aa58752017-01-16 07:04:26 -070026else
Bin Meng3d2a7872017-07-27 06:12:35 -070027PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
Simon Glass5aa58752017-01-16 07:04:26 -070028endif
Graeme Russ9381c8a2011-02-12 15:11:21 +110029
30PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
31
Simon Glass5aa58752017-01-16 07:04:26 -070032PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
33PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
Graeme Russ9381c8a2011-02-12 15:11:21 +110034
Simon Glass63f581f2015-08-04 12:33:52 -060035# This is used in the top-level Makefile which does not include
36# PLATFORM_LDFLAGS
37LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
38
Ben Stoltzc24aae52015-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 Glass5aa58752017-01-16 07:04:26 -070042ifeq ($(IS_32BIT),y)
Ben Stoltzc24aae52015-08-04 12:33:42 -060043CFLAGS_NON_EFI := -mregparm=3
Simon Glass5aa58752017-01-16 07:04:26 -070044endif
Ben Stoltzc24aae52015-08-04 12:33:42 -060045CFLAGS_EFI := -fpic -fshort-wchar
46
Simon Glassce62a252015-08-04 12:33:56 -060047ifeq ($(CONFIG_EFI_STUB_64BIT),)
48CFLAGS_EFI += $(call cc-option, -mno-red-zone)
Ben Stoltzc24aae52015-08-04 12:33:42 -060049EFIARCH = ia32
Simon Glass63f581f2015-08-04 12:33:52 -060050EFIPAYLOAD_BFDTARGET = elf32-i386
Simon Glassce62a252015-08-04 12:33:56 -060051else
52EFIARCH = x86_64
53EFIPAYLOAD_BFDTARGET = elf64-x86-64
54endif
Simon Glass63f581f2015-08-04 12:33:52 -060055
56EFIPAYLOAD_BFDARCH = i386
Ben Stoltzc24aae52015-08-04 12:33:42 -060057
Simon Glassb776fc02016-11-07 08:47:13 -070058LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
Simon Glass6f4b08a2016-11-07 08:47:14 -070059EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
Ben Stoltzc24aae52015-08-04 12:33:42 -060060OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
61
Simon Glassce62a252015-08-04 12:33:56 -060062CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
63CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
64
Ben Stoltzc24aae52015-08-04 12:33:42 -060065ifeq ($(CONFIG_EFI_APP),y)
66
67PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
68LDFLAGS_FINAL += -znocombreloc -shared
69LDSCRIPT := $(LDSCRIPT_EFI)
70
71else
72
73PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
74PLATFORM_LDFLAGS += --emit-relocs
Simon Glass5aa58752017-01-16 07:04:26 -070075LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
76
77endif
Ben Stoltzc24aae52015-08-04 12:33:42 -060078
Simon Glass5aa58752017-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__
Ben Stoltzc24aae52015-08-04 12:33:42 -060087endif
Simon Glass105c9362016-11-07 08:47:15 -070088
Heinrich Schuchardte2425b62018-05-18 19:12:19 +020089ifdef CONFIG_EFI_STUB
Simon Glass105c9362016-11-07 08:47:15 -070090
Heinrich Schuchardte2425b62018-05-18 19:12:19 +020091ifdef CONFIG_EFI_STUB_64BIT
Simon Glass105c9362016-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 Glass105c9362016-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 Schuchardt82182892018-04-06 15:36:31 +020099endif
100
Heinrich Schuchardte2425b62018-05-18 19:12:19 +0200101else
102
Heinrich Schuchardt82182892018-04-06 15:36:31 +0200103ifdef CONFIG_X86_64
Heinrich Schuchardte2425b62018-05-18 19:12:19 +0200104EFI_LDS := elf_x86_64_efi.lds
105EFI_CRT0 := crt0_x86_64_efi.o
106EFI_RELOC := reloc_x86_64_efi.o
Heinrich Schuchardt82182892018-04-06 15:36:31 +0200107else
Heinrich Schuchardte2425b62018-05-18 19:12:19 +0200108EFI_LDS := elf_ia32_efi.lds
109EFI_CRT0 := crt0_ia32_efi.o
110EFI_RELOC := reloc_ia32_efi.o
111endif
112
Simon Glass105c9362016-11-07 08:47:15 -0700113endif
114
Heinrich Schuchardte2425b62018-05-18 19:12:19 +0200115ifdef CONFIG_X86_64
116EFI_TARGET := --target=efi-app-x86_64
117else
118EFI_TARGET := --target=efi-app-ia32
Simon Glass105c9362016-11-07 08:47:15 -0700119endif