2009-10-14 18:12:16 +08:00
|
|
|
#
|
|
|
|
# This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
# License.
|
|
|
|
#
|
|
|
|
# Adapted for MIPS Pete Popov, Dan Malek
|
|
|
|
#
|
|
|
|
# Copyright (C) 1994 by Linus Torvalds
|
|
|
|
# Adapted for PowerPC by Gary Thomas
|
|
|
|
# modified by Cort (cort@cs.nmt.edu)
|
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University
|
2010-01-04 17:16:51 +08:00
|
|
|
# Author: Wu Zhangjin <wuzhangjin@gmail.com>
|
2009-10-14 18:12:16 +08:00
|
|
|
#
|
|
|
|
|
2015-03-16 14:43:08 -07:00
|
|
|
include $(srctree)/arch/mips/Kbuild.platforms
|
|
|
|
|
2009-10-14 18:12:16 +08:00
|
|
|
# set the default size of the mallocing area for decompressing
|
|
|
|
BOOT_HEAP_SIZE := 0x400000
|
|
|
|
|
|
|
|
# Disable Function Tracer
|
2021-04-20 15:00:52 +08:00
|
|
|
KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE), $(KBUILD_CFLAGS))
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2013-07-01 09:38:30 +00:00
|
|
|
KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
|
|
|
|
|
2020-09-21 17:12:27 +08:00
|
|
|
# Disable lq/sq in zboot
|
|
|
|
ifdef CONFIG_CPU_LOONGSON64
|
|
|
|
KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2
|
|
|
|
endif
|
|
|
|
|
2020-09-01 16:26:51 +02:00
|
|
|
KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \
|
2010-01-26 17:04:02 +08:00
|
|
|
-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2016-11-25 13:36:18 +01:00
|
|
|
KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
|
2010-01-26 17:04:02 +08:00
|
|
|
-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
|
2013-08-30 16:42:41 +01:00
|
|
|
-DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2010-05-30 16:28:03 +02:00
|
|
|
# decompressor objects (linked with vmlinuz)
|
2021-07-02 16:28:37 +02:00
|
|
|
vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2010-01-31 20:39:40 +08:00
|
|
|
ifdef CONFIG_DEBUG_ZBOOT
|
2010-12-25 23:11:49 +08:00
|
|
|
vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o
|
2010-05-30 16:28:03 +02:00
|
|
|
vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
|
2015-12-10 10:57:21 +01:00
|
|
|
vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o
|
2010-07-15 21:45:04 +02:00
|
|
|
vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o
|
2016-01-26 09:38:29 +01:00
|
|
|
vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o
|
2010-01-31 20:39:40 +08:00
|
|
|
endif
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2021-07-02 16:28:37 +02:00
|
|
|
vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
|
2015-12-10 10:57:20 +01:00
|
|
|
|
2022-01-07 18:57:22 +00:00
|
|
|
vmlinuzobjs-$(CONFIG_KERNEL_ZSTD) += $(obj)/bswapdi.o $(obj)/ashldi3.o $(obj)/clz_ctz.o
|
2021-11-09 19:09:44 -08:00
|
|
|
|
2015-12-10 10:57:20 +01:00
|
|
|
targets := $(notdir $(vmlinuzobjs-y))
|
2013-09-11 11:51:41 +01:00
|
|
|
|
2010-05-30 16:28:03 +02:00
|
|
|
targets += vmlinux.bin
|
2020-11-01 15:12:52 +00:00
|
|
|
|
2009-10-14 18:12:16 +08:00
|
|
|
OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
|
2020-11-01 15:12:52 +00:00
|
|
|
|
2010-05-30 16:28:03 +02:00
|
|
|
$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
|
2009-10-14 18:12:16 +08:00
|
|
|
$(call if_changed,objcopy)
|
|
|
|
|
|
|
|
tool_$(CONFIG_KERNEL_GZIP) = gzip
|
kbuild: rename cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22}
GZIP-compressed files end with 4 byte data that represents the size
of the original input. The decompressors (the self-extracting kernel)
exploit it to know the vmlinux size beforehand. To mimic the GZIP's
trailer, Kbuild provides cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22}.
Unfortunately these macros are used everywhere despite the appended
size data is only useful for the decompressors.
There is no guarantee that such hand-crafted trailers are safely ignored.
In fact, the kernel refuses compressed initramdfs with the garbage data.
That is why usr/Makefile overrides size_append to make it no-op.
To limit the use of such broken compressed files, this commit renames
the existing macros as follows:
cmd_bzip2 --> cmd_bzip2_with_size
cmd_lzma --> cmd_lzma_with_size
cmd_lzo --> cmd_lzo_with_size
cmd_lz4 --> cmd_lz4_with_size
cmd_xzkern --> cmd_xzkern_with_size
cmd_zstd22 --> cmd_zstd22_with_size
To keep the decompressors working, I updated the following Makefiles
accordingly:
arch/arm/boot/compressed/Makefile
arch/h8300/boot/compressed/Makefile
arch/mips/boot/compressed/Makefile
arch/parisc/boot/compressed/Makefile
arch/s390/boot/compressed/Makefile
arch/sh/boot/compressed/Makefile
arch/x86/boot/compressed/Makefile
I reused the current macro names for the normal usecases; they produce
the compressed data in the proper format.
I did not touch the following:
arch/arc/boot/Makefile
arch/arm64/boot/Makefile
arch/csky/boot/Makefile
arch/mips/boot/Makefile
arch/riscv/boot/Makefile
arch/sh/boot/Makefile
kernel/Makefile
This means those Makefiles will stop appending the size data.
I dropped the 'override size_append' hack from usr/Makefile.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
2022-01-10 03:15:27 +09:00
|
|
|
tool_$(CONFIG_KERNEL_BZIP2) = bzip2_with_size
|
|
|
|
tool_$(CONFIG_KERNEL_LZ4) = lz4_with_size
|
|
|
|
tool_$(CONFIG_KERNEL_LZMA) = lzma_with_size
|
|
|
|
tool_$(CONFIG_KERNEL_LZO) = lzo_with_size
|
|
|
|
tool_$(CONFIG_KERNEL_XZ) = xzkern_with_size
|
|
|
|
tool_$(CONFIG_KERNEL_ZSTD) = zstd22_with_size
|
2010-05-30 16:28:03 +02:00
|
|
|
|
2010-06-02 16:35:24 +08:00
|
|
|
targets += vmlinux.bin.z
|
2020-11-01 15:12:52 +00:00
|
|
|
|
2010-06-02 16:35:24 +08:00
|
|
|
$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
|
2009-10-14 18:12:16 +08:00
|
|
|
$(call if_changed,$(tool_y))
|
|
|
|
|
2015-12-10 10:57:20 +01:00
|
|
|
targets += piggy.o dummy.o
|
2020-11-01 15:12:52 +00:00
|
|
|
|
2010-06-02 16:35:24 +08:00
|
|
|
OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
|
2013-01-22 12:59:30 +01:00
|
|
|
--set-section-flags=.image=contents,alloc,load,readonly,data
|
2020-11-01 15:12:52 +00:00
|
|
|
|
2010-06-02 16:35:24 +08:00
|
|
|
$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
|
2010-05-30 16:28:03 +02:00
|
|
|
$(call if_changed,objcopy)
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2019-06-19 15:08:18 +01:00
|
|
|
HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE)
|
|
|
|
|
2010-06-02 16:35:25 +08:00
|
|
|
# Calculate the load address of the compressed kernel image
|
2020-02-02 01:49:24 +09:00
|
|
|
hostprogs := calc_vmlinuz_load_addr
|
2010-06-02 16:35:25 +08:00
|
|
|
|
2021-12-22 13:43:46 +00:00
|
|
|
ifneq (0x0,$(CONFIG_ZBOOT_LOAD_ADDRESS))
|
|
|
|
zload-y = $(CONFIG_ZBOOT_LOAD_ADDRESS)
|
|
|
|
endif
|
|
|
|
|
2015-03-16 14:43:08 -07:00
|
|
|
ifneq ($(zload-y),)
|
|
|
|
VMLINUZ_LOAD_ADDRESS := $(zload-y)
|
2012-03-30 16:48:05 +02:00
|
|
|
else
|
2010-06-02 16:35:25 +08:00
|
|
|
VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
|
2020-05-06 13:52:45 +08:00
|
|
|
$(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS))
|
2012-03-30 16:48:05 +02:00
|
|
|
endif
|
2016-10-31 15:19:55 +01:00
|
|
|
UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS)
|
2010-06-02 16:35:25 +08:00
|
|
|
|
|
|
|
vmlinuzobjs-y += $(obj)/piggy.o
|
|
|
|
|
2020-11-01 15:12:52 +00:00
|
|
|
targets += ../../../../vmlinuz
|
|
|
|
|
2015-08-18 15:03:10 +01:00
|
|
|
quiet_cmd_zld = LD $@
|
2018-08-24 08:20:39 +09:00
|
|
|
cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
|
2020-11-01 15:12:52 +00:00
|
|
|
quiet_cmd_strip = STRIP $@
|
2010-06-16 15:52:21 +08:00
|
|
|
cmd_strip = $(STRIP) -s $@
|
2020-11-01 15:12:52 +00:00
|
|
|
|
|
|
|
$(objtree)/vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
|
2010-06-02 16:35:25 +08:00
|
|
|
$(call cmd,zld)
|
2010-06-16 15:52:21 +08:00
|
|
|
$(call cmd,strip)
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2020-11-01 15:12:52 +00:00
|
|
|
objboot := $(objtree)/arch/mips/boot
|
|
|
|
|
|
|
|
$(objboot)/vmlinuz: $(objtree)/vmlinuz FORCE
|
|
|
|
|
2009-10-14 18:12:16 +08:00
|
|
|
#
|
|
|
|
# Some DECstations need all possible sections of an ECOFF executable
|
|
|
|
#
|
|
|
|
ifdef CONFIG_MACH_DECSTATION
|
2010-05-30 16:28:03 +02:00
|
|
|
e2eflag := -a
|
2009-10-14 18:12:16 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# elf2ecoff can only handle 32bit image
|
2020-02-02 01:49:24 +09:00
|
|
|
hostprogs += ../elf2ecoff
|
2009-10-14 18:12:16 +08:00
|
|
|
|
|
|
|
ifdef CONFIG_32BIT
|
2020-11-01 15:12:52 +00:00
|
|
|
VMLINUZ = $(objtree)/vmlinuz
|
2009-10-14 18:12:16 +08:00
|
|
|
else
|
2020-11-01 15:12:52 +00:00
|
|
|
VMLINUZ = $(objboot)/vmlinuz.32
|
2009-10-14 18:12:16 +08:00
|
|
|
endif
|
|
|
|
|
2020-11-01 15:12:52 +00:00
|
|
|
targets += ../vmlinuz.32
|
|
|
|
|
2010-05-30 16:28:03 +02:00
|
|
|
quiet_cmd_32 = OBJCOPY $@
|
|
|
|
cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
|
2020-11-01 15:12:52 +00:00
|
|
|
|
|
|
|
$(objboot)/vmlinuz.32: $(objtree)/vmlinuz
|
2010-05-30 16:28:03 +02:00
|
|
|
$(call cmd,32)
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2020-11-01 15:12:52 +00:00
|
|
|
targets += ../vmlinuz.ecoff
|
|
|
|
|
2013-01-22 12:59:30 +01:00
|
|
|
quiet_cmd_ecoff = ECOFF $@
|
2010-05-30 16:28:03 +02:00
|
|
|
cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
|
2020-11-01 15:12:52 +00:00
|
|
|
|
|
|
|
$(objboot)/vmlinuz.ecoff: $(objboot)/elf2ecoff $(VMLINUZ)
|
2010-05-30 16:28:03 +02:00
|
|
|
$(call cmd,ecoff)
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2020-11-01 15:12:52 +00:00
|
|
|
targets += ../vmlinuz.bin
|
|
|
|
|
2009-12-10 22:55:13 +08:00
|
|
|
OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
|
2020-11-01 15:12:52 +00:00
|
|
|
|
|
|
|
$(objboot)/vmlinuz.bin: $(objtree)/vmlinuz
|
2010-05-30 16:28:03 +02:00
|
|
|
$(call cmd,objcopy)
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2020-11-01 15:12:52 +00:00
|
|
|
targets += ../vmlinuz.srec
|
|
|
|
|
2009-12-10 22:55:13 +08:00
|
|
|
OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
|
2020-11-01 15:12:52 +00:00
|
|
|
|
|
|
|
$(objboot)/vmlinuz.srec: $(objtree)/vmlinuz
|
2010-05-30 16:28:03 +02:00
|
|
|
$(call cmd,objcopy)
|
2009-10-14 18:12:16 +08:00
|
|
|
|
2020-11-01 15:12:52 +00:00
|
|
|
targets += ../uzImage.bin
|
2016-10-31 15:19:55 +01:00
|
|
|
|
2020-11-01 15:12:52 +00:00
|
|
|
$(objboot)/uzImage.bin: $(objboot)/vmlinuz.bin FORCE
|
|
|
|
$(call if_changed,uimage,none)
|
2020-11-01 15:13:01 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Flattened Image Tree (.itb) image
|
|
|
|
#
|
|
|
|
|
|
|
|
ifeq ($(ADDR_BITS),32)
|
|
|
|
itb_addr_cells = 1
|
|
|
|
endif
|
|
|
|
ifeq ($(ADDR_BITS),64)
|
|
|
|
itb_addr_cells = 2
|
|
|
|
endif
|
|
|
|
|
|
|
|
targets += ../vmlinuz.its.S
|
|
|
|
|
|
|
|
quiet_cmd_its_cat = CAT $@
|
|
|
|
cmd_its_cat = cat $(real-prereqs) >$@
|
|
|
|
|
|
|
|
$(objboot)/vmlinuz.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
|
|
|
|
$(call if_changed,its_cat)
|
|
|
|
|
|
|
|
targets += ../vmlinuz.its
|
|
|
|
|
|
|
|
quiet_cmd_cpp_its_S = ITS $@
|
|
|
|
cmd_cpp_its_S = $(CPP) -P -C -o $@ $< \
|
|
|
|
-DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
|
|
|
|
-DVMLINUX_BINARY="\"$(2)\"" \
|
|
|
|
-DVMLINUX_COMPRESSION="\"none\"" \
|
|
|
|
-DVMLINUX_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
|
|
|
|
-DVMLINUX_ENTRY_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
|
|
|
|
-DADDR_BITS=$(ADDR_BITS) \
|
|
|
|
-DADDR_CELLS=$(itb_addr_cells)
|
|
|
|
|
|
|
|
$(objboot)/vmlinuz.its: $(objboot)/vmlinuz.its.S FORCE
|
|
|
|
$(call if_changed,cpp_its_S,vmlinuz.bin)
|
|
|
|
|
|
|
|
targets += ../vmlinuz.itb
|
|
|
|
|
|
|
|
quiet_cmd_itb-image = ITB $@
|
|
|
|
cmd_itb-image = \
|
|
|
|
env PATH="$(objtree)/scripts/dtc:$(PATH)" \
|
|
|
|
$(BASH) $(MKIMAGE) \
|
|
|
|
-D "-I dts -O dtb -p 500 \
|
|
|
|
--include $(objtree)/arch/mips \
|
|
|
|
--warning no-unit_address_vs_reg" \
|
|
|
|
-f $(2) $@
|
|
|
|
|
|
|
|
$(objboot)/vmlinuz.itb: $(objboot)/vmlinuz.its $(objboot)/vmlinuz.bin FORCE
|
|
|
|
$(call if_changed,itb-image,$<)
|