riscv-software-src / riscv-pk

RISC-V Proxy Kernel
Other
593 stars 308 forks source link

pk:cannot execute binary file: Exec format error #212

Open BeenLi opened 4 years ago

BeenLi commented 4 years ago

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.

kito-cheng commented 4 years ago

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

$ spike pk <your-riscv-program>
BeenLi commented 4 years ago

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

Can you help me?

 

------------------ 原始邮件 ------------------ 发件人: "riscv/riscv-pk" <notifications@github.com>; 发送时间: 2020年8月17日(星期一) 晚上11:12 收件人: "riscv/riscv-pk"<riscv-pk@noreply.github.com>; 抄送: "万力"<550296815@qq.com>;"Author"<author@noreply.github.com>; 主题: 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.

kito-cheng commented 4 years ago

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

BeenLi commented 4 years ago

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?)

kito-cheng commented 4 years ago

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

Ice Cole notifications@github.com於 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 .

seldridge commented 4 years ago

@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
BeenLi commented 4 years ago

@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 commented 4 years ago

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

gjunyi commented 2 years ago

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

jundijiujieke commented 1 year ago

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"