When building with -fstack-protector, gcc emits the __stack_chk_guard and __stack_chk_fail symbols to check for stack stability. These symbols are defined in vmlinux but the generated vmlinux.bin that is used to create the compressed vmlinuz image has no symbol table so the linker can't find these symbols during the final linking phase. As a result of which, we need either to redefine these symbols just for the compressed image or drop the -fstack-protector option when building the compressed image. This patch implements the latter of two options. Fixes the following linking problem: dbg.c:(.text+0x7c): undefined reference to `__stack_chk_guard' dbg.c:(.text+0x80): undefined reference to `__stack_chk_guard' dbg.c:(.text+0xd4): undefined reference to `__stack_chk_guard' dbg.c:(.text+0xec): undefined reference to `__stack_chk_fail' [ralf@linux-mips.org: I'm applying this before the patch that actually adds stack protector support for MIPS. This means, it will not be possible to trigger above error message with any commit from the tree but rather they are what one would hit without this commit.] Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Cc: linux-mips@linux-mips.org Cc: Markos Chandras <markos.chandras@imgtec.com> Patchwork: https://patchwork.linux-mips.org/patch/5575/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
115 lines
3.3 KiB
Makefile
115 lines
3.3 KiB
Makefile
#
|
|
# 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
|
|
# Author: Wu Zhangjin <wuzhangjin@gmail.com>
|
|
#
|
|
|
|
# set the default size of the mallocing area for decompressing
|
|
BOOT_HEAP_SIZE := 0x400000
|
|
|
|
# Disable Function Tracer
|
|
KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
|
|
|
|
KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
|
|
|
|
KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
|
|
-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
|
|
|
|
KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
|
|
-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
|
|
-DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ )
|
|
|
|
targets := head.o decompress.o dbg.o uart-16550.o uart-alchemy.o
|
|
|
|
# decompressor objects (linked with vmlinuz)
|
|
vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
|
|
|
|
ifdef CONFIG_DEBUG_ZBOOT
|
|
vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
|
|
vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o
|
|
endif
|
|
|
|
targets += vmlinux.bin
|
|
OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
|
|
$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
|
|
$(call if_changed,objcopy)
|
|
|
|
tool_$(CONFIG_KERNEL_GZIP) = gzip
|
|
tool_$(CONFIG_KERNEL_BZIP2) = bzip2
|
|
tool_$(CONFIG_KERNEL_LZMA) = lzma
|
|
tool_$(CONFIG_KERNEL_LZO) = lzo
|
|
|
|
targets += vmlinux.bin.z
|
|
$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
|
|
$(call if_changed,$(tool_y))
|
|
|
|
targets += piggy.o
|
|
OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
|
|
--set-section-flags=.image=contents,alloc,load,readonly,data
|
|
$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
|
|
$(call if_changed,objcopy)
|
|
|
|
# Calculate the load address of the compressed kernel image
|
|
hostprogs-y := calc_vmlinuz_load_addr
|
|
|
|
ifeq ($(CONFIG_MACH_JZ4740),y)
|
|
VMLINUZ_LOAD_ADDRESS := 0x80600000
|
|
else
|
|
VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
|
|
$(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
|
|
endif
|
|
|
|
vmlinuzobjs-y += $(obj)/piggy.o
|
|
|
|
quiet_cmd_zld = LD $@
|
|
cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
|
|
quiet_cmd_strip = STRIP $@
|
|
cmd_strip = $(STRIP) -s $@
|
|
vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
|
|
$(call cmd,zld)
|
|
$(call cmd,strip)
|
|
|
|
#
|
|
# Some DECstations need all possible sections of an ECOFF executable
|
|
#
|
|
ifdef CONFIG_MACH_DECSTATION
|
|
e2eflag := -a
|
|
endif
|
|
|
|
# elf2ecoff can only handle 32bit image
|
|
hostprogs-y += ../elf2ecoff
|
|
|
|
ifdef CONFIG_32BIT
|
|
VMLINUZ = vmlinuz
|
|
else
|
|
VMLINUZ = vmlinuz.32
|
|
endif
|
|
|
|
quiet_cmd_32 = OBJCOPY $@
|
|
cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
|
|
vmlinuz.32: vmlinuz
|
|
$(call cmd,32)
|
|
|
|
quiet_cmd_ecoff = ECOFF $@
|
|
cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
|
|
vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
|
|
$(call cmd,ecoff)
|
|
|
|
OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
|
|
vmlinuz.bin: vmlinuz
|
|
$(call cmd,objcopy)
|
|
|
|
OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
|
|
vmlinuz.srec: vmlinuz
|
|
$(call cmd,objcopy)
|
|
|
|
clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}
|