Makefile 3.3 KB
Newer Older
1 2 3 4 5
#
# linux/arch/x86/boot/compressed/Makefile
#
# create a compressed vmlinux image from the original vmlinux
#
6 7 8 9 10 11 12 13 14 15 16 17
# vmlinuz is:
#	decompression code (*.o)
#	asm globals (piggy.S), including:
#		vmlinux.bin.(gz|bz2|lzma|...)
#
# vmlinux.bin is:
#	vmlinux stripped of debugging and comments
# vmlinux.bin.all is:
#	vmlinux.bin + vmlinux.relocs
# vmlinux.bin.(gz|bz2|lzma|...) is:
#	(see scripts/Makefile.lib size_append)
#	compressed vmlinux.bin.all + u32 size of vmlinux.bin.all
18

19 20
KASAN_SANITIZE			:= n
OBJECT_FILES_NON_STANDARD	:= y
A
Andrey Ryabinin 已提交
21

22 23
targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
	vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
24 25 26

KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
27
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
28
cflags-$(CONFIG_X86_32) := -march=i386
29 30
cflags-$(CONFIG_X86_64) := -mcmodel=small
KBUILD_CFLAGS += $(cflags-y)
31
KBUILD_CFLAGS += -mno-mmx -mno-sse
32 33 34 35
KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)

KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
36
GCOV_PROFILE := n
37
UBSAN_SANITIZE :=n
38 39 40 41

LDFLAGS := -m elf_$(UTS_MACHINE)
LDFLAGS_vmlinux := -T

42
hostprogs-y	:= mkpiggy
43
HOST_EXTRACFLAGS += -I$(srctree)/tools/include
44

45
vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
46
	$(obj)/string.o $(obj)/cmdline.o \
47 48
	$(obj)/piggy.o $(obj)/cpuflags.o

49
vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o
50
vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o
M
Matt Fleming 已提交
51

52 53
$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone

A
Ard Biesheuvel 已提交
54 55
vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \
	$(objtree)/drivers/firmware/efi/libstub/lib.a
56
vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
M
Matt Fleming 已提交
57

58
$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
59 60 61
	$(call if_changed,ld)
	@:

62
OBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S
63 64 65
$(obj)/vmlinux.bin: vmlinux FORCE
	$(call if_changed,objcopy)

66
targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
67

68
CMD_RELOCS = arch/x86/tools/relocs
69
quiet_cmd_relocs = RELOCS  $@
70 71
      cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
$(obj)/vmlinux.relocs: vmlinux FORCE
72 73 74
	$(call if_changed,relocs)

vmlinux.bin.all-y := $(obj)/vmlinux.bin
75
vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
76

77
$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
78
	$(call if_changed,gzip)
79
$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
80
	$(call if_changed,bzip2)
81
$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
82
	$(call if_changed,lzma)
L
Lasse Collin 已提交
83 84
$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
	$(call if_changed,xzkern)
85 86
$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
	$(call if_changed,lzo)
87 88
$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
	$(call if_changed,lz4)
89

90 91 92
suffix-$(CONFIG_KERNEL_GZIP)	:= gz
suffix-$(CONFIG_KERNEL_BZIP2)	:= bz2
suffix-$(CONFIG_KERNEL_LZMA)	:= lzma
L
Lasse Collin 已提交
93
suffix-$(CONFIG_KERNEL_XZ)	:= xz
94
suffix-$(CONFIG_KERNEL_LZO) 	:= lzo
95
suffix-$(CONFIG_KERNEL_LZ4) 	:= lz4
96

97
RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
98
	     $(CONFIG_SHELL) $(srctree)/arch/x86/tools/calc_run_size.sh)
99
quiet_cmd_mkpiggy = MKPIGGY $@
100
      cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
101 102 103 104

targets += piggy.S
$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
	$(call if_changed,mkpiggy)