以下の内容はhttps://msyksphinz.hatenablog.com/entry/2025/04/26/040000より取得しました。


RISC-V 命令セットシミュレータ Whisperを試す (2. LLVMでビルドしたバイナリを試す)

LLVMでビルドしたバイナリをWhisperで流してみる。

#include <stdio.h>

int main(int argc, char **argv)
{
  printf("Hello World\n");
  if (argc > 1) {
    printf("%s\n", argv[1]);
  }
  return 0;
}
/home/msyksphinz/llvm/LLVM-20.1.2-Linux-X64/bin/clang --target=riscv64-unknown-linux-gnu -march=rv64gc --sysroot=/home/msyksphinz/riscv64-linux/sysroot --gcc-toolchain=/home/msyksphinz/riscv64-linux hello_world.c -o hello_world

Whisperで動かすと途中で止まってしまう:

/home/msyksphinz/work/riscv/whisper/build-Linux/whisper -t hello_world
Error: Failed stop: Hart 0: 16 consecutive illegal instructions
Executed 45 instructions and retired 0 instruction in 0.00s  428571 inst/s hart=0

GLOBAL_OFFSET_TABLEが定義されていないせいでこうなってしまっている?

#1 0  M 0000000000000580 02e000ef r 0000000000000001 0000000000000584 jal      x1, . + 0x2e
#2 0  M 00000000000005ae 00002197 r 0000000000000003 00000000000025ae auipc    x3, 0x2
#3 0  M 00000000000005b2 25218193 r 0000000000000003 0000000000002800 addi     x3, x3, 594
#4 0  M 00000000000005b6     8082 r 0000000000000000 0000000000000000 c.jr     x1
#5 0  M 0000000000000584     87aa r 000000000000000f 0000000000000000 c.mv     x15, x10
#6 0  M 0000000000000586 00002517 r 000000000000000a 0000000000002586 auipc    x10, 0x2
#7 0  M 000000000000058a ab253503 r 000000000000000a 0000000000000000 ld       x10, -0x54e(x10) [0x2038]
#8 0  M 000000000000058e     6582 r 000000000000000b 00010102464c457f c.ldsp   x11, 0x0 [0x0]
#9 0  M 0000000000000590     0030 r 000000000000000c 0000000000000008 c.addi4spn  x12, 0x2
#10 0  M 0000000000000592 ff017113 r 0000000000000002 0000000000000000 andi     x2, x2, -16
#11 0  M 0000000000000596 00000697 r 000000000000000d 0000000000000596 auipc    x13, 0x0
#12 0  M 000000000000059a 0fa68693 r 000000000000000d 0000000000000690 addi     x13, x13, 250
#13 0  M 000000000000059e 00000717 r 000000000000000e 000000000000059e auipc    x14, 0x0
#14 0  M 00000000000005a2 14a70713 r 000000000000000e 00000000000006e8 addi     x14, x14, 330
#15 0  M 00000000000005a6     880a r 0000000000000010 0000000000000000 c.mv     x16, x2
#16 0  M 00000000000005a8 fb9ff0ef r 0000000000000001 00000000000005ac jal      x1, . - 0x48
#17 0  M 0000000000000560 00002e17 r 000000000000001c 0000000000002560 auipc    x28, 0x2
#18 0  M 0000000000000564 ab8e3e03 r 000000000000001c 0000000000000540 ld       x28, -0x548(x28) [0x2018]
#19 0  M 0000000000000568 000e0367 r 0000000000000006 000000000000056c jalr     x6, 0x0(x28)
#20 0  M 0000000000000540 00002397 r 0000000000000007 0000000000002540 auipc    x7, 0x2                                                                                                                                                                                                                                                                                                   
#21 0  M 0000000000000544 41c30333 r 0000000000000006 000000000000002c sub      x6, x6, x28
#22 0  M 0000000000000548 ac83be03 r 000000000000001c ffffffffffffffff ld       x28, -0x538(x7) [0x2008]
#23 0  M 000000000000054c fd430313 r 0000000000000006 0000000000000000 addi     x6, x6, -44
#24 0  M 0000000000000550 ac838293 r 0000000000000005 0000000000002008 addi     x5, x7, -1336                                                                                                
#25 0  M 0000000000000554 00135313 r 0000000000000006 0000000000000000 srli     x6, x6, 1
#26 0  M 0000000000000558 0082b283 r 0000000000000005 0000000000000000 ld       x5, 0x8(x5) [0x2010]
#27 0  M 000000000000055c 000e0067 r 0000000000000000 0000000000000000 jalr     x0, 0x0(x28)
#28 0  M fffffffffffffffe     0000 c 0000000000000300 0000000a00001800 illegal  +                                                                                                            
#28 0  M fffffffffffffffe     0000 c 0000000000000341 fffffffffffffffe illegal  +         
#28 0  M fffffffffffffffe     0000 c 0000000000000342 0000000000000001 illegal  +
#28 0  M fffffffffffffffe     0000 c 0000000000000343 fffffffffffffffe illegal
#29 0  M 0000000000000000 464c457f c 0000000000000300 0000000a00001800 illegal  +
#29 0  M 0000000000000000 464c457f c 0000000000000341 0000000000000000 illegal  +                                                                                                            
#29 0  M 0000000000000000 464c457f c 0000000000000342 0000000000000002 illegal  +
#29 0  M 0000000000000000 464c457f c 0000000000000343 0000000000000000 illegal



以上の内容はhttps://msyksphinz.hatenablog.com/entry/2025/04/26/040000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14