1# 2# This file is subject to the terms and conditions of the GNU General Public 3# License. 4# 5# Adapted for MIPS Pete Popov, Dan Malek 6# 7# Copyright (C) 1994 by Linus Torvalds 8# Adapted for PowerPC by Gary Thomas 9# modified by Cort (cort@cs.nmt.edu) 10# 11# Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University 12# Author: Wu Zhangjin <wuzhangjin@gmail.com> 13# 14 15include $(srctree)/arch/mips/Kbuild.platforms 16 17# set the default size of the mallocing area for decompressing 18BOOT_HEAP_SIZE := 0x400000 19 20# Disable Function Tracer 21KBUILD_CFLAGS := $(filter-out -pg, $(KBUILD_CFLAGS)) 22 23KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS)) 24 25# Disable lq/sq in zboot 26ifdef CONFIG_CPU_LOONGSON64 27KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2 28endif 29 30KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \ 31 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" 32 33KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ 34 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ 35 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) 36 37# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 38KCOV_INSTRUMENT := n 39 40# decompressor objects (linked with vmlinuz) 41vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o 42 43ifdef CONFIG_DEBUG_ZBOOT 44vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o 45vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o 46vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o 47vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o 48vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o 49endif 50 51extra-y += uart-ath79.c 52$(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c 53 $(call cmd,shipped) 54 55vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o 56 57extra-y += ashldi3.c 58$(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE 59 $(call if_changed,shipped) 60 61extra-y += bswapsi.c 62$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE 63 $(call if_changed,shipped) 64 65targets := $(notdir $(vmlinuzobjs-y)) 66 67targets += vmlinux.bin 68OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S 69$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE 70 $(call if_changed,objcopy) 71 72tool_$(CONFIG_KERNEL_GZIP) = gzip 73tool_$(CONFIG_KERNEL_BZIP2) = bzip2 74tool_$(CONFIG_KERNEL_LZ4) = lz4 75tool_$(CONFIG_KERNEL_LZMA) = lzma 76tool_$(CONFIG_KERNEL_LZO) = lzo 77tool_$(CONFIG_KERNEL_XZ) = xzkern 78tool_$(CONFIG_KERNEL_ZSTD) = zstd22 79 80targets += vmlinux.bin.z 81$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE 82 $(call if_changed,$(tool_y)) 83 84targets += piggy.o dummy.o 85OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ 86 --set-section-flags=.image=contents,alloc,load,readonly,data 87$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE 88 $(call if_changed,objcopy) 89 90HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE) 91 92# Calculate the load address of the compressed kernel image 93hostprogs := calc_vmlinuz_load_addr 94 95ifneq ($(zload-y),) 96VMLINUZ_LOAD_ADDRESS := $(zload-y) 97else 98VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ 99 $(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS)) 100endif 101UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS) 102 103vmlinuzobjs-y += $(obj)/piggy.o 104 105quiet_cmd_zld = LD $@ 106 cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ 107quiet_cmd_strip = STRIP $@ 108 cmd_strip = $(STRIP) -s $@ 109vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr 110 $(call cmd,zld) 111 $(call cmd,strip) 112 113# 114# Some DECstations need all possible sections of an ECOFF executable 115# 116ifdef CONFIG_MACH_DECSTATION 117 e2eflag := -a 118endif 119 120# elf2ecoff can only handle 32bit image 121hostprogs += ../elf2ecoff 122 123ifdef CONFIG_32BIT 124 VMLINUZ = vmlinuz 125else 126 VMLINUZ = vmlinuz.32 127endif 128 129quiet_cmd_32 = OBJCOPY $@ 130 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ 131vmlinuz.32: vmlinuz 132 $(call cmd,32) 133 134quiet_cmd_ecoff = ECOFF $@ 135 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) 136vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) 137 $(call cmd,ecoff) 138 139OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary 140vmlinuz.bin: vmlinuz 141 $(call cmd,objcopy) 142 143OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec 144vmlinuz.srec: vmlinuz 145 $(call cmd,objcopy) 146 147uzImage.bin: vmlinuz.bin FORCE 148 $(call if_changed,uimage,none) 149 150clean-files += $(objtree)/vmlinuz 151clean-files += $(objtree)/vmlinuz.32 152clean-files += $(objtree)/vmlinuz.ecoff 153clean-files += $(objtree)/vmlinuz.bin 154clean-files += $(objtree)/vmlinuz.srec 155