coreboot-kgpe-d16/util/riscvtools/make-spike-elf.sh
Jonathan Neuschäfer 3af80a9377 util: make-spike-elf.sh: Fix busybox mktemp compatibility
Busybox mktemp does not support patterns with any characters after the XXXXXX
part. Drop the .o extension to make make-spike-elf.sh work on Alpine Linux.

Change-Id: I2e37ceef115c6d4d31eb617558481b2284dada83
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-on: https://review.coreboot.org/23174
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2018-02-20 23:14:06 +00:00

30 lines
720 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)
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"