xref: /linux/arch/arm/boot/compressed/Makefile (revision 2a6b6c9a226279b4f6668450ddb21ae655558087)
1# SPDX-License-Identifier: GPL-2.0
2#
3# linux/arch/arm/boot/compressed/Makefile
4#
5# create a compressed vmlinuz image from the original vmlinux
6#
7
8OBJS		=
9
10HEAD	= head.o
11OBJS	+= misc.o decompress.o
12ifeq ($(CONFIG_DEBUG_UNCOMPRESS),y)
13OBJS	+= debug.o
14AFLAGS_head.o += -DDEBUG
15endif
16
17# string library code (-Os is enforced to keep it much smaller)
18OBJS		+= string.o
19CFLAGS_string.o	:= -Os
20
21ifeq ($(CONFIG_ARM_VIRT_EXT),y)
22OBJS		+= hyp-stub.o
23endif
24
25#
26# Architecture dependencies
27#
28ifeq ($(CONFIG_ARCH_ACORN),y)
29OBJS		+= ll_char_wr.o font.o
30endif
31
32ifeq ($(CONFIG_ARCH_SA1100),y)
33OBJS		+= head-sa1100.o
34endif
35
36ifeq ($(CONFIG_CPU_XSCALE),y)
37OBJS		+= head-xscale.o
38endif
39
40ifeq ($(CONFIG_PXA_SHARPSL_DETECT_MACH_ID),y)
41OBJS		+= head-sharpsl.o
42endif
43
44ifeq ($(CONFIG_CPU_ENDIAN_BE32),y)
45ifeq ($(CONFIG_CPU_CP15),y)
46OBJS		+= big-endian.o
47else
48# The endian should be set by h/w design.
49endif
50endif
51
52#
53# We now have a PIC decompressor implementation.  Decompressors running
54# from RAM should not define ZTEXTADDR.  Decompressors running directly
55# from ROM or Flash must define ZTEXTADDR (preferably via the config)
56# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
57ifeq ($(CONFIG_ZBOOT_ROM),y)
58ZTEXTADDR	:= $(CONFIG_ZBOOT_ROM_TEXT)
59ZBSSADDR	:= $(CONFIG_ZBOOT_ROM_BSS)
60else
61ZTEXTADDR	:= 0
62ZBSSADDR	:= ALIGN(8)
63endif
64
65MALLOC_SIZE	:= 65536
66
67AFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET) -DMALLOC_SIZE=$(MALLOC_SIZE)
68CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
69CPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_OFFSET)"
70CPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLOC_SIZE)"
71
72compress-$(CONFIG_KERNEL_GZIP) = gzip
73compress-$(CONFIG_KERNEL_LZO)  = lzo_with_size
74compress-$(CONFIG_KERNEL_LZMA) = lzma_with_size
75compress-$(CONFIG_KERNEL_XZ)   = xzkern_with_size
76compress-$(CONFIG_KERNEL_LZ4)  = lz4_with_size
77
78libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
79
80ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
81CFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN}
82CFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280
83OBJS	+= $(libfdt_objs) atags_to_fdt.o
84endif
85ifeq ($(CONFIG_USE_OF),y)
86OBJS	+= $(libfdt_objs) fdt_check_mem_start.o
87endif
88
89OBJS	+= lib1funcs.o ashldi3.o bswapsdi2.o
90
91targets       := vmlinux vmlinux.lds piggy_data piggy.o \
92		 head.o $(OBJS)
93
94KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
95
96ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \
97	     -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
98	     -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN)
99ccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg
100asflags-y := -DZIMAGE
101
102# Supply kernel BSS size to the decompressor via a linker symbol.
103KBSS_SZ = $(shell echo $$(($$($(NM) vmlinux | \
104		sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \
105		       -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) )
106LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
107# Supply ZRELADDR to the decompressor via a linker symbol.
108ifneq ($(CONFIG_AUTO_ZRELADDR),y)
109LDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
110endif
111ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
112LDFLAGS_vmlinux += --be8
113endif
114# Report unresolved symbol references
115LDFLAGS_vmlinux += --no-undefined
116# Delete all temporary local symbols
117LDFLAGS_vmlinux += -X
118# Report orphan sections
119ifdef CONFIG_LD_ORPHAN_WARN
120LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
121endif
122# Next argument is a linker script
123LDFLAGS_vmlinux += -T
124
125# We need to prevent any GOTOFF relocs being used with references
126# to symbols in the .bss section since we cannot relocate them
127# independently from the rest at run time.  This can be achieved by
128# ensuring that no private .bss symbols exist, as global symbols
129# always have a GOT entry which is what we need.
130# The .data section is already discarded by the linker script so no need
131# to bother about it here.
132check_for_bad_syms = \
133bad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
134[ -z "$$bad_syms" ] || \
135  ( echo "following symbols must have non local/private scope:" >&2; \
136    echo "$$bad_syms" >&2; false )
137
138check_for_multiple_zreladdr = \
139if [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \
140	echo 'multiple zreladdrs: $(ZRELADDR)'; \
141	echo 'This needs CONFIG_AUTO_ZRELADDR to be set'; \
142	false; \
143fi
144
145efi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a
146
147$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
148		$(addprefix $(obj)/, $(OBJS)) \
149		$(efi-obj-y) FORCE
150	@$(check_for_multiple_zreladdr)
151	$(call if_changed,ld)
152	@$(check_for_bad_syms)
153
154$(obj)/piggy_data: $(obj)/../Image FORCE
155	$(call if_changed,$(compress-y))
156
157$(obj)/piggy.o: $(obj)/piggy_data
158
159CFLAGS_font.o := -Dstatic=
160