switch-coreboot/util/riscvtools/make-spike-elf.sh
Ronald G. Minnich 7df5dbc624 UPSTREAM: RISCV: change make-spike-elf to use the coreboot toolchain.
BUG=None
BRANCH=None
TEST=None

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
[jn: Added XGCC_BIN variable to avoid requiring the tools in $PATH]
Signed-off-by: Jonathan Neuschfer <j.neuschaefer@gmx.net>
Reviewed-on: https://review.coreboot.org/16955
Tested-by: build bot (Jenkins)

Change-Id: I81ced8c6e02b00a3835e3b42c9cf2669b1b2bd3e
Reviewed-on: https://chromium-review.googlesource.com/400107
Commit-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-10-18 22:14:47 -07:00

30 lines
722 B
Bash
Executable file

#!/bin/sh
#
# This script is based on:
# https://docs.google.com/document/d/1Pvf9Yxorcd3sbgs8WcomcTl3J4bmX6e1UE0ROCefR88
set -e
usage() {
echo "This script converts a flat file into an ELF, that can be passed"
echo "to SPIKE, the RISC-V reference emulator."
echo ""
echo "Usage: $0 coreboot.rom coreboot.elf"
}
if [ $# -ne 2 ]; then
usage
exit 1
fi
FLAT_FILE="$1"
OBJECT_FILE=$(mktemp /tmp/coreboot-spike.XXXXXX.o)
ELF_FILE="$2"
TOOL_PATH="$(dirname "$0")"
XGCC_BIN="$TOOL_PATH/../crossgcc/xgcc/bin"
"$XGCC_BIN/riscv64-elf-objcopy" -I binary -O elf64-littleriscv \
-B riscv "$FLAT_FILE" "$OBJECT_FILE"
"$XGCC_BIN/riscv64-elf-ld" "$OBJECT_FILE" -T "$TOOL_PATH/spike-elf.ld" \
-o "$ELF_FILE"
rm "$OBJECT_FILE"