binman: Add a ELF test file with disjoint text sections
[platform/kernel/u-boot.git] / tools / binman / test / Makefile
1 #
2 # Builds test programs. This is launched from elf_test.BuildElfTestFiles()
3 #
4 # Copyright (C) 2017 Google, Inc
5 # Written by Simon Glass <sjg@chromium.org>
6 #
7 # SPDX-License-Identifier:      GPL-2.0+
8 #
9
10 HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ )
11 ifeq ($(findstring $(HOSTARCH),"x86" "x86_64"),)
12 ifeq ($(findstring $(MAKECMDGOALS),"help" "clean"),)
13 ifndef CROSS_COMPILE
14 $(error Binman tests need to compile to x86, but the CPU arch of your \
15         machine is $(HOSTARCH). Set CROSS_COMPILE to a suitable cross compiler)
16 endif
17 endif
18 endif
19
20 CC              = $(CROSS_COMPILE)gcc
21 OBJCOPY         = $(CROSS_COMPILE)objcopy
22
23 VPATH := $(SRC)
24 CFLAGS := -march=i386 -m32 -nostdlib -I $(SRC)../../../include \
25         -Wl,--no-dynamic-linker
26
27 LDS_UCODE := -T $(SRC)u_boot_ucode_ptr.lds
28 LDS_BINMAN := -T $(SRC)u_boot_binman_syms.lds
29 LDS_BINMAN_BAD := -T $(SRC)u_boot_binman_syms_bad.lds
30 LDS_BINMAN_X86 := -T $(SRC)u_boot_binman_syms_x86.lds
31 LDS_BINMAN_EMBED := -T $(SRC)u_boot_binman_embed.lds
32 LDS_EFL_SECTIONS := -T $(SRC)elf_sections.lds
33
34 TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data \
35         u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \
36         u_boot_binman_syms_size u_boot_binman_syms_x86 embed_data \
37         u_boot_binman_embed u_boot_binman_embed_sm elf_sections
38
39 all: $(TARGETS)
40
41 u_boot_no_ucode_ptr: CFLAGS += $(LDS_UCODE)
42 u_boot_no_ucode_ptr: u_boot_no_ucode_ptr.c
43
44 u_boot_ucode_ptr: CFLAGS += $(LDS_UCODE)
45 u_boot_ucode_ptr: u_boot_ucode_ptr.c
46
47 bss_data: CFLAGS += $(SRC)bss_data.lds
48 bss_data: bss_data.c
49
50 embed_data: CFLAGS += $(SRC)embed_data.lds
51 embed_data: embed_data.c
52
53 u_boot_binman_syms.bin: u_boot_binman_syms
54         $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@
55
56 u_boot_binman_syms: CFLAGS += $(LDS_BINMAN)
57 u_boot_binman_syms: u_boot_binman_syms.c
58
59 u_boot_binman_syms_x86: CFLAGS += $(LDS_BINMAN_X86)
60 u_boot_binman_syms_x86: u_boot_binman_syms_x86.c
61
62 u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD)
63 u_boot_binman_syms_bad: u_boot_binman_syms_bad.c
64
65 u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN)
66 u_boot_binman_syms_size: u_boot_binman_syms_size.c
67
68 u_boot_binman_embed: CFLAGS += $(LDS_BINMAN_EMBED)
69 u_boot_binman_embed: u_boot_binman_embed.c
70
71 u_boot_binman_embed_sm: CFLAGS += $(LDS_BINMAN_EMBED)
72 u_boot_binman_embed_sm: u_boot_binman_embed_sm.c
73
74 elf_sections: CFLAGS += $(LDS_EFL_SECTIONS)
75 elf_sections: elf_sections.c
76
77 clean:
78         rm -f $(TARGETS)
79
80 help:
81         @echo "Makefile for binman test programs"
82         @echo
83         @echo "Intended for use on x86 hosts"
84         @echo
85         @echo "Targets:"
86         @echo
87         @echo -e "\thelp        - Print help (this is it!)"
88         @echo -e "\tall - Builds test programs (default targget)"
89         @echo -e "\tclean       - Delete output files"