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
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
12 PLATFORM_CPPFLAGS += -DSANDBOX_NO_SDL
14 PLATFORM_LIBS += $(shell $(SDL_CONFIG) --libs)
15 PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags)
20 SANITIZERS += -fsanitize=address
23 SANITIZERS += -fsanitize=fuzzer
25 KBUILD_CFLAGS += $(SANITIZERS)
27 cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
28 $(KBUILD_LDFLAGS:%=-Wl,%) \
30 $(LTO_FINAL_LDFLAGS) \
33 $(u-boot-keep-syms-lto) \
34 -Wl,--no-whole-archive \
35 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map
37 cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
38 $(KBUILD_LDFLAGS:%=-Wl,%) \
40 $(LTO_FINAL_LDFLAGS) \
41 $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \
43 $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
44 $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
45 $(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto)) \
46 -Wl,--no-whole-archive \
47 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections)
49 CONFIG_ARCH_DEVICE_TREE := sandbox
51 ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64))
52 EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds
53 EFI_TARGET := --target=efi-app-x86_64
54 else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86))
55 EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_ia32_efi.lds
56 EFI_TARGET := --target=efi-app-ia32
57 else ifeq ($(HOST_ARCH),$(HOST_ARCH_AARCH64))
58 EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_aarch64_efi.lds
59 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
60 -j __u_boot_list -j .rela.dyn -j .got -j .got.plt \
61 -j .binman_sym_table -j .text_rest \
62 -j .efi_runtime -j .efi_runtime_rel
63 else ifeq ($(HOST_ARCH),$(HOST_ARCH_ARM))
64 EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_arm_efi.lds
65 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
66 -j .data -j .got -j .got.plt -j __u_boot_list -j .rel.dyn \
67 -j .binman_sym_table -j .text_rest \
68 -j .efi_runtime -j .efi_runtime_rel
69 else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV32))
70 EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv32_efi.lds
71 else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV64))
72 EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
74 EFI_CRT0 := crt0_sandbox_efi.o
75 EFI_RELOC := reloc_sandbox_efi.o
76 AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
77 CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"