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 123b4af9bcSShawn Guoifeq ($(CONFIG_DEBUG_UNCOMPRESS),y) 133b4af9bcSShawn GuoOBJS += debug.o 142596a72dSLinus WalleijAFLAGS_head.o += -DDEBUG 153b4af9bcSShawn Guoendif 161da177e4SLinus Torvalds 17df4879faSNicolas Pitre# string library code (-Os is enforced to keep it much smaller) 18df4879faSNicolas PitreOBJS += string.o 19df4879faSNicolas PitreCFLAGS_string.o := -Os 20df4879faSNicolas Pitre 21424e5994SDave Martinifeq ($(CONFIG_ARM_VIRT_EXT),y) 22424e5994SDave MartinOBJS += hyp-stub.o 23424e5994SDave Martinendif 24424e5994SDave Martin 2575c34906SVincent SandersGCOV_PROFILE := n 26d5d44e7eSLinus WalleijKASAN_SANITIZE := 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 71adc5f702SRussell KingMALLOC_SIZE := 65536 72adc5f702SRussell King 73adc5f702SRussell KingAFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET) -DMALLOC_SIZE=$(MALLOC_SIZE) 74c79bf928SRussell KingCPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)" 7583dfeedbSRussell KingCPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_OFFSET)" 76adc5f702SRussell KingCPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLOC_SIZE)" 771da177e4SLinus Torvalds 78f57deb0bSMasahiro Yamadacompress-$(CONFIG_KERNEL_GZIP) = gzip 797ce7e984SMasahiro Yamadacompress-$(CONFIG_KERNEL_LZO) = lzo_with_size 807ce7e984SMasahiro Yamadacompress-$(CONFIG_KERNEL_LZMA) = lzma_with_size 817ce7e984SMasahiro Yamadacompress-$(CONFIG_KERNEL_XZ) = xzkern_with_size 827ce7e984SMasahiro Yamadacompress-$(CONFIG_KERNEL_LZ4) = lz4_with_size 83e7db7b42SAlbin Tonnerre 847ae4a78dSMasahiro Yamadalibfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o 85b90b9a38SNicolas Pitre 86b90b9a38SNicolas Pitreifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) 87b30d0289SDavid HeidelbergCFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN} 88b30d0289SDavid HeidelbergCFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280 89b90b9a38SNicolas PitreOBJS += $(libfdt_objs) atags_to_fdt.o 90b90b9a38SNicolas Pitreendif 910673cb38SGeert Uytterhoevenifeq ($(CONFIG_USE_OF),y) 920673cb38SGeert UytterhoevenOBJS += $(libfdt_objs) fdt_check_mem_start.o 930673cb38SGeert Uytterhoevenendif 94b90b9a38SNicolas Pitre 959c6d6652SMasahiro YamadaOBJS += lib1funcs.o ashldi3.o bswapsdi2.o 969c6d6652SMasahiro Yamada 9753f67545SMasahiro Yamadatargets := vmlinux vmlinux.lds piggy_data piggy.o \ 98684c1201SMasahiro Yamada head.o $(OBJS) 99014c257cSAbhishek Sagar 1008c36a757SArnd BergmannKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 1018c36a757SArnd Bergmann 10289604523SArd Biesheuvelccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ 103672513bfSArd Biesheuvel -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \ 10489604523SArd Biesheuvel -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN) 10515d5761aSMasahiro Yamadaccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg 106da94a829SArnd Bergmannasflags-y := -DZIMAGE 1071da177e4SLinus Torvalds 1085ffb04f6SNicolas Pitre# Supply kernel BSS size to the decompressor via a linker symbol. 10929c623d6SDmitry GolovinKBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \ 110c4e792d1SArd Biesheuvel sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \ 111c4e792d1SArd Biesheuvel -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) ) 1125ffb04f6SNicolas PitreLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) 1139e84ed63SRussell King# Supply ZRELADDR to the decompressor via a linker symbol. 1149e84ed63SRussell Kingifneq ($(CONFIG_AUTO_ZRELADDR),y) 115d239b1dcSNicolas PitreLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR) 1169e84ed63SRussell Kingendif 11726584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE8),y) 11826584853SCatalin MarinasLDFLAGS_vmlinux += --be8 11926584853SCatalin Marinasendif 120e7db7b42SAlbin Tonnerre# Report unresolved symbol references 121e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += --no-undefined 122e7db7b42SAlbin Tonnerre# Delete all temporary local symbols 123e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -X 1244409d2f8SKees Cook# Report orphan sections 12559612b24SNathan Chancellorifdef CONFIG_LD_ORPHAN_WARN 126*e1789d7cSXin LiLDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) 12759612b24SNathan Chancellorendif 128e7db7b42SAlbin Tonnerre# Next argument is a linker script 129e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -T 130e7db7b42SAlbin Tonnerre 1318d7e4cc2SNicolas Pitre# We need to prevent any GOTOFF relocs being used with references 1328d7e4cc2SNicolas Pitre# to symbols in the .bss section since we cannot relocate them 1338d7e4cc2SNicolas Pitre# independently from the rest at run time. This can be achieved by 1348d7e4cc2SNicolas Pitre# ensuring that no private .bss symbols exist, as global symbols 1358d7e4cc2SNicolas Pitre# always have a GOT entry which is what we need. 1368d7e4cc2SNicolas Pitre# The .data section is already discarded by the linker script so no need 1378d7e4cc2SNicolas Pitre# to bother about it here. 1388d7e4cc2SNicolas Pitrecheck_for_bad_syms = \ 13929c623d6SDmitry Golovinbad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \ 1408d7e4cc2SNicolas Pitre[ -z "$$bad_syms" ] || \ 1418d7e4cc2SNicolas Pitre ( echo "following symbols must have non local/private scope:" >&2; \ 142172caf19SMasahiro Yamada echo "$$bad_syms" >&2; false ) 1438d7e4cc2SNicolas Pitre 14460aac932SSascha Hauercheck_for_multiple_zreladdr = \ 1454bdad983SRabin Vincentif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \ 14660aac932SSascha Hauer echo 'multiple zreladdrs: $(ZRELADDR)'; \ 14760aac932SSascha Hauer echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \ 14860aac932SSascha Hauer false; \ 14960aac932SSascha Hauerfi 15060aac932SSascha Hauer 15181a0bc39SRoy Franzefi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a 15281a0bc39SRoy Franz 15353f67545SMasahiro Yamada$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \ 154251cc826SMasahiro Yamada $(addprefix $(obj)/, $(OBJS)) \ 155251cc826SMasahiro Yamada $(efi-obj-y) FORCE 15660aac932SSascha Hauer @$(check_for_multiple_zreladdr) 1571da177e4SLinus Torvalds $(call if_changed,ld) 1588d7e4cc2SNicolas Pitre @$(check_for_bad_syms) 1591da177e4SLinus Torvalds 16053f67545SMasahiro Yamada$(obj)/piggy_data: $(obj)/../Image FORCE 161f57deb0bSMasahiro Yamada $(call if_changed,$(compress-y)) 1621da177e4SLinus Torvalds 16353f67545SMasahiro Yamada$(obj)/piggy.o: $(obj)/piggy_data 1641da177e4SLinus Torvalds 1654486b863SRussell KingCFLAGS_font.o := -Dstatic= 166c7edd7f9SJean-Philippe BruckerAFLAGS_hyp-stub.o := -Wa,-march=armv7-a 167