mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
UPSTREAM: util/riscvtools: Add script that turns coreboot.rom into an ELF
This is required because SPIKE doesn't support loading flat files yet. Change-Id: If745d78712ca8108b5dcc21591201bc2d3f70b86 Signed-off-by: Jonathan Neuschfer <j.neuschaefer@gmx.net> Reviewed-on: https://review.coreboot.org/14964 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/354696 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
parent
670f907f56
commit
556317cca0
2 changed files with 38 additions and 0 deletions
27
util/riscvtools/make-spike-elf.sh
Executable file
27
util/riscvtools/make-spike-elf.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/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")"
|
||||
|
||||
objcopy -I binary -O elf32-i386 --binary-architecture i386 "$FLAT_FILE" "$OBJECT_FILE"
|
||||
ld -m elf_i386 "$OBJECT_FILE" -T "$TOOL_PATH/spike-elf.ld" -o "$ELF_FILE"
|
||||
rm "$OBJECT_FILE"
|
11
util/riscvtools/spike-elf.ld
Normal file
11
util/riscvtools/spike-elf.ld
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* See make-spike-elf.sh */
|
||||
|
||||
ENTRY(_start);
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x80000000;
|
||||
_start = .;
|
||||
.data : {
|
||||
*(.data)
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue