gdb fails to run 'elf64-x86-64' format on gdbserver (Rust x64)

Viewed 1864

I'm trying remote debug a Rust executable using gdbserver on the remote machine and gdb on the local machine. I set up a Vagrant VM (bento/ubuntu-18.04) and start a gdbserver:

$ vagrant ssh
$ uname -a

Linux dev 4.15.0-121-generic #123-Ubuntu SMP Mon Oct 5 16:16:40 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ gdbserver --version

GNU gdbserver (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "x86_64-linux-gnu"

$ cargo run
$ file ./target/debug/my-app

./target/debug/my-app: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=31b1870cf7ef9e35ebe980acedf7eeaad694bb60, with debug_info, not stripped

$ gdbserver localhost:2000 ./target/debug/my-app

Process ./target/debug/my-app created; pid = 3851
Listening on port 2000

On my local macOS workstation:

$ uname -a

Darwin XXX 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64

$ gdb

GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin19.6.0".
Type "show configuration" for configuration details.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote localhost:2000
Remote debugging using localhost:2000
Reading /vagrant/target/debug/my-app from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /vagrant/target/debug/my-app from remote target...
Reading symbols from target:/vagrant/target/debug/my-app...
warning: I'm sorry, Dave, I can't do that.  Symbol format `elf64-x86-64' unknown.
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
Reading symbols from target:/lib64/ld-linux-x86-64.so.2...
Error while reading shared library symbols for target:/lib64/ld-linux-x86-64.so.2:
I'm sorry, Dave, I can't do that.  Symbol format `elf64-x86-64' unknown.
[1]    16617 abort      gdb

What is going wrong here?

2 Answers

I had a similar problem on macOS Catalina:

GDB failed with message: I'm sorry, Dave, I can't do that.  Symbol format `elf64-x86-64' unknown.

I could solve it by building from source with specifying the correct target:

  • download gdb source, unzip, and cd into it

  • ./configure --target=amd64-linux

  • make

  • sudo make install

  • (optional for VS Code) add "miDebuggerPath": "/usr/local/bin/amd64-linux-gdb"

binary is installed in "/usr/local/bin/amd64-linux-gdb", and can be called with

amd64-linux-gdb in a terminal.

If this does not work, try these suggested modifications before building:

Update

The approach worked with

Apple clang version 11.0.3 (clang-1103.0.32.29)
and sometimes work with
Apple clang version 12.0.0 (clang-1200.0.32.28) .

Related