xref: /linux/arch/arm/boot/compressed/Makefile (revision f9b493ac9b833fd9dd3bbd50460adb33f29e1238)
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
9090ab3ffSSimon Horman# Ensure that MMCIF loader code appears early in the image
10f45b1149SSimon Horman# to minimise that number of bocks that have to be read in
11f45b1149SSimon Horman# order to load it.
12f45b1149SSimon Hormanifeq ($(CONFIG_ZBOOT_ROM_MMCIF),y)
13f45b1149SSimon HormanOBJS		+= mmcif-sh7372.o
14f45b1149SSimon Hormanendif
15090ab3ffSSimon Horman
16090ab3ffSSimon Horman# Ensure that SDHI loader code appears early in the image
17090ab3ffSSimon Horman# to minimise that number of bocks that have to be read in
18090ab3ffSSimon Horman# order to load it.
19090ab3ffSSimon Hormanifeq ($(CONFIG_ZBOOT_ROM_SH_MOBILE_SDHI),y)
20090ab3ffSSimon HormanOBJS		+= sdhi-shmobile.o
21090ab3ffSSimon HormanOBJS		+= sdhi-sh7372.o
22f45b1149SSimon Hormanendif
23f45b1149SSimon Horman
24e69edc79SEric MiaoAFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET)
251da177e4SLinus TorvaldsHEAD	= head.o
26f45b1149SSimon HormanOBJS	+= misc.o decompress.o
273b4af9bcSShawn Guoifeq ($(CONFIG_DEBUG_UNCOMPRESS),y)
283b4af9bcSShawn GuoOBJS	+= debug.o
293b4af9bcSShawn Guoendif
30ee89bd6bSGeert UytterhoevenFONTC	= $(srctree)/lib/fonts/font_acorn_8x8.c
311da177e4SLinus Torvalds
32df4879faSNicolas Pitre# string library code (-Os is enforced to keep it much smaller)
33df4879faSNicolas PitreOBJS		+= string.o
34df4879faSNicolas PitreCFLAGS_string.o	:= -Os
35df4879faSNicolas Pitre
36424e5994SDave Martinifeq ($(CONFIG_ARM_VIRT_EXT),y)
37424e5994SDave MartinOBJS		+= hyp-stub.o
38424e5994SDave Martinendif
39424e5994SDave Martin
401da177e4SLinus Torvalds#
411da177e4SLinus Torvalds# Architecture dependencies
421da177e4SLinus Torvalds#
431da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_ACORN),y)
444486b863SRussell KingOBJS		+= ll_char_wr.o font.o
451da177e4SLinus Torvaldsendif
461da177e4SLinus Torvalds
471da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_SHARK),y)
481da177e4SLinus TorvaldsOBJS		+= head-shark.o ofw-shark.o
491da177e4SLinus Torvaldsendif
501da177e4SLinus Torvalds
511da177e4SLinus Torvaldsifeq ($(CONFIG_ARCH_SA1100),y)
521da177e4SLinus TorvaldsOBJS		+= head-sa1100.o
531da177e4SLinus Torvaldsendif
541da177e4SLinus Torvalds
551da177e4SLinus Torvaldsifeq ($(CONFIG_CPU_XSCALE),y)
561da177e4SLinus TorvaldsOBJS		+= head-xscale.o
571da177e4SLinus Torvaldsendif
581da177e4SLinus Torvalds
599c3fca2eSEric Miaoifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y)
601da177e4SLinus TorvaldsOBJS		+= head-sharpsl.o
611da177e4SLinus Torvaldsendif
621da177e4SLinus Torvalds
6326584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE32),y)
64f12d0d7cSHyok S. Choiifeq ($(CONFIG_CPU_CP15),y)
651da177e4SLinus TorvaldsOBJS		+= big-endian.o
66f12d0d7cSHyok S. Choielse
67f12d0d7cSHyok S. Choi# The endian should be set by h/w design.
68f12d0d7cSHyok S. Choiendif
691da177e4SLinus Torvaldsendif
701da177e4SLinus Torvalds
719a4af112SKuninori Morimotoifeq ($(CONFIG_ARCH_SHMOBILE),y)
729a4af112SKuninori MorimotoOBJS		+= head-shmobile.o
739a4af112SKuninori Morimotoendif
749a4af112SKuninori Morimoto
751da177e4SLinus Torvalds#
761da177e4SLinus Torvalds# We now have a PIC decompressor implementation.  Decompressors running
771da177e4SLinus Torvalds# from RAM should not define ZTEXTADDR.  Decompressors running directly
781da177e4SLinus Torvalds# from ROM or Flash must define ZTEXTADDR (preferably via the config)
791da177e4SLinus Torvalds# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
801da177e4SLinus Torvaldsifeq ($(CONFIG_ZBOOT_ROM),y)
811da177e4SLinus TorvaldsZTEXTADDR	:= $(CONFIG_ZBOOT_ROM_TEXT)
821da177e4SLinus TorvaldsZBSSADDR	:= $(CONFIG_ZBOOT_ROM_BSS)
831da177e4SLinus Torvaldselse
841da177e4SLinus TorvaldsZTEXTADDR	:= 0
853bd2cbb9SNicolas PitreZBSSADDR	:= ALIGN(8)
861da177e4SLinus Torvaldsendif
871da177e4SLinus Torvalds
881da177e4SLinus TorvaldsSEDFLAGS	= s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/
891da177e4SLinus Torvalds
90e7db7b42SAlbin Tonnerresuffix_$(CONFIG_KERNEL_GZIP) = gzip
91e7db7b42SAlbin Tonnerresuffix_$(CONFIG_KERNEL_LZO)  = lzo
926e8699f7SAlbin Tonnerresuffix_$(CONFIG_KERNEL_LZMA) = lzma
93a7f464f3SImre Kalozsuffix_$(CONFIG_KERNEL_XZ)   = xzkern
94*f9b493acSKyungsik Leesuffix_$(CONFIG_KERNEL_LZ4)  = lz4
95e7db7b42SAlbin Tonnerre
96b90b9a38SNicolas Pitre# Borrowed libfdt files for the ATAG compatibility mode
97b90b9a38SNicolas Pitre
98b90b9a38SNicolas Pitrelibfdt		:= fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
99b90b9a38SNicolas Pitrelibfdt_hdrs	:= fdt.h libfdt.h libfdt_internal.h
100b90b9a38SNicolas Pitre
101b90b9a38SNicolas Pitrelibfdt_objs	:= $(addsuffix .o, $(basename $(libfdt)))
102b90b9a38SNicolas Pitre
103b90b9a38SNicolas Pitre$(addprefix $(obj)/,$(libfdt) $(libfdt_hdrs)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
104b90b9a38SNicolas Pitre	$(call cmd,shipped)
105b90b9a38SNicolas Pitre
106b90b9a38SNicolas Pitre$(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
107b90b9a38SNicolas Pitre	$(addprefix $(obj)/,$(libfdt_hdrs))
108b90b9a38SNicolas Pitre
109b90b9a38SNicolas Pitreifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
110b90b9a38SNicolas PitreOBJS	+= $(libfdt_objs) atags_to_fdt.o
111b90b9a38SNicolas Pitreendif
112b90b9a38SNicolas Pitre
113e7db7b42SAlbin Tonnerretargets       := vmlinux vmlinux.lds \
114e7db7b42SAlbin Tonnerre		 piggy.$(suffix_y) piggy.$(suffix_y).o \
115a7f464f3SImre Kaloz		 lib1funcs.o lib1funcs.S ashldi3.o ashldi3.S \
116a7f464f3SImre Kaloz		 font.o font.c head.o misc.o $(OBJS)
117014c257cSAbhishek Sagar
118f1b957d3SMagnus Damm# Make sure files are removed during clean
119*f9b493acSKyungsik Leeextra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
12069f91ff8SMagnus Damm		 lib1funcs.S ashldi3.S $(libfdt) $(libfdt_hdrs) \
12169f91ff8SMagnus Damm		 hyp-stub.S
122f1b957d3SMagnus Damm
123606576ceSSteven Rostedtifeq ($(CONFIG_FUNCTION_TRACER),y)
124014c257cSAbhishek SagarORIG_CFLAGS := $(KBUILD_CFLAGS)
125014c257cSAbhishek SagarKBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
126014c257cSAbhishek Sagarendif
127014c257cSAbhishek Sagar
128b8083f86SJonathan Austinccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
129da94a829SArnd Bergmannasflags-y := -DZIMAGE
1301da177e4SLinus Torvalds
1315ffb04f6SNicolas Pitre# Supply kernel BSS size to the decompressor via a linker symbol.
1321ec332a3SJanusz KrzysztofikKBSS_SZ = $(shell $(CROSS_COMPILE)size $(obj)/../../../../vmlinux | \
1331ec332a3SJanusz Krzysztofik		awk 'END{print $$3}')
1345ffb04f6SNicolas PitreLDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
1359e84ed63SRussell King# Supply ZRELADDR to the decompressor via a linker symbol.
1369e84ed63SRussell Kingifneq ($(CONFIG_AUTO_ZRELADDR),y)
137d239b1dcSNicolas PitreLDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
1389e84ed63SRussell Kingendif
13926584853SCatalin Marinasifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
14026584853SCatalin MarinasLDFLAGS_vmlinux += --be8
14126584853SCatalin Marinasendif
142e7db7b42SAlbin Tonnerre# ?
143e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -p
144e7db7b42SAlbin Tonnerre# Report unresolved symbol references
145e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += --no-undefined
146e7db7b42SAlbin Tonnerre# Delete all temporary local symbols
147e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -X
148e7db7b42SAlbin Tonnerre# Next argument is a linker script
149e7db7b42SAlbin TonnerreLDFLAGS_vmlinux += -T
150e7db7b42SAlbin Tonnerre
151e7db7b42SAlbin Tonnerre# For __aeabi_uidivmod
152e7db7b42SAlbin Tonnerrelib1funcs = $(obj)/lib1funcs.o
153e7db7b42SAlbin Tonnerre
15463d15148SNicolas Pitre$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
155e7db7b42SAlbin Tonnerre	$(call cmd,shipped)
1561da177e4SLinus Torvalds
157a7f464f3SImre Kaloz# For __aeabi_llsl
158a7f464f3SImre Kalozashldi3 = $(obj)/ashldi3.o
159a7f464f3SImre Kaloz
160a7f464f3SImre Kaloz$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S
161a7f464f3SImre Kaloz	$(call cmd,shipped)
162a7f464f3SImre Kaloz
1638d7e4cc2SNicolas Pitre# We need to prevent any GOTOFF relocs being used with references
1648d7e4cc2SNicolas Pitre# to symbols in the .bss section since we cannot relocate them
1658d7e4cc2SNicolas Pitre# independently from the rest at run time.  This can be achieved by
1668d7e4cc2SNicolas Pitre# ensuring that no private .bss symbols exist, as global symbols
1678d7e4cc2SNicolas Pitre# always have a GOT entry which is what we need.
1688d7e4cc2SNicolas Pitre# The .data section is already discarded by the linker script so no need
1698d7e4cc2SNicolas Pitre# to bother about it here.
1708d7e4cc2SNicolas Pitrecheck_for_bad_syms = \
1718d7e4cc2SNicolas Pitrebad_syms=$$($(CROSS_COMPILE)nm $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
1728d7e4cc2SNicolas Pitre[ -z "$$bad_syms" ] || \
1738d7e4cc2SNicolas Pitre  ( echo "following symbols must have non local/private scope:" >&2; \
1748d7e4cc2SNicolas Pitre    echo "$$bad_syms" >&2; rm -f $@; false )
1758d7e4cc2SNicolas Pitre
17660aac932SSascha Hauercheck_for_multiple_zreladdr = \
1774bdad983SRabin Vincentif [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \
17860aac932SSascha Hauer	echo 'multiple zreladdrs: $(ZRELADDR)'; \
17960aac932SSascha Hauer	echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \
18060aac932SSascha Hauer	false; \
18160aac932SSascha Hauerfi
18260aac932SSascha Hauer
183e7db7b42SAlbin Tonnerre$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
184a7f464f3SImre Kaloz		$(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) FORCE
18560aac932SSascha Hauer	@$(check_for_multiple_zreladdr)
1861da177e4SLinus Torvalds	$(call if_changed,ld)
1878d7e4cc2SNicolas Pitre	@$(check_for_bad_syms)
1881da177e4SLinus Torvalds
189e7db7b42SAlbin Tonnerre$(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
190e7db7b42SAlbin Tonnerre	$(call if_changed,$(suffix_y))
1911da177e4SLinus Torvalds
192e7db7b42SAlbin Tonnerre$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y) FORCE
1931da177e4SLinus Torvalds
1944486b863SRussell KingCFLAGS_font.o := -Dstatic=
1954486b863SRussell King
1964486b863SRussell King$(obj)/font.c: $(FONTC)
1974486b863SRussell King	$(call cmd,shipped)
1981da177e4SLinus Torvalds
199d93c333dSRussell King$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG)
2001da177e4SLinus Torvalds	@sed "$(SEDFLAGS)" < $< > $@
201424e5994SDave Martin
202424e5994SDave Martin$(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S
203424e5994SDave Martin	$(call cmd,shipped)
204