blob: d7addd872866a7e752ae2be4856157fe5bd9242c [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
Vasili Galka37215b72014-06-10 16:14:56 +030018PLATFORM_CPPFLAGS += -march=i386 -m32
Graeme Russ9381c8a2011-02-12 15:11:21 +110019
20PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
21
Ben Stoltzc24aae52015-08-04 12:33:42 -060022PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions -m elf_i386
Graeme Russ9381c8a2011-02-12 15:11:21 +110023
Gabe Black1662cf12011-11-16 23:01:37 +000024LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
25LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
Ben Stoltzc24aae52015-08-04 12:33:42 -060026
Simon Glass63f581f2015-08-04 12:33:52 -060027# This is used in the top-level Makefile which does not include
28# PLATFORM_LDFLAGS
29LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
30
Ben Stoltzc24aae52015-08-04 12:33:42 -060031OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
32 -j .rel -j .rela -j .reloc
33
34CFLAGS_NON_EFI := -mregparm=3
35CFLAGS_EFI := -fpic -fshort-wchar
36
Simon Glassce62a252015-08-04 12:33:56 -060037ifeq ($(CONFIG_EFI_STUB_64BIT),)
38CFLAGS_EFI += $(call cc-option, -mno-red-zone)
Ben Stoltzc24aae52015-08-04 12:33:42 -060039EFIARCH = ia32
Simon Glass63f581f2015-08-04 12:33:52 -060040EFIPAYLOAD_BFDTARGET = elf32-i386
Simon Glassce62a252015-08-04 12:33:56 -060041else
42EFIARCH = x86_64
43EFIPAYLOAD_BFDTARGET = elf64-x86-64
44endif
Simon Glass63f581f2015-08-04 12:33:52 -060045
46EFIPAYLOAD_BFDARCH = i386
Ben Stoltzc24aae52015-08-04 12:33:42 -060047
48LDSCRIPT_EFI := $(srctree)/$(CPUDIR)/efi/elf_$(EFIARCH)_efi.lds
Simon Glassce62a252015-08-04 12:33:56 -060049EFISTUB := crt0-efi-$(EFIARCH).o reloc_$(EFIARCH).o
Ben Stoltzc24aae52015-08-04 12:33:42 -060050OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
51
Simon Glassce62a252015-08-04 12:33:56 -060052CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
53CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
54
Ben Stoltzc24aae52015-08-04 12:33:42 -060055ifeq ($(CONFIG_EFI_APP),y)
56
57PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
58LDFLAGS_FINAL += -znocombreloc -shared
59LDSCRIPT := $(LDSCRIPT_EFI)
60
61else
62
63PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
64PLATFORM_LDFLAGS += --emit-relocs
65LDFLAGS_FINAL += --gc-sections -pie
66
67endif