From f20a27e3277c608f1bfb81a793aa33a58c614f7f Mon Sep 17 00:00:00 2001 From: Alexander Kabaev Date: Thu, 5 Jan 2017 19:17:14 +0000 Subject: [PATCH] Use compiler driver to link BERI boot loaders Do not hardcode elf64-tradbigmips as output format in BERI linker scrips. Unfortunately, in-tree toolchain and external newer versions of binutils mean two different things under that. When creating elf binaries using external toolchain, gcc uses elf64-tradbigmips-freebsd and so linker script file has to match in order for ld to be able to create the final loader binary. Rather than trying to guess, remove hardcoded output format directive from the linker directive files and use CC to invoke the linker instead. Reviewed by: brooks Differential Revision: https://reviews.freebsd.org/D9050 --- sys/boot/mips/beri/boot2/Makefile | 4 ++-- sys/boot/mips/beri/common/common.ldscript | 1 - sys/boot/mips/beri/loader/loader.ldscript | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/boot/mips/beri/boot2/Makefile b/sys/boot/mips/beri/boot2/Makefile index f9950a96b875..46af76298e96 100644 --- a/sys/boot/mips/beri/boot2/Makefile +++ b/sys/boot/mips/beri/boot2/Makefile @@ -71,7 +71,7 @@ LDFLAGS= -nostdlib \ CFLAGS+= -I${.CURDIR}/../common flashboot.elf: relocate.o start.o boot2.o altera_jtag_uart.o cfi.o sdcard.o - ${LD} ${_LDFLAGS} -T ${.CURDIR}/flashboot.ldscript -o ${.TARGET} \ + ${CC} ${_LDFLAGS} -T ${.CURDIR}/flashboot.ldscript -o ${.TARGET} \ ${.ALLSRC} ${LIBSTAND} flashboot: flashboot.elf ${OBJCOPY} -S -O binary ${.TARGET}.elf ${.TARGET} @@ -79,7 +79,7 @@ flashboot.md5: flashboot md5 flashboot > flashboot.md5 jtagboot: start.o boot2.o altera_jtag_uart.o cfi.o sdcard.o - ${LD} ${_LDFLAGS} -T ${.CURDIR}/jtagboot.ldscript -o ${.TARGET} \ + ${CC} ${_LDFLAGS} -T ${.CURDIR}/jtagboot.ldscript -o ${.TARGET} \ ${.ALLSRC} ${LIBSTAND} jtagboot.md5: jtagboot md5 jtagboot > jtagboot.md5 diff --git a/sys/boot/mips/beri/common/common.ldscript b/sys/boot/mips/beri/common/common.ldscript index ac3b07601298..6266646cfc3c 100644 --- a/sys/boot/mips/beri/common/common.ldscript +++ b/sys/boot/mips/beri/common/common.ldscript @@ -73,5 +73,4 @@ __cheri_sdcard_vaddr__ = __mips64_xkphys_uncached__ + __cheri_sdcard_base__; __kernel_base__ = 0x100000; __kernel_vaddr__ = __mips64_xkphys_cached__ + __kernel_base__; -OUTPUT_FORMAT("elf64-tradbigmips"); OUTPUT_ARCH(mips) diff --git a/sys/boot/mips/beri/loader/loader.ldscript b/sys/boot/mips/beri/loader/loader.ldscript index f3d286ae61e4..deb4865c28ee 100644 --- a/sys/boot/mips/beri/loader/loader.ldscript +++ b/sys/boot/mips/beri/loader/loader.ldscript @@ -44,7 +44,6 @@ __loader_base_vaddr__ = __mips64_xkphys_cached__ + __loader_base__; __loader_end__ = 0x100000; __loader_end_vaddr__ = __mips64_xkphys_cached__ + __loader_end__; -OUTPUT_FORMAT("elf64-tradbigmips"); OUTPUT_ARCH(mips) ENTRY(start) SECTIONS