xref: /openbmc/linux/arch/s390/boot/Makefile (revision d3741027)
1# SPDX-License-Identifier: GPL-2.0
2#
3# Makefile for the linux s390-specific parts of the memory manager.
4#
5
6KCOV_INSTRUMENT := n
7GCOV_PROFILE := n
8UBSAN_SANITIZE := n
9KASAN_SANITIZE := n
10KCSAN_SANITIZE := n
11
12KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
13KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
14
15#
16# Use minimum architecture for als.c to be able to print an error
17# message if the kernel is started on a machine which is too old
18#
19ifndef CONFIG_CC_IS_CLANG
20CC_FLAGS_MARCH_MINIMUM := -march=z900
21else
22CC_FLAGS_MARCH_MINIMUM := -march=z10
23endif
24
25ifneq ($(CC_FLAGS_MARCH),$(CC_FLAGS_MARCH_MINIMUM))
26AFLAGS_REMOVE_head.o		+= $(CC_FLAGS_MARCH)
27AFLAGS_head.o			+= $(CC_FLAGS_MARCH_MINIMUM)
28AFLAGS_REMOVE_mem.o		+= $(CC_FLAGS_MARCH)
29AFLAGS_mem.o			+= $(CC_FLAGS_MARCH_MINIMUM)
30CFLAGS_REMOVE_als.o		+= $(CC_FLAGS_MARCH)
31CFLAGS_als.o			+= $(CC_FLAGS_MARCH_MINIMUM)
32CFLAGS_REMOVE_sclp_early_core.o	+= $(CC_FLAGS_MARCH)
33CFLAGS_sclp_early_core.o	+= $(CC_FLAGS_MARCH_MINIMUM)
34endif
35
36CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
37
38obj-y	:= head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o
39obj-y	+= string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
40obj-y	+= version.o pgm_check_info.o ctype.o ipl_data.o
41obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE))	+= uv.o
42obj-$(CONFIG_RELOCATABLE)	+= machine_kexec_reloc.o
43obj-$(CONFIG_RANDOMIZE_BASE)	+= kaslr.o
44obj-y	+= $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
45obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
46obj-all := $(obj-y) piggy.o syms.o
47
48targets	:= bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
49targets	+= vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
50targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
51targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
52
53OBJECTS := $(addprefix $(obj)/,$(obj-y))
54OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
55
56quiet_cmd_section_cmp = SECTCMP $*
57define cmd_section_cmp
58	s1=`$(OBJDUMP) -t -j "$*" "$<" | sort | \
59		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
60	s2=`$(OBJDUMP) -t -j "$*" "$(word 2,$^)" | sort | \
61		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
62	if [ "$$s1" != "$$s2" ]; then \
63		echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
64		exit 1; \
65	fi; \
66	touch $@
67endef
68
69$(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
70	$(call if_changed,objcopy)
71
72$(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
73	$(call if_changed,section_cmp)
74
75LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T
76$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
77	$(call if_changed,ld)
78
79LDFLAGS_vmlinux.syms := --oformat $(LD_BFD) -e startup -T
80$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
81	$(call if_changed,ld)
82
83quiet_cmd_dumpsyms = DUMPSYMS $<
84define cmd_dumpsyms
85	$(NM) -n -S --format=bsd "$<" | sed -nE 's/^0*([0-9a-fA-F]+) 0*([0-9a-fA-F]+) [tT] ([^ ]*)$$/\1 \2 \3/p' | tr '\n' '\0' > "$@"
86endef
87
88$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
89	$(call if_changed,dumpsyms)
90
91OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
92$(obj)/syms.o: $(obj)/syms.bin FORCE
93	$(call if_changed,objcopy)
94
95OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
96$(obj)/info.bin: vmlinux FORCE
97	$(call if_changed,objcopy)
98
99OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
100$(obj)/info.o: $(obj)/info.bin FORCE
101	$(call if_changed,objcopy)
102
103OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
104$(obj)/vmlinux.bin: vmlinux FORCE
105	$(call if_changed,objcopy)
106
107suffix-$(CONFIG_KERNEL_GZIP)  := .gz
108suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
109suffix-$(CONFIG_KERNEL_LZ4)  := .lz4
110suffix-$(CONFIG_KERNEL_LZMA)  := .lzma
111suffix-$(CONFIG_KERNEL_LZO)  := .lzo
112suffix-$(CONFIG_KERNEL_XZ)  := .xz
113suffix-$(CONFIG_KERNEL_ZSTD)  := .zst
114
115$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
116	$(call if_changed,gzip)
117$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
118	$(call if_changed,bzip2_with_size)
119$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
120	$(call if_changed,lz4_with_size)
121$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
122	$(call if_changed,lzma_with_size)
123$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
124	$(call if_changed,lzo_with_size)
125$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
126	$(call if_changed,xzkern_with_size)
127$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
128	$(call if_changed,zstd22_with_size)
129
130OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
131$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
132	$(call if_changed,objcopy)
133