xref: /linux/arch/s390/boot/Makefile (revision 4e9903b0861c9df3464b82db4a7025863bac1897)
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
14KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
15KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
16
17#
18# Use minimum architecture for als.c to be able to print an error
19# message if the kernel is started on a machine which is too old
20#
21ifndef CONFIG_CC_IS_CLANG
22CC_FLAGS_MARCH_MINIMUM := -march=z900
23else
24CC_FLAGS_MARCH_MINIMUM := -march=z10
25endif
26
27ifneq ($(CC_FLAGS_MARCH),$(CC_FLAGS_MARCH_MINIMUM))
28AFLAGS_REMOVE_head.o		+= $(CC_FLAGS_MARCH)
29AFLAGS_head.o			+= $(CC_FLAGS_MARCH_MINIMUM)
30AFLAGS_REMOVE_mem.o		+= $(CC_FLAGS_MARCH)
31AFLAGS_mem.o			+= $(CC_FLAGS_MARCH_MINIMUM)
32CFLAGS_REMOVE_als.o		+= $(CC_FLAGS_MARCH)
33CFLAGS_als.o			+= $(CC_FLAGS_MARCH_MINIMUM)
34CFLAGS_REMOVE_sclp_early_core.o	+= $(CC_FLAGS_MARCH)
35CFLAGS_sclp_early_core.o	+= $(CC_FLAGS_MARCH_MINIMUM)
36endif
37
38CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
39
40obj-y	:= head.o als.o startup.o physmem_info.o ipl_parm.o ipl_report.o vmem.o
41obj-y	+= string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
42obj-y	+= version.o pgm_check_info.o ctype.o ipl_data.o relocs.o alternative.o uv.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-$(CONFIG_KMSAN) += kmsan.o
47obj-all := $(obj-y) piggy.o syms.o
48
49targets	:= bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
50targets	+= vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
51targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
52targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
53targets += relocs.S
54
55OBJECTS := $(addprefix $(obj)/,$(obj-y))
56OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
57
58clean-files += vmlinux.map
59
60quiet_cmd_section_cmp = SECTCMP $*
61define cmd_section_cmp
62	s1=`$(OBJDUMP) -t "$<" | grep "\s$*\s\+" | sort | \
63		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
64	s2=`$(OBJDUMP) -t "$(word 2,$^)" | grep "\s$*\s\+" | sort | \
65		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
66	if [ "$$s1" != "$$s2" ]; then \
67		echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
68		exit 1; \
69	fi; \
70	touch $@
71endef
72
73$(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
74	$(call if_changed,objcopy)
75
76$(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
77	$(call if_changed,section_cmp)
78
79LDFLAGS_vmlinux-$(CONFIG_LD_ORPHAN_WARN) := --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
80LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup $(if $(CONFIG_VMLINUX_MAP),-Map=$(obj)/vmlinux.map) --build-id=sha1 -T
81$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
82	$(call if_changed,ld)
83
84LDFLAGS_vmlinux.syms := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup -T
85$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
86	$(call if_changed,ld)
87
88quiet_cmd_dumpsyms = DUMPSYMS $<
89define cmd_dumpsyms
90	$(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' > "$@"
91endef
92
93$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
94	$(call if_changed,dumpsyms)
95
96OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
97$(obj)/syms.o: $(obj)/syms.bin FORCE
98	$(call if_changed,objcopy)
99
100OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=alloc,load
101$(obj)/info.bin: vmlinux FORCE
102	$(call if_changed,objcopy)
103
104OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
105$(obj)/info.o: $(obj)/info.bin FORCE
106	$(call if_changed,objcopy)
107
108OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
109$(obj)/vmlinux.bin: vmlinux FORCE
110	$(call if_changed,objcopy)
111
112CMD_RELOCS=arch/s390/tools/relocs
113quiet_cmd_relocs = RELOCS  $@
114	cmd_relocs = $(CMD_RELOCS) $< > $@
115$(obj)/relocs.S: vmlinux FORCE
116	$(call if_changed,relocs)
117
118suffix-$(CONFIG_KERNEL_GZIP)  := .gz
119suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
120suffix-$(CONFIG_KERNEL_LZ4)  := .lz4
121suffix-$(CONFIG_KERNEL_LZMA)  := .lzma
122suffix-$(CONFIG_KERNEL_LZO)  := .lzo
123suffix-$(CONFIG_KERNEL_XZ)  := .xz
124suffix-$(CONFIG_KERNEL_ZSTD)  := .zst
125
126$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
127	$(call if_changed,gzip)
128$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
129	$(call if_changed,bzip2_with_size)
130$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
131	$(call if_changed,lz4_with_size)
132$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
133	$(call if_changed,lzma_with_size)
134$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
135	$(call if_changed,lzo_with_size)
136$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
137	$(call if_changed,xzkern_with_size)
138$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
139	$(call if_changed,zstd22_with_size)
140
141OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
142$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
143	$(call if_changed,objcopy)
144