1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun# 3*4882a593Smuzhiyun# linux/arch/arm/boot/compressed/Makefile 4*4882a593Smuzhiyun# 5*4882a593Smuzhiyun# create a compressed vmlinuz image from the original vmlinux 6*4882a593Smuzhiyun# 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunOBJS = 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunHEAD = head.o 11*4882a593SmuzhiyunOBJS += misc.o decompress.o 12*4882a593Smuzhiyunifeq ($(CONFIG_DEBUG_UNCOMPRESS),y) 13*4882a593SmuzhiyunOBJS += debug.o 14*4882a593SmuzhiyunAFLAGS_head.o += -DDEBUG 15*4882a593Smuzhiyunendif 16*4882a593SmuzhiyunFONTC = $(srctree)/lib/fonts/font_acorn_8x8.c 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun# string library code (-Os is enforced to keep it much smaller) 19*4882a593SmuzhiyunOBJS += string.o 20*4882a593SmuzhiyunCFLAGS_string.o := -Os 21*4882a593Smuzhiyun 22*4882a593Smuzhiyunifeq ($(CONFIG_ARM_VIRT_EXT),y) 23*4882a593SmuzhiyunOBJS += hyp-stub.o 24*4882a593Smuzhiyunendif 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunGCOV_PROFILE := n 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 29*4882a593SmuzhiyunKCOV_INSTRUMENT := n 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun# 32*4882a593Smuzhiyun# Architecture dependencies 33*4882a593Smuzhiyun# 34*4882a593Smuzhiyunifeq ($(CONFIG_ARCH_ACORN),y) 35*4882a593SmuzhiyunOBJS += ll_char_wr.o font.o 36*4882a593Smuzhiyunendif 37*4882a593Smuzhiyun 38*4882a593Smuzhiyunifeq ($(CONFIG_ARCH_SA1100),y) 39*4882a593SmuzhiyunOBJS += head-sa1100.o 40*4882a593Smuzhiyunendif 41*4882a593Smuzhiyun 42*4882a593Smuzhiyunifeq ($(CONFIG_CPU_XSCALE),y) 43*4882a593SmuzhiyunOBJS += head-xscale.o 44*4882a593Smuzhiyunendif 45*4882a593Smuzhiyun 46*4882a593Smuzhiyunifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y) 47*4882a593SmuzhiyunOBJS += head-sharpsl.o 48*4882a593Smuzhiyunendif 49*4882a593Smuzhiyun 50*4882a593Smuzhiyunifeq ($(CONFIG_CPU_ENDIAN_BE32),y) 51*4882a593Smuzhiyunifeq ($(CONFIG_CPU_CP15),y) 52*4882a593SmuzhiyunOBJS += big-endian.o 53*4882a593Smuzhiyunelse 54*4882a593Smuzhiyun# The endian should be set by h/w design. 55*4882a593Smuzhiyunendif 56*4882a593Smuzhiyunendif 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun# 59*4882a593Smuzhiyun# We now have a PIC decompressor implementation. Decompressors running 60*4882a593Smuzhiyun# from RAM should not define ZTEXTADDR. Decompressors running directly 61*4882a593Smuzhiyun# from ROM or Flash must define ZTEXTADDR (preferably via the config) 62*4882a593Smuzhiyun# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK 63*4882a593Smuzhiyunifeq ($(CONFIG_ZBOOT_ROM),y) 64*4882a593SmuzhiyunZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT) 65*4882a593SmuzhiyunZBSSADDR := $(CONFIG_ZBOOT_ROM_BSS) 66*4882a593Smuzhiyunelse 67*4882a593SmuzhiyunZTEXTADDR := 0 68*4882a593SmuzhiyunZBSSADDR := ALIGN(8) 69*4882a593Smuzhiyunendif 70*4882a593Smuzhiyun 71*4882a593SmuzhiyunMALLOC_SIZE := 65536 72*4882a593Smuzhiyun 73*4882a593SmuzhiyunAFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET) -DMALLOC_SIZE=$(MALLOC_SIZE) 74*4882a593SmuzhiyunCPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)" 75*4882a593SmuzhiyunCPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_OFFSET)" 76*4882a593SmuzhiyunCPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLOC_SIZE)" 77*4882a593Smuzhiyun 78*4882a593Smuzhiyuncompress-$(CONFIG_KERNEL_GZIP) = gzip 79*4882a593Smuzhiyuncompress-$(CONFIG_KERNEL_LZO) = lzo 80*4882a593Smuzhiyuncompress-$(CONFIG_KERNEL_LZMA) = lzma 81*4882a593Smuzhiyuncompress-$(CONFIG_KERNEL_XZ) = xzkern 82*4882a593Smuzhiyuncompress-$(CONFIG_KERNEL_LZ4) = lz4 83*4882a593Smuzhiyun 84*4882a593Smuzhiyunlibfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o 85*4882a593Smuzhiyun 86*4882a593Smuzhiyunifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) 87*4882a593SmuzhiyunCFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN} 88*4882a593SmuzhiyunCFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280 89*4882a593SmuzhiyunOBJS += $(libfdt_objs) atags_to_fdt.o 90*4882a593Smuzhiyunendif 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun# -fstack-protector-strong triggers protection checks in this code, 93*4882a593Smuzhiyun# but it is being used too early to link to meaningful stack_chk logic. 94*4882a593Smuzhiyun$(foreach o, $(libfdt_objs) atags_to_fdt.o, \ 95*4882a593Smuzhiyun $(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector)) 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun# These were previously generated C files. When you are building the kernel 98*4882a593Smuzhiyun# with O=, make sure to remove the stale files in the output tree. Otherwise, 99*4882a593Smuzhiyun# the build system wrongly compiles the stale ones. 100*4882a593Smuzhiyunifdef building_out_of_srctree 101*4882a593Smuzhiyun$(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c)) 102*4882a593Smuzhiyunendif 103*4882a593Smuzhiyun 104*4882a593Smuzhiyuntargets := vmlinux vmlinux.lds piggy_data piggy.o \ 105*4882a593Smuzhiyun lib1funcs.o ashldi3.o bswapsdi2.o \ 106*4882a593Smuzhiyun head.o $(OBJS) 107*4882a593Smuzhiyun 108*4882a593Smuzhiyunclean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S 109*4882a593Smuzhiyun 110*4882a593SmuzhiyunKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 111*4882a593Smuzhiyun 112*4882a593Smuzhiyunccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ 113*4882a593Smuzhiyun -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN) 114*4882a593Smuzhiyunccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg 115*4882a593Smuzhiyunasflags-y := -DZIMAGE 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun# Supply kernel BSS size to the decompressor via a linker symbol. 118*4882a593SmuzhiyunKBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \ 119*4882a593Smuzhiyun sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \ 120*4882a593Smuzhiyun -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) ) 121*4882a593SmuzhiyunLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) 122*4882a593Smuzhiyun# Supply ZRELADDR to the decompressor via a linker symbol. 123*4882a593Smuzhiyunifneq ($(CONFIG_AUTO_ZRELADDR),y) 124*4882a593SmuzhiyunLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR) 125*4882a593Smuzhiyunendif 126*4882a593Smuzhiyunifeq ($(CONFIG_CPU_ENDIAN_BE8),y) 127*4882a593SmuzhiyunLDFLAGS_vmlinux += --be8 128*4882a593Smuzhiyunendif 129*4882a593Smuzhiyun# Report unresolved symbol references 130*4882a593SmuzhiyunLDFLAGS_vmlinux += --no-undefined 131*4882a593Smuzhiyun# Delete all temporary local symbols 132*4882a593SmuzhiyunLDFLAGS_vmlinux += -X 133*4882a593Smuzhiyun# Report orphan sections 134*4882a593Smuzhiyunifdef CONFIG_LD_ORPHAN_WARN 135*4882a593SmuzhiyunLDFLAGS_vmlinux += --orphan-handling=warn 136*4882a593Smuzhiyunendif 137*4882a593Smuzhiyun# Next argument is a linker script 138*4882a593SmuzhiyunLDFLAGS_vmlinux += -T 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun# For __aeabi_uidivmod 141*4882a593Smuzhiyunlib1funcs = $(obj)/lib1funcs.o 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S 144*4882a593Smuzhiyun $(call cmd,shipped) 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun# For __aeabi_llsl 147*4882a593Smuzhiyunashldi3 = $(obj)/ashldi3.o 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S 150*4882a593Smuzhiyun $(call cmd,shipped) 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun# For __bswapsi2, __bswapdi2 153*4882a593Smuzhiyunbswapsdi2 = $(obj)/bswapsdi2.o 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun$(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S 156*4882a593Smuzhiyun $(call cmd,shipped) 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun# We need to prevent any GOTOFF relocs being used with references 159*4882a593Smuzhiyun# to symbols in the .bss section since we cannot relocate them 160*4882a593Smuzhiyun# independently from the rest at run time. This can be achieved by 161*4882a593Smuzhiyun# ensuring that no private .bss symbols exist, as global symbols 162*4882a593Smuzhiyun# always have a GOT entry which is what we need. 163*4882a593Smuzhiyun# The .data section is already discarded by the linker script so no need 164*4882a593Smuzhiyun# to bother about it here. 165*4882a593Smuzhiyuncheck_for_bad_syms = \ 166*4882a593Smuzhiyunbad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \ 167*4882a593Smuzhiyun[ -z "$$bad_syms" ] || \ 168*4882a593Smuzhiyun ( echo "following symbols must have non local/private scope:" >&2; \ 169*4882a593Smuzhiyun echo "$$bad_syms" >&2; false ) 170*4882a593Smuzhiyun 171*4882a593Smuzhiyuncheck_for_multiple_zreladdr = \ 172*4882a593Smuzhiyunif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \ 173*4882a593Smuzhiyun echo 'multiple zreladdrs: $(ZRELADDR)'; \ 174*4882a593Smuzhiyun echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \ 175*4882a593Smuzhiyun false; \ 176*4882a593Smuzhiyunfi 177*4882a593Smuzhiyun 178*4882a593Smuzhiyunefi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \ 181*4882a593Smuzhiyun $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \ 182*4882a593Smuzhiyun $(bswapsdi2) $(efi-obj-y) FORCE 183*4882a593Smuzhiyun @$(check_for_multiple_zreladdr) 184*4882a593Smuzhiyun $(call if_changed,ld) 185*4882a593Smuzhiyun @$(check_for_bad_syms) 186*4882a593Smuzhiyun 187*4882a593Smuzhiyun$(obj)/piggy_data: $(obj)/../Image FORCE 188*4882a593Smuzhiyun $(call if_changed,$(compress-y)) 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun$(obj)/piggy.o: $(obj)/piggy_data 191*4882a593Smuzhiyun 192*4882a593SmuzhiyunCFLAGS_font.o := -Dstatic= 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun$(obj)/font.c: $(FONTC) 195*4882a593Smuzhiyun $(call cmd,shipped) 196*4882a593Smuzhiyun 197*4882a593SmuzhiyunAFLAGS_hyp-stub.o := -Wa,-march=armv7-a 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun$(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S 200*4882a593Smuzhiyun $(call cmd,shipped) 201