Please provide various methods to generate a trace of executed instructions for C code using the Spike simulator.
I have created a simple "Hello World" C file and generated hello.elf and then tried running this command:
/home/vindhya/riscv-vector/riscv-isa-sim/build/spike -l /home/latitude-7390/rvv64/bin/riscv64-unknown-elf/bin/pk hello.elf
The output obtained after running the "Hello World" C program on a RISC-V architecture seems unusual. Instead of the expected simple output, the program execution shows a repetitive sequence of RISC-V instructions involving memory loading and branching.
where could have gone wrong and how to fix the error?
It really depends on how you implemented the print of "Hello World" and how the program was compiled. Judging from the use of proxy kernel (
pk), it's very likely that you have statically linked your program against a standard C library (e.g.newlib). And the initialization of a C library does involve non-trivial sequence of instructions. You can verify this byobjdump -dyour ELF program, and check the assembly.