airbus-seclab / cpu_rec

Recognize cpu instructions in an arbitrary binary file
Apache License 2.0
637 stars 55 forks source link

cpu_rec wrong detection case with clang assembled RISC-V64 binary #20

Open Popolon opened 5 months ago

Popolon commented 5 months ago

In attachement, a RISC-V binary, object file and assembly source code, assembled with clang. The binary is wrongly detected as OCaml.

If I'm not wrong, I used these instruction to make this binary clang_build64.sh:

 
file=${1//.s}
clang --target=riscv64 -march=rv64imac -mno-relax ${file}.s -c -o ${file}.o
ld.lld -strip-all ${file}.o -o ${file}

hello_clang.tar.gz

LRGH commented 5 months ago

This binary is very small, and contains almost no instructions (the .text section is 32 bytes long), that's why cpu_rec does not detect the type of cpu. Do you have the same issue when running cpu_rec on RISC-V binaries that actually do something?