blob: 410603252ee0396e1bf1364668ffc12cc6c01ecd [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glass4b0730d2011-09-26 14:10:39 +00002# Copyright (c) 2011 The Chromium OS Authors.
Simon Glass4b0730d2011-09-26 14:10:39 +00003
Masahiro Yamada90f984e2014-07-30 14:08:23 +09004PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
Andy Shevchenkoe599c4e72018-09-03 12:08:10 +03005PLATFORM_CPPFLAGS += -fPIC
Matthias Weisserd99a6872011-11-29 12:16:40 +01006PLATFORM_LIBS += -lrt
Simon Glass96d0cd42020-02-03 07:36:12 -07007SDL_CONFIG ?= sdl2-config
Simon Glassa733b062013-04-26 02:53:43 +00008
Simon Glasse50ab222015-02-10 18:52:35 -07009# Define this to avoid linking with SDL, which requires SDL libraries
10# This can solve 'sdl-config: Command not found' errors
11ifneq ($(NO_SDL),)
12PLATFORM_CPPFLAGS += -DSANDBOX_NO_SDL
13else
Simon Glasse8a7b302019-05-18 11:59:47 -060014PLATFORM_LIBS += $(shell $(SDL_CONFIG) --libs)
15PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags)
Simon Glassbbc09bf2014-02-27 13:26:17 -070016endif
17
Andrew Scull1e578ed2022-05-30 10:00:05 +000018SANITIZERS :=
19ifdef CONFIG_ASAN
20SANITIZERS += -fsanitize=address
21endif
22KBUILD_CFLAGS += $(SANITIZERS)
23
Simon Glass40e9ede2018-11-23 21:29:30 -070024cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
Andrew Scull1e578ed2022-05-30 10:00:05 +000025 $(KBUILD_LDFLAGS:%=-Wl,%) \
26 $(SANITIZERS) \
27 $(LTO_FINAL_LDFLAGS) \
Marek Behún958f2e52021-05-20 13:24:02 +020028 -Wl,--whole-archive \
29 $(u-boot-main) \
Marek Behún94bb8912021-05-20 13:24:07 +020030 $(u-boot-keep-syms-lto) \
Marek Behún958f2e52021-05-20 13:24:02 +020031 -Wl,--no-whole-archive \
Masahiro Yamadaad0fed42014-02-24 11:12:18 +090032 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map
Simon Glass714a5622014-02-26 15:59:14 -070033
Simon Glass4cfc4162016-07-04 11:57:46 -060034cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
Andrew Scull1e578ed2022-05-30 10:00:05 +000035 $(KBUILD_LDFLAGS:%=-Wl,%) \
36 $(SANITIZERS) \
37 $(LTO_FINAL_LDFLAGS) \
Simon Glass40e9ede2018-11-23 21:29:30 -070038 $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \
Marek Behún958f2e52021-05-20 13:24:02 +020039 -Wl,--whole-archive \
40 $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
41 $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
Marek Behún94bb8912021-05-20 13:24:07 +020042 $(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto)) \
Marek Behún958f2e52021-05-20 13:24:02 +020043 -Wl,--no-whole-archive \
Simon Glass4cfc4162016-07-04 11:57:46 -060044 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections)
45
Simon Glass714a5622014-02-26 15:59:14 -070046CONFIG_ARCH_DEVICE_TREE := sandbox
Heinrich Schuchardt3b4847c2019-11-07 08:05:17 +010047
48ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64))
49EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds
50EFI_TARGET := --target=efi-app-x86_64
51else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86))
52EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_ia32_efi.lds
53EFI_TARGET := --target=efi-app-ia32
54else ifeq ($(HOST_ARCH),$(HOST_ARCH_AARCH64))
55EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_aarch64_efi.lds
56OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
Andrew Scull99e2fbc2022-05-30 10:00:04 +000057 -j __u_boot_list -j .rela.dyn -j .got -j .got.plt \
Heinrich Schuchardt3b4847c2019-11-07 08:05:17 +010058 -j .binman_sym_table -j .text_rest \
59 -j .efi_runtime -j .efi_runtime_rel
60else ifeq ($(HOST_ARCH),$(HOST_ARCH_ARM))
61EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_arm_efi.lds
62OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
Andrew Scull99e2fbc2022-05-30 10:00:04 +000063 -j .data -j .got -j .got.plt -j __u_boot_list -j .rel.dyn \
Heinrich Schuchardt3b4847c2019-11-07 08:05:17 +010064 -j .binman_sym_table -j .text_rest \
65 -j .efi_runtime -j .efi_runtime_rel
66else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV32))
67EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv32_efi.lds
68else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV64))
69EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
70endif
71EFI_CRT0 := crt0_sandbox_efi.o
72EFI_RELOC := reloc_sandbox_efi.o
73AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
74CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"