Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 3d750d7 | 2011-09-26 14:10:39 +0000 | [diff] [blame] | 2 | # Copyright (c) 2011 The Chromium OS Authors. |
Simon Glass | 3d750d7 | 2011-09-26 14:10:39 +0000 | [diff] [blame] | 3 | |
Masahiro Yamada | 4869aee | 2014-07-30 14:08:23 +0900 | [diff] [blame] | 4 | PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE |
Heinrich Schuchardt | a98850c | 2023-10-24 08:30:47 +0200 | [diff] [blame] | 5 | PLATFORM_CPPFLAGS += -fPIC -ffunction-sections -fdata-sections |
Matthias Weisser | 0d3dd14 | 2011-11-29 12:16:40 +0100 | [diff] [blame] | 6 | PLATFORM_LIBS += -lrt |
Simon Glass | b6f4c1c | 2020-02-03 07:36:12 -0700 | [diff] [blame] | 7 | SDL_CONFIG ?= sdl2-config |
Simon Glass | 62cf912 | 2013-04-26 02:53:43 +0000 | [diff] [blame] | 8 | |
Simon Glass | d8e2292 | 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 |
Tom Rini | ea79bb7 | 2022-11-19 18:45:43 -0500 | [diff] [blame] | 11 | ifeq ($(CONFIG_SANDBOX_SDL),y) |
Simon Glass | 73585b9 | 2019-05-18 11:59:47 -0600 | [diff] [blame] | 12 | PLATFORM_LIBS += $(shell $(SDL_CONFIG) --libs) |
| 13 | PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags) |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 14 | endif |
| 15 | |
Andrew Scull | f9a2c5e | 2022-05-30 10:00:05 +0000 | [diff] [blame] | 16 | SANITIZERS := |
| 17 | ifdef CONFIG_ASAN |
| 18 | SANITIZERS += -fsanitize=address |
| 19 | endif |
Andrew Scull | 2b40f80 | 2022-05-30 10:00:11 +0000 | [diff] [blame] | 20 | ifdef CONFIG_FUZZ |
| 21 | SANITIZERS += -fsanitize=fuzzer |
| 22 | endif |
Andrew Scull | f9a2c5e | 2022-05-30 10:00:05 +0000 | [diff] [blame] | 23 | KBUILD_CFLAGS += $(SANITIZERS) |
| 24 | |
Simon Glass | 66cf8f7 | 2018-11-23 21:29:30 -0700 | [diff] [blame] | 25 | cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \ |
Andrew Scull | f9a2c5e | 2022-05-30 10:00:05 +0000 | [diff] [blame] | 26 | $(KBUILD_LDFLAGS:%=-Wl,%) \ |
| 27 | $(SANITIZERS) \ |
| 28 | $(LTO_FINAL_LDFLAGS) \ |
Marek Behún | f872685 | 2021-05-20 13:24:02 +0200 | [diff] [blame] | 29 | -Wl,--whole-archive \ |
| 30 | $(u-boot-main) \ |
Marek Behún | 7243493 | 2021-05-20 13:24:07 +0200 | [diff] [blame] | 31 | $(u-boot-keep-syms-lto) \ |
Marek Behún | f872685 | 2021-05-20 13:24:02 +0200 | [diff] [blame] | 32 | -Wl,--no-whole-archive \ |
Heinrich Schuchardt | a98850c | 2023-10-24 08:30:47 +0200 | [diff] [blame] | 33 | $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -Wl,--gc-sections |
Simon Glass | 66c164b | 2014-02-26 15:59:14 -0700 | [diff] [blame] | 34 | |
Simon Glass | 1a3ba62 | 2016-07-04 11:57:46 -0600 | [diff] [blame] | 35 | cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \ |
Andrew Scull | f9a2c5e | 2022-05-30 10:00:05 +0000 | [diff] [blame] | 36 | $(KBUILD_LDFLAGS:%=-Wl,%) \ |
| 37 | $(SANITIZERS) \ |
| 38 | $(LTO_FINAL_LDFLAGS) \ |
Simon Glass | 66cf8f7 | 2018-11-23 21:29:30 -0700 | [diff] [blame] | 39 | $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ |
Marek Behún | f872685 | 2021-05-20 13:24:02 +0200 | [diff] [blame] | 40 | -Wl,--whole-archive \ |
| 41 | $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \ |
| 42 | $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \ |
Marek Behún | 7243493 | 2021-05-20 13:24:07 +0200 | [diff] [blame] | 43 | $(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto)) \ |
Marek Behún | f872685 | 2021-05-20 13:24:02 +0200 | [diff] [blame] | 44 | -Wl,--no-whole-archive \ |
Simon Glass | 1a3ba62 | 2016-07-04 11:57:46 -0600 | [diff] [blame] | 45 | $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections) |
| 46 | |
Heinrich Schuchardt | 0f675d9 | 2019-11-07 08:05:17 +0100 | [diff] [blame] | 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 \ |
Andrew Scull | 5a9095c | 2022-05-30 10:00:04 +0000 | [diff] [blame] | 56 | -j __u_boot_list -j .rela.dyn -j .got -j .got.plt \ |
Heinrich Schuchardt | 0f675d9 | 2019-11-07 08:05:17 +0100 | [diff] [blame] | 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 \ |
Andrew Scull | 5a9095c | 2022-05-30 10:00:04 +0000 | [diff] [blame] | 62 | -j .data -j .got -j .got.plt -j __u_boot_list -j .rel.dyn \ |
Heinrich Schuchardt | 0f675d9 | 2019-11-07 08:05:17 +0100 | [diff] [blame] | 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 |
| 69 | endif |
| 70 | EFI_CRT0 := crt0_sandbox_efi.o |
| 71 | EFI_RELOC := reloc_sandbox_efi.o |
| 72 | AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)" |
| 73 | CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)" |