• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# linux/arch/x86/boot/compressed/Makefile
3#
4# create a compressed vmlinux image from the original vmlinux
5#
6
7KASAN_SANITIZE := n
8
9# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
10KCOV_INSTRUMENT		:= n
11
12targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
13	vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
14
15KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
16KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
17KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
18cflags-$(CONFIG_X86_32) := -march=i386
19cflags-$(CONFIG_X86_64) := -mcmodel=small
20KBUILD_CFLAGS += $(cflags-y)
21KBUILD_CFLAGS += -mno-mmx -mno-sse
22KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
23KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
24
25KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
26GCOV_PROFILE := n
27
28LDFLAGS := -m elf_$(UTS_MACHINE)
29ifeq ($(CONFIG_RELOCATABLE),y)
30# If kernel is relocatable, build compressed kernel as PIE.
31ifeq ($(CONFIG_X86_32),y)
32LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker)
33else
34# To build 64-bit compressed kernel as PIE, we disable relocation
35# overflow check to avoid relocation overflow error with a new linker
36# command-line option, -z noreloc-overflow.
37LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
38	&& echo "-z noreloc-overflow -pie --no-dynamic-linker")
39endif
40endif
41LDFLAGS_vmlinux := -T
42
43hostprogs-y	:= mkpiggy
44HOST_EXTRACFLAGS += -I$(srctree)/tools/include
45
46vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
47	$(obj)/string.o $(obj)/cmdline.o \
48	$(obj)/piggy.o $(obj)/cpuflags.o
49
50vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o
51vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o
52
53$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
54
55vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o
56vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
57
58$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
59	$(call if_changed,ld)
60	@:
61
62OBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S
63$(obj)/vmlinux.bin: vmlinux FORCE
64	$(call if_changed,objcopy)
65
66targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
67
68CMD_RELOCS = arch/x86/tools/relocs
69quiet_cmd_relocs = RELOCS  $@
70      cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
71$(obj)/vmlinux.relocs: vmlinux FORCE
72	$(call if_changed,relocs)
73
74vmlinux.bin.all-y := $(obj)/vmlinux.bin
75vmlinux.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)
83$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
84	$(call if_changed,xzkern)
85$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
86	$(call if_changed,lzo)
87$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
88	$(call if_changed,lz4)
89
90suffix-$(CONFIG_KERNEL_GZIP)	:= gz
91suffix-$(CONFIG_KERNEL_BZIP2)	:= bz2
92suffix-$(CONFIG_KERNEL_LZMA)	:= lzma
93suffix-$(CONFIG_KERNEL_XZ)	:= xz
94suffix-$(CONFIG_KERNEL_LZO) 	:= lzo
95suffix-$(CONFIG_KERNEL_LZ4) 	:= lz4
96
97RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
98	     $(CONFIG_SHELL) $(srctree)/arch/x86/tools/calc_run_size.sh)
99quiet_cmd_mkpiggy = MKPIGGY $@
100      cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
101
102targets += piggy.S
103$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
104	$(call if_changed,mkpiggy)
105