blob: a5889238fc9fc6fe6f3c2dc1b2c7e172fc597594 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#
3# linux/arch/arm/boot/compressed/Makefile
4#
5# create a compressed vmlinuz image from the original vmlinux
6#
7
Simon Hormanf45b1142011-01-11 04:01:08 +01008OBJS =
9
Eric Miaoe69edc792010-07-05 15:56:50 +020010AFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET)
Linus Torvalds1da177e2005-04-16 15:20:36 -070011HEAD = head.o
Simon Hormanf45b1142011-01-11 04:01:08 +010012OBJS += misc.o decompress.o
Shawn Guo3b4af9b2013-03-14 08:48:06 +010013ifeq ($(CONFIG_DEBUG_UNCOMPRESS),y)
14OBJS += debug.o
15endif
Geert Uytterhoevenee89bd62013-06-09 11:46:43 +020016FONTC = $(srctree)/lib/fonts/font_acorn_8x8.c
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Nicolas Pitredf4879f2011-09-13 21:42:55 -040018# string library code (-Os is enforced to keep it much smaller)
19OBJS += string.o
20CFLAGS_string.o := -Os
21
Dave Martin424e5992012-02-10 18:07:07 -080022ifeq ($(CONFIG_ARM_VIRT_EXT),y)
23OBJS += hyp-stub.o
24endif
25
Vincent Sanders75c34902014-09-18 20:39:15 +010026GCOV_PROFILE := n
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#
29# Architecture dependencies
30#
31ifeq ($(CONFIG_ARCH_ACORN),y)
Russell King4486b862007-06-03 18:54:42 +010032OBJS += ll_char_wr.o font.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070033endif
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035ifeq ($(CONFIG_ARCH_SA1100),y)
36OBJS += head-sa1100.o
37endif
38
39ifeq ($(CONFIG_CPU_XSCALE),y)
40OBJS += head-xscale.o
41endif
42
Eric Miao9c3fca22010-06-23 09:27:32 +080043ifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044OBJS += head-sharpsl.o
45endif
46
Catalin Marinas26584852009-05-30 14:00:18 +010047ifeq ($(CONFIG_CPU_ENDIAN_BE32),y)
Hyok S. Choif12d0d72006-09-26 17:36:37 +090048ifeq ($(CONFIG_CPU_CP15),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049OBJS += big-endian.o
Hyok S. Choif12d0d72006-09-26 17:36:37 +090050else
51# The endian should be set by h/w design.
52endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070053endif
54
55#
56# We now have a PIC decompressor implementation. Decompressors running
57# from RAM should not define ZTEXTADDR. Decompressors running directly
58# from ROM or Flash must define ZTEXTADDR (preferably via the config)
59# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
60ifeq ($(CONFIG_ZBOOT_ROM),y)
61ZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT)
62ZBSSADDR := $(CONFIG_ZBOOT_ROM_BSS)
63else
64ZTEXTADDR := 0
Nicolas Pitre3bd2cbb2011-04-21 21:45:08 -040065ZBSSADDR := ALIGN(8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066endif
67
Russell Kingc79bf922014-06-17 15:00:54 +010068CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Masahiro Yamadaf57deb02016-02-22 13:32:58 +010070compress-$(CONFIG_KERNEL_GZIP) = gzip
71compress-$(CONFIG_KERNEL_LZO) = lzo
72compress-$(CONFIG_KERNEL_LZMA) = lzma
73compress-$(CONFIG_KERNEL_XZ) = xzkern
74compress-$(CONFIG_KERNEL_LZ4) = lz4
Albin Tonnerree7db7b42010-01-08 14:42:43 -080075
Nicolas Pitreb90b9a32011-09-13 22:37:07 -040076# Borrowed libfdt files for the ATAG compatibility mode
77
78libfdt := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
79libfdt_hdrs := fdt.h libfdt.h libfdt_internal.h
80
81libfdt_objs := $(addsuffix .o, $(basename $(libfdt)))
82
83$(addprefix $(obj)/,$(libfdt) $(libfdt_hdrs)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
84 $(call cmd,shipped)
85
86$(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
87 $(addprefix $(obj)/,$(libfdt_hdrs))
88
89ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
90OBJS += $(libfdt_objs) atags_to_fdt.o
91endif
92
Masahiro Yamada53f67542016-02-22 13:32:24 +010093targets := vmlinux vmlinux.lds piggy_data piggy.o \
Masahiro Yamadab44c72d2016-02-22 13:29:35 +010094 lib1funcs.o ashldi3.o bswapsdi2.o \
Masahiro Yamada684c1202016-02-22 13:30:37 +010095 head.o $(OBJS)
Abhishek Sagar014c2572008-05-31 14:23:50 +053096
Masahiro Yamada53f67542016-02-22 13:32:24 +010097clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S \
98 $(libfdt) $(libfdt_hdrs) hyp-stub.S
Magnus Dammf1b957d2010-07-28 05:46:21 +010099
Arnd Bergmann8c36a752015-05-26 15:39:36 +0100100KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
101
Steven Rostedt606576c2008-10-06 19:06:12 -0400102ifeq ($(CONFIG_FUNCTION_TRACER),y)
Abhishek Sagar014c2572008-05-31 14:23:50 +0530103ORIG_CFLAGS := $(KBUILD_CFLAGS)
104KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
105endif
106
Kees Cook7f66cd32016-01-26 01:18:13 +0100107# -fstack-protector-strong triggers protection checks in this code,
108# but it is being used too early to link to meaningful stack_chk logic.
109nossp_flags := $(call cc-option, -fno-stack-protector)
110CFLAGS_atags_to_fdt.o := $(nossp_flags)
111CFLAGS_fdt.o := $(nossp_flags)
112CFLAGS_fdt_ro.o := $(nossp_flags)
113CFLAGS_fdt_rw.o := $(nossp_flags)
114CFLAGS_fdt_wip.o := $(nossp_flags)
115
Jonathan Austinb8083f82013-03-04 15:17:36 +0100116ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
Arnd Bergmannda94a822013-05-31 22:50:47 +0100117asflags-y := -DZIMAGE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Nicolas Pitre5ffb04f2011-06-12 01:07:33 -0400119# Supply kernel BSS size to the decompressor via a linker symbol.
Janusz Krzysztofik1ec332a2011-12-01 22:45:47 +0100120KBSS_SZ = $(shell $(CROSS_COMPILE)size $(obj)/../../../../vmlinux | \
121 awk 'END{print $$3}')
Nicolas Pitre5ffb04f2011-06-12 01:07:33 -0400122LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
Russell King9e84ed62010-09-09 22:39:41 +0100123# Supply ZRELADDR to the decompressor via a linker symbol.
124ifneq ($(CONFIG_AUTO_ZRELADDR),y)
Nicolas Pitred239b1d2011-02-21 04:57:38 +0100125LDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
Russell King9e84ed62010-09-09 22:39:41 +0100126endif
Catalin Marinas26584852009-05-30 14:00:18 +0100127ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
128LDFLAGS_vmlinux += --be8
129endif
Albin Tonnerree7db7b42010-01-08 14:42:43 -0800130# ?
131LDFLAGS_vmlinux += -p
132# Report unresolved symbol references
133LDFLAGS_vmlinux += --no-undefined
134# Delete all temporary local symbols
135LDFLAGS_vmlinux += -X
136# Next argument is a linker script
137LDFLAGS_vmlinux += -T
138
139# For __aeabi_uidivmod
140lib1funcs = $(obj)/lib1funcs.o
141
Nicolas Pitre63d15142011-09-14 00:16:21 -0400142$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
Albin Tonnerree7db7b42010-01-08 14:42:43 -0800143 $(call cmd,shipped)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Imre Kaloza7f464f2012-01-26 13:08:57 +0100145# For __aeabi_llsl
146ashldi3 = $(obj)/ashldi3.o
147
148$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S
149 $(call cmd,shipped)
150
Kim Phillips017f1612013-11-06 05:15:24 +0100151# For __bswapsi2, __bswapdi2
152bswapsdi2 = $(obj)/bswapsdi2.o
153
154$(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S
155 $(call cmd,shipped)
156
Nicolas Pitre8d7e4cc2011-04-27 14:54:39 -0400157# We need to prevent any GOTOFF relocs being used with references
158# to symbols in the .bss section since we cannot relocate them
159# independently from the rest at run time. This can be achieved by
160# ensuring that no private .bss symbols exist, as global symbols
161# always have a GOT entry which is what we need.
162# The .data section is already discarded by the linker script so no need
163# to bother about it here.
164check_for_bad_syms = \
165bad_syms=$$($(CROSS_COMPILE)nm $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
166[ -z "$$bad_syms" ] || \
167 ( echo "following symbols must have non local/private scope:" >&2; \
168 echo "$$bad_syms" >&2; rm -f $@; false )
169
Sascha Hauer60aac932011-08-17 14:22:11 +0100170check_for_multiple_zreladdr = \
Rabin Vincent4bdad982011-10-04 14:33:34 +0100171if [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \
Sascha Hauer60aac932011-08-17 14:22:11 +0100172 echo 'multiple zreladdrs: $(ZRELADDR)'; \
173 echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \
174 false; \
175fi
176
Roy Franz81a0bc32015-09-23 20:17:54 -0700177efi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a
178
Masahiro Yamada53f67542016-02-22 13:32:24 +0100179$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
Kim Phillips017f1612013-11-06 05:15:24 +0100180 $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \
Roy Franz81a0bc32015-09-23 20:17:54 -0700181 $(bswapsdi2) $(efi-obj-y) FORCE
Sascha Hauer60aac932011-08-17 14:22:11 +0100182 @$(check_for_multiple_zreladdr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 $(call if_changed,ld)
Nicolas Pitre8d7e4cc2011-04-27 14:54:39 -0400184 @$(check_for_bad_syms)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
Masahiro Yamada53f67542016-02-22 13:32:24 +0100186$(obj)/piggy_data: $(obj)/../Image FORCE
Masahiro Yamadaf57deb02016-02-22 13:32:58 +0100187 $(call if_changed,$(compress-y))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Masahiro Yamada53f67542016-02-22 13:32:24 +0100189$(obj)/piggy.o: $(obj)/piggy_data
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Russell King4486b862007-06-03 18:54:42 +0100191CFLAGS_font.o := -Dstatic=
192
193$(obj)/font.c: $(FONTC)
194 $(call cmd,shipped)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
Jean-Philippe Bruckerc7edd7f2016-02-19 11:04:45 +0100196AFLAGS_hyp-stub.o := -Wa,-march=armv7-a
197
Dave Martin424e5992012-02-10 18:07:07 -0800198$(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S
199 $(call cmd,shipped)