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 36c6d30853SAndrey RyabininUBSAN_SANITIZE :=n 37db569afaSSam Ravnborg 38db569afaSSam RavnborgLDFLAGS := -m elf_$(UTS_MACHINE) 39db569afaSSam RavnborgLDFLAGS_vmlinux := -T 40db569afaSSam Ravnborg 4102a884c0SH. Peter Anvinhostprogs-y := mkpiggy 4212871c56SMatt FlemingHOST_EXTRACFLAGS += -I$(srctree)/tools/include 4302a884c0SH. Peter Anvin 449a1cb471SJosh Triplettvmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ 453afed06aSJosh Triplett $(obj)/string.o $(obj)/cmdline.o \ 469e6abd2aSJosh Triplett $(obj)/piggy.o $(obj)/cpuflags.o 479e6abd2aSJosh Triplett 483afed06aSJosh Triplettvmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o 499e6abd2aSJosh Triplettvmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o 50291f3632SMatt Fleming 519dead5bbSMatthew Garrett$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone 529dead5bbSMatthew Garrett 53243b6754SArd Biesheuvelvmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \ 54243b6754SArd Biesheuvel $(objtree)/drivers/firmware/efi/libstub/lib.a 5596738c69SMatt Flemingvmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o 56291f3632SMatt Fleming 579a1cb471SJosh Triplett$(obj)/vmlinux: $(vmlinux-objs-y) FORCE 58db569afaSSam Ravnborg $(call if_changed,ld) 59db569afaSSam Ravnborg @: 60db569afaSSam Ravnborg 61099e1377SIan CampbellOBJCOPYFLAGS_vmlinux.bin := -R .comment -S 62db569afaSSam Ravnborg$(obj)/vmlinux.bin: vmlinux FORCE 63db569afaSSam Ravnborg $(call if_changed,objcopy) 64db569afaSSam Ravnborg 659a1cb471SJosh Tripletttargets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs 66db569afaSSam Ravnborg 676520fe55SH. Peter AnvinCMD_RELOCS = arch/x86/tools/relocs 68db569afaSSam Ravnborgquiet_cmd_relocs = RELOCS $@ 696520fe55SH. Peter Anvin cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $< 706520fe55SH. Peter Anvin$(obj)/vmlinux.relocs: vmlinux FORCE 71db569afaSSam Ravnborg $(call if_changed,relocs) 72db569afaSSam Ravnborg 73db569afaSSam Ravnborgvmlinux.bin.all-y := $(obj)/vmlinux.bin 745f11e020SH. Peter Anvinvmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs 75db569afaSSam Ravnborg 765f11e020SH. Peter Anvin$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE 77db569afaSSam Ravnborg $(call if_changed,gzip) 785f11e020SH. Peter Anvin$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE 79ae03c499SAlain Knaff $(call if_changed,bzip2) 805f11e020SH. Peter Anvin$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE 81ae03c499SAlain Knaff $(call if_changed,lzma) 8230314804SLasse Collin$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE 8330314804SLasse Collin $(call if_changed,xzkern) 8413510997SAlbin Tonnerre$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE 8513510997SAlbin Tonnerre $(call if_changed,lzo) 86f9b493acSKyungsik Lee$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE 87f9b493acSKyungsik Lee $(call if_changed,lz4) 88db569afaSSam Ravnborg 89283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_GZIP) := gz 90283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_BZIP2) := bz2 91283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_LZMA) := lzma 9230314804SLasse Collinsuffix-$(CONFIG_KERNEL_XZ) := xz 9313510997SAlbin Tonnerresuffix-$(CONFIG_KERNEL_LZO) := lzo 94f9b493acSKyungsik Leesuffix-$(CONFIG_KERNEL_LZ4) := lz4 95ae03c499SAlain Knaff 96e2e68ae6SChris ClaytonRUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \ 97d69911a6SKees Cook $(CONFIG_SHELL) $(srctree)/arch/x86/tools/calc_run_size.sh) 9802a884c0SH. Peter Anvinquiet_cmd_mkpiggy = MKPIGGY $@ 99e6023367SJunjie Mao cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false ) 10002a884c0SH. Peter Anvin 10102a884c0SH. Peter Anvintargets += piggy.S 10202a884c0SH. Peter Anvin$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE 10302a884c0SH. Peter Anvin $(call if_changed,mkpiggy) 104