blob: 74b87ceac54b646fa17bfd34b50b5cf3defb67a6 [file] [log] [blame]
wdenk591dda52002-11-18 00:14:45 +00001#
2# (C) Copyright 2000-2002
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
wdenk591dda52002-11-18 00:14:45 +00006#
7
Wolfgang Denk33a57342011-02-04 14:25:17 +01008CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
Mike Frysinger5b660442009-09-03 23:12:47 -04009
Graeme Russbed10fa2010-10-07 20:03:23 +110010PLATFORM_CPPFLAGS += -fno-strict-aliasing
Graeme Russbed10fa2010-10-07 20:03:23 +110011PLATFORM_CPPFLAGS += -fomit-frame-pointer
Masahiro Yamada4fad1492014-02-26 14:51:01 +090012PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
Wolfgang Denk9209ed52011-11-01 20:54:02 +000013 $(call cc-option, -fno-unit-at-a-time)) \
Wolfgang Denk9209ed52011-11-01 20:54:02 +000014 $(call cc-option, -mpreferred-stack-boundary=2)
Ben Stoltzc24aae52015-08-04 12:33:42 -060015
Wolfgang Denk9209ed52011-11-01 20:54:02 +000016PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
Graeme Russ9381c8a2011-02-12 15:11:21 +110017PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Simon Glass5aa58752017-01-16 07:04:26 -070018
19ifdef CONFIG_SPL_BUILD
20IS_32BIT := y
21else
22ifndef CONFIG_X86_64
23IS_32BIT := y
24endif
25endif
26
27ifeq ($(IS_32BIT),y)
Vasili Galka37215b72014-06-10 16:14:56 +030028PLATFORM_CPPFLAGS += -march=i386 -m32
Simon Glass5aa58752017-01-16 07:04:26 -070029else
30PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common
31endif
Graeme Russ9381c8a2011-02-12 15:11:21 +110032
33PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
34
Simon Glass5aa58752017-01-16 07:04:26 -070035PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
36PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
Graeme Russ9381c8a2011-02-12 15:11:21 +110037
Gabe Black1662cf12011-11-16 23:01:37 +000038LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
39LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
Ben Stoltzc24aae52015-08-04 12:33:42 -060040
Simon Glass63f581f2015-08-04 12:33:52 -060041# This is used in the top-level Makefile which does not include
42# PLATFORM_LDFLAGS
43LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
44
Ben Stoltzc24aae52015-08-04 12:33:42 -060045OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
46 -j .rel -j .rela -j .reloc
47
Simon Glass5aa58752017-01-16 07:04:26 -070048ifeq ($(IS_32BIT),y)
Ben Stoltzc24aae52015-08-04 12:33:42 -060049CFLAGS_NON_EFI := -mregparm=3
Simon Glass5aa58752017-01-16 07:04:26 -070050endif
Ben Stoltzc24aae52015-08-04 12:33:42 -060051CFLAGS_EFI := -fpic -fshort-wchar
52
Simon Glassce62a252015-08-04 12:33:56 -060053ifeq ($(CONFIG_EFI_STUB_64BIT),)
54CFLAGS_EFI += $(call cc-option, -mno-red-zone)
Ben Stoltzc24aae52015-08-04 12:33:42 -060055EFIARCH = ia32
Simon Glass63f581f2015-08-04 12:33:52 -060056EFIPAYLOAD_BFDTARGET = elf32-i386
Simon Glassce62a252015-08-04 12:33:56 -060057else
58EFIARCH = x86_64
59EFIPAYLOAD_BFDTARGET = elf64-x86-64
60endif
Simon Glass63f581f2015-08-04 12:33:52 -060061
62EFIPAYLOAD_BFDARCH = i386
Ben Stoltzc24aae52015-08-04 12:33:42 -060063
Simon Glassb776fc02016-11-07 08:47:13 -070064LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
Simon Glass6f4b08a2016-11-07 08:47:14 -070065EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
Ben Stoltzc24aae52015-08-04 12:33:42 -060066OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
67
Simon Glassce62a252015-08-04 12:33:56 -060068CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
69CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
70
Ben Stoltzc24aae52015-08-04 12:33:42 -060071ifeq ($(CONFIG_EFI_APP),y)
72
73PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
74LDFLAGS_FINAL += -znocombreloc -shared
75LDSCRIPT := $(LDSCRIPT_EFI)
76
77else
78
79PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
80PLATFORM_LDFLAGS += --emit-relocs
Simon Glass5aa58752017-01-16 07:04:26 -070081LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
82
83endif
Ben Stoltzc24aae52015-08-04 12:33:42 -060084
Simon Glass5aa58752017-01-16 07:04:26 -070085ifdef CONFIG_X86_64
86ifndef CONFIG_SPL_BUILD
87PLATFORM_CPPFLAGS += -D__x86_64__
88else
89PLATFORM_CPPFLAGS += -D__I386__
90endif
91else
92PLATFORM_CPPFLAGS += -D__I386__
Ben Stoltzc24aae52015-08-04 12:33:42 -060093endif
Simon Glass105c9362016-11-07 08:47:15 -070094
Alexander Grafb5483512016-11-17 22:40:10 +010095ifneq ($(CONFIG_EFI_STUB)$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
Simon Glass105c9362016-11-07 08:47:15 -070096
97ifneq ($(CONFIG_EFI_STUB_64BIT),)
98EFI_LDS := elf_x86_64_efi.lds
99EFI_CRT0 := crt0_x86_64_efi.o
100EFI_RELOC := reloc_x86_64_efi.o
101EFI_TARGET := --target=efi-app-ia32
102else
103EFI_LDS := elf_ia32_efi.lds
104EFI_CRT0 := crt0_ia32_efi.o
105EFI_RELOC := reloc_ia32_efi.o
106EFI_TARGET := --target=efi-app-x86_64
107endif
108
109endif