xref: /linux/arch/s390/boot/Makefile (revision 6f7e6393d1ce636bb7ec77a7fe7b77458fddf701)
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) -D__DISABLE_EXPORTS
23KBUILD_CFLAGS += $(CC_FLAGS_MARCH_MINIMUM) -D__DISABLE_EXPORTS
24KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
25
26CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
27
28obj-y	:= head.o als.o startup.o physmem_info.o ipl_parm.o ipl_report.o vmem.o
29obj-y	+= string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
30obj-y	+= version.o pgm_check.o ctype.o ipl_data.o relocs.o alternative.o
31obj-y	+= uv.o printk.o trampoline.o
32obj-$(CONFIG_RANDOMIZE_BASE)	+= kaslr.o
33obj-y	+= $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
34obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
35obj-$(CONFIG_KMSAN) += kmsan.o
36obj-$(CONFIG_STACKPROTECTOR) += stackprotector.o
37obj-all := $(obj-y) piggy.o syms.o
38
39targets	:= bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
40targets	+= vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
41targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
42targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
43targets += relocs.S
44
45OBJECTS := $(addprefix $(obj)/,$(obj-y))
46OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
47
48clean-files += vmlinux.map
49
50quiet_cmd_section_cmp = SECTCMP $*
51define cmd_section_cmp
52	s1=`$(OBJDUMP) -t "$<" | grep "\s$*\s\+" | sort | \
53		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
54	s2=`$(OBJDUMP) -t "$(word 2,$^)" | grep "\s$*\s\+" | sort | \
55		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
56	if [ "$$s1" != "$$s2" ]; then \
57		echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
58		exit 1; \
59	fi; \
60	touch $@
61endef
62
63$(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
64	$(call if_changed,objcopy)
65
66$(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
67	$(call if_changed,section_cmp)
68
69LDFLAGS_vmlinux-$(CONFIG_LD_ORPHAN_WARN) := --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
70LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup $(if $(CONFIG_VMLINUX_MAP),-Map=$(obj)/vmlinux.map) --build-id=sha1 -T
71$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
72	$(call if_changed,ld)
73
74LDFLAGS_vmlinux.syms := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup -T
75$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
76	$(call if_changed,ld)
77
78quiet_cmd_dumpsyms = DUMPSYMS $<
79define cmd_dumpsyms
80	$(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' > "$@"
81endef
82
83$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
84	$(call if_changed,dumpsyms)
85
86OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
87$(obj)/syms.o: $(obj)/syms.bin FORCE
88	$(call if_changed,objcopy)
89
90OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=alloc,load
91$(obj)/info.bin: vmlinux FORCE
92	$(call if_changed,objcopy)
93
94OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
95$(obj)/info.o: $(obj)/info.bin FORCE
96	$(call if_changed,objcopy)
97
98OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
99$(obj)/vmlinux.bin: vmlinux FORCE
100	$(call if_changed,objcopy)
101
102# relocs.S is created by the vmlinux postlink step.
103$(obj)/relocs.S: vmlinux
104	@true
105
106suffix-$(CONFIG_KERNEL_GZIP)  := .gz
107suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
108suffix-$(CONFIG_KERNEL_LZ4)  := .lz4
109suffix-$(CONFIG_KERNEL_LZMA)  := .lzma
110suffix-$(CONFIG_KERNEL_LZO)  := .lzo
111suffix-$(CONFIG_KERNEL_XZ)  := .xz
112suffix-$(CONFIG_KERNEL_ZSTD)  := .zst
113
114$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
115	$(call if_changed,gzip)
116$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
117	$(call if_changed,bzip2_with_size)
118$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
119	$(call if_changed,lz4_with_size)
120$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
121	$(call if_changed,lzma_with_size)
122$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
123	$(call if_changed,lzo_with_size)
124$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
125	$(call if_changed,xzkern_with_size)
126$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
127	$(call if_changed,zstd22_with_size)
128
129OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
130$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
131	$(call if_changed,objcopy)
132