162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci# 362306a36Sopenharmony_ci# linux/arch/arm/boot/compressed/Makefile 462306a36Sopenharmony_ci# 562306a36Sopenharmony_ci# create a compressed vmlinuz image from the original vmlinux 662306a36Sopenharmony_ci# 762306a36Sopenharmony_ci 862306a36Sopenharmony_ciOBJS = 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciHEAD = head.o 1162306a36Sopenharmony_ciOBJS += misc.o decompress.o 1262306a36Sopenharmony_ciifeq ($(CONFIG_DEBUG_UNCOMPRESS),y) 1362306a36Sopenharmony_ciOBJS += debug.o 1462306a36Sopenharmony_ciAFLAGS_head.o += -DDEBUG 1562306a36Sopenharmony_ciendif 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci# string library code (-Os is enforced to keep it much smaller) 1862306a36Sopenharmony_ciOBJS += string.o 1962306a36Sopenharmony_ciCFLAGS_string.o := -Os 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciifeq ($(CONFIG_ARM_VIRT_EXT),y) 2262306a36Sopenharmony_ciOBJS += hyp-stub.o 2362306a36Sopenharmony_ciendif 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ciGCOV_PROFILE := n 2662306a36Sopenharmony_ciKASAN_SANITIZE := n 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 2962306a36Sopenharmony_ciKCOV_INSTRUMENT := n 3062306a36Sopenharmony_ciUBSAN_SANITIZE := n 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci# 3362306a36Sopenharmony_ci# Architecture dependencies 3462306a36Sopenharmony_ci# 3562306a36Sopenharmony_ciifeq ($(CONFIG_ARCH_ACORN),y) 3662306a36Sopenharmony_ciOBJS += ll_char_wr.o font.o 3762306a36Sopenharmony_ciendif 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciifeq ($(CONFIG_ARCH_SA1100),y) 4062306a36Sopenharmony_ciOBJS += head-sa1100.o 4162306a36Sopenharmony_ciendif 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciifeq ($(CONFIG_CPU_XSCALE),y) 4462306a36Sopenharmony_ciOBJS += head-xscale.o 4562306a36Sopenharmony_ciendif 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ciifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y) 4862306a36Sopenharmony_ciOBJS += head-sharpsl.o 4962306a36Sopenharmony_ciendif 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ciifeq ($(CONFIG_CPU_ENDIAN_BE32),y) 5262306a36Sopenharmony_ciifeq ($(CONFIG_CPU_CP15),y) 5362306a36Sopenharmony_ciOBJS += big-endian.o 5462306a36Sopenharmony_cielse 5562306a36Sopenharmony_ci# The endian should be set by h/w design. 5662306a36Sopenharmony_ciendif 5762306a36Sopenharmony_ciendif 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci# 6062306a36Sopenharmony_ci# We now have a PIC decompressor implementation. Decompressors running 6162306a36Sopenharmony_ci# from RAM should not define ZTEXTADDR. Decompressors running directly 6262306a36Sopenharmony_ci# from ROM or Flash must define ZTEXTADDR (preferably via the config) 6362306a36Sopenharmony_ci# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK 6462306a36Sopenharmony_ciifeq ($(CONFIG_ZBOOT_ROM),y) 6562306a36Sopenharmony_ciZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT) 6662306a36Sopenharmony_ciZBSSADDR := $(CONFIG_ZBOOT_ROM_BSS) 6762306a36Sopenharmony_cielse 6862306a36Sopenharmony_ciZTEXTADDR := 0 6962306a36Sopenharmony_ciZBSSADDR := ALIGN(8) 7062306a36Sopenharmony_ciendif 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ciMALLOC_SIZE := 65536 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ciAFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET) -DMALLOC_SIZE=$(MALLOC_SIZE) 7562306a36Sopenharmony_ciCPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)" 7662306a36Sopenharmony_ciCPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_OFFSET)" 7762306a36Sopenharmony_ciCPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLOC_SIZE)" 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_cicompress-$(CONFIG_KERNEL_GZIP) = gzip 8062306a36Sopenharmony_cicompress-$(CONFIG_KERNEL_LZO) = lzo_with_size 8162306a36Sopenharmony_cicompress-$(CONFIG_KERNEL_LZMA) = lzma_with_size 8262306a36Sopenharmony_cicompress-$(CONFIG_KERNEL_XZ) = xzkern_with_size 8362306a36Sopenharmony_cicompress-$(CONFIG_KERNEL_LZ4) = lz4_with_size 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_cilibfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ciifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) 8862306a36Sopenharmony_ciCFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN} 8962306a36Sopenharmony_ciCFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280 9062306a36Sopenharmony_ciOBJS += $(libfdt_objs) atags_to_fdt.o 9162306a36Sopenharmony_ciendif 9262306a36Sopenharmony_ciifeq ($(CONFIG_USE_OF),y) 9362306a36Sopenharmony_ciOBJS += $(libfdt_objs) fdt_check_mem_start.o 9462306a36Sopenharmony_ciendif 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ciOBJS += lib1funcs.o ashldi3.o bswapsdi2.o 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_citargets := vmlinux vmlinux.lds piggy_data piggy.o \ 9962306a36Sopenharmony_ci head.o $(OBJS) 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ciKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ciccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ 10462306a36Sopenharmony_ci -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \ 10562306a36Sopenharmony_ci -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN) 10662306a36Sopenharmony_ciccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg 10762306a36Sopenharmony_ciasflags-y := -DZIMAGE 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci# Supply kernel BSS size to the decompressor via a linker symbol. 11062306a36Sopenharmony_ciKBSS_SZ = $(shell echo $$(($$($(NM) vmlinux | \ 11162306a36Sopenharmony_ci sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \ 11262306a36Sopenharmony_ci -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) ) 11362306a36Sopenharmony_ciLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) 11462306a36Sopenharmony_ci# Supply ZRELADDR to the decompressor via a linker symbol. 11562306a36Sopenharmony_ciifneq ($(CONFIG_AUTO_ZRELADDR),y) 11662306a36Sopenharmony_ciLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR) 11762306a36Sopenharmony_ciendif 11862306a36Sopenharmony_ciifeq ($(CONFIG_CPU_ENDIAN_BE8),y) 11962306a36Sopenharmony_ciLDFLAGS_vmlinux += --be8 12062306a36Sopenharmony_ciendif 12162306a36Sopenharmony_ci# Report unresolved symbol references 12262306a36Sopenharmony_ciLDFLAGS_vmlinux += --no-undefined 12362306a36Sopenharmony_ci# Delete all temporary local symbols 12462306a36Sopenharmony_ciLDFLAGS_vmlinux += -X 12562306a36Sopenharmony_ci# Report orphan sections 12662306a36Sopenharmony_ciifdef CONFIG_LD_ORPHAN_WARN 12762306a36Sopenharmony_ciLDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) 12862306a36Sopenharmony_ciendif 12962306a36Sopenharmony_ci# Next argument is a linker script 13062306a36Sopenharmony_ciLDFLAGS_vmlinux += -T 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci# We need to prevent any GOTOFF relocs being used with references 13362306a36Sopenharmony_ci# to symbols in the .bss section since we cannot relocate them 13462306a36Sopenharmony_ci# independently from the rest at run time. This can be achieved by 13562306a36Sopenharmony_ci# ensuring that no private .bss symbols exist, as global symbols 13662306a36Sopenharmony_ci# always have a GOT entry which is what we need. 13762306a36Sopenharmony_ci# The .data section is already discarded by the linker script so no need 13862306a36Sopenharmony_ci# to bother about it here. 13962306a36Sopenharmony_cicheck_for_bad_syms = \ 14062306a36Sopenharmony_cibad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \ 14162306a36Sopenharmony_ci[ -z "$$bad_syms" ] || \ 14262306a36Sopenharmony_ci ( echo "following symbols must have non local/private scope:" >&2; \ 14362306a36Sopenharmony_ci echo "$$bad_syms" >&2; false ) 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_cicheck_for_multiple_zreladdr = \ 14662306a36Sopenharmony_ciif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \ 14762306a36Sopenharmony_ci echo 'multiple zreladdrs: $(ZRELADDR)'; \ 14862306a36Sopenharmony_ci echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \ 14962306a36Sopenharmony_ci false; \ 15062306a36Sopenharmony_cifi 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ciefi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \ 15562306a36Sopenharmony_ci $(addprefix $(obj)/, $(OBJS)) \ 15662306a36Sopenharmony_ci $(efi-obj-y) FORCE 15762306a36Sopenharmony_ci @$(check_for_multiple_zreladdr) 15862306a36Sopenharmony_ci $(call if_changed,ld) 15962306a36Sopenharmony_ci @$(check_for_bad_syms) 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci$(obj)/piggy_data: $(obj)/../Image FORCE 16262306a36Sopenharmony_ci $(call if_changed,$(compress-y)) 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci$(obj)/piggy.o: $(obj)/piggy_data 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ciCFLAGS_font.o := -Dstatic= 167