Symbol format 'elf64-littleriscv' unknown

Symbol format 'elf64-littleriscv' unknown

March 1, 2021
riscv, compilers

tags
RISCV Compiler

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.


No notes link to this note