xref: /openbmc/linux/arch/s390/purgatory/Makefile (revision e9b7b8b3)
1# SPDX-License-Identifier: GPL-2.0
2
3OBJECT_FILES_NON_STANDARD := y
4
5purgatory-y := head.o purgatory.o string.o sha256.o mem.o
6
7targets += $(purgatory-y) purgatory.lds purgatory purgatory.chk purgatory.ro
8PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
9
10$(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
11	$(call if_changed_rule,cc_o_c)
12
13CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY
14
15$(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE
16	$(call if_changed_rule,as_o_S)
17
18KCOV_INSTRUMENT := n
19GCOV_PROFILE := n
20UBSAN_SANITIZE := n
21KASAN_SANITIZE := n
22KCSAN_SANITIZE := n
23
24KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes
25KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
26KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding
27KBUILD_CFLAGS += -Os -m64 -msoft-float -fno-common
28KBUILD_CFLAGS += -fno-stack-protector
29KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
30KBUILD_CFLAGS += $(CLANG_FLAGS)
31KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
32KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
33
34# Since we link purgatory with -r unresolved symbols are not checked, so we
35# also link a purgatory.chk binary without -r to check for unresolved symbols.
36PURGATORY_LDFLAGS := -nostdlib -z nodefaultlib
37LDFLAGS_purgatory := -r $(PURGATORY_LDFLAGS) -T
38LDFLAGS_purgatory.chk := -e purgatory_start $(PURGATORY_LDFLAGS)
39$(obj)/purgatory: $(obj)/purgatory.lds $(PURGATORY_OBJS) FORCE
40		$(call if_changed,ld)
41
42$(obj)/purgatory.chk: $(obj)/purgatory FORCE
43		$(call if_changed,ld)
44
45OBJCOPYFLAGS_purgatory.ro := -O elf64-s390
46OBJCOPYFLAGS_purgatory.ro += --remove-section='*debug*'
47OBJCOPYFLAGS_purgatory.ro += --remove-section='.comment'
48OBJCOPYFLAGS_purgatory.ro += --remove-section='.note.*'
49$(obj)/purgatory.ro: $(obj)/purgatory $(obj)/purgatory.chk FORCE
50		$(call if_changed,objcopy)
51
52$(obj)/kexec-purgatory.o: $(obj)/purgatory.ro
53
54obj-y += kexec-purgatory.o
55