1 # SPDX-License-Identifier: GPL-2.0 << 2 # 1 # 3 # linux/arch/x86/boot/compressed/Makefile !! 2 # linux/arch/i386/boot/compressed/Makefile 4 # 3 # 5 # create a compressed vmlinux image from the o 4 # create a compressed vmlinux image from the original vmlinux 6 # 5 # 7 # vmlinuz is: !! 6 8 # decompression code (*.o) !! 7 HEAD = head.o 9 # asm globals (piggy.S), including: !! 8 SYSTEM = $(TOPDIR)/vmlinux 10 # vmlinux.bin.(gz|bz2|lzma|...) !! 9 >> 10 OBJECTS = $(HEAD) misc.o >> 11 >> 12 ZLDFLAGS = -e startup_32 >> 13 11 # 14 # 12 # vmlinux.bin is: !! 15 # ZIMAGE_OFFSET is the load offset of the compression loader 13 # vmlinux stripped of debugging and comm !! 16 # BZIMAGE_OFFSET is the load offset of the high loaded compression loader 14 # vmlinux.bin.all is: !! 17 # 15 # vmlinux.bin + vmlinux.relocs !! 18 ZIMAGE_OFFSET = 0x1000 16 # vmlinux.bin.(gz|bz2|lzma|...) is: !! 19 BZIMAGE_OFFSET = 0x100000 17 # (see scripts/Makefile.lib size_append) !! 20 18 # compressed vmlinux.bin.all + u32 size !! 21 ZLINKFLAGS = -Ttext $(ZIMAGE_OFFSET) $(ZLDFLAGS) 19 !! 22 BZLINKFLAGS = -Ttext $(BZIMAGE_OFFSET) $(ZLDFLAGS) 20 targets := vmlinux vmlinux.bin vmlinux.bin.gz !! 23 21 vmlinux.bin.xz vmlinux.bin.lzo vmlinux !! 24 all: vmlinux 22 !! 25 23 # CLANG_FLAGS must come before any cc-disable- !! 26 vmlinux: piggy.o $(OBJECTS) 24 # case of cross compiling, as it has the '--ta !! 27 $(LD) $(ZLINKFLAGS) -o vmlinux $(OBJECTS) piggy.o 25 # avoid errors with '-march=i386', and future !! 28 26 # be valid. !! 29 bvmlinux: piggy.o $(OBJECTS) 27 KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS) !! 30 $(LD) $(BZLINKFLAGS) -o bvmlinux $(OBJECTS) piggy.o 28 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE !! 31 29 KBUILD_CFLAGS += -Wundef !! 32 head.o: head.S 30 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING !! 33 $(CC) $(AFLAGS) -traditional -c head.S 31 cflags-$(CONFIG_X86_32) := -march=i386 !! 34 32 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno !! 35 comma := , 33 KBUILD_CFLAGS += $(cflags-y) !! 36 34 KBUILD_CFLAGS += -mno-mmx -mno-sse !! 37 misc.o: misc.c 35 KBUILD_CFLAGS += -ffreestanding -fshort-wchar !! 38 $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c misc.c 36 KBUILD_CFLAGS += -fno-stack-protector !! 39 37 KBUILD_CFLAGS += $(call cc-disable-warning, ad !! 40 piggy.o: $(SYSTEM) 38 KBUILD_CFLAGS += $(call cc-disable-warning, gn !! 41 tmppiggy=_tmp_$$$$piggy; \ 39 KBUILD_CFLAGS += -Wno-pointer-sign !! 42 rm -f $$tmppiggy $$tmppiggy.gz $$tmppiggy.lnk; \ 40 KBUILD_CFLAGS += $(call cc-option,-fmacro-pref !! 43 $(OBJCOPY) $(SYSTEM) $$tmppiggy; \ 41 KBUILD_CFLAGS += -fno-asynchronous-unwind-tabl !! 44 gzip -f -9 < $$tmppiggy > $$tmppiggy.gz; \ 42 KBUILD_CFLAGS += -D__DISABLE_EXPORTS !! 45 echo "SECTIONS { .data : { input_len = .; LONG(input_data_end - input_data) input_data = .; *(.data) input_data_end = .; }}" > $$tmppiggy.lnk; \ 43 # Disable relocation relaxation in case the li !! 46 $(LD) -r -o piggy.o -b binary $$tmppiggy.gz -b elf32-i386 -T $$tmppiggy.lnk; \ 44 KBUILD_CFLAGS += $(call cc-option,-Wa$(comma)- !! 47 rm -f $$tmppiggy $$tmppiggy.gz $$tmppiggy.lnk 45 KBUILD_CFLAGS += -include $(srctree)/include/l !! 48 46 !! 49 clean: 47 # sev.c indirectly includes inat-table.h which !! 50 rm -f vmlinux bvmlinux _tmp_* 48 # compilation and stored in $(objtree). Add th << 49 # that the compiler finds it even with out-of- << 50 CFLAGS_sev.o += -I$(objtree)/arch/x86/lib/ << 51 << 52 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBL << 53 << 54 KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) << 55 KBUILD_LDFLAGS += $(call ld-option,--no-ld-gen << 56 # Compressed kernel should be built as PIE sin << 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 << 110 $(obj)/vmlinux: $(vmlinux-objs-y) $(vmlinux-li << 111 $(call if_changed,ld) << 112 << 113 OBJCOPYFLAGS_vmlinux.bin := -R .comment -S << 114 $(obj)/vmlinux.bin: vmlinux FORCE << 115 $(call if_changed,objcopy) << 116 << 117 targets += $(patsubst $(obj)/%,%,$(vmlinux-obj << 118 << 119 # vmlinux.relocs is created by the vmlinux pos << 120 $(obj)/vmlinux.relocs: vmlinux << 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.