1 # SPDX-License-Identifier: GPL-2.0 << 2 # 1 # 3 # linux/arch/arm/boot/compressed/Makefile !! 2 # This file is subject to the terms and conditions of the GNU General Public >> 3 # License. 4 # 4 # 5 # create a compressed vmlinuz image from the o !! 5 # Adapted for MIPS Pete Popov, Dan Malek >> 6 # >> 7 # Copyright (C) 1994 by Linus Torvalds >> 8 # Adapted for PowerPC by Gary Thomas >> 9 # modified by Cort (cort@cs.nmt.edu) >> 10 # >> 11 # Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University >> 12 # Author: Wu Zhangjin <wuzhangjin@gmail.com> 6 # 13 # 7 14 8 OBJS = !! 15 include $(srctree)/arch/mips/Kbuild.platforms 9 16 10 HEAD = head.o !! 17 # set the default size of the mallocing area for decompressing 11 OBJS += misc.o decompress.o !! 18 BOOT_HEAP_SIZE := 0x400000 12 CFLAGS_decompress.o += $(DISABLE_STACKLEAK_PLU !! 19 13 ifeq ($(CONFIG_DEBUG_UNCOMPRESS),y) !! 20 # Disable Function Tracer 14 OBJS += debug.o !! 21 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE), $(KBUILD_CFLAGS)) 15 AFLAGS_head.o += -DDEBUG << 16 endif << 17 22 18 # string library code (-Os is enforced to keep !! 23 KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS)) 19 OBJS += string.o << 20 CFLAGS_string.o := -Os << 21 24 22 ifeq ($(CONFIG_ARM_VIRT_EXT),y) !! 25 # Disable lq/sq in zboot 23 OBJS += hyp-stub.o !! 26 ifdef CONFIG_CPU_LOONGSON64 >> 27 KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2 24 endif 28 endif 25 29 26 # !! 30 KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \ 27 # Architecture dependencies !! 31 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" 28 # !! 32 29 ifeq ($(CONFIG_ARCH_ACORN),y) !! 33 KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ 30 OBJS += ll_char_wr.o font.o !! 34 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ >> 35 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) >> 36 >> 37 # decompressor objects (linked with vmlinuz) >> 38 vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o >> 39 >> 40 ifdef CONFIG_DEBUG_ZBOOT >> 41 vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o >> 42 vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o >> 43 vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o >> 44 vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o >> 45 vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o 31 endif 46 endif 32 47 33 ifeq ($(CONFIG_ARCH_SA1100),y) !! 48 vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o 34 OBJS += head-sa1100.o !! 49 >> 50 vmlinuzobjs-$(CONFIG_KERNEL_ZSTD) += $(obj)/bswapdi.o $(obj)/ashldi3.o $(obj)/clz_ctz.o >> 51 >> 52 targets := $(notdir $(vmlinuzobjs-y)) >> 53 >> 54 targets += vmlinux.bin >> 55 >> 56 OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S >> 57 >> 58 $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE >> 59 $(call if_changed,objcopy) >> 60 >> 61 tool_$(CONFIG_KERNEL_GZIP) = gzip >> 62 tool_$(CONFIG_KERNEL_BZIP2) = bzip2_with_size >> 63 tool_$(CONFIG_KERNEL_LZ4) = lz4_with_size >> 64 tool_$(CONFIG_KERNEL_LZMA) = lzma_with_size >> 65 tool_$(CONFIG_KERNEL_LZO) = lzo_with_size >> 66 tool_$(CONFIG_KERNEL_XZ) = xzkern_with_size >> 67 tool_$(CONFIG_KERNEL_ZSTD) = zstd22_with_size >> 68 >> 69 targets += vmlinux.bin.z >> 70 >> 71 $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE >> 72 $(call if_changed,$(tool_y)) >> 73 >> 74 targets += piggy.o dummy.o >> 75 >> 76 OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ >> 77 --set-section-flags=.image=contents,alloc,load,readonly,data >> 78 >> 79 $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE >> 80 $(call if_changed,objcopy) >> 81 >> 82 HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE) >> 83 >> 84 # Calculate the load address of the compressed kernel image >> 85 hostprogs := calc_vmlinuz_load_addr >> 86 >> 87 ifneq (0x0,$(CONFIG_ZBOOT_LOAD_ADDRESS)) >> 88 zload-y = $(CONFIG_ZBOOT_LOAD_ADDRESS) 35 endif 89 endif 36 90 37 ifeq ($(CONFIG_CPU_XSCALE),y) !! 91 ifneq ($(zload-y),) 38 OBJS += head-xscale.o !! 92 VMLINUZ_LOAD_ADDRESS := $(zload-y) >> 93 else >> 94 VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ >> 95 $(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS)) 39 endif 96 endif >> 97 UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS) >> 98 >> 99 vmlinuzobjs-y += $(obj)/piggy.o >> 100 >> 101 targets += ../../../../vmlinuz >> 102 >> 103 quiet_cmd_zld = LD $@ >> 104 cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ >> 105 quiet_cmd_strip = STRIP $@ >> 106 cmd_strip = $(STRIP) -s $@ >> 107 >> 108 $(objtree)/vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr >> 109 $(call cmd,zld) >> 110 $(call cmd,strip) 40 111 41 ifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y) !! 112 objboot := $(objtree)/arch/mips/boot 42 OBJS += head-sharpsl.o !! 113 >> 114 $(objboot)/vmlinuz: $(objtree)/vmlinuz FORCE >> 115 >> 116 # >> 117 # Some DECstations need all possible sections of an ECOFF executable >> 118 # >> 119 ifdef CONFIG_MACH_DECSTATION >> 120 e2eflag := -a 43 endif 121 endif 44 122 45 ifeq ($(CONFIG_CPU_ENDIAN_BE32),y) !! 123 # elf2ecoff can only handle 32bit image 46 ifeq ($(CONFIG_CPU_CP15),y) !! 124 hostprogs += ../elf2ecoff 47 OBJS += big-endian.o !! 125 >> 126 ifdef CONFIG_32BIT >> 127 VMLINUZ = $(objtree)/vmlinuz 48 else 128 else 49 # The endian should be set by h/w design. !! 129 VMLINUZ = $(objboot)/vmlinuz.32 50 endif << 51 endif 130 endif 52 131 >> 132 targets += ../vmlinuz.32 >> 133 >> 134 quiet_cmd_32 = OBJCOPY $@ >> 135 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ >> 136 >> 137 $(objboot)/vmlinuz.32: $(objtree)/vmlinuz >> 138 $(call cmd,32) >> 139 >> 140 targets += ../vmlinuz.ecoff >> 141 >> 142 quiet_cmd_ecoff = ECOFF $@ >> 143 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) >> 144 >> 145 $(objboot)/vmlinuz.ecoff: $(objboot)/elf2ecoff $(VMLINUZ) >> 146 $(call cmd,ecoff) >> 147 >> 148 targets += ../vmlinuz.bin >> 149 >> 150 OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary >> 151 >> 152 $(objboot)/vmlinuz.bin: $(objtree)/vmlinuz >> 153 $(call cmd,objcopy) >> 154 >> 155 targets += ../vmlinuz.srec >> 156 >> 157 OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec >> 158 >> 159 $(objboot)/vmlinuz.srec: $(objtree)/vmlinuz >> 160 $(call cmd,objcopy) >> 161 >> 162 targets += ../uzImage.bin >> 163 >> 164 $(objboot)/uzImage.bin: $(objboot)/vmlinuz.bin FORCE >> 165 $(call if_changed,uimage,none) >> 166 53 # 167 # 54 # We now have a PIC decompressor implementatio !! 168 # Flattened Image Tree (.itb) image 55 # from RAM should not define ZTEXTADDR. Decom !! 169 # 56 # from ROM or Flash must define ZTEXTADDR (pre !! 170 57 # FIXME: Previous assignment to ztextaddr-y is !! 171 ifeq ($(ADDR_BITS),32) 58 ifeq ($(CONFIG_ZBOOT_ROM),y) !! 172 itb_addr_cells = 1 59 ZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT) << 60 ZBSSADDR := $(CONFIG_ZBOOT_ROM_BSS) << 61 else << 62 ZTEXTADDR := 0 << 63 ZBSSADDR := ALIGN(8) << 64 endif 173 endif >> 174 ifeq ($(ADDR_BITS),64) >> 175 itb_addr_cells = 2 >> 176 endif >> 177 >> 178 targets += ../vmlinuz.its.S >> 179 >> 180 quiet_cmd_its_cat = CAT $@ >> 181 cmd_its_cat = cat $(real-prereqs) >$@ >> 182 >> 183 $(objboot)/vmlinuz.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE >> 184 $(call if_changed,its_cat) >> 185 >> 186 targets += ../vmlinuz.its 65 187 66 MALLOC_SIZE := 65536 !! 188 quiet_cmd_cpp_its_S = ITS $@ >> 189 cmd_cpp_its_S = $(CPP) -P -C -o $@ $< \ >> 190 -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \ >> 191 -DVMLINUX_BINARY="\"$(2)\"" \ >> 192 -DVMLINUX_COMPRESSION="\"none\"" \ >> 193 -DVMLINUX_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \ >> 194 -DVMLINUX_ENTRY_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \ >> 195 -DADDR_BITS=$(ADDR_BITS) \ >> 196 -DADDR_CELLS=$(itb_addr_cells) 67 197 68 AFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET) !! 198 $(objboot)/vmlinuz.its: $(objboot)/vmlinuz.its.S FORCE 69 CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTA !! 199 $(call if_changed,cpp_its_S,vmlinuz.bin) 70 CPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_ << 71 CPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLO << 72 << 73 compress-$(CONFIG_KERNEL_GZIP) = gzip << 74 compress-$(CONFIG_KERNEL_LZO) = lzo_with_size << 75 compress-$(CONFIG_KERNEL_LZMA) = lzma_with_siz << 76 compress-$(CONFIG_KERNEL_XZ) = xzkern_with_s << 77 compress-$(CONFIG_KERNEL_LZ4) = lz4_with_size << 78 << 79 libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt << 80 << 81 ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) << 82 CFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger << 83 CFLAGS_atags_to_fdt.o += -Wframe-larger-than=1 << 84 OBJS += $(libfdt_objs) atags_to_fdt.o << 85 endif << 86 ifeq ($(CONFIG_USE_OF),y) << 87 OBJS += $(libfdt_objs) fdt_check_mem_start. << 88 endif << 89 << 90 OBJS += lib1funcs.o ashldi3.o bswapsdi2.o << 91 << 92 targets := vmlinux vmlinux.lds piggy_dat << 93 head.o $(OBJS) << 94 << 95 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING << 96 << 97 ccflags-y := -fpic $(call cc-option,-mno-singl << 98 -I$(srctree)/scripts/dtc/libfdt - << 99 -I$(obj) $(DISABLE_ARM_SSP_PER_TA << 100 ccflags-remove-$(CONFIG_FUNCTION_TRACER) += -p << 101 asflags-y := -DZIMAGE << 102 << 103 # Supply kernel BSS size to the decompressor v << 104 KBSS_SZ = $(shell echo $$(($$($(NM) vmlinux | << 105 sed -n -e 's/^\([^ ]*\) [ABD] << 106 -e 's/^\([^ ]*\) [ABD] << 107 LDFLAGS_vmlinux = --defsym _kernel_bss_size=$( << 108 # Supply ZRELADDR to the decompressor via a li << 109 ifneq ($(CONFIG_AUTO_ZRELADDR),y) << 110 LDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADD << 111 endif << 112 ifeq ($(CONFIG_CPU_ENDIAN_BE8),y) << 113 LDFLAGS_vmlinux += --be8 << 114 endif << 115 # Report unresolved symbol references << 116 LDFLAGS_vmlinux += --no-undefined << 117 # Delete all temporary local symbols << 118 LDFLAGS_vmlinux += -X << 119 # Report orphan sections << 120 ifdef CONFIG_LD_ORPHAN_WARN << 121 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_ << 122 endif << 123 # Next argument is a linker script << 124 LDFLAGS_vmlinux += -T << 125 << 126 # We need to prevent any GOTOFF relocs being u << 127 # to symbols in the .bss section since we cann << 128 # independently from the rest at run time. Th << 129 # ensuring that no private .bss symbols exist, << 130 # always have a GOT entry which is what we nee << 131 # The .data section is already discarded by th << 132 # to bother about it here. << 133 check_for_bad_syms = \ << 134 bad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] << 135 [ -z "$$bad_syms" ] || \ << 136 ( echo "following symbols must have non loca << 137 echo "$$bad_syms" >&2; false ) << 138 << 139 check_for_multiple_zreladdr = \ << 140 if [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_A << 141 echo 'multiple zreladdrs: $(ZRELADDR)' << 142 echo 'This needs CONFIG_AUTO_ZRELADDR << 143 false; \ << 144 fi << 145 << 146 efi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drive << 147 << 148 $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HE << 149 $(addprefix $(obj)/, $(OBJS)) << 150 $(efi-obj-y) FORCE << 151 @$(check_for_multiple_zreladdr) << 152 $(call if_changed,ld) << 153 @$(check_for_bad_syms) << 154 200 155 $(obj)/piggy_data: $(obj)/../Image FORCE !! 201 targets += ../vmlinuz.itb 156 $(call if_changed,$(compress-y)) << 157 202 158 $(obj)/piggy.o: $(obj)/piggy_data !! 203 quiet_cmd_itb-image = ITB $@ >> 204 cmd_itb-image = \ >> 205 env PATH="$(objtree)/scripts/dtc:$(PATH)" \ >> 206 $(BASH) $(MKIMAGE) \ >> 207 -D "-I dts -O dtb -p 500 \ >> 208 --include $(objtree)/arch/mips \ >> 209 --warning no-unit_address_vs_reg" \ >> 210 -f $(2) $@ 159 211 160 CFLAGS_font.o := -Dstatic= !! 212 $(objboot)/vmlinuz.itb: $(objboot)/vmlinuz.its $(objboot)/vmlinuz.bin FORCE >> 213 $(call if_changed,itb-image,$<)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.