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 15# set the default size of the mallocing area for decompressing 16BOOT_HEAP_SIZE := 0x400000 17 18# Disable Function Tracer 19KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//") 20 21KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS)) 22 23KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \ 24 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" 25 26KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ 27 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ 28 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) 29 30targets := head.o decompress.o string.o dbg.o uart-16550.o uart-alchemy.o 31 32# decompressor objects (linked with vmlinuz) 33vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/dbg.o 34 35ifdef CONFIG_DEBUG_ZBOOT 36vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o 37vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o 38endif 39 40ifdef CONFIG_KERNEL_XZ 41vmlinuzobjs-y += $(obj)/../../lib/ashldi3.o 42endif 43 44targets += vmlinux.bin 45OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S 46$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE 47 $(call if_changed,objcopy) 48 49tool_$(CONFIG_KERNEL_GZIP) = gzip 50tool_$(CONFIG_KERNEL_BZIP2) = bzip2 51tool_$(CONFIG_KERNEL_LZ4) = lz4 52tool_$(CONFIG_KERNEL_LZMA) = lzma 53tool_$(CONFIG_KERNEL_LZO) = lzo 54tool_$(CONFIG_KERNEL_XZ) = xzkern 55 56targets += vmlinux.bin.z 57$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE 58 $(call if_changed,$(tool_y)) 59 60targets += piggy.o 61OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ 62 --set-section-flags=.image=contents,alloc,load,readonly,data 63$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE 64 $(call if_changed,objcopy) 65 66# Calculate the load address of the compressed kernel image 67hostprogs-y := calc_vmlinuz_load_addr 68 69ifeq ($(CONFIG_MACH_JZ4740),y) 70VMLINUZ_LOAD_ADDRESS := 0x80600000 71else 72VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ 73 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS)) 74endif 75 76vmlinuzobjs-y += $(obj)/piggy.o 77 78quiet_cmd_zld = LD $@ 79 cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ 80quiet_cmd_strip = STRIP $@ 81 cmd_strip = $(STRIP) -s $@ 82vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr 83 $(call cmd,zld) 84 $(call cmd,strip) 85 86# 87# Some DECstations need all possible sections of an ECOFF executable 88# 89ifdef CONFIG_MACH_DECSTATION 90 e2eflag := -a 91endif 92 93# elf2ecoff can only handle 32bit image 94hostprogs-y += ../elf2ecoff 95 96ifdef CONFIG_32BIT 97 VMLINUZ = vmlinuz 98else 99 VMLINUZ = vmlinuz.32 100endif 101 102quiet_cmd_32 = OBJCOPY $@ 103 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ 104vmlinuz.32: vmlinuz 105 $(call cmd,32) 106 107quiet_cmd_ecoff = ECOFF $@ 108 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) 109vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) 110 $(call cmd,ecoff) 111 112OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary 113vmlinuz.bin: vmlinuz 114 $(call cmd,objcopy) 115 116OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec 117vmlinuz.srec: vmlinuz 118 $(call cmd,objcopy) 119 120clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec} 121