1 # SPDX-License-Identifier: GPL-2.0 << 2 # 1 # 3 # linux/arch/x86/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 vmlinux image from the o !! 5 # Adapted for MIPS Pete Popov, Dan Malek 6 # 6 # 7 # vmlinuz is: !! 7 # Copyright (C) 1994 by Linus Torvalds 8 # decompression code (*.o) !! 8 # Adapted for PowerPC by Gary Thomas 9 # asm globals (piggy.S), including: !! 9 # modified by Cort (cort@cs.nmt.edu) 10 # vmlinux.bin.(gz|bz2|lzma|...) !! 10 # 11 # !! 11 # Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University 12 # vmlinux.bin is: !! 12 # Author: Wu Zhangjin <wuzhangjin@gmail.com> 13 # vmlinux stripped of debugging and comm !! 13 # 14 # vmlinux.bin.all is: !! 14 15 # vmlinux.bin + vmlinux.relocs !! 15 include $(srctree)/arch/mips/Kbuild.platforms 16 # vmlinux.bin.(gz|bz2|lzma|...) is: !! 16 17 # (see scripts/Makefile.lib size_append) !! 17 # set the default size of the mallocing area for decompressing 18 # compressed vmlinux.bin.all + u32 size !! 18 BOOT_HEAP_SIZE := 0x400000 19 !! 19 20 targets := vmlinux vmlinux.bin vmlinux.bin.gz !! 20 # Disable Function Tracer 21 vmlinux.bin.xz vmlinux.bin.lzo vmlinux !! 21 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE), $(KBUILD_CFLAGS)) 22 !! 22 23 # CLANG_FLAGS must come before any cc-disable- !! 23 KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS)) 24 # case of cross compiling, as it has the '--ta !! 24 25 # avoid errors with '-march=i386', and future !! 25 # Disable lq/sq in zboot 26 # be valid. !! 26 ifdef CONFIG_CPU_LOONGSON64 27 KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS) !! 27 KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2 28 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE !! 28 endif 29 KBUILD_CFLAGS += -Wundef !! 29 30 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING !! 30 KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \ 31 cflags-$(CONFIG_X86_32) := -march=i386 !! 31 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" 32 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno !! 32 33 KBUILD_CFLAGS += $(cflags-y) !! 33 KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ 34 KBUILD_CFLAGS += -mno-mmx -mno-sse !! 34 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ 35 KBUILD_CFLAGS += -ffreestanding -fshort-wchar !! 35 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) 36 KBUILD_CFLAGS += -fno-stack-protector !! 36 37 KBUILD_CFLAGS += $(call cc-disable-warning, ad !! 37 # decompressor objects (linked with vmlinuz) 38 KBUILD_CFLAGS += $(call cc-disable-warning, gn !! 38 vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o 39 KBUILD_CFLAGS += -Wno-pointer-sign !! 39 40 KBUILD_CFLAGS += $(call cc-option,-fmacro-pref !! 40 ifdef CONFIG_DEBUG_ZBOOT 41 KBUILD_CFLAGS += -fno-asynchronous-unwind-tabl !! 41 vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o 42 KBUILD_CFLAGS += -D__DISABLE_EXPORTS !! 42 vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o 43 # Disable relocation relaxation in case the li !! 43 vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o 44 KBUILD_CFLAGS += $(call cc-option,-Wa$(comma)- !! 44 vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o 45 KBUILD_CFLAGS += -include $(srctree)/include/l !! 45 vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o 46 !! 46 endif 47 # sev.c indirectly includes inat-table.h which !! 47 48 # compilation and stored in $(objtree). Add th !! 48 vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o 49 # that the compiler finds it even with out-of- !! 49 50 CFLAGS_sev.o += -I$(objtree)/arch/x86/lib/ !! 50 vmlinuzobjs-$(CONFIG_KERNEL_ZSTD) += $(obj)/bswapdi.o $(obj)/ashldi3.o $(obj)/clz_ctz.o 51 !! 51 52 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBL !! 52 targets := $(notdir $(vmlinuzobjs-y)) 53 !! 53 54 KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) !! 54 targets += vmlinux.bin 55 KBUILD_LDFLAGS += $(call ld-option,--no-ld-gen !! 55 56 # Compressed kernel should be built as PIE sin !! 56 OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S 57 # address by the bootloader. << 58 LDFLAGS_vmlinux := -pie $(call ld-option, --no << 59 ifdef CONFIG_LD_ORPHAN_WARN << 60 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_ << 61 endif << 62 LDFLAGS_vmlinux += -z noexecstack << 63 ifeq ($(CONFIG_LD_IS_BFD),y) << 64 LDFLAGS_vmlinux += $(call ld-option,--no-warn- << 65 endif << 66 ifeq ($(CONFIG_EFI_STUB),y) << 67 # ensure that the static EFI stub library will << 68 # never referenced explicitly from the startup << 69 LDFLAGS_vmlinux += -u efi_pe_entry << 70 endif << 71 LDFLAGS_vmlinux += -T << 72 << 73 hostprogs := mkpiggy << 74 HOST_EXTRACFLAGS += -I$(srctree)/tools/include << 75 << 76 sed-voffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGR << 77 << 78 quiet_cmd_voffset = VOFFSET $@ << 79 cmd_voffset = $(NM) $< | sed -n $(sed-vo << 80 << 81 targets += ../voffset.h << 82 << 83 $(obj)/../voffset.h: vmlinux FORCE << 84 $(call if_changed,voffset) << 85 << 86 $(obj)/misc.o: $(obj)/../voffset.h << 87 << 88 vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/ke << 89 $(obj)/misc.o $(obj)/string.o $(obj)/c << 90 $(obj)/piggy.o $(obj)/cpuflags.o << 91 << 92 vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/ << 93 vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj << 94 ifdef CONFIG_X86_64 << 95 vmlinux-objs-y += $(obj)/ident_map_64. << 96 vmlinux-objs-y += $(obj)/idt_64.o $(ob << 97 vmlinux-objs-$(CONFIG_AMD_MEM_ENCRYPT) << 98 vmlinux-objs-y += $(obj)/pgtable_64.o << 99 vmlinux-objs-$(CONFIG_AMD_MEM_ENCRYPT) << 100 endif << 101 << 102 vmlinux-objs-$(CONFIG_ACPI) += $(obj)/acpi.o << 103 vmlinux-objs-$(CONFIG_INTEL_TDX_GUEST) += $(ob << 104 vmlinux-objs-$(CONFIG_UNACCEPTED_MEMORY) += $( << 105 << 106 vmlinux-objs-$(CONFIG_EFI) += $(obj)/efi.o << 107 vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi << 108 vmlinux-libs-$(CONFIG_EFI_STUB) += $(objtree)/ << 109 57 110 $(obj)/vmlinux: $(vmlinux-objs-y) $(vmlinux-li !! 58 $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE 111 $(call if_changed,ld) !! 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)) 112 73 113 OBJCOPYFLAGS_vmlinux.bin := -R .comment -S !! 74 targets += piggy.o dummy.o 114 $(obj)/vmlinux.bin: vmlinux FORCE !! 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 115 $(call if_changed,objcopy) 80 $(call if_changed,objcopy) 116 81 117 targets += $(patsubst $(obj)/%,%,$(vmlinux-obj !! 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) >> 89 endif >> 90 >> 91 ifneq ($(zload-y),) >> 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)) >> 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) >> 111 >> 112 objboot := $(objtree)/arch/mips/boot >> 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 >> 121 endif >> 122 >> 123 # elf2ecoff can only handle 32bit image >> 124 hostprogs += ../elf2ecoff >> 125 >> 126 ifdef CONFIG_32BIT >> 127 VMLINUZ = $(objtree)/vmlinuz >> 128 else >> 129 VMLINUZ = $(objboot)/vmlinuz.32 >> 130 endif >> 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 >> 167 # >> 168 # Flattened Image Tree (.itb) image >> 169 # >> 170 >> 171 ifeq ($(ADDR_BITS),32) >> 172 itb_addr_cells = 1 >> 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 >> 187 >> 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) >> 197 >> 198 $(objboot)/vmlinuz.its: $(objboot)/vmlinuz.its.S FORCE >> 199 $(call if_changed,cpp_its_S,vmlinuz.bin) >> 200 >> 201 targets += ../vmlinuz.itb >> 202 >> 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) $@ 118 211 119 # vmlinux.relocs is created by the vmlinux pos !! 212 $(objboot)/vmlinuz.itb: $(objboot)/vmlinuz.its $(objboot)/vmlinuz.bin FORCE 120 $(obj)/vmlinux.relocs: vmlinux !! 213 $(call if_changed,itb-image,$<) 121 @true << 122 << 123 vmlinux.bin.all-y := $(obj)/vmlinux.bin << 124 vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $ << 125 << 126 $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FO << 127 $(call if_changed,gzip) << 128 $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) F << 129 $(call if_changed,bzip2_with_size) << 130 $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) << 131 $(call if_changed,lzma_with_size) << 132 $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FO << 133 $(call if_changed,xzkern_with_size) << 134 $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) F << 135 $(call if_changed,lzo_with_size) << 136 $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) F << 137 $(call if_changed,lz4_with_size) << 138 $(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) F << 139 $(call if_changed,zstd22_with_size) << 140 << 141 suffix-$(CONFIG_KERNEL_GZIP) := gz << 142 suffix-$(CONFIG_KERNEL_BZIP2) := bz2 << 143 suffix-$(CONFIG_KERNEL_LZMA) := lzma << 144 suffix-$(CONFIG_KERNEL_XZ) := xz << 145 suffix-$(CONFIG_KERNEL_LZO) := lzo << 146 suffix-$(CONFIG_KERNEL_LZ4) := lz4 << 147 suffix-$(CONFIG_KERNEL_ZSTD) := zst << 148 << 149 quiet_cmd_mkpiggy = MKPIGGY $@ << 150 cmd_mkpiggy = $(obj)/mkpiggy $< > $@ << 151 << 152 targets += piggy.S << 153 $(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) << 154 $(call if_changed,mkpiggy) <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.