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 20c0dd6716SJosh PoimboeufOBJECT_FILES_NON_STANDARD := y 21ef7f0d6aSAndrey Ryabinin 225c9a8750SDmitry Vyukov# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 235c9a8750SDmitry VyukovKCOV_INSTRUMENT := n 245c9a8750SDmitry Vyukov 25f9b493acSKyungsik Leetargets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ 26f9b493acSKyungsik Lee vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 27db569afaSSam Ravnborg 28db569afaSSam RavnborgKBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 29db569afaSSam RavnborgKBUILD_CFLAGS += -fno-strict-aliasing -fPIC 3095a38f34SH. Peter AnvinKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 3117a2a9b5SH. Peter Anvincflags-$(CONFIG_X86_32) := -march=i386 32db569afaSSam Ravnborgcflags-$(CONFIG_X86_64) := -mcmodel=small 33db569afaSSam RavnborgKBUILD_CFLAGS += $(cflags-y) 348b3b005dSH. Peter AnvinKBUILD_CFLAGS += -mno-mmx -mno-sse 35db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-ffreestanding) 36db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) 37db569afaSSam Ravnborg 38db569afaSSam RavnborgKBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ 397bf99fb6SPeter OberparleiterGCOV_PROFILE := n 40c6d30853SAndrey RyabininUBSAN_SANITIZE :=n 41db569afaSSam Ravnborg 42db569afaSSam RavnborgLDFLAGS := -m elf_$(UTS_MACHINE) 43db569afaSSam RavnborgLDFLAGS_vmlinux := -T 44db569afaSSam Ravnborg 4502a884c0SH. Peter Anvinhostprogs-y := mkpiggy 4612871c56SMatt FlemingHOST_EXTRACFLAGS += -I$(srctree)/tools/include 4702a884c0SH. Peter Anvin 489a1cb471SJosh Triplettvmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ 493afed06aSJosh Triplett $(obj)/string.o $(obj)/cmdline.o \ 509e6abd2aSJosh Triplett $(obj)/piggy.o $(obj)/cpuflags.o 519e6abd2aSJosh Triplett 523afed06aSJosh Triplettvmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o 539e6abd2aSJosh Triplettvmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o 54291f3632SMatt Fleming 559dead5bbSMatthew Garrett$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone 569dead5bbSMatthew Garrett 57243b6754SArd Biesheuvelvmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \ 58243b6754SArd Biesheuvel $(objtree)/drivers/firmware/efi/libstub/lib.a 5996738c69SMatt Flemingvmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o 60291f3632SMatt Fleming 619a1cb471SJosh Triplett$(obj)/vmlinux: $(vmlinux-objs-y) FORCE 62db569afaSSam Ravnborg $(call if_changed,ld) 63db569afaSSam Ravnborg @: 64db569afaSSam Ravnborg 65099e1377SIan CampbellOBJCOPYFLAGS_vmlinux.bin := -R .comment -S 66db569afaSSam Ravnborg$(obj)/vmlinux.bin: vmlinux FORCE 67db569afaSSam Ravnborg $(call if_changed,objcopy) 68db569afaSSam Ravnborg 699a1cb471SJosh Tripletttargets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs 70db569afaSSam Ravnborg 716520fe55SH. Peter AnvinCMD_RELOCS = arch/x86/tools/relocs 72db569afaSSam Ravnborgquiet_cmd_relocs = RELOCS $@ 736520fe55SH. Peter Anvin cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $< 746520fe55SH. Peter Anvin$(obj)/vmlinux.relocs: vmlinux FORCE 75db569afaSSam Ravnborg $(call if_changed,relocs) 76db569afaSSam Ravnborg 77db569afaSSam Ravnborgvmlinux.bin.all-y := $(obj)/vmlinux.bin 785f11e020SH. Peter Anvinvmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs 79db569afaSSam Ravnborg 805f11e020SH. Peter Anvin$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE 81db569afaSSam Ravnborg $(call if_changed,gzip) 825f11e020SH. Peter Anvin$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE 83ae03c499SAlain Knaff $(call if_changed,bzip2) 845f11e020SH. Peter Anvin$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE 85ae03c499SAlain Knaff $(call if_changed,lzma) 8630314804SLasse Collin$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE 8730314804SLasse Collin $(call if_changed,xzkern) 8813510997SAlbin Tonnerre$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE 8913510997SAlbin Tonnerre $(call if_changed,lzo) 90f9b493acSKyungsik Lee$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE 91f9b493acSKyungsik Lee $(call if_changed,lz4) 92db569afaSSam Ravnborg 93283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_GZIP) := gz 94283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_BZIP2) := bz2 95283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_LZMA) := lzma 9630314804SLasse Collinsuffix-$(CONFIG_KERNEL_XZ) := xz 9713510997SAlbin Tonnerresuffix-$(CONFIG_KERNEL_LZO) := lzo 98f9b493acSKyungsik Leesuffix-$(CONFIG_KERNEL_LZ4) := lz4 99ae03c499SAlain Knaff 100e2e68ae6SChris ClaytonRUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \ 101d69911a6SKees Cook $(CONFIG_SHELL) $(srctree)/arch/x86/tools/calc_run_size.sh) 10202a884c0SH. Peter Anvinquiet_cmd_mkpiggy = MKPIGGY $@ 103e6023367SJunjie Mao cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false ) 10402a884c0SH. Peter Anvin 10502a884c0SH. Peter Anvintargets += piggy.S 10602a884c0SH. Peter Anvin$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE 10702a884c0SH. Peter Anvin $(call if_changed,mkpiggy) 108