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 19f9b493acSKyungsik Leetargets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ 20f9b493acSKyungsik Lee vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 21db569afaSSam Ravnborg 22db569afaSSam RavnborgKBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 23db569afaSSam RavnborgKBUILD_CFLAGS += -fno-strict-aliasing -fPIC 2495a38f34SH. Peter AnvinKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 2517a2a9b5SH. Peter Anvincflags-$(CONFIG_X86_32) := -march=i386 26db569afaSSam Ravnborgcflags-$(CONFIG_X86_64) := -mcmodel=small 27db569afaSSam RavnborgKBUILD_CFLAGS += $(cflags-y) 288b3b005dSH. Peter AnvinKBUILD_CFLAGS += -mno-mmx -mno-sse 29db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-ffreestanding) 30db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) 31db569afaSSam Ravnborg 32db569afaSSam RavnborgKBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ 337bf99fb6SPeter OberparleiterGCOV_PROFILE := n 34db569afaSSam Ravnborg 35db569afaSSam RavnborgLDFLAGS := -m elf_$(UTS_MACHINE) 36db569afaSSam RavnborgLDFLAGS_vmlinux := -T 37db569afaSSam Ravnborg 3802a884c0SH. Peter Anvinhostprogs-y := mkpiggy 3912871c56SMatt FlemingHOST_EXTRACFLAGS += -I$(srctree)/tools/include 4002a884c0SH. Peter Anvin 419a1cb471SJosh Triplettvmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ 423afed06aSJosh Triplett $(obj)/string.o $(obj)/cmdline.o \ 439e6abd2aSJosh Triplett $(obj)/piggy.o $(obj)/cpuflags.o 449e6abd2aSJosh Triplett 453afed06aSJosh Triplettvmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o 469e6abd2aSJosh Triplettvmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o 47291f3632SMatt Fleming 489dead5bbSMatthew Garrett$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone 499dead5bbSMatthew Garrett 50243b6754SArd Biesheuvelvmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \ 51243b6754SArd Biesheuvel $(objtree)/drivers/firmware/efi/libstub/lib.a 52291f3632SMatt Fleming 539a1cb471SJosh Triplett$(obj)/vmlinux: $(vmlinux-objs-y) FORCE 54db569afaSSam Ravnborg $(call if_changed,ld) 55db569afaSSam Ravnborg @: 56db569afaSSam Ravnborg 57099e1377SIan CampbellOBJCOPYFLAGS_vmlinux.bin := -R .comment -S 58db569afaSSam Ravnborg$(obj)/vmlinux.bin: vmlinux FORCE 59db569afaSSam Ravnborg $(call if_changed,objcopy) 60db569afaSSam Ravnborg 619a1cb471SJosh Tripletttargets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs 62db569afaSSam Ravnborg 636520fe55SH. Peter AnvinCMD_RELOCS = arch/x86/tools/relocs 64db569afaSSam Ravnborgquiet_cmd_relocs = RELOCS $@ 656520fe55SH. Peter Anvin cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $< 666520fe55SH. Peter Anvin$(obj)/vmlinux.relocs: vmlinux FORCE 67db569afaSSam Ravnborg $(call if_changed,relocs) 68db569afaSSam Ravnborg 69db569afaSSam Ravnborgvmlinux.bin.all-y := $(obj)/vmlinux.bin 705f11e020SH. Peter Anvinvmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs 71db569afaSSam Ravnborg 725f11e020SH. Peter Anvin$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE 73db569afaSSam Ravnborg $(call if_changed,gzip) 745f11e020SH. Peter Anvin$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE 75ae03c499SAlain Knaff $(call if_changed,bzip2) 765f11e020SH. Peter Anvin$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE 77ae03c499SAlain Knaff $(call if_changed,lzma) 7830314804SLasse Collin$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE 7930314804SLasse Collin $(call if_changed,xzkern) 8013510997SAlbin Tonnerre$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE 8113510997SAlbin Tonnerre $(call if_changed,lzo) 82f9b493acSKyungsik Lee$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE 83f9b493acSKyungsik Lee $(call if_changed,lz4) 84db569afaSSam Ravnborg 85283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_GZIP) := gz 86283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_BZIP2) := bz2 87283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_LZMA) := lzma 8830314804SLasse Collinsuffix-$(CONFIG_KERNEL_XZ) := xz 8913510997SAlbin Tonnerresuffix-$(CONFIG_KERNEL_LZO) := lzo 90f9b493acSKyungsik Leesuffix-$(CONFIG_KERNEL_LZ4) := lz4 91ae03c499SAlain Knaff 92e2e68ae6SChris ClaytonRUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \ 93d69911a6SKees Cook $(CONFIG_SHELL) $(srctree)/arch/x86/tools/calc_run_size.sh) 9402a884c0SH. Peter Anvinquiet_cmd_mkpiggy = MKPIGGY $@ 95e6023367SJunjie Mao cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false ) 9602a884c0SH. Peter Anvin 9702a884c0SH. Peter Anvintargets += piggy.S 9802a884c0SH. Peter Anvin$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE 9902a884c0SH. Peter Anvin $(call if_changed,mkpiggy) 100