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 ([email protected]) 10# 11# Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University 12# Author: Wu Zhangjin <[email protected]> 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 25KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \ 26 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" 27 28KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ 29 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ 30 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) 31 32# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 33KCOV_INSTRUMENT := n 34 35# decompressor objects (linked with vmlinuz) 36vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o 37 38ifdef CONFIG_DEBUG_ZBOOT 39vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o 40vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o 41vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o 42vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o 43vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o 44endif 45 46extra-y += uart-ath79.c 47$(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c 48 $(call cmd,shipped) 49 50vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o 51 52extra-y += ashldi3.c 53$(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE 54 $(call if_changed,shipped) 55 56extra-y += bswapsi.c 57$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE 58 $(call if_changed,shipped) 59 60targets := $(notdir $(vmlinuzobjs-y)) 61 62targets += vmlinux.bin 63OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S 64$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE 65 $(call if_changed,objcopy) 66 67tool_$(CONFIG_KERNEL_GZIP) = gzip 68tool_$(CONFIG_KERNEL_BZIP2) = bzip2 69tool_$(CONFIG_KERNEL_LZ4) = lz4 70tool_$(CONFIG_KERNEL_LZMA) = lzma 71tool_$(CONFIG_KERNEL_LZO) = lzo 72tool_$(CONFIG_KERNEL_XZ) = xzkern 73tool_$(CONFIG_KERNEL_ZSTD) = zstd22 74 75targets += vmlinux.bin.z 76$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE 77 $(call if_changed,$(tool_y)) 78 79targets += piggy.o dummy.o 80OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ 81 --set-section-flags=.image=contents,alloc,load,readonly,data 82$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE 83 $(call if_changed,objcopy) 84 85HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE) 86 87# Calculate the load address of the compressed kernel image 88hostprogs := calc_vmlinuz_load_addr 89 90ifneq ($(zload-y),) 91VMLINUZ_LOAD_ADDRESS := $(zload-y) 92else 93VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ 94 $(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS)) 95endif 96UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS) 97 98vmlinuzobjs-y += $(obj)/piggy.o 99 100quiet_cmd_zld = LD $@ 101 cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ 102quiet_cmd_strip = STRIP $@ 103 cmd_strip = $(STRIP) -s $@ 104vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr 105 $(call cmd,zld) 106 $(call cmd,strip) 107 108# 109# Some DECstations need all possible sections of an ECOFF executable 110# 111ifdef CONFIG_MACH_DECSTATION 112 e2eflag := -a 113endif 114 115# elf2ecoff can only handle 32bit image 116hostprogs += ../elf2ecoff 117 118ifdef CONFIG_32BIT 119 VMLINUZ = vmlinuz 120else 121 VMLINUZ = vmlinuz.32 122endif 123 124quiet_cmd_32 = OBJCOPY $@ 125 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ 126vmlinuz.32: vmlinuz 127 $(call cmd,32) 128 129quiet_cmd_ecoff = ECOFF $@ 130 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) 131vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) 132 $(call cmd,ecoff) 133 134OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary 135vmlinuz.bin: vmlinuz 136 $(call cmd,objcopy) 137 138OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec 139vmlinuz.srec: vmlinuz 140 $(call cmd,objcopy) 141 142uzImage.bin: vmlinuz.bin FORCE 143 $(call if_changed,uimage,none) 144 145clean-files += $(objtree)/vmlinuz 146clean-files += $(objtree)/vmlinuz.32 147clean-files += $(objtree)/vmlinuz.ecoff 148clean-files += $(objtree)/vmlinuz.bin 149clean-files += $(objtree)/vmlinuz.srec 150