xref: /linux/arch/arm/boot/compressed/Makefile (revision b44c72de44173f47e782610e31d4cd1abca3741f)
11da177e4SLinus Torvalds#
21da177e4SLinus Torvalds# linux/arch/arm/boot/compressed/Makefile
31da177e4SLinus Torvalds#
41da177e4SLinus Torvalds# create a compressed vmlinuz image from the original vmlinux
51da177e4SLinus Torvalds#
61da177e4SLinus Torvalds
7f45b1149SSimon HormanOBJS		=
8f45b1149SSimon Horman
9e69edc79SEric MiaoAFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET)
101da177e4SLinus TorvaldsHEAD	= head.o
11f45b1149SSimon HormanOBJS	+= misc.o decompress.o
123b4af9bcSShawn Guoifeq ($(CONFIG_DEBUG_UNCOMPRESS),y)
133b4af9bcSShawn GuoOBJS	+= debug.o
143b4af9bcSShawn Guoendif
15ee89bd6bSGeert UytterhoevenFONTC	= $(srctree)/lib/fonts/font_acorn_8x8.c
161da177e4SLinus Torvalds
17df4879faSNicolas Pitre# string library code (-Os is enforced to keep it much smaller)
18df4879faSNicolas PitreOBJS		+= string.o
19df4879faSNicolas PitreCFLAGS_string.o	:= -Os
20df4879faSNicolas Pitre
21424e5994SDave Martinifeq ($(CONFIG_ARM_VIRT_EXT),y)
22424e5994SDave MartinOBJS		+= hyp-stub.o
23424e5994SDave Martinendif
24424e5994SDave Martin
2575c34906SVincent SandersGCOV_PROFILE		:= n
2675c34906SVincent Sanders
271da177e4SLinus Torvalds#
281da177e4SLinus Torvalds# Architecture dependencies
291da177e4SLinus Torvalds#
301da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_ACORN),y)
314486b863SRussell KingOBJS		+= ll_char_wr.o font.o
321da177e4SLinus Torvaldsendif
331da177e4SLinus Torvalds
341da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_SA1100),y)
351da177e4SLinus TorvaldsOBJS		+= head-sa1100.o
361da177e4SLinus Torvaldsendif
371da177e4SLinus Torvalds
381da177e4SLinus Torvaldsifeq ($(CONFIG_CPU_XSCALE),y)
391da177e4SLinus TorvaldsOBJS		+= head-xscale.o
401da177e4SLinus Torvaldsendif
411da177e4SLinus Torvalds
429c3fca2eSEric Miaoifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y)
431da177e4SLinus TorvaldsOBJS		+= head-sharpsl.o
441da177e4SLinus Torvaldsendif
451da177e4SLinus Torvalds
4626584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE32),y)
47f12d0d7cSHyok S. Choiifeq ($(CONFIG_CPU_CP15),y)
481da177e4SLinus TorvaldsOBJS		+= big-endian.o
49f12d0d7cSHyok S. Choielse
50f12d0d7cSHyok S. Choi# The endian should be set by h/w design.
51f12d0d7cSHyok S. Choiendif
521da177e4SLinus Torvaldsendif
531da177e4SLinus Torvalds
541da177e4SLinus Torvalds#
551da177e4SLinus Torvalds# We now have a PIC decompressor implementation.  Decompressors running
561da177e4SLinus Torvalds# from RAM should not define ZTEXTADDR.  Decompressors running directly
571da177e4SLinus Torvalds# from ROM or Flash must define ZTEXTADDR (preferably via the config)
581da177e4SLinus Torvalds# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
591da177e4SLinus Torvaldsifeq ($(CONFIG_ZBOOT_ROM),y)
601da177e4SLinus TorvaldsZTEXTADDR	:= $(CONFIG_ZBOOT_ROM_TEXT)
611da177e4SLinus TorvaldsZBSSADDR	:= $(CONFIG_ZBOOT_ROM_BSS)
621da177e4SLinus Torvaldselse
631da177e4SLinus TorvaldsZTEXTADDR	:= 0
643bd2cbb9SNicolas PitreZBSSADDR	:= ALIGN(8)
651da177e4SLinus Torvaldsendif
661da177e4SLinus Torvalds
67c79bf928SRussell KingCPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
681da177e4SLinus Torvalds
69e7db7b42SAlbin Tonnerresuffix_$(CONFIG_KERNEL_GZIP) = gzip
70e7db7b42SAlbin Tonnerresuffix_$(CONFIG_KERNEL_LZO)  = lzo
716e8699f7SAlbin Tonnerresuffix_$(CONFIG_KERNEL_LZMA) = lzma
72a7f464f3SImre Kalozsuffix_$(CONFIG_KERNEL_XZ)   = xzkern
73f9b493acSKyungsik Leesuffix_$(CONFIG_KERNEL_LZ4)  = lz4
74e7db7b42SAlbin Tonnerre
75b90b9a38SNicolas Pitre# Borrowed libfdt files for the ATAG compatibility mode
76b90b9a38SNicolas Pitre
77b90b9a38SNicolas Pitrelibfdt		:= fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
78b90b9a38SNicolas Pitrelibfdt_hdrs	:= fdt.h libfdt.h libfdt_internal.h
79b90b9a38SNicolas Pitre
80b90b9a38SNicolas Pitrelibfdt_objs	:= $(addsuffix .o, $(basename $(libfdt)))
81b90b9a38SNicolas Pitre
82b90b9a38SNicolas Pitre$(addprefix $(obj)/,$(libfdt) $(libfdt_hdrs)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
83b90b9a38SNicolas Pitre	$(call cmd,shipped)
84b90b9a38SNicolas Pitre
85b90b9a38SNicolas Pitre$(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
86b90b9a38SNicolas Pitre	$(addprefix $(obj)/,$(libfdt_hdrs))
87b90b9a38SNicolas Pitre
88b90b9a38SNicolas Pitreifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
89b90b9a38SNicolas PitreOBJS	+= $(libfdt_objs) atags_to_fdt.o
90b90b9a38SNicolas Pitreendif
91b90b9a38SNicolas Pitre
92e7db7b42SAlbin Tonnerretargets       := vmlinux vmlinux.lds \
93e7db7b42SAlbin Tonnerre		 piggy.$(suffix_y) piggy.$(suffix_y).o \
94*b44c72deSMasahiro Yamada		 lib1funcs.o ashldi3.o bswapsdi2.o \
95*b44c72deSMasahiro Yamada		 font.o head.o misc.o $(OBJS)
96014c257cSAbhishek Sagar
97f1b957d3SMagnus Damm# Make sure files are removed during clean
98f9b493acSKyungsik Leeextra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
99017f161aSKim Phillips		 lib1funcs.S ashldi3.S bswapsdi2.S $(libfdt) $(libfdt_hdrs) \
100c79bf928SRussell King		 hyp-stub.S
101f1b957d3SMagnus Damm
1028c36a757SArnd BergmannKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
1038c36a757SArnd Bergmann
104606576ceSSteven Rostedtifeq ($(CONFIG_FUNCTION_TRACER),y)
105014c257cSAbhishek SagarORIG_CFLAGS := $(KBUILD_CFLAGS)
106014c257cSAbhishek SagarKBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
107014c257cSAbhishek Sagarendif
108014c257cSAbhishek Sagar
109b8083f86SJonathan Austinccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
110da94a829SArnd Bergmannasflags-y := -DZIMAGE
1111da177e4SLinus Torvalds
1125ffb04f6SNicolas Pitre# Supply kernel BSS size to the decompressor via a linker symbol.
1131ec332a3SJanusz KrzysztofikKBSS_SZ = $(shell $(CROSS_COMPILE)size $(obj)/../../../../vmlinux | \
1141ec332a3SJanusz Krzysztofik		awk 'END{print $$3}')
1155ffb04f6SNicolas PitreLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
1169e84ed63SRussell King# Supply ZRELADDR to the decompressor via a linker symbol.
1179e84ed63SRussell Kingifneq ($(CONFIG_AUTO_ZRELADDR),y)
118d239b1dcSNicolas PitreLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
1199e84ed63SRussell Kingendif
12026584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
12126584853SCatalin MarinasLDFLAGS_vmlinux += --be8
12226584853SCatalin Marinasendif
123e7db7b42SAlbin Tonnerre# ?
124e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -p
125e7db7b42SAlbin Tonnerre# Report unresolved symbol references
126e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += --no-undefined
127e7db7b42SAlbin Tonnerre# Delete all temporary local symbols
128e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -X
129e7db7b42SAlbin Tonnerre# Next argument is a linker script
130e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -T
131e7db7b42SAlbin Tonnerre
132e7db7b42SAlbin Tonnerre# For __aeabi_uidivmod
133e7db7b42SAlbin Tonnerrelib1funcs = $(obj)/lib1funcs.o
134e7db7b42SAlbin Tonnerre
13563d15148SNicolas Pitre$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
136e7db7b42SAlbin Tonnerre	$(call cmd,shipped)
1371da177e4SLinus Torvalds
138a7f464f3SImre Kaloz# For __aeabi_llsl
139a7f464f3SImre Kalozashldi3 = $(obj)/ashldi3.o
140a7f464f3SImre Kaloz
141a7f464f3SImre Kaloz$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S
142a7f464f3SImre Kaloz	$(call cmd,shipped)
143a7f464f3SImre Kaloz
144017f161aSKim Phillips# For __bswapsi2, __bswapdi2
145017f161aSKim Phillipsbswapsdi2 = $(obj)/bswapsdi2.o
146017f161aSKim Phillips
147017f161aSKim Phillips$(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S
148017f161aSKim Phillips	$(call cmd,shipped)
149017f161aSKim Phillips
1508d7e4cc2SNicolas Pitre# We need to prevent any GOTOFF relocs being used with references
1518d7e4cc2SNicolas Pitre# to symbols in the .bss section since we cannot relocate them
1528d7e4cc2SNicolas Pitre# independently from the rest at run time.  This can be achieved by
1538d7e4cc2SNicolas Pitre# ensuring that no private .bss symbols exist, as global symbols
1548d7e4cc2SNicolas Pitre# always have a GOT entry which is what we need.
1558d7e4cc2SNicolas Pitre# The .data section is already discarded by the linker script so no need
1568d7e4cc2SNicolas Pitre# to bother about it here.
1578d7e4cc2SNicolas Pitrecheck_for_bad_syms = \
1588d7e4cc2SNicolas Pitrebad_syms=$$($(CROSS_COMPILE)nm $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
1598d7e4cc2SNicolas Pitre[ -z "$$bad_syms" ] || \
1608d7e4cc2SNicolas Pitre  ( echo "following symbols must have non local/private scope:" >&2; \
1618d7e4cc2SNicolas Pitre    echo "$$bad_syms" >&2; rm -f $@; false )
1628d7e4cc2SNicolas Pitre
16360aac932SSascha Hauercheck_for_multiple_zreladdr = \
1644bdad983SRabin Vincentif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \
16560aac932SSascha Hauer	echo 'multiple zreladdrs: $(ZRELADDR)'; \
16660aac932SSascha Hauer	echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \
16760aac932SSascha Hauer	false; \
16860aac932SSascha Hauerfi
16960aac932SSascha Hauer
17081a0bc39SRoy Franzefi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a
17181a0bc39SRoy Franz
172e7db7b42SAlbin Tonnerre$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
173017f161aSKim Phillips		$(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \
17481a0bc39SRoy Franz		$(bswapsdi2) $(efi-obj-y) FORCE
17560aac932SSascha Hauer	@$(check_for_multiple_zreladdr)
1761da177e4SLinus Torvalds	$(call if_changed,ld)
1778d7e4cc2SNicolas Pitre	@$(check_for_bad_syms)
1781da177e4SLinus Torvalds
179e7db7b42SAlbin Tonnerre$(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
180e7db7b42SAlbin Tonnerre	$(call if_changed,$(suffix_y))
1811da177e4SLinus Torvalds
182e7db7b42SAlbin Tonnerre$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y) FORCE
1831da177e4SLinus Torvalds
1844486b863SRussell KingCFLAGS_font.o := -Dstatic=
1854486b863SRussell King
1864486b863SRussell King$(obj)/font.c: $(FONTC)
1874486b863SRussell King	$(call cmd,shipped)
1881da177e4SLinus Torvalds
1898d9f4913SJean-Philippe BruckerAFLAGS_hyp-stub.o := -Wa,-march=armv7-a
1908d9f4913SJean-Philippe Brucker
191424e5994SDave Martin$(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S
192424e5994SDave Martin	$(call cmd,shipped)
193