blob: cc940712a8a4d632ca92bfccfd31f9b1d9d6cdff [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 += -fomit-frame-pointer
Masahiro Yamada4fad1492014-02-26 14:51:01 +09009PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
Bin Meng20358f62017-07-27 06:12:34 -070010 $(call cc-option, -fno-unit-at-a-time))
Ben Stoltzc24aae52015-08-04 12:33:42 -060011
Wolfgang Denk9209ed52011-11-01 20:54:02 +000012PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
Graeme Russ9381c8a2011-02-12 15:11:21 +110013PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Simon Glass5aa58752017-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 Galka37215b72014-06-10 16:14:56 +030024PLATFORM_CPPFLAGS += -march=i386 -m32
Simon Glass5aa58752017-01-16 07:04:26 -070025else
Bin Meng3d2a7872017-07-27 06:12:35 -070026PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
Simon Glass5aa58752017-01-16 07:04:26 -070027endif
Graeme Russ9381c8a2011-02-12 15:11:21 +110028
Alexander Graf86642972018-08-20 14:20:51 +020029PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
Graeme Russ9381c8a2011-02-12 15:11:21 +110030
Simon Glass5aa58752017-01-16 07:04:26 -070031PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
32PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
Graeme Russ9381c8a2011-02-12 15:11:21 +110033
Simon Glass63f581f2015-08-04 12:33:52 -060034# This is used in the top-level Makefile which does not include
35# PLATFORM_LDFLAGS
36LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
37
Ben Stoltzc24aae52015-08-04 12:33:42 -060038OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
39 -j .rel -j .rela -j .reloc
40
Simon Glass5aa58752017-01-16 07:04:26 -070041ifeq ($(IS_32BIT),y)
Ben Stoltzc24aae52015-08-04 12:33:42 -060042CFLAGS_NON_EFI := -mregparm=3
Simon Glass5aa58752017-01-16 07:04:26 -070043endif
Ben Stoltzc24aae52015-08-04 12:33:42 -060044CFLAGS_EFI := -fpic -fshort-wchar
45
Simon Glassce62a252015-08-04 12:33:56 -060046ifeq ($(CONFIG_EFI_STUB_64BIT),)
47CFLAGS_EFI += $(call cc-option, -mno-red-zone)
Ben Stoltzc24aae52015-08-04 12:33:42 -060048EFIARCH = ia32
Simon Glass63f581f2015-08-04 12:33:52 -060049EFIPAYLOAD_BFDTARGET = elf32-i386
Simon Glassce62a252015-08-04 12:33:56 -060050else
51EFIARCH = x86_64
52EFIPAYLOAD_BFDTARGET = elf64-x86-64
53endif
Simon Glass63f581f2015-08-04 12:33:52 -060054
55EFIPAYLOAD_BFDARCH = i386
Ben Stoltzc24aae52015-08-04 12:33:42 -060056
Simon Glassb776fc02016-11-07 08:47:13 -070057LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
Simon Glass6f4b08a2016-11-07 08:47:14 -070058EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
Ben Stoltzc24aae52015-08-04 12:33:42 -060059OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
60
Simon Glassce62a252015-08-04 12:33:56 -060061CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
62CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
63
Ben Stoltzc24aae52015-08-04 12:33:42 -060064ifeq ($(CONFIG_EFI_APP),y)
65
66PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
67LDFLAGS_FINAL += -znocombreloc -shared
68LDSCRIPT := $(LDSCRIPT_EFI)
69
70else
71
72PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
73PLATFORM_LDFLAGS += --emit-relocs
Simon Glass5aa58752017-01-16 07:04:26 -070074LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
75
76endif
Ben Stoltzc24aae52015-08-04 12:33:42 -060077
Simon Glass5aa58752017-01-16 07:04:26 -070078ifdef CONFIG_X86_64
79ifndef CONFIG_SPL_BUILD
80PLATFORM_CPPFLAGS += -D__x86_64__
81else
82PLATFORM_CPPFLAGS += -D__I386__
83endif
84else
85PLATFORM_CPPFLAGS += -D__I386__
Ben Stoltzc24aae52015-08-04 12:33:42 -060086endif
Simon Glass105c9362016-11-07 08:47:15 -070087
Heinrich Schuchardte2425b62018-05-18 19:12:19 +020088ifdef CONFIG_EFI_STUB
Simon Glass105c9362016-11-07 08:47:15 -070089
Heinrich Schuchardte2425b62018-05-18 19:12:19 +020090ifdef CONFIG_EFI_STUB_64BIT
Simon Glass105c9362016-11-07 08:47:15 -070091EFI_LDS := elf_x86_64_efi.lds
92EFI_CRT0 := crt0_x86_64_efi.o
93EFI_RELOC := reloc_x86_64_efi.o
Simon Glass105c9362016-11-07 08:47:15 -070094else
95EFI_LDS := elf_ia32_efi.lds
96EFI_CRT0 := crt0_ia32_efi.o
97EFI_RELOC := reloc_ia32_efi.o
Heinrich Schuchardt82182892018-04-06 15:36:31 +020098endif
99
Heinrich Schuchardte2425b62018-05-18 19:12:19 +0200100else
101
Heinrich Schuchardt82182892018-04-06 15:36:31 +0200102ifdef CONFIG_X86_64
Heinrich Schuchardte2425b62018-05-18 19:12:19 +0200103EFI_LDS := elf_x86_64_efi.lds
104EFI_CRT0 := crt0_x86_64_efi.o
105EFI_RELOC := reloc_x86_64_efi.o
Heinrich Schuchardt82182892018-04-06 15:36:31 +0200106else
Heinrich Schuchardte2425b62018-05-18 19:12:19 +0200107EFI_LDS := elf_ia32_efi.lds
108EFI_CRT0 := crt0_ia32_efi.o
109EFI_RELOC := reloc_ia32_efi.o
110endif
111
Simon Glass105c9362016-11-07 08:47:15 -0700112endif
113
Heinrich Schuchardte2425b62018-05-18 19:12:19 +0200114ifdef CONFIG_X86_64
115EFI_TARGET := --target=efi-app-x86_64
116else
117EFI_TARGET := --target=efi-app-ia32
Simon Glass105c9362016-11-07 08:47:15 -0700118endif