18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci# 38c2ecf20Sopenharmony_ci# linux/arch/arm/boot/compressed/Makefile 48c2ecf20Sopenharmony_ci# 58c2ecf20Sopenharmony_ci# create a compressed vmlinuz image from the original vmlinux 68c2ecf20Sopenharmony_ci# 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ciOBJS = 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciHEAD = head.o 118c2ecf20Sopenharmony_ciOBJS += misc.o decompress.o 128c2ecf20Sopenharmony_ciifeq ($(CONFIG_DEBUG_UNCOMPRESS),y) 138c2ecf20Sopenharmony_ciOBJS += debug.o 148c2ecf20Sopenharmony_ciAFLAGS_head.o += -DDEBUG 158c2ecf20Sopenharmony_ciendif 168c2ecf20Sopenharmony_ciFONTC = $(srctree)/lib/fonts/font_acorn_8x8.c 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci# string library code (-Os is enforced to keep it much smaller) 198c2ecf20Sopenharmony_ciOBJS += string.o 208c2ecf20Sopenharmony_ciCFLAGS_string.o := -Os 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciifeq ($(CONFIG_ARM_VIRT_EXT),y) 238c2ecf20Sopenharmony_ciOBJS += hyp-stub.o 248c2ecf20Sopenharmony_ciendif 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciGCOV_PROFILE := n 278c2ecf20Sopenharmony_ciKASAN_SANITIZE := n 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 308c2ecf20Sopenharmony_ciKCOV_INSTRUMENT := n 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci# 338c2ecf20Sopenharmony_ci# Architecture dependencies 348c2ecf20Sopenharmony_ci# 358c2ecf20Sopenharmony_ciifeq ($(CONFIG_ARCH_ACORN),y) 368c2ecf20Sopenharmony_ciOBJS += ll_char_wr.o font.o 378c2ecf20Sopenharmony_ciendif 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciifeq ($(CONFIG_ARCH_SA1100),y) 408c2ecf20Sopenharmony_ciOBJS += head-sa1100.o 418c2ecf20Sopenharmony_ciendif 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciifeq ($(CONFIG_CPU_XSCALE),y) 448c2ecf20Sopenharmony_ciOBJS += head-xscale.o 458c2ecf20Sopenharmony_ciendif 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y) 488c2ecf20Sopenharmony_ciOBJS += head-sharpsl.o 498c2ecf20Sopenharmony_ciendif 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciifeq ($(CONFIG_CPU_ENDIAN_BE32),y) 528c2ecf20Sopenharmony_ciifeq ($(CONFIG_CPU_CP15),y) 538c2ecf20Sopenharmony_ciOBJS += big-endian.o 548c2ecf20Sopenharmony_cielse 558c2ecf20Sopenharmony_ci# The endian should be set by h/w design. 568c2ecf20Sopenharmony_ciendif 578c2ecf20Sopenharmony_ciendif 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci# 608c2ecf20Sopenharmony_ci# We now have a PIC decompressor implementation. Decompressors running 618c2ecf20Sopenharmony_ci# from RAM should not define ZTEXTADDR. Decompressors running directly 628c2ecf20Sopenharmony_ci# from ROM or Flash must define ZTEXTADDR (preferably via the config) 638c2ecf20Sopenharmony_ci# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK 648c2ecf20Sopenharmony_ciifeq ($(CONFIG_ZBOOT_ROM),y) 658c2ecf20Sopenharmony_ciZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT) 668c2ecf20Sopenharmony_ciZBSSADDR := $(CONFIG_ZBOOT_ROM_BSS) 678c2ecf20Sopenharmony_cielse 688c2ecf20Sopenharmony_ciZTEXTADDR := 0 698c2ecf20Sopenharmony_ciZBSSADDR := ALIGN(8) 708c2ecf20Sopenharmony_ciendif 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ciMALLOC_SIZE := 65536 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ciAFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET) -DMALLOC_SIZE=$(MALLOC_SIZE) 758c2ecf20Sopenharmony_ciCPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)" 768c2ecf20Sopenharmony_ciCPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_OFFSET)" 778c2ecf20Sopenharmony_ciCPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLOC_SIZE)" 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cicompress-$(CONFIG_KERNEL_GZIP) = gzip 808c2ecf20Sopenharmony_cicompress-$(CONFIG_KERNEL_LZO) = lzo 818c2ecf20Sopenharmony_cicompress-$(CONFIG_KERNEL_LZMA) = lzma 828c2ecf20Sopenharmony_cicompress-$(CONFIG_KERNEL_XZ) = xzkern 838c2ecf20Sopenharmony_cicompress-$(CONFIG_KERNEL_LZ4) = lz4 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cilibfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ciifneq ($(CONFIG_ARM_ATAG_DTB_COMPAT)$(CONFIG_RANDOMIZE_BASE),) 888c2ecf20Sopenharmony_ciOBJS += $(libfdt_objs) 898c2ecf20Sopenharmony_ciifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) 908c2ecf20Sopenharmony_ciCFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN} 918c2ecf20Sopenharmony_ciCFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280 928c2ecf20Sopenharmony_ciOBJS += atags_to_fdt.o 938c2ecf20Sopenharmony_ciendif 948c2ecf20Sopenharmony_ciifeq ($(CONFIG_RANDOMIZE_BASE),y) 958c2ecf20Sopenharmony_ciOBJS += kaslr.o 968c2ecf20Sopenharmony_ciCFLAGS_kaslr.o := -I $(srctree)/scripts/dtc/libfdt 978c2ecf20Sopenharmony_ciendif 988c2ecf20Sopenharmony_ciendif 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci# -fstack-protector-strong triggers protection checks in this code, 1018c2ecf20Sopenharmony_ci# but it is being used too early to link to meaningful stack_chk logic. 1028c2ecf20Sopenharmony_ci$(foreach o, $(libfdt_objs) atags_to_fdt.o, \ 1038c2ecf20Sopenharmony_ci $(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector)) 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci# These were previously generated C files. When you are building the kernel 1068c2ecf20Sopenharmony_ci# with O=, make sure to remove the stale files in the output tree. Otherwise, 1078c2ecf20Sopenharmony_ci# the build system wrongly compiles the stale ones. 1088c2ecf20Sopenharmony_ciifdef building_out_of_srctree 1098c2ecf20Sopenharmony_ci$(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c)) 1108c2ecf20Sopenharmony_ciendif 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_citargets := vmlinux vmlinux.lds piggy_data piggy.o \ 1138c2ecf20Sopenharmony_ci lib1funcs.o ashldi3.o bswapsdi2.o \ 1148c2ecf20Sopenharmony_ci head.o $(OBJS) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciclean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ciifeq ($(CONFIG_RELOCATABLE),y) 1198c2ecf20Sopenharmony_ciHIDDEN_STR := -include $(srctree)/include/linux/hidden.h 1208c2ecf20Sopenharmony_ciKBUILD_CFLAGS := $(subst $(HIDDEN_STR), , $(KBUILD_CFLAGS)) 1218c2ecf20Sopenharmony_ciendif 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ciccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ 1268c2ecf20Sopenharmony_ci -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN) 1278c2ecf20Sopenharmony_ciccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg 1288c2ecf20Sopenharmony_ciasflags-y := -DZIMAGE 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci# Supply kernel BSS size to the decompressor via a linker symbol. 1318c2ecf20Sopenharmony_ciKBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \ 1328c2ecf20Sopenharmony_ci sed -n -e 's/^\([^ ]*\) [ABbD] __bss_start$$/-0x\1/p' \ 1338c2ecf20Sopenharmony_ci -e 's/^\([^ ]*\) [ABbD] __bss_stop$$/+0x\1/p') )) ) 1348c2ecf20Sopenharmony_ciLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) 1358c2ecf20Sopenharmony_ci# Supply ZRELADDR to the decompressor via a linker symbol. 1368c2ecf20Sopenharmony_ciifneq ($(CONFIG_AUTO_ZRELADDR),y) 1378c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR) 1388c2ecf20Sopenharmony_ciendif 1398c2ecf20Sopenharmony_ciifeq ($(CONFIG_CPU_ENDIAN_BE8),y) 1408c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --be8 1418c2ecf20Sopenharmony_ciendif 1428c2ecf20Sopenharmony_ci# Report unresolved symbol references 1438c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --no-undefined 1448c2ecf20Sopenharmony_ci# Delete all temporary local symbols 1458c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += -X 1468c2ecf20Sopenharmony_ci# Report orphan sections 1478c2ecf20Sopenharmony_ciifdef CONFIG_LD_ORPHAN_WARN 1488c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --orphan-handling=warn 1498c2ecf20Sopenharmony_ciendif 1508c2ecf20Sopenharmony_ci# Next argument is a linker script 1518c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += -T 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci# For __aeabi_uidivmod 1548c2ecf20Sopenharmony_cilib1funcs = $(obj)/lib1funcs.o 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S 1578c2ecf20Sopenharmony_ci $(call cmd,shipped) 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci# For __aeabi_llsl 1608c2ecf20Sopenharmony_ciashldi3 = $(obj)/ashldi3.o 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S 1638c2ecf20Sopenharmony_ci $(call cmd,shipped) 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci# For __bswapsi2, __bswapdi2 1668c2ecf20Sopenharmony_cibswapsdi2 = $(obj)/bswapsdi2.o 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci$(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S 1698c2ecf20Sopenharmony_ci $(call cmd,shipped) 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci# We need to prevent any GOTOFF relocs being used with references 1728c2ecf20Sopenharmony_ci# to symbols in the .bss section since we cannot relocate them 1738c2ecf20Sopenharmony_ci# independently from the rest at run time. This can be achieved by 1748c2ecf20Sopenharmony_ci# ensuring that no private .bss symbols exist, as global symbols 1758c2ecf20Sopenharmony_ci# always have a GOT entry which is what we need. 1768c2ecf20Sopenharmony_ci# The .data section is already discarded by the linker script so no need 1778c2ecf20Sopenharmony_ci# to bother about it here. 1788c2ecf20Sopenharmony_cicheck_for_bad_syms = \ 1798c2ecf20Sopenharmony_cibad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \ 1808c2ecf20Sopenharmony_ci[ -z "$$bad_syms" ] || \ 1818c2ecf20Sopenharmony_ci ( echo "following symbols must have non local/private scope:" >&2; \ 1828c2ecf20Sopenharmony_ci echo "$$bad_syms" >&2; false ) 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_cicheck_for_multiple_zreladdr = \ 1858c2ecf20Sopenharmony_ciif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \ 1868c2ecf20Sopenharmony_ci echo 'multiple zreladdrs: $(ZRELADDR)'; \ 1878c2ecf20Sopenharmony_ci echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \ 1888c2ecf20Sopenharmony_ci false; \ 1898c2ecf20Sopenharmony_cifi 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ciefi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \ 1948c2ecf20Sopenharmony_ci $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \ 1958c2ecf20Sopenharmony_ci $(bswapsdi2) $(efi-obj-y) FORCE 1968c2ecf20Sopenharmony_ci @$(check_for_multiple_zreladdr) 1978c2ecf20Sopenharmony_ci $(call if_changed,ld) 1988c2ecf20Sopenharmony_ci @$(check_for_bad_syms) 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci$(obj)/piggy_data: $(obj)/../Image FORCE 2018c2ecf20Sopenharmony_ci $(call if_changed,$(compress-y)) 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci$(obj)/piggy.o: $(obj)/piggy_data 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ciCFLAGS_font.o := -Dstatic= 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci$(obj)/font.c: $(FONTC) 2088c2ecf20Sopenharmony_ci $(call cmd,shipped) 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ciAFLAGS_hyp-stub.o := -Wa,-march=armv7-a 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci$(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S 2138c2ecf20Sopenharmony_ci $(call cmd,shipped) 214