Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 4b0730d | 2011-09-26 14:10:39 +0000 | [diff] [blame] | 2 | # Copyright (c) 2011 The Chromium OS Authors. |
Simon Glass | 4b0730d | 2011-09-26 14:10:39 +0000 | [diff] [blame] | 3 | |
Masahiro Yamada | 90f984e | 2014-07-30 14:08:23 +0900 | [diff] [blame] | 4 | PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE |
Andy Shevchenko | e599c4e7 | 2018-09-03 12:08:10 +0300 | [diff] [blame] | 5 | PLATFORM_CPPFLAGS += -fPIC |
Matthias Weisser | d99a687 | 2011-11-29 12:16:40 +0100 | [diff] [blame] | 6 | PLATFORM_LIBS += -lrt |
Simon Glass | 96d0cd4 | 2020-02-03 07:36:12 -0700 | [diff] [blame] | 7 | SDL_CONFIG ?= sdl2-config |
Simon Glass | a733b06 | 2013-04-26 02:53:43 +0000 | [diff] [blame] | 8 | |
Simon Glass | e50ab22 | 2015-02-10 18:52:35 -0700 | [diff] [blame] | 9 | # Define this to avoid linking with SDL, which requires SDL libraries |
| 10 | # This can solve 'sdl-config: Command not found' errors |
| 11 | ifneq ($(NO_SDL),) |
| 12 | PLATFORM_CPPFLAGS += -DSANDBOX_NO_SDL |
| 13 | else |
Simon Glass | e8a7b30 | 2019-05-18 11:59:47 -0600 | [diff] [blame] | 14 | PLATFORM_LIBS += $(shell $(SDL_CONFIG) --libs) |
| 15 | PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags) |
Simon Glass | bbc09bf | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 16 | endif |
| 17 | |
Andrew Scull | 1e578ed | 2022-05-30 10:00:05 +0000 | [diff] [blame] | 18 | SANITIZERS := |
| 19 | ifdef CONFIG_ASAN |
| 20 | SANITIZERS += -fsanitize=address |
| 21 | endif |
Andrew Scull | d9962b1 | 2022-05-30 10:00:11 +0000 | [diff] [blame] | 22 | ifdef CONFIG_FUZZ |
| 23 | SANITIZERS += -fsanitize=fuzzer |
| 24 | endif |
Andrew Scull | 1e578ed | 2022-05-30 10:00:05 +0000 | [diff] [blame] | 25 | KBUILD_CFLAGS += $(SANITIZERS) |
| 26 | |
Simon Glass | 40e9ede | 2018-11-23 21:29:30 -0700 | [diff] [blame] | 27 | cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \ |
Andrew Scull | 1e578ed | 2022-05-30 10:00:05 +0000 | [diff] [blame] | 28 | $(KBUILD_LDFLAGS:%=-Wl,%) \ |
| 29 | $(SANITIZERS) \ |
| 30 | $(LTO_FINAL_LDFLAGS) \ |
Marek Behún | 958f2e5 | 2021-05-20 13:24:02 +0200 | [diff] [blame] | 31 | -Wl,--whole-archive \ |
| 32 | $(u-boot-main) \ |
Marek Behún | 94bb891 | 2021-05-20 13:24:07 +0200 | [diff] [blame] | 33 | $(u-boot-keep-syms-lto) \ |
Marek Behún | 958f2e5 | 2021-05-20 13:24:02 +0200 | [diff] [blame] | 34 | -Wl,--no-whole-archive \ |
Masahiro Yamada | ad0fed4 | 2014-02-24 11:12:18 +0900 | [diff] [blame] | 35 | $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map |
Simon Glass | 714a562 | 2014-02-26 15:59:14 -0700 | [diff] [blame] | 36 | |
Simon Glass | 4cfc416 | 2016-07-04 11:57:46 -0600 | [diff] [blame] | 37 | cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \ |
Andrew Scull | 1e578ed | 2022-05-30 10:00:05 +0000 | [diff] [blame] | 38 | $(KBUILD_LDFLAGS:%=-Wl,%) \ |
| 39 | $(SANITIZERS) \ |
| 40 | $(LTO_FINAL_LDFLAGS) \ |
Simon Glass | 40e9ede | 2018-11-23 21:29:30 -0700 | [diff] [blame] | 41 | $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ |
Marek Behún | 958f2e5 | 2021-05-20 13:24:02 +0200 | [diff] [blame] | 42 | -Wl,--whole-archive \ |
| 43 | $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \ |
| 44 | $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \ |
Marek Behún | 94bb891 | 2021-05-20 13:24:07 +0200 | [diff] [blame] | 45 | $(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto)) \ |
Marek Behún | 958f2e5 | 2021-05-20 13:24:02 +0200 | [diff] [blame] | 46 | -Wl,--no-whole-archive \ |
Simon Glass | 4cfc416 | 2016-07-04 11:57:46 -0600 | [diff] [blame] | 47 | $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections) |
| 48 | |
Simon Glass | 714a562 | 2014-02-26 15:59:14 -0700 | [diff] [blame] | 49 | CONFIG_ARCH_DEVICE_TREE := sandbox |
Heinrich Schuchardt | 3b4847c | 2019-11-07 08:05:17 +0100 | [diff] [blame] | 50 | |
| 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 \ |
Andrew Scull | 99e2fbc | 2022-05-30 10:00:04 +0000 | [diff] [blame] | 60 | -j __u_boot_list -j .rela.dyn -j .got -j .got.plt \ |
Heinrich Schuchardt | 3b4847c | 2019-11-07 08:05:17 +0100 | [diff] [blame] | 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 \ |
Andrew Scull | 99e2fbc | 2022-05-30 10:00:04 +0000 | [diff] [blame] | 66 | -j .data -j .got -j .got.plt -j __u_boot_list -j .rel.dyn \ |
Heinrich Schuchardt | 3b4847c | 2019-11-07 08:05:17 +0100 | [diff] [blame] | 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 |
| 73 | endif |
| 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)" |