xref: /linux/arch/arm/boot/compressed/Makefile (revision 2596a72d338481b49a678ab880338fd5a661e663)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds#
31da177e4SLinus Torvalds# linux/arch/arm/boot/compressed/Makefile
41da177e4SLinus Torvalds#
51da177e4SLinus Torvalds# create a compressed vmlinuz image from the original vmlinux
61da177e4SLinus Torvalds#
71da177e4SLinus Torvalds
8f45b1149SSimon HormanOBJS		=
9f45b1149SSimon Horman
10e69edc79SEric MiaoAFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET)
111da177e4SLinus TorvaldsHEAD	= head.o
12f45b1149SSimon HormanOBJS	+= misc.o decompress.o
133b4af9bcSShawn Guoifeq ($(CONFIG_DEBUG_UNCOMPRESS),y)
143b4af9bcSShawn GuoOBJS	+= debug.o
15*2596a72dSLinus WalleijAFLAGS_head.o += -DDEBUG
163b4af9bcSShawn Guoendif
17ee89bd6bSGeert UytterhoevenFONTC	= $(srctree)/lib/fonts/font_acorn_8x8.c
181da177e4SLinus Torvalds
19df4879faSNicolas Pitre# string library code (-Os is enforced to keep it much smaller)
20df4879faSNicolas PitreOBJS		+= string.o
21df4879faSNicolas PitreCFLAGS_string.o	:= -Os
22df4879faSNicolas Pitre
23424e5994SDave Martinifeq ($(CONFIG_ARM_VIRT_EXT),y)
24424e5994SDave MartinOBJS		+= hyp-stub.o
25424e5994SDave Martinendif
26424e5994SDave Martin
2775c34906SVincent SandersGCOV_PROFILE		:= n
2875c34906SVincent Sanders
2975851720SDmitry Vyukov# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
3075851720SDmitry VyukovKCOV_INSTRUMENT		:= n
3175851720SDmitry Vyukov
321da177e4SLinus Torvalds#
331da177e4SLinus Torvalds# Architecture dependencies
341da177e4SLinus Torvalds#
351da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_ACORN),y)
364486b863SRussell KingOBJS		+= ll_char_wr.o font.o
371da177e4SLinus Torvaldsendif
381da177e4SLinus Torvalds
391da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_SA1100),y)
401da177e4SLinus TorvaldsOBJS		+= head-sa1100.o
411da177e4SLinus Torvaldsendif
421da177e4SLinus Torvalds
431da177e4SLinus Torvaldsifeq ($(CONFIG_CPU_XSCALE),y)
441da177e4SLinus TorvaldsOBJS		+= head-xscale.o
451da177e4SLinus Torvaldsendif
461da177e4SLinus Torvalds
479c3fca2eSEric Miaoifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y)
481da177e4SLinus TorvaldsOBJS		+= head-sharpsl.o
491da177e4SLinus Torvaldsendif
501da177e4SLinus Torvalds
5126584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE32),y)
52f12d0d7cSHyok S. Choiifeq ($(CONFIG_CPU_CP15),y)
531da177e4SLinus TorvaldsOBJS		+= big-endian.o
54f12d0d7cSHyok S. Choielse
55f12d0d7cSHyok S. Choi# The endian should be set by h/w design.
56f12d0d7cSHyok S. Choiendif
571da177e4SLinus Torvaldsendif
581da177e4SLinus Torvalds
591da177e4SLinus Torvalds#
601da177e4SLinus Torvalds# We now have a PIC decompressor implementation.  Decompressors running
611da177e4SLinus Torvalds# from RAM should not define ZTEXTADDR.  Decompressors running directly
621da177e4SLinus Torvalds# from ROM or Flash must define ZTEXTADDR (preferably via the config)
631da177e4SLinus Torvalds# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
641da177e4SLinus Torvaldsifeq ($(CONFIG_ZBOOT_ROM),y)
651da177e4SLinus TorvaldsZTEXTADDR	:= $(CONFIG_ZBOOT_ROM_TEXT)
661da177e4SLinus TorvaldsZBSSADDR	:= $(CONFIG_ZBOOT_ROM_BSS)
671da177e4SLinus Torvaldselse
681da177e4SLinus TorvaldsZTEXTADDR	:= 0
693bd2cbb9SNicolas PitreZBSSADDR	:= ALIGN(8)
701da177e4SLinus Torvaldsendif
711da177e4SLinus Torvalds
72c79bf928SRussell KingCPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
731da177e4SLinus Torvalds
74f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_GZIP) = gzip
75f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_LZO)  = lzo
76f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_LZMA) = lzma
77f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_XZ)   = xzkern
78f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_LZ4)  = lz4
79e7db7b42SAlbin Tonnerre
807ae4a78dSMasahiro Yamadalibfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
81b90b9a38SNicolas Pitre
82b90b9a38SNicolas Pitreifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
83b90b9a38SNicolas PitreOBJS	+= $(libfdt_objs) atags_to_fdt.o
84b90b9a38SNicolas Pitreendif
85b90b9a38SNicolas Pitre
867ae4a78dSMasahiro Yamada# -fstack-protector-strong triggers protection checks in this code,
877ae4a78dSMasahiro Yamada# but it is being used too early to link to meaningful stack_chk logic.
887ae4a78dSMasahiro Yamada$(foreach o, $(libfdt_objs) atags_to_fdt.o, \
89893ab004SMasahiro Yamada	$(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector))
907ae4a78dSMasahiro Yamada
917ae4a78dSMasahiro Yamada# These were previously generated C files. When you are building the kernel
927ae4a78dSMasahiro Yamada# with O=, make sure to remove the stale files in the output tree. Otherwise,
937ae4a78dSMasahiro Yamada# the build system wrongly compiles the stale ones.
947ae4a78dSMasahiro Yamadaifdef building_out_of_srctree
957ae4a78dSMasahiro Yamada$(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c))
967ae4a78dSMasahiro Yamadaendif
977ae4a78dSMasahiro Yamada
9853f67545SMasahiro Yamadatargets       := vmlinux vmlinux.lds piggy_data piggy.o \
99b44c72deSMasahiro Yamada		 lib1funcs.o ashldi3.o bswapsdi2.o \
100684c1201SMasahiro Yamada		 head.o $(OBJS)
101014c257cSAbhishek Sagar
1027ae4a78dSMasahiro Yamadaclean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S
103f1b957d3SMagnus Damm
1048c36a757SArnd BergmannKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
1058c36a757SArnd Bergmann
10689604523SArd Biesheuvelccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \
10789604523SArd Biesheuvel	     -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN)
10815d5761aSMasahiro Yamadaccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg
109da94a829SArnd Bergmannasflags-y := -DZIMAGE
1101da177e4SLinus Torvalds
1115ffb04f6SNicolas Pitre# Supply kernel BSS size to the decompressor via a linker symbol.
11229c623d6SDmitry GolovinKBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \
1136cea14f5SRussell King		sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \
1146cea14f5SRussell King		       -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) )
1155ffb04f6SNicolas PitreLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
1169e84ed63SRussell King# Supply ZRELADDR to the decompressor via a linker symbol.
1179e84ed63SRussell Kingifneq ($(CONFIG_AUTO_ZRELADDR),y)
118d239b1dcSNicolas PitreLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
1199e84ed63SRussell Kingendif
12026584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
12126584853SCatalin MarinasLDFLAGS_vmlinux += --be8
12226584853SCatalin Marinasendif
123e7db7b42SAlbin Tonnerre# Report unresolved symbol references
124e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += --no-undefined
125e7db7b42SAlbin Tonnerre# Delete all temporary local symbols
126e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -X
127e7db7b42SAlbin Tonnerre# Next argument is a linker script
128e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -T
129e7db7b42SAlbin Tonnerre
130e7db7b42SAlbin Tonnerre# For __aeabi_uidivmod
131e7db7b42SAlbin Tonnerrelib1funcs = $(obj)/lib1funcs.o
132e7db7b42SAlbin Tonnerre
13363d15148SNicolas Pitre$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
134e7db7b42SAlbin Tonnerre	$(call cmd,shipped)
1351da177e4SLinus Torvalds
136a7f464f3SImre Kaloz# For __aeabi_llsl
137a7f464f3SImre Kalozashldi3 = $(obj)/ashldi3.o
138a7f464f3SImre Kaloz
139a7f464f3SImre Kaloz$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S
140a7f464f3SImre Kaloz	$(call cmd,shipped)
141a7f464f3SImre Kaloz
142017f161aSKim Phillips# For __bswapsi2, __bswapdi2
143017f161aSKim Phillipsbswapsdi2 = $(obj)/bswapsdi2.o
144017f161aSKim Phillips
145017f161aSKim Phillips$(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S
146017f161aSKim Phillips	$(call cmd,shipped)
147017f161aSKim Phillips
1488d7e4cc2SNicolas Pitre# We need to prevent any GOTOFF relocs being used with references
1498d7e4cc2SNicolas Pitre# to symbols in the .bss section since we cannot relocate them
1508d7e4cc2SNicolas Pitre# independently from the rest at run time.  This can be achieved by
1518d7e4cc2SNicolas Pitre# ensuring that no private .bss symbols exist, as global symbols
1528d7e4cc2SNicolas Pitre# always have a GOT entry which is what we need.
1538d7e4cc2SNicolas Pitre# The .data section is already discarded by the linker script so no need
1548d7e4cc2SNicolas Pitre# to bother about it here.
1558d7e4cc2SNicolas Pitrecheck_for_bad_syms = \
15629c623d6SDmitry Golovinbad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
1578d7e4cc2SNicolas Pitre[ -z "$$bad_syms" ] || \
1588d7e4cc2SNicolas Pitre  ( echo "following symbols must have non local/private scope:" >&2; \
159172caf19SMasahiro Yamada    echo "$$bad_syms" >&2; false )
1608d7e4cc2SNicolas Pitre
16160aac932SSascha Hauercheck_for_multiple_zreladdr = \
1624bdad983SRabin Vincentif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \
16360aac932SSascha Hauer	echo 'multiple zreladdrs: $(ZRELADDR)'; \
16460aac932SSascha Hauer	echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \
16560aac932SSascha Hauer	false; \
16660aac932SSascha Hauerfi
16760aac932SSascha Hauer
16881a0bc39SRoy Franzefi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a
16981a0bc39SRoy Franz
17053f67545SMasahiro Yamada$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
171017f161aSKim Phillips		$(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \
17281a0bc39SRoy Franz		$(bswapsdi2) $(efi-obj-y) FORCE
17360aac932SSascha Hauer	@$(check_for_multiple_zreladdr)
1741da177e4SLinus Torvalds	$(call if_changed,ld)
1758d7e4cc2SNicolas Pitre	@$(check_for_bad_syms)
1761da177e4SLinus Torvalds
17753f67545SMasahiro Yamada$(obj)/piggy_data: $(obj)/../Image FORCE
178f57deb0bSMasahiro Yamada	$(call if_changed,$(compress-y))
1791da177e4SLinus Torvalds
18053f67545SMasahiro Yamada$(obj)/piggy.o: $(obj)/piggy_data
1811da177e4SLinus Torvalds
1824486b863SRussell KingCFLAGS_font.o := -Dstatic=
1834486b863SRussell King
1844486b863SRussell King$(obj)/font.c: $(FONTC)
1854486b863SRussell King	$(call cmd,shipped)
1861da177e4SLinus Torvalds
187c7edd7f9SJean-Philippe BruckerAFLAGS_hyp-stub.o := -Wa,-march=armv7-a
188c7edd7f9SJean-Philippe Brucker
189424e5994SDave Martin$(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S
190424e5994SDave Martin	$(call cmd,shipped)
191