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