Symbol format 'elf64-littleriscv' unknown
After an hour of compiling RISC-V’s toolchain, I ran riscv64-unknown-elf-gdb
remotely against my Rust kernel running in Qemu. This happened.
riscv64-unknown-elf-gdb \
-q \
-ex 'file target/riscv64gc-unknown-none-elf/debug/strail-rs' \
-ex 'target remote localhost:3333' \
-ex "b main"
Reading symbols from target/riscv64gc-unknown-none-elf/debug/strail-rs...
I'm sorry, Dave, I can't do that. Symbol format `elf64-littleriscv' unknown.
Remote debugging using localhost:3333
make: *** [gdb] Abort trap: 6
What the hell. I immediately started to investigate what is going on, is it my build system? Is Rust compiling my binary in a wrong format (although it seems correct from the output)?
It seems that I did not configure RISC-V’s toolchain with
=--enable-multilib
flag. The following solved the issue:
RISC-V toolchain compilation flags
./configure \
--prefix=$HOME/workspace/opt/riscv64 \
--with-arch=rv64imac \
--with-abi=lp64 \
--enable-multilib
make -j8
One more hour wasted at compiling everything again.
❗ ️Update: This didn’t work. I ended up downloading RISC-V’s OSX pre-compiled
toolchain from their website. I need to find free time to figure out what flag I
am missing.
❗ ️Update: This issue got addressed in GDB’s upstream, but for some reason RISC-V’s toolchain did not cherry-pick that commit. Either you cherry-pick that commit to your toolchain repository, or use GDB’s upstream.
See riscv-gnu-toolchain/issues/867 and thanks @jrtc27 for helping me out with the issue.
Fun fact: The error message I'm sorry, Dave, I can't do that.
, comes from a
scene of A Space Odyssey (1968). It seems to have been committed in 28 March
1991, by K. Richard Pixley.
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/97b6FfQbibM?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
></iframe>
</div>