Loading...
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
30obj-y += uv.o printk.o
31obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
32obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
33obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
34obj-$(CONFIG_KMSAN) += kmsan.o
35obj-all := $(obj-y) piggy.o syms.o
36
37targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
38targets += vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
39targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
40targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
41targets += relocs.S
42
43OBJECTS := $(addprefix $(obj)/,$(obj-y))
44OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
45
46clean-files += vmlinux.map
47
48quiet_cmd_section_cmp = SECTCMP $*
49define cmd_section_cmp
50 s1=`$(OBJDUMP) -t "$<" | grep "\s$*\s\+" | sort | \
51 sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
52 s2=`$(OBJDUMP) -t "$(word 2,$^)" | grep "\s$*\s\+" | sort | \
53 sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
54 if [ "$$s1" != "$$s2" ]; then \
55 echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
56 exit 1; \
57 fi; \
58 touch $@
59endef
60
61$(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
62 $(call if_changed,objcopy)
63
64$(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
65 $(call if_changed,section_cmp)
66
67LDFLAGS_vmlinux-$(CONFIG_LD_ORPHAN_WARN) := --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
68LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup $(if $(CONFIG_VMLINUX_MAP),-Map=$(obj)/vmlinux.map) --build-id=sha1 -T
69$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
70 $(call if_changed,ld)
71
72LDFLAGS_vmlinux.syms := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup -T
73$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
74 $(call if_changed,ld)
75
76quiet_cmd_dumpsyms = DUMPSYMS $<
77define cmd_dumpsyms
78 $(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' > "$@"
79endef
80
81$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
82 $(call if_changed,dumpsyms)
83
84OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
85$(obj)/syms.o: $(obj)/syms.bin FORCE
86 $(call if_changed,objcopy)
87
88OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=alloc,load
89$(obj)/info.bin: vmlinux FORCE
90 $(call if_changed,objcopy)
91
92OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
93$(obj)/info.o: $(obj)/info.bin FORCE
94 $(call if_changed,objcopy)
95
96OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
97$(obj)/vmlinux.bin: vmlinux FORCE
98 $(call if_changed,objcopy)
99
100# relocs.S is created by the vmlinux postlink step.
101$(obj)/relocs.S: vmlinux
102 @true
103
104suffix-$(CONFIG_KERNEL_GZIP) := .gz
105suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
106suffix-$(CONFIG_KERNEL_LZ4) := .lz4
107suffix-$(CONFIG_KERNEL_LZMA) := .lzma
108suffix-$(CONFIG_KERNEL_LZO) := .lzo
109suffix-$(CONFIG_KERNEL_XZ) := .xz
110suffix-$(CONFIG_KERNEL_ZSTD) := .zst
111
112$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
113 $(call if_changed,gzip)
114$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
115 $(call if_changed,bzip2_with_size)
116$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
117 $(call if_changed,lz4_with_size)
118$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
119 $(call if_changed,lzma_with_size)
120$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
121 $(call if_changed,lzo_with_size)
122$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
123 $(call if_changed,xzkern_with_size)
124$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
125 $(call if_changed,zstd22_with_size)
126
127OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
128$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
129 $(call if_changed,objcopy)
1#
2# Makefile for the linux s390-specific parts of the memory manager.
3#
4
5COMPILE_VERSION := __linux_compile_version_id__`hostname | \
6 tr -c '[0-9A-Za-z]' '_'`__`date | \
7 tr -c '[0-9A-Za-z]' '_'`_t
8
9ccflags-y := -DCOMPILE_VERSION=$(COMPILE_VERSION) -gstabs -I.
10
11targets := image
12targets += bzImage
13subdir- := compressed
14
15$(obj)/image: vmlinux FORCE
16 $(call if_changed,objcopy)
17
18$(obj)/bzImage: $(obj)/compressed/vmlinux FORCE
19 $(call if_changed,objcopy)
20
21$(obj)/compressed/vmlinux: FORCE
22 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
23
24install: $(CONFIGURE) $(obj)/bzImage
25 sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
26 System.map "$(INSTALL_PATH)"