blob: 1d50991f8d24d3b815e0ffdd1301a8405254ef50 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glass3d750d72011-09-26 14:10:39 +00002# Copyright (c) 2011 The Chromium OS Authors.
Simon Glass3d750d72011-09-26 14:10:39 +00003
Masahiro Yamada4869aee2014-07-30 14:08:23 +09004PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
Heinrich Schuchardta98850c2023-10-24 08:30:47 +02005PLATFORM_CPPFLAGS += -fPIC -ffunction-sections -fdata-sections
Matthias Weisser0d3dd142011-11-29 12:16:40 +01006PLATFORM_LIBS += -lrt
Simon Glassb6f4c1c2020-02-03 07:36:12 -07007SDL_CONFIG ?= sdl2-config
Simon Glass62cf9122013-04-26 02:53:43 +00008
Simon Glassd8e22922015-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
Tom Riniea79bb72022-11-19 18:45:43 -050011ifeq ($(CONFIG_SANDBOX_SDL),y)
Simon Glass73585b92019-05-18 11:59:47 -060012PLATFORM_LIBS += $(shell $(SDL_CONFIG) --libs)
13PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags)
Simon Glass0d10f292014-02-27 13:26:17 -070014endif
15
Andrew Scullf9a2c5e2022-05-30 10:00:05 +000016SANITIZERS :=
17ifdef CONFIG_ASAN
18SANITIZERS += -fsanitize=address
19endif
Andrew Scull2b40f802022-05-30 10:00:11 +000020ifdef CONFIG_FUZZ
21SANITIZERS += -fsanitize=fuzzer
22endif
Andrew Scullf9a2c5e2022-05-30 10:00:05 +000023KBUILD_CFLAGS += $(SANITIZERS)
24
Simon Glass66cf8f72018-11-23 21:29:30 -070025cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
Andrew Scullf9a2c5e2022-05-30 10:00:05 +000026 $(KBUILD_LDFLAGS:%=-Wl,%) \
27 $(SANITIZERS) \
28 $(LTO_FINAL_LDFLAGS) \
Marek Behúnf8726852021-05-20 13:24:02 +020029 -Wl,--whole-archive \
30 $(u-boot-main) \
Marek Behún72434932021-05-20 13:24:07 +020031 $(u-boot-keep-syms-lto) \
Marek Behúnf8726852021-05-20 13:24:02 +020032 -Wl,--no-whole-archive \
Heinrich Schuchardta98850c2023-10-24 08:30:47 +020033 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -Wl,--gc-sections
Simon Glass66c164b2014-02-26 15:59:14 -070034
Simon Glass1a3ba622016-07-04 11:57:46 -060035cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
Andrew Scullf9a2c5e2022-05-30 10:00:05 +000036 $(KBUILD_LDFLAGS:%=-Wl,%) \
37 $(SANITIZERS) \
38 $(LTO_FINAL_LDFLAGS) \
Simon Glass66cf8f72018-11-23 21:29:30 -070039 $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \
Marek Behúnf8726852021-05-20 13:24:02 +020040 -Wl,--whole-archive \
41 $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
42 $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
Marek Behún72434932021-05-20 13:24:07 +020043 $(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto)) \
Marek Behúnf8726852021-05-20 13:24:02 +020044 -Wl,--no-whole-archive \
Simon Glass1a3ba622016-07-04 11:57:46 -060045 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections)
46
Heinrich Schuchardt0f675d92019-11-07 08:05:17 +010047ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64))
48EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds
49EFI_TARGET := --target=efi-app-x86_64
50else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86))
51EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_ia32_efi.lds
52EFI_TARGET := --target=efi-app-ia32
53else ifeq ($(HOST_ARCH),$(HOST_ARCH_AARCH64))
54EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_aarch64_efi.lds
55OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
Andrew Scull5a9095c2022-05-30 10:00:04 +000056 -j __u_boot_list -j .rela.dyn -j .got -j .got.plt \
Heinrich Schuchardt0f675d92019-11-07 08:05:17 +010057 -j .binman_sym_table -j .text_rest \
58 -j .efi_runtime -j .efi_runtime_rel
59else ifeq ($(HOST_ARCH),$(HOST_ARCH_ARM))
60EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_arm_efi.lds
61OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
Andrew Scull5a9095c2022-05-30 10:00:04 +000062 -j .data -j .got -j .got.plt -j __u_boot_list -j .rel.dyn \
Heinrich Schuchardt0f675d92019-11-07 08:05:17 +010063 -j .binman_sym_table -j .text_rest \
64 -j .efi_runtime -j .efi_runtime_rel
65else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV32))
66EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv32_efi.lds
67else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV64))
68EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
69endif
70EFI_CRT0 := crt0_sandbox_efi.o
71EFI_RELOC := reloc_sandbox_efi.o
72AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
73CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"