1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2011 The Chromium OS Authors.
4 PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
5 PLATFORM_CPPFLAGS += -fPIC -ffunction-sections -fdata-sections
7 SDL_CONFIG ?= sdl2-config
9 # Define this to avoid linking with SDL, which requires SDL libraries
10 # This can solve 'sdl-config: Command not found' errors
11 ifeq ($(CONFIG_SANDBOX_SDL),y)
12 PLATFORM_LIBS += $(shell $(SDL_CONFIG) --libs)
13 PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags)
18 SANITIZERS += -fsanitize=address
21 SANITIZERS += -fsanitize=fuzzer
23 KBUILD_CFLAGS += $(SANITIZERS)
25 cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
26 $(KBUILD_LDFLAGS:%=-Wl,%) \
28 $(LTO_FINAL_LDFLAGS) \
31 $(u-boot-keep-syms-lto) \
32 -Wl,--no-whole-archive \
33 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -Wl,--gc-sections
35 cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
36 $(KBUILD_LDFLAGS:%=-Wl,%) \
38 $(LTO_FINAL_LDFLAGS) \
39 $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \
41 $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
42 $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
43 $(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto)) \
44 -Wl,--no-whole-archive \
45 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections)
47 ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64))
48 EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds
49 EFI_TARGET := --target=efi-app-x86_64
50 else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86))
51 EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_ia32_efi.lds
52 EFI_TARGET := --target=efi-app-ia32
53 else ifeq ($(HOST_ARCH),$(HOST_ARCH_AARCH64))
54 EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_aarch64_efi.lds
55 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
56 -j __u_boot_list -j .rela.dyn -j .got -j .got.plt \
57 -j .binman_sym_table -j .text_rest \
58 -j .efi_runtime -j .efi_runtime_rel
59 else ifeq ($(HOST_ARCH),$(HOST_ARCH_ARM))
60 EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_arm_efi.lds
61 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
62 -j .data -j .got -j .got.plt -j __u_boot_list -j .rel.dyn \
63 -j .binman_sym_table -j .text_rest \
64 -j .efi_runtime -j .efi_runtime_rel
65 else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV32))
66 EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv32_efi.lds
67 else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV64))
68 EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
70 EFI_CRT0 := crt0_sandbox_efi.o
71 EFI_RELOC := reloc_sandbox_efi.o