diff options
Diffstat (limited to 'util/riscv')
-rwxr-xr-x | util/riscv/make-spike-elf.sh | 30 | ||||
-rw-r--r-- | util/riscv/spike-elf.ld | 15 |
2 files changed, 45 insertions, 0 deletions
diff --git a/util/riscv/make-spike-elf.sh b/util/riscv/make-spike-elf.sh new file mode 100755 index 0000000000..834e8d2cb6 --- /dev/null +++ b/util/riscv/make-spike-elf.sh @@ -0,0 +1,30 @@ +#!/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" diff --git a/util/riscv/spike-elf.ld b/util/riscv/spike-elf.ld new file mode 100644 index 0000000000..44114f7cad --- /dev/null +++ b/util/riscv/spike-elf.ld @@ -0,0 +1,15 @@ +/* See make-spike-elf.sh */ + +ENTRY(_start); +SECTIONS +{ + . = 0x80000000; + _start = .; + .data : { + *(.data) + } + + tohost = .; + . = . + 8; + fromhost = .; +} |