1db569afaSSam Ravnborg# 2db569afaSSam Ravnborg# linux/arch/x86/boot/compressed/Makefile 3db569afaSSam Ravnborg# 4db569afaSSam Ravnborg# create a compressed vmlinux image from the original vmlinux 5db569afaSSam Ravnborg# 6fb7183efSKees Cook# vmlinuz is: 7fb7183efSKees Cook# decompression code (*.o) 8fb7183efSKees Cook# asm globals (piggy.S), including: 9fb7183efSKees Cook# vmlinux.bin.(gz|bz2|lzma|...) 10fb7183efSKees Cook# 11fb7183efSKees Cook# vmlinux.bin is: 12fb7183efSKees Cook# vmlinux stripped of debugging and comments 13fb7183efSKees Cook# vmlinux.bin.all is: 14fb7183efSKees Cook# vmlinux.bin + vmlinux.relocs 15fb7183efSKees Cook# vmlinux.bin.(gz|bz2|lzma|...) is: 16fb7183efSKees Cook# (see scripts/Makefile.lib size_append) 17fb7183efSKees Cook# compressed vmlinux.bin.all + u32 size of vmlinux.bin.all 18db569afaSSam Ravnborg 19ef7f0d6aSAndrey RyabininKASAN_SANITIZE := n 20ef7f0d6aSAndrey Ryabinin 21f9b493acSKyungsik Leetargets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ 22f9b493acSKyungsik Lee vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 23db569afaSSam Ravnborg 24db569afaSSam RavnborgKBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 25db569afaSSam RavnborgKBUILD_CFLAGS += -fno-strict-aliasing -fPIC 2695a38f34SH. Peter AnvinKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 2717a2a9b5SH. Peter Anvincflags-$(CONFIG_X86_32) := -march=i386 28db569afaSSam Ravnborgcflags-$(CONFIG_X86_64) := -mcmodel=small 29db569afaSSam RavnborgKBUILD_CFLAGS += $(cflags-y) 308b3b005dSH. Peter AnvinKBUILD_CFLAGS += -mno-mmx -mno-sse 31db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-ffreestanding) 32db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) 33db569afaSSam Ravnborg 34db569afaSSam RavnborgKBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ 357bf99fb6SPeter OberparleiterGCOV_PROFILE := n 36db569afaSSam Ravnborg 37db569afaSSam RavnborgLDFLAGS := -m elf_$(UTS_MACHINE) 38db569afaSSam RavnborgLDFLAGS_vmlinux := -T 39db569afaSSam Ravnborg 4002a884c0SH. Peter Anvinhostprogs-y := mkpiggy 4112871c56SMatt FlemingHOST_EXTRACFLAGS += -I$(srctree)/tools/include 4202a884c0SH. Peter Anvin 439a1cb471SJosh Triplettvmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ 443afed06aSJosh Triplett $(obj)/string.o $(obj)/cmdline.o \ 459e6abd2aSJosh Triplett $(obj)/piggy.o $(obj)/cpuflags.o 469e6abd2aSJosh Triplett 473afed06aSJosh Triplettvmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o 489e6abd2aSJosh Triplettvmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o 49291f3632SMatt Fleming 509dead5bbSMatthew Garrett$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone 519dead5bbSMatthew Garrett 52243b6754SArd Biesheuvelvmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \ 53243b6754SArd Biesheuvel $(objtree)/drivers/firmware/efi/libstub/lib.a 54291f3632SMatt Fleming 559a1cb471SJosh Triplett$(obj)/vmlinux: $(vmlinux-objs-y) FORCE 56db569afaSSam Ravnborg $(call if_changed,ld) 57db569afaSSam Ravnborg @: 58db569afaSSam Ravnborg 59099e1377SIan CampbellOBJCOPYFLAGS_vmlinux.bin := -R .comment -S 60db569afaSSam Ravnborg$(obj)/vmlinux.bin: vmlinux FORCE 61db569afaSSam Ravnborg $(call if_changed,objcopy) 62db569afaSSam Ravnborg 639a1cb471SJosh Tripletttargets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs 64db569afaSSam Ravnborg 656520fe55SH. Peter AnvinCMD_RELOCS = arch/x86/tools/relocs 66db569afaSSam Ravnborgquiet_cmd_relocs = RELOCS $@ 676520fe55SH. Peter Anvin cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $< 686520fe55SH. Peter Anvin$(obj)/vmlinux.relocs: vmlinux FORCE 69db569afaSSam Ravnborg $(call if_changed,relocs) 70db569afaSSam Ravnborg 71db569afaSSam Ravnborgvmlinux.bin.all-y := $(obj)/vmlinux.bin 725f11e020SH. Peter Anvinvmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs 73db569afaSSam Ravnborg 745f11e020SH. Peter Anvin$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE 75db569afaSSam Ravnborg $(call if_changed,gzip) 765f11e020SH. Peter Anvin$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE 77ae03c499SAlain Knaff $(call if_changed,bzip2) 785f11e020SH. Peter Anvin$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE 79ae03c499SAlain Knaff $(call if_changed,lzma) 8030314804SLasse Collin$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE 8130314804SLasse Collin $(call if_changed,xzkern) 8213510997SAlbin Tonnerre$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE 8313510997SAlbin Tonnerre $(call if_changed,lzo) 84f9b493acSKyungsik Lee$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE 85f9b493acSKyungsik Lee $(call if_changed,lz4) 86db569afaSSam Ravnborg 87283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_GZIP) := gz 88283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_BZIP2) := bz2 89283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_LZMA) := lzma 9030314804SLasse Collinsuffix-$(CONFIG_KERNEL_XZ) := xz 9113510997SAlbin Tonnerresuffix-$(CONFIG_KERNEL_LZO) := lzo 92f9b493acSKyungsik Leesuffix-$(CONFIG_KERNEL_LZ4) := lz4 93ae03c499SAlain Knaff 94e2e68ae6SChris ClaytonRUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \ 95d69911a6SKees Cook $(CONFIG_SHELL) $(srctree)/arch/x86/tools/calc_run_size.sh) 9602a884c0SH. Peter Anvinquiet_cmd_mkpiggy = MKPIGGY $@ 97e6023367SJunjie Mao cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false ) 9802a884c0SH. Peter Anvin 9902a884c0SH. Peter Anvintargets += piggy.S 10002a884c0SH. Peter Anvin$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE 10102a884c0SH. Peter Anvin $(call if_changed,mkpiggy) 102