• 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
7targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo
8
9KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
10KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
11KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
12cflags-$(CONFIG_X86_32) := -march=i386
13cflags-$(CONFIG_X86_64) := -mcmodel=small
14KBUILD_CFLAGS += $(cflags-y)
15KBUILD_CFLAGS += -mno-mmx -mno-sse
16KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
17KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
18
19KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
20GCOV_PROFILE := n
21
22LDFLAGS := -m elf_$(UTS_MACHINE)
23ifeq ($(CONFIG_RELOCATABLE),y)
24# If kernel is relocatable, build compressed kernel as PIE.
25ifeq ($(CONFIG_X86_32),y)
26LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker)
27else
28# To build 64-bit compressed kernel as PIE, we disable relocation
29# overflow check to avoid relocation overflow error with a new linker
30# command-line option, -z noreloc-overflow.
31LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
32	&& echo "-z noreloc-overflow -pie --no-dynamic-linker")
33endif
34endif
35LDFLAGS_vmlinux := -T
36
37hostprogs-y	:= mkpiggy
38HOST_EXTRACFLAGS += -I$(srctree)/tools/include
39
40VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
41	$(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o \
42	$(obj)/piggy.o
43
44$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
45
46ifeq ($(CONFIG_EFI_STUB), y)
47	VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o
48endif
49
50$(obj)/vmlinux: $(VMLINUX_OBJS) FORCE
51	$(call if_changed,ld)
52	@:
53
54OBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S
55$(obj)/vmlinux.bin: vmlinux FORCE
56	$(call if_changed,objcopy)
57
58targets += $(patsubst $(obj)/%,%,$(VMLINUX_OBJS)) vmlinux.bin.all vmlinux.relocs
59
60CMD_RELOCS = arch/x86/tools/relocs
61quiet_cmd_relocs = RELOCS  $@
62      cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
63$(obj)/vmlinux.relocs: vmlinux FORCE
64	$(call if_changed,relocs)
65
66vmlinux.bin.all-y := $(obj)/vmlinux.bin
67vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
68
69$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
70	$(call if_changed,gzip)
71$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
72	$(call if_changed,bzip2)
73$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
74	$(call if_changed,lzma)
75$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
76	$(call if_changed,xzkern)
77$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
78	$(call if_changed,lzo)
79
80suffix-$(CONFIG_KERNEL_GZIP)	:= gz
81suffix-$(CONFIG_KERNEL_BZIP2)	:= bz2
82suffix-$(CONFIG_KERNEL_LZMA)	:= lzma
83suffix-$(CONFIG_KERNEL_XZ)	:= xz
84suffix-$(CONFIG_KERNEL_LZO) 	:= lzo
85
86quiet_cmd_mkpiggy = MKPIGGY $@
87      cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false )
88
89targets += piggy.S
90$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
91	$(call if_changed,mkpiggy)
92