Skip to content

Commit d352f28

Browse files
committed
Determine QEMU CPU dynamically from ELF files.
Remove hardcoded QEMU CPU selection logic and instead use "mcpu-to-cpu-opts" to dynamically determine the appropriate CPU and XLEN from the ELF file in simulator wrappers. Signed-off-by: Luis Silva <[email protected]>
1 parent faba84d commit d352f28

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

Makefile.in

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,6 @@ NEWLIB_CC_FOR_TARGET ?= $(NEWLIB_TUPLE)-gcc
118118
NEWLIB_CXX_FOR_TARGET ?= $(NEWLIB_TUPLE)-g++
119119
NEWLIB_TARGET_BOARDS ?= arc-sim
120120

121-
# QEMU sim setup for running the tests
122-
ifeq (@target_alias@,arc)
123-
QEMU_CPU = archs
124-
else
125-
ifeq (@target_alias@,arc32)
126-
QEMU_CPU = hs5x
127-
else
128-
QEMU_CPU = hs6x
129-
endif
130-
endif
131-
132121
ifeq (@default_target@,linux)
133122
TARGET_ALIAS = $(call make_tuple,linux-gnu)
134123
TARGET_TRIPLET = $(call make_tupple,unknown-linux-gnu)

scripts/wrapper/qemu/arc64-elf-run

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ do
1010
shift
1111
done
1212

13-
xlen="$(readelf -h $1 | grep 'Class' | cut -d: -f 2 | xargs echo | sed 's/^ELF//')"
13+
cpu=$(mcpu-to-cpu-opts --elf-file-path $1 --print-cpu)
14+
xlen=$(mcpu-to-cpu-opts --elf-file-path $1 --print-xlen)
1415

1516
case "$xlen" in
1617
64) qemu="64"
@@ -19,5 +20,5 @@ case "$xlen" in
1920
mem="2G";;
2021
esac
2122

22-
qemu-system-arc$qemu -cpu ${QEMU_CPU} -M arc-sim -m $mem "${qemu_args[@]}" -nographic \
23+
qemu-system-arc$qemu -cpu $cpu -M arc-sim -m $mem "${qemu_args[@]}" -nographic \
2324
-no-reboot -monitor none -kernel "$@"

scripts/wrapper/qemu/arc64-linux-gnu-run

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ do
1010
shift
1111
done
1212

13-
xlen="$(readelf -h $1 | grep 'Class' | cut -d: -f 2 | xargs echo | sed 's/^ELF//')"
13+
cpu=$(mcpu-to-cpu-opts --elf-file-path $1 --print-cpu)
14+
xlen=$(mcpu-to-cpu-opts --elf-file-path $1 --print-xlen)
1415

1516
case "$xlen" in
1617
64) qemu="64";;
1718
*) qemu="";;
1819
esac
1920

20-
qemu-arc$qemu -cpu ${QEMU_CPU} -R 3G "${qemu_args[@]}" -L ${ARC_SYSROOT} "$@"
21+
qemu-arc$qemu -cpu $cpu -R 3G "${qemu_args[@]}" -L ${ARC_SYSROOT} "$@"

0 commit comments

Comments
 (0)