xref: /openbmc/u-boot/arch/x86/config.mk (revision fb1b7712)
1# SPDX-License-Identifier: GPL-2.0+
2#
3# (C) Copyright 2000-2002
4# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5
6CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
7
8PLATFORM_CPPFLAGS += -fomit-frame-pointer
9PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
10		     $(call cc-option, -fno-unit-at-a-time))
11
12PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
13PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
14
15ifdef CONFIG_SPL_BUILD
16IS_32BIT := y
17else
18ifndef CONFIG_X86_64
19IS_32BIT := y
20endif
21endif
22
23ifeq ($(IS_32BIT),y)
24PLATFORM_CPPFLAGS += -march=i386 -m32
25else
26PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64
27PLATFORM_CPPFLAGS += -mno-mmx -mno-sse
28endif
29
30PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
31
32PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
33PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
34
35# This is used in the top-level Makefile which does not include
36# PLATFORM_LDFLAGS
37LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined -s
38
39OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
40	-j .rel -j .rela -j .reloc
41
42ifeq ($(IS_32BIT),y)
43CFLAGS_NON_EFI := -mregparm=3
44endif
45CFLAGS_EFI := -fpic -fshort-wchar
46
47ifeq ($(CONFIG_EFI_STUB_64BIT),)
48CFLAGS_EFI += $(call cc-option, -mno-red-zone)
49EFIARCH = ia32
50EFIPAYLOAD_BFDTARGET = elf32-i386
51else
52EFIARCH = x86_64
53EFIPAYLOAD_BFDTARGET = elf64-x86-64
54endif
55
56EFIPAYLOAD_BFDARCH = i386
57
58LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
59EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
60OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
61
62CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
63CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
64
65ifeq ($(CONFIG_EFI_APP),y)
66
67PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
68LDFLAGS_FINAL += -znocombreloc -shared -s
69LDSCRIPT := $(LDSCRIPT_EFI)
70
71else
72
73PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
74PLATFORM_LDFLAGS += --emit-relocs
75LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
76
77endif
78
79ifdef 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
89ifdef CONFIG_EFI_STUB
90
91ifdef CONFIG_EFI_STUB_64BIT
92EFI_LDS := elf_x86_64_efi.lds
93EFI_CRT0 := crt0_x86_64_efi.o
94EFI_RELOC := reloc_x86_64_efi.o
95else
96EFI_LDS := elf_ia32_efi.lds
97EFI_CRT0 := crt0_ia32_efi.o
98EFI_RELOC := reloc_ia32_efi.o
99endif
100
101else
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
115ifdef CONFIG_X86_64
116EFI_TARGET := --target=efi-app-x86_64
117else
118EFI_TARGET := --target=efi-app-ia32
119endif
120