xref: /linux/arch/arm/boot/compressed/Makefile (revision 9db78852739e9f4335d1f2350c01a6b5e2998507)
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
153b4af9bcSShawn Guoendif
16ee89bd6bSGeert UytterhoevenFONTC	= $(srctree)/lib/fonts/font_acorn_8x8.c
171da177e4SLinus Torvalds
18df4879faSNicolas Pitre# string library code (-Os is enforced to keep it much smaller)
19df4879faSNicolas PitreOBJS		+= string.o
20df4879faSNicolas PitreCFLAGS_string.o	:= -Os
21df4879faSNicolas Pitre
22424e5994SDave Martinifeq ($(CONFIG_ARM_VIRT_EXT),y)
23424e5994SDave MartinOBJS		+= hyp-stub.o
24424e5994SDave Martinendif
25424e5994SDave Martin
2675c34906SVincent SandersGCOV_PROFILE		:= n
2775c34906SVincent Sanders
2875851720SDmitry Vyukov# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
2975851720SDmitry VyukovKCOV_INSTRUMENT		:= n
3075851720SDmitry Vyukov
311da177e4SLinus Torvalds#
321da177e4SLinus Torvalds# Architecture dependencies
331da177e4SLinus Torvalds#
341da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_ACORN),y)
354486b863SRussell KingOBJS		+= ll_char_wr.o font.o
361da177e4SLinus Torvaldsendif
371da177e4SLinus Torvalds
381da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_SA1100),y)
391da177e4SLinus TorvaldsOBJS		+= head-sa1100.o
401da177e4SLinus Torvaldsendif
411da177e4SLinus Torvalds
421da177e4SLinus Torvaldsifeq ($(CONFIG_CPU_XSCALE),y)
431da177e4SLinus TorvaldsOBJS		+= head-xscale.o
441da177e4SLinus Torvaldsendif
451da177e4SLinus Torvalds
469c3fca2eSEric Miaoifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y)
471da177e4SLinus TorvaldsOBJS		+= head-sharpsl.o
481da177e4SLinus Torvaldsendif
491da177e4SLinus Torvalds
5026584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE32),y)
51f12d0d7cSHyok S. Choiifeq ($(CONFIG_CPU_CP15),y)
521da177e4SLinus TorvaldsOBJS		+= big-endian.o
53f12d0d7cSHyok S. Choielse
54f12d0d7cSHyok S. Choi# The endian should be set by h/w design.
55f12d0d7cSHyok S. Choiendif
561da177e4SLinus Torvaldsendif
571da177e4SLinus Torvalds
581da177e4SLinus Torvalds#
591da177e4SLinus Torvalds# We now have a PIC decompressor implementation.  Decompressors running
601da177e4SLinus Torvalds# from RAM should not define ZTEXTADDR.  Decompressors running directly
611da177e4SLinus Torvalds# from ROM or Flash must define ZTEXTADDR (preferably via the config)
621da177e4SLinus Torvalds# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
631da177e4SLinus Torvaldsifeq ($(CONFIG_ZBOOT_ROM),y)
641da177e4SLinus TorvaldsZTEXTADDR	:= $(CONFIG_ZBOOT_ROM_TEXT)
651da177e4SLinus TorvaldsZBSSADDR	:= $(CONFIG_ZBOOT_ROM_BSS)
661da177e4SLinus Torvaldselse
671da177e4SLinus TorvaldsZTEXTADDR	:= 0
683bd2cbb9SNicolas PitreZBSSADDR	:= ALIGN(8)
691da177e4SLinus Torvaldsendif
701da177e4SLinus Torvalds
71c79bf928SRussell KingCPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
721da177e4SLinus Torvalds
73f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_GZIP) = gzip
74f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_LZO)  = lzo
75f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_LZMA) = lzma
76f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_XZ)   = xzkern
77f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_LZ4)  = lz4
78e7db7b42SAlbin Tonnerre
79b90b9a38SNicolas Pitre# Borrowed libfdt files for the ATAG compatibility mode
80b90b9a38SNicolas Pitre
81b90b9a38SNicolas Pitrelibfdt		:= fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
82b90b9a38SNicolas Pitrelibfdt_hdrs	:= fdt.h libfdt.h libfdt_internal.h
83b90b9a38SNicolas Pitre
84b90b9a38SNicolas Pitrelibfdt_objs	:= $(addsuffix .o, $(basename $(libfdt)))
85b90b9a38SNicolas Pitre
86b90b9a38SNicolas Pitre$(addprefix $(obj)/,$(libfdt) $(libfdt_hdrs)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
87b90b9a38SNicolas Pitre	$(call cmd,shipped)
88b90b9a38SNicolas Pitre
89b90b9a38SNicolas Pitre$(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
90b90b9a38SNicolas Pitre	$(addprefix $(obj)/,$(libfdt_hdrs))
91b90b9a38SNicolas Pitre
92b90b9a38SNicolas Pitreifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
93b90b9a38SNicolas PitreOBJS	+= $(libfdt_objs) atags_to_fdt.o
94b90b9a38SNicolas Pitreendif
95b90b9a38SNicolas Pitre
9653f67545SMasahiro Yamadatargets       := vmlinux vmlinux.lds piggy_data piggy.o \
97b44c72deSMasahiro Yamada		 lib1funcs.o ashldi3.o bswapsdi2.o \
98684c1201SMasahiro Yamada		 head.o $(OBJS)
99014c257cSAbhishek Sagar
10053f67545SMasahiro Yamadaclean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S \
10153f67545SMasahiro Yamada		$(libfdt) $(libfdt_hdrs) hyp-stub.S
102f1b957d3SMagnus Damm
1038c36a757SArnd BergmannKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
104189af465SArd BiesheuvelKBUILD_CFLAGS += $(DISABLE_ARM_SSP_PER_TASK_PLUGIN)
1058c36a757SArnd Bergmann
106606576ceSSteven Rostedtifeq ($(CONFIG_FUNCTION_TRACER),y)
107014c257cSAbhishek SagarORIG_CFLAGS := $(KBUILD_CFLAGS)
108014c257cSAbhishek SagarKBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
109014c257cSAbhishek Sagarendif
110014c257cSAbhishek Sagar
1117f66cd3fSKees Cook# -fstack-protector-strong triggers protection checks in this code,
1127f66cd3fSKees Cook# but it is being used too early to link to meaningful stack_chk logic.
113*9db78852SMasahiro Yamadanossp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
114*9db78852SMasahiro YamadaCFLAGS_atags_to_fdt.o := $(nossp-flags-y)
115*9db78852SMasahiro YamadaCFLAGS_fdt.o := $(nossp-flags-y)
116*9db78852SMasahiro YamadaCFLAGS_fdt_ro.o := $(nossp-flags-y)
117*9db78852SMasahiro YamadaCFLAGS_fdt_rw.o := $(nossp-flags-y)
118*9db78852SMasahiro YamadaCFLAGS_fdt_wip.o := $(nossp-flags-y)
1197f66cd3fSKees Cook
120c1c38668SStefan Agnerccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin -I$(obj)
121da94a829SArnd Bergmannasflags-y := -DZIMAGE
1221da177e4SLinus Torvalds
1235ffb04f6SNicolas Pitre# Supply kernel BSS size to the decompressor via a linker symbol.
12429c623d6SDmitry GolovinKBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \
1256cea14f5SRussell King		sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \
1266cea14f5SRussell King		       -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) )
1275ffb04f6SNicolas PitreLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
1289e84ed63SRussell King# Supply ZRELADDR to the decompressor via a linker symbol.
1299e84ed63SRussell Kingifneq ($(CONFIG_AUTO_ZRELADDR),y)
130d239b1dcSNicolas PitreLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
1319e84ed63SRussell Kingendif
13226584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
13326584853SCatalin MarinasLDFLAGS_vmlinux += --be8
13426584853SCatalin Marinasendif
135e7db7b42SAlbin Tonnerre# Report unresolved symbol references
136e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += --no-undefined
137e7db7b42SAlbin Tonnerre# Delete all temporary local symbols
138e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -X
139e7db7b42SAlbin Tonnerre# Next argument is a linker script
140e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -T
141e7db7b42SAlbin Tonnerre
142e7db7b42SAlbin Tonnerre# For __aeabi_uidivmod
143e7db7b42SAlbin Tonnerrelib1funcs = $(obj)/lib1funcs.o
144e7db7b42SAlbin Tonnerre
14563d15148SNicolas Pitre$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
146e7db7b42SAlbin Tonnerre	$(call cmd,shipped)
1471da177e4SLinus Torvalds
148a7f464f3SImre Kaloz# For __aeabi_llsl
149a7f464f3SImre Kalozashldi3 = $(obj)/ashldi3.o
150a7f464f3SImre Kaloz
151a7f464f3SImre Kaloz$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S
152a7f464f3SImre Kaloz	$(call cmd,shipped)
153a7f464f3SImre Kaloz
154017f161aSKim Phillips# For __bswapsi2, __bswapdi2
155017f161aSKim Phillipsbswapsdi2 = $(obj)/bswapsdi2.o
156017f161aSKim Phillips
157017f161aSKim Phillips$(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S
158017f161aSKim Phillips	$(call cmd,shipped)
159017f161aSKim Phillips
1608d7e4cc2SNicolas Pitre# We need to prevent any GOTOFF relocs being used with references
1618d7e4cc2SNicolas Pitre# to symbols in the .bss section since we cannot relocate them
1628d7e4cc2SNicolas Pitre# independently from the rest at run time.  This can be achieved by
1638d7e4cc2SNicolas Pitre# ensuring that no private .bss symbols exist, as global symbols
1648d7e4cc2SNicolas Pitre# always have a GOT entry which is what we need.
1658d7e4cc2SNicolas Pitre# The .data section is already discarded by the linker script so no need
1668d7e4cc2SNicolas Pitre# to bother about it here.
1678d7e4cc2SNicolas Pitrecheck_for_bad_syms = \
16829c623d6SDmitry Golovinbad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
1698d7e4cc2SNicolas Pitre[ -z "$$bad_syms" ] || \
1708d7e4cc2SNicolas Pitre  ( echo "following symbols must have non local/private scope:" >&2; \
171172caf19SMasahiro Yamada    echo "$$bad_syms" >&2; false )
1728d7e4cc2SNicolas Pitre
17360aac932SSascha Hauercheck_for_multiple_zreladdr = \
1744bdad983SRabin Vincentif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \
17560aac932SSascha Hauer	echo 'multiple zreladdrs: $(ZRELADDR)'; \
17660aac932SSascha Hauer	echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \
17760aac932SSascha Hauer	false; \
17860aac932SSascha Hauerfi
17960aac932SSascha Hauer
18081a0bc39SRoy Franzefi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a
18181a0bc39SRoy Franz
18253f67545SMasahiro Yamada$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
183017f161aSKim Phillips		$(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \
18481a0bc39SRoy Franz		$(bswapsdi2) $(efi-obj-y) FORCE
18560aac932SSascha Hauer	@$(check_for_multiple_zreladdr)
1861da177e4SLinus Torvalds	$(call if_changed,ld)
1878d7e4cc2SNicolas Pitre	@$(check_for_bad_syms)
1881da177e4SLinus Torvalds
18953f67545SMasahiro Yamada$(obj)/piggy_data: $(obj)/../Image FORCE
190f57deb0bSMasahiro Yamada	$(call if_changed,$(compress-y))
1911da177e4SLinus Torvalds
19253f67545SMasahiro Yamada$(obj)/piggy.o: $(obj)/piggy_data
1931da177e4SLinus Torvalds
1944486b863SRussell KingCFLAGS_font.o := -Dstatic=
1954486b863SRussell King
1964486b863SRussell King$(obj)/font.c: $(FONTC)
1974486b863SRussell King	$(call cmd,shipped)
1981da177e4SLinus Torvalds
199c7edd7f9SJean-Philippe BruckerAFLAGS_hyp-stub.o := -Wa,-march=armv7-a
200c7edd7f9SJean-Philippe Brucker
201424e5994SDave Martin$(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S
202424e5994SDave Martin	$(call cmd,shipped)
203