hi
so I’ve been using milkv duo for a while. One of the reasons I actually went for this board was the fact that it was based on RISCV and as I’m trying to learn the instructions and datapath I was hoping if I could disassemble the compiled c code into riscv instructions. I searched a lot but I couldn’t find any syntax that actually works. Can u guys help me out?
1 Like
Have you tried something like the following ?
$ cat hello.c
#include <stdio.h>
int main(int argc, const char * argv[]) {
printf("Hello, World!\n");
return 0;
}
$ gcc -S hello.c
$ cat hello.s
Or do you want to disassemble other peoples code from binaries ?
Because disassembly of binaries is far more difficult. My go to was objdump and is now Ghidra, but I know other people who use radare2.
2 Likes
I was kinda looking for sth to use on the board terminal.
Though I just went with an objdump on chaintool a few hours ago :
riscv64-unknown-elf-objdump -d filename.o > disassembled.s
and it worked fine.
I also tried yours and it worked as well
I didn’t know about Ghidra and radare2 either, tnx for the help, really appreciated
2 Likes
我用 MilkV Duo 学习 RiscV 汇编
gcc -S -O2 tesc.s
gcc -c -O2 tesc.s
objdump -d test.o
还可以用来玩 Rust
rustc --emit llvm-ir a.rs
rustc --emit asm a.rs
3 Likes
highly appreciated!
1 Like