riscv-pk icon indicating copy to clipboard operation
riscv-pk copied to clipboard

pk:cannot execute binary file: Exec format error

Open BeenLi opened this issue 5 years ago • 10 comments

I have installed riscv64-unknown-linux-gnu pk succesfully in my utunbu at x86_64,but when I enter the commad pk The following error occurred.

oneshot@ubuntu:~/riscv/riscv-pk/build$ pk bash: /opt/riscv/riscv64-unknown-linux-gnu/bin/pk: cannot execute binary file: Exec format error

Any help is appreciated.

BeenLi avatar Aug 17 '20 14:08 BeenLi

You need run pk with spike / riscv-isa-sim. e.g.

$ spike pk <your-riscv-program>

kito-cheng avatar Aug 17 '20 15:08 kito-cheng

Thanks. But I still can't run the hello successfully using your method.

Can you help me?

 

------------------ 原始邮件 ------------------ 发件人: "riscv/riscv-pk" <[email protected]>; 发送时间: 2020年8月17日(星期一) 晚上11:12 收件人: "riscv/riscv-pk"<[email protected]>; 抄送: "万力"<[email protected]>;"Author"<[email protected]>; 主题: Re: [riscv/riscv-pk] pk:cannot execute binary file: Exec format error (#212)

You need run pk with spike / riscv-isa-sim. e.g. $ spike pk <your-riscv-program>
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

BeenLi avatar Aug 19 '20 13:08 BeenLi

Hmmm, you might need to provide more info e.g. what command you use, what message you get, how you built the hello program.

kito-cheng avatar Aug 22 '20 15:08 kito-cheng

Sorry, there is a picture providing the information in my reply to your email, but it was gone in github. I build my hello program with riscv64-unknown-linux-gnu-gcc. When I run pk, it outputs the following message. $ spike Spike RISC-V ISA Simulator 1.0.1-dev $ file hello hello: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 4.15.0, with debug_info, not stripped $ spike pk hello terminate called after throwing an instance of 'std::runtime_error' what(): could not open pk (did you misspell it? If VCS, did you forget +permissive/+permissive-off?)

BeenLi avatar Aug 22 '20 15:08 BeenLi

Oh, you need to using static link for your program, pk/spike don't support dynamic link yet.

Ice Cole [email protected]於 2020年8月22日 週六,23:45寫道:

Sorry, there is a picture providing the information in my reply to your email, but it was gone in github.

I build my hello program with riscv64-unknown-linux-gnu-gcc.

When I run pk, it outputs the following message.

$ spike

Spike RISC-V ISA Simulator 1.0.1-dev

$ file hello

hello: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 4.15.0, with debug_info, not stripped

$ spike pk hello

terminate called after throwing an instance of 'std::runtime_error'

what(): could not open pk (did you misspell it? If VCS, did you forget +permissive/+permissive-off?)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/riscv/riscv-pk/issues/212#issuecomment-678656134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUY24I2WPKZL7GQ7QLHAELSB7RZHANCNFSM4QBWQMVA .

kito-cheng avatar Aug 22 '20 16:08 kito-cheng

@BeenLi: The "could not open pk" seems to indicate that you need a full path to pk. There's no discovery of pk on your PATH that I'm aware of. Try something like:

spike $RISCV/riscv64-unknown-elf/bin/pk hello

seldridge avatar Aug 22 '20 18:08 seldridge

@kito-cheng Thanks a lot, But I'm poor about how to build hello program using static link. Can you talk about the whole process in detail.

BeenLi avatar Aug 25 '20 14:08 BeenLi

@seldridge Thanks. But it seems that it doesn't work in your way.

BeenLi avatar Aug 25 '20 14:08 BeenLi

just like $ riscv64-unknown-linux-gnu-gcc -static hello.c

gjunyi avatar Dec 07 '21 08:12 gjunyi

image when i run spike pk hello. It doesn't print "hello world", and its result likes this. Dose it work sucessfully? And when i check the pk version. It prints "riscv64-unknown-elf/bin/pk: cannot execute binary file: Exec format error"

jundijiujieke avatar May 04 '23 07:05 jundijiujieke