xref: /linux/arch/s390/boot/Makefile (revision c5288cda69ee2d8607f5026bd599a5cebf0ee783)
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 physmem_info.o ipl_parm.o ipl_report.o vmem.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 relocs.o
41obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE))	+= uv.o
42obj-$(CONFIG_RANDOMIZE_BASE)	+= kaslr.o
43obj-y	+= $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
44obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
45obj-all := $(obj-y) piggy.o syms.o
46
47targets	:= bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
48targets	+= vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
49targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
50targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
51targets += relocs.S
52
53OBJECTS := $(addprefix $(obj)/,$(obj-y))
54OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
55
56clean-files += vmlinux.map
57
58quiet_cmd_section_cmp = SECTCMP $*
59define cmd_section_cmp
60	s1=`$(OBJDUMP) -t "$<" | grep "\s$*\s\+" | sort | \
61		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
62	s2=`$(OBJDUMP) -t "$(word 2,$^)" | grep "\s$*\s\+" | sort | \
63		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
64	if [ "$$s1" != "$$s2" ]; then \
65		echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
66		exit 1; \
67	fi; \
68	touch $@
69endef
70
71$(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
72	$(call if_changed,objcopy)
73
74$(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
75	$(call if_changed,section_cmp)
76
77LDFLAGS_vmlinux-$(CONFIG_LD_ORPHAN_WARN) := --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
78LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup $(if $(CONFIG_VMLINUX_MAP),-Map=$(obj)/vmlinux.map) --build-id=sha1 -T
79$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
80	$(call if_changed,ld)
81
82LDFLAGS_vmlinux.syms := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup -T
83$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
84	$(call if_changed,ld)
85
86quiet_cmd_dumpsyms = DUMPSYMS $<
87define cmd_dumpsyms
88	$(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' > "$@"
89endef
90
91$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
92	$(call if_changed,dumpsyms)
93
94OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
95$(obj)/syms.o: $(obj)/syms.bin FORCE
96	$(call if_changed,objcopy)
97
98OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=alloc,load
99$(obj)/info.bin: vmlinux FORCE
100	$(call if_changed,objcopy)
101
102OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
103$(obj)/info.o: $(obj)/info.bin FORCE
104	$(call if_changed,objcopy)
105
106OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
107$(obj)/vmlinux.bin: vmlinux FORCE
108	$(call if_changed,objcopy)
109
110CMD_RELOCS=arch/s390/tools/relocs
111quiet_cmd_relocs = RELOCS  $@
112	cmd_relocs = $(CMD_RELOCS) $< > $@
113$(obj)/relocs.S: vmlinux FORCE
114	$(call if_changed,relocs)
115
116suffix-$(CONFIG_KERNEL_GZIP)  := .gz
117suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
118suffix-$(CONFIG_KERNEL_LZ4)  := .lz4
119suffix-$(CONFIG_KERNEL_LZMA)  := .lzma
120suffix-$(CONFIG_KERNEL_LZO)  := .lzo
121suffix-$(CONFIG_KERNEL_XZ)  := .xz
122suffix-$(CONFIG_KERNEL_ZSTD)  := .zst
123
124$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
125	$(call if_changed,gzip)
126$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
127	$(call if_changed,bzip2_with_size)
128$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
129	$(call if_changed,lz4_with_size)
130$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
131	$(call if_changed,lzma_with_size)
132$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
133	$(call if_changed,lzo_with_size)
134$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
135	$(call if_changed,xzkern_with_size)
136$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
137	$(call if_changed,zstd22_with_size)
138
139OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
140$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
141	$(call if_changed,objcopy)
142