xref: /linux/arch/arm/boot/compressed/Makefile (revision 01a620d491592ead12eca039fe1c9e74908c35cf)
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
101da177e4SLinus TorvaldsHEAD	= head.o
11f45b1149SSimon HormanOBJS	+= misc.o decompress.o
12*2335c9cbSJinjie RuanCFLAGS_decompress.o += $(DISABLE_STACKLEAK_PLUGIN)
133b4af9bcSShawn Guoifeq ($(CONFIG_DEBUG_UNCOMPRESS),y)
143b4af9bcSShawn GuoOBJS	+= debug.o
152596a72dSLinus WalleijAFLAGS_head.o += -DDEBUG
163b4af9bcSShawn Guoendif
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
261da177e4SLinus Torvalds#
271da177e4SLinus Torvalds# Architecture dependencies
281da177e4SLinus Torvalds#
291da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_ACORN),y)
304486b863SRussell KingOBJS		+= ll_char_wr.o font.o
311da177e4SLinus Torvaldsendif
321da177e4SLinus Torvalds
331da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_SA1100),y)
341da177e4SLinus TorvaldsOBJS		+= head-sa1100.o
351da177e4SLinus Torvaldsendif
361da177e4SLinus Torvalds
371da177e4SLinus Torvaldsifeq ($(CONFIG_CPU_XSCALE),y)
381da177e4SLinus TorvaldsOBJS		+= head-xscale.o
391da177e4SLinus Torvaldsendif
401da177e4SLinus Torvalds
419c3fca2eSEric Miaoifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y)
421da177e4SLinus TorvaldsOBJS		+= head-sharpsl.o
431da177e4SLinus Torvaldsendif
441da177e4SLinus Torvalds
4526584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE32),y)
46f12d0d7cSHyok S. Choiifeq ($(CONFIG_CPU_CP15),y)
471da177e4SLinus TorvaldsOBJS		+= big-endian.o
48f12d0d7cSHyok S. Choielse
49f12d0d7cSHyok S. Choi# The endian should be set by h/w design.
50f12d0d7cSHyok S. Choiendif
511da177e4SLinus Torvaldsendif
521da177e4SLinus Torvalds
531da177e4SLinus Torvalds#
541da177e4SLinus Torvalds# We now have a PIC decompressor implementation.  Decompressors running
551da177e4SLinus Torvalds# from RAM should not define ZTEXTADDR.  Decompressors running directly
561da177e4SLinus Torvalds# from ROM or Flash must define ZTEXTADDR (preferably via the config)
571da177e4SLinus Torvalds# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
581da177e4SLinus Torvaldsifeq ($(CONFIG_ZBOOT_ROM),y)
591da177e4SLinus TorvaldsZTEXTADDR	:= $(CONFIG_ZBOOT_ROM_TEXT)
601da177e4SLinus TorvaldsZBSSADDR	:= $(CONFIG_ZBOOT_ROM_BSS)
611da177e4SLinus Torvaldselse
621da177e4SLinus TorvaldsZTEXTADDR	:= 0
633bd2cbb9SNicolas PitreZBSSADDR	:= ALIGN(8)
641da177e4SLinus Torvaldsendif
651da177e4SLinus Torvalds
66adc5f702SRussell KingMALLOC_SIZE	:= 65536
67adc5f702SRussell King
68adc5f702SRussell KingAFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET) -DMALLOC_SIZE=$(MALLOC_SIZE)
69c79bf928SRussell KingCPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
7083dfeedbSRussell KingCPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_OFFSET)"
71adc5f702SRussell KingCPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLOC_SIZE)"
721da177e4SLinus Torvalds
73f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_GZIP) = gzip
747ce7e984SMasahiro Yamadacompress-$(CONFIG_KERNEL_LZO)  = lzo_with_size
757ce7e984SMasahiro Yamadacompress-$(CONFIG_KERNEL_LZMA) = lzma_with_size
767ce7e984SMasahiro Yamadacompress-$(CONFIG_KERNEL_XZ)   = xzkern_with_size
777ce7e984SMasahiro Yamadacompress-$(CONFIG_KERNEL_LZ4)  = lz4_with_size
78e7db7b42SAlbin Tonnerre
797ae4a78dSMasahiro Yamadalibfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
80b90b9a38SNicolas Pitre
81b90b9a38SNicolas Pitreifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
82b30d0289SDavid HeidelbergCFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN}
83b30d0289SDavid HeidelbergCFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280
84b90b9a38SNicolas PitreOBJS	+= $(libfdt_objs) atags_to_fdt.o
85b90b9a38SNicolas Pitreendif
860673cb38SGeert Uytterhoevenifeq ($(CONFIG_USE_OF),y)
870673cb38SGeert UytterhoevenOBJS	+= $(libfdt_objs) fdt_check_mem_start.o
880673cb38SGeert Uytterhoevenendif
89b90b9a38SNicolas Pitre
909c6d6652SMasahiro YamadaOBJS	+= lib1funcs.o ashldi3.o bswapsdi2.o
919c6d6652SMasahiro Yamada
9253f67545SMasahiro Yamadatargets       := vmlinux vmlinux.lds piggy_data piggy.o \
93684c1201SMasahiro Yamada		 head.o $(OBJS)
94014c257cSAbhishek Sagar
958c36a757SArnd BergmannKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
968c36a757SArnd Bergmann
9789604523SArd Biesheuvelccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \
98672513bfSArd Biesheuvel	     -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
9989604523SArd Biesheuvel	     -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN)
10015d5761aSMasahiro Yamadaccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg
101da94a829SArnd Bergmannasflags-y := -DZIMAGE
1021da177e4SLinus Torvalds
1035ffb04f6SNicolas Pitre# Supply kernel BSS size to the decompressor via a linker symbol.
1041881b4d6SMasahiro YamadaKBSS_SZ = $(shell echo $$(($$($(NM) vmlinux | \
105c4e792d1SArd Biesheuvel		sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \
106c4e792d1SArd Biesheuvel		       -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) )
1075ffb04f6SNicolas PitreLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
1089e84ed63SRussell King# Supply ZRELADDR to the decompressor via a linker symbol.
1099e84ed63SRussell Kingifneq ($(CONFIG_AUTO_ZRELADDR),y)
110d239b1dcSNicolas PitreLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
1119e84ed63SRussell Kingendif
11226584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
11326584853SCatalin MarinasLDFLAGS_vmlinux += --be8
11426584853SCatalin Marinasendif
115e7db7b42SAlbin Tonnerre# Report unresolved symbol references
116e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += --no-undefined
117e7db7b42SAlbin Tonnerre# Delete all temporary local symbols
118e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -X
1194409d2f8SKees Cook# Report orphan sections
12059612b24SNathan Chancellorifdef CONFIG_LD_ORPHAN_WARN
121e1789d7cSXin LiLDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
12259612b24SNathan Chancellorendif
123e7db7b42SAlbin Tonnerre# Next argument is a linker script
124e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -T
125e7db7b42SAlbin Tonnerre
1268d7e4cc2SNicolas Pitre# We need to prevent any GOTOFF relocs being used with references
1278d7e4cc2SNicolas Pitre# to symbols in the .bss section since we cannot relocate them
1288d7e4cc2SNicolas Pitre# independently from the rest at run time.  This can be achieved by
1298d7e4cc2SNicolas Pitre# ensuring that no private .bss symbols exist, as global symbols
1308d7e4cc2SNicolas Pitre# always have a GOT entry which is what we need.
1318d7e4cc2SNicolas Pitre# The .data section is already discarded by the linker script so no need
1328d7e4cc2SNicolas Pitre# to bother about it here.
1338d7e4cc2SNicolas Pitrecheck_for_bad_syms = \
13429c623d6SDmitry Golovinbad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
1358d7e4cc2SNicolas Pitre[ -z "$$bad_syms" ] || \
1368d7e4cc2SNicolas Pitre  ( echo "following symbols must have non local/private scope:" >&2; \
137172caf19SMasahiro Yamada    echo "$$bad_syms" >&2; false )
1388d7e4cc2SNicolas Pitre
13960aac932SSascha Hauercheck_for_multiple_zreladdr = \
1404bdad983SRabin Vincentif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \
14160aac932SSascha Hauer	echo 'multiple zreladdrs: $(ZRELADDR)'; \
14260aac932SSascha Hauer	echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \
14360aac932SSascha Hauer	false; \
14460aac932SSascha Hauerfi
14560aac932SSascha Hauer
14681a0bc39SRoy Franzefi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a
14781a0bc39SRoy Franz
14853f67545SMasahiro Yamada$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
149251cc826SMasahiro Yamada		$(addprefix $(obj)/, $(OBJS)) \
150251cc826SMasahiro Yamada		$(efi-obj-y) FORCE
15160aac932SSascha Hauer	@$(check_for_multiple_zreladdr)
1521da177e4SLinus Torvalds	$(call if_changed,ld)
1538d7e4cc2SNicolas Pitre	@$(check_for_bad_syms)
1541da177e4SLinus Torvalds
15553f67545SMasahiro Yamada$(obj)/piggy_data: $(obj)/../Image FORCE
156f57deb0bSMasahiro Yamada	$(call if_changed,$(compress-y))
1571da177e4SLinus Torvalds
15853f67545SMasahiro Yamada$(obj)/piggy.o: $(obj)/piggy_data
1591da177e4SLinus Torvalds
1604486b863SRussell KingCFLAGS_font.o := -Dstatic=
161