coreboot-kgpe-d16/util/riscv/make-spike-elf.sh
Martin Roth 0ad5fbd48d util: Update all shebangs to use /usr/bin/env
Instead of hardcoding paths to the executables, use the version in the
path.  This allows the scripts to work on more systems, and allows the
binary version to be changed more easily if needed.

Signed-off-by: Martin Roth <martin@coreboot.org>
Change-Id: Ifcc56aa21092cd3866eacb6a02d198110ec6051d
Reviewed-on: https://review.coreboot.org/c/coreboot/+/48904
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-01-25 08:57:40 +00:00

30 lines
728 B
Bash
Executable file

#!/usr/bin/env 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)
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"