]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | # SPDX-License-Identifier: GPL-2.0+ |
2262cfee WD |
2 | # |
3 | # (C) Copyright 2000-2002 | |
4 | # Wolfgang Denk, DENX Software Engineering, [email protected]. | |
2262cfee | 5 | |
8ae86b76 | 6 | CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000 |
262ae0a6 | 7 | |
5c161653 | 8 | PLATFORM_CPPFLAGS += -fomit-frame-pointer |
f694183b | 9 | PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \ |
9a95f51f | 10 | $(call cc-option, -fno-unit-at-a-time)) |
3f1c046c | 11 | |
cca4e4ae | 12 | PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86) |
a85f53cd | 13 | PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm |
3a03703a SG |
14 | |
15 | ifdef CONFIG_SPL_BUILD | |
16 | IS_32BIT := y | |
17 | else | |
18 | ifndef CONFIG_X86_64 | |
19 | IS_32BIT := y | |
20 | endif | |
21 | endif | |
22 | ||
23 | ifeq ($(IS_32BIT),y) | |
dbb7234b | 24 | PLATFORM_CPPFLAGS += -march=i386 -m32 |
3a03703a | 25 | else |
a139cc18 | 26 | PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64 |
dd4611de | 27 | PLATFORM_CPPFLAGS += -mno-mmx -mno-sse |
3a03703a | 28 | endif |
a85f53cd | 29 | |
1acbd0ea | 30 | PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden |
a85f53cd | 31 | |
587e4a42 TR |
32 | KBUILD_LDFLAGS += -Bsymbolic -Bsymbolic-functions |
33 | KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64) | |
a85f53cd | 34 | |
476476e7 | 35 | # This is used in the top-level Makefile which does not include |
587e4a42 | 36 | # KBUILD_LDFLAGS |
972ffcd7 | 37 | LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined -s |
476476e7 | 38 | |
3f1c046c BS |
39 | OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ |
40 | -j .rel -j .rela -j .reloc | |
41 | ||
3a03703a | 42 | ifeq ($(IS_32BIT),y) |
3f1c046c | 43 | CFLAGS_NON_EFI := -mregparm=3 |
3a03703a | 44 | endif |
3f1c046c BS |
45 | CFLAGS_EFI := -fpic -fshort-wchar |
46 | ||
96a8d409 SG |
47 | ifeq ($(CONFIG_EFI_STUB_64BIT),) |
48 | CFLAGS_EFI += $(call cc-option, -mno-red-zone) | |
3f1c046c | 49 | EFIARCH = ia32 |
476476e7 | 50 | EFIPAYLOAD_BFDTARGET = elf32-i386 |
96a8d409 SG |
51 | else |
52 | EFIARCH = x86_64 | |
53 | EFIPAYLOAD_BFDTARGET = elf64-x86-64 | |
54 | endif | |
476476e7 SG |
55 | |
56 | EFIPAYLOAD_BFDARCH = i386 | |
3f1c046c | 57 | |
d36badfd | 58 | LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds |
2dcd4e9e | 59 | EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o |
3f1c046c BS |
60 | OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH) |
61 | ||
96a8d409 SG |
62 | CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI) |
63 | CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI) | |
64 | ||
3f1c046c BS |
65 | ifeq ($(CONFIG_EFI_APP),y) |
66 | ||
67 | PLATFORM_CPPFLAGS += $(CFLAGS_EFI) | |
c54ed3ef | 68 | LDFLAGS_FINAL += -znocombreloc -shared -s |
3f1c046c BS |
69 | LDSCRIPT := $(LDSCRIPT_EFI) |
70 | ||
71 | else | |
72 | ||
73 | PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI) | |
587e4a42 | 74 | KBUILD_LDFLAGS += --emit-relocs |
3a03703a SG |
75 | LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie) |
76 | ||
77 | endif | |
3f1c046c | 78 | |
3a03703a SG |
79 | ifdef CONFIG_X86_64 |
80 | ifndef CONFIG_SPL_BUILD | |
81 | PLATFORM_CPPFLAGS += -D__x86_64__ | |
82 | else | |
83 | PLATFORM_CPPFLAGS += -D__I386__ | |
84 | endif | |
85 | else | |
86 | PLATFORM_CPPFLAGS += -D__I386__ | |
3f1c046c | 87 | endif |
5bd828b5 | 88 | |
508d8567 | 89 | ifdef CONFIG_EFI_STUB |
5bd828b5 | 90 | |
508d8567 | 91 | ifdef CONFIG_EFI_STUB_64BIT |
5bd828b5 SG |
92 | EFI_LDS := elf_x86_64_efi.lds |
93 | EFI_CRT0 := crt0_x86_64_efi.o | |
94 | EFI_RELOC := reloc_x86_64_efi.o | |
5bd828b5 SG |
95 | else |
96 | EFI_LDS := elf_ia32_efi.lds | |
97 | EFI_CRT0 := crt0_ia32_efi.o | |
98 | EFI_RELOC := reloc_ia32_efi.o | |
f4cf153a HS |
99 | endif |
100 | ||
508d8567 HS |
101 | else |
102 | ||
f4cf153a | 103 | ifdef CONFIG_X86_64 |
508d8567 HS |
104 | EFI_LDS := elf_x86_64_efi.lds |
105 | EFI_CRT0 := crt0_x86_64_efi.o | |
106 | EFI_RELOC := reloc_x86_64_efi.o | |
f4cf153a | 107 | else |
508d8567 HS |
108 | EFI_LDS := elf_ia32_efi.lds |
109 | EFI_CRT0 := crt0_ia32_efi.o | |
110 | EFI_RELOC := reloc_ia32_efi.o | |
111 | endif | |
112 | ||
5bd828b5 SG |
113 | endif |
114 | ||
508d8567 HS |
115 | ifdef CONFIG_X86_64 |
116 | EFI_TARGET := --target=efi-app-x86_64 | |
117 | else | |
118 | EFI_TARGET := --target=efi-app-ia32 | |
5bd828b5 | 119 | endif |