[ACCEPTED]-gdb fails to run ELF 64-bit program with "File format not recognized-gdb

Accepted answer
Score: 21

The executable is 64-bit (x86-64) and the 3 debugger is a 32 bit (i686-pc-linux) build. You 2 may need to install a 64-bit (x86-64) version 1 of the debugger.

Score: 5

I'm not sure if this is your problem, but 6 I faced this situation very often. The executable 5 in the build tree, build by make/automake 4 is not a binary, but a script, so you cannot 3 use gdb with it. Try to install the application 2 and change the directory, because else gdb 1 tries to debug the script.

Score: 4

The question refers to "./filename" and 14 to "/path/executable". Are these the same 13 file?

If you are doing a post-mortem analysis, you 12 would run:

gdb executable-file core-file

If you are going to ignore the 11 core file, you would run:

gdb executable-file

In both cases, 'executable-file' means 10 a pathname to the binary you want to debug. Most 9 usually, that is actually a simple filename 8 in the current directory, since you have 7 the source code from your debug build there.

On 6 Solaris, a 64-bit build of GDB is supposed 5 to be able to debug both 32-bit and 64-bit 4 executables (though I've had some issues 3 with recent versions of GDB). I'm not sure 2 of the converse - that a 32-bit GDB can 1 necessarily debug 64-bit executables.

Score: 2

What you need to be checking, is really 4 the bfd library. The binary file descriptor library is what binutils 3 / gdb uses to actually parse and handle 2 binaries (ELF/a.out etc..).

You can see the 1 current supported platforms via objdump;

# objdump -H

objdump: supported targets: elf32-powerpc aixcoff-rs6000 elf32-powerpcle ppcboot elf64-powerpc elf64-powerpcle elf64-little elf64-big elf32-little elf32-big srec symbolsrec tekhex binary ihex
objdump: supported architectures: rs6000:6000 rs6000:rs1 rs6000:rsc rs6000:rs2 powerpc:common powerpc:common64 powerpc:603 powerpc:EC603e powerpc:604 powerpc:403 powerpc:601 powerpc:620 powerpc:630 powerpc:a35 powerpc:rs64ii powerpc:rs64iii powerpc:7400 powerpc:e500 powerpc:MPC8XX powerpc:750

The following PPC specific disassembler options are supported for use with
the -M switch:
  booke|booke32|booke64    Disassemble the BookE instructions
  e300                     Disassemble the e300 instructions
  e500|e500x2              Disassemble the e500 instructions
  efs                      Disassemble the EFS instructions
  power4                   Disassemble the Power4 instructions
  power5                   Disassemble the Power5 instructions
  power6                   Disassemble the Power6 instructions
  32                       Do not disassemble 64-bit instructions
  64                       Allow disassembly of 64-bit instructions
Score: 1

It seems your GNU Debugger (gdb) doesn't support 5 x86_64 architecture.

So try LLDB Debugger (lldb) which aims 4 to replace it. It supports i386, x86-64 3 and ARM instruction sets.

It's available 2 by default on BSD/OS X, on Linux install 1 via: sudo apt-get install lldb (or use yum).

See: gdb to lldb command map page for more info.

More Related questions