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