LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-27-2017, 01:58 PM   #1
blastwave
LQ Newbie
 
Registered: Jan 2017
Location: Canada
Distribution: Debian, RHEL, Solaris, various others and LFS
Posts: 19

Rep: Reputation: Disabled
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1 says foo not in executable format: File format not recognized


I am baffled here.

The debugger won't. Here is what I did :

Code:
deb8_ppc64$ cat hello.c

#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[])
{
    fprintf ( stdout, "hello world.\n" );
    return (  EXIT_SUCCESS );
}
Compile it, run it and look at it :

Code:
deb8_ppc64$ gcc -m64 -g -o hello hello.c
deb8_ppc64$ ./hello
hello world.
deb8_ppc64$ 
deb8_ppc64$ file hello
hello: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked, interpreter /lib64/ld64.so.1, for GNU/Linux 2.6.32, BuildID[sha1]=c79bcf90665edeb4b1d9a5972c4f7ddf8ec9877d, not stripped
deb8_ppc64$
However debugger gdb says "no" :
Code:
deb8_ppc64$ which gdb
/usr/bin/gdb
deb8_ppc64$ ls -lap /usr/bin/gdb
-rwxr-xr-x 1 root root 6301688 Nov  9  2014 /usr/bin/gdb
deb8_ppc64$ /usr/bin/gdb hello
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 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 "powerpc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
"/usr/local/src/test/hello/hello": not in executable format: File format not recognized
(gdb) quit
deb8_ppc64$
What is going on here?
 
Old 09-27-2017, 02:20 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Now try this with gcc option '-m32'
 
Old 09-27-2017, 02:48 PM   #3
blastwave
LQ Newbie
 
Registered: Jan 2017
Location: Canada
Distribution: Debian, RHEL, Solaris, various others and LFS
Posts: 19

Original Poster
Rep: Reputation: Disabled
Did that first. Works. However I need to debug a 64-bit piece of software. Clearly not "hello world".

The correct action to take here is to simply install gdb 8.0.1 and then give it a whirl.

Last edited by blastwave; 09-27-2017 at 04:10 PM.
 
Old 09-27-2017, 06:41 PM   #4
blastwave
LQ Newbie
 
Registered: Jan 2017
Location: Canada
Distribution: Debian, RHEL, Solaris, various others and LFS
Posts: 19

Original Poster
Rep: Reputation: Disabled
Problem solved .. I simply built a new gdb :
Code:
deb8_ppc64$ /usr/local/bin/gdb pi_ld 
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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 "powerpc64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from pi_ld...done.
(gdb) break 57
Breakpoint 1 at 0x10000670: file pi_ld.c, line 57.
(gdb) run
Starting program: /usr/local/src/test/pi_ld 

NOTE : sizeof(long double) = 16


Breakpoint 1, main (argc=1, argv=0x3ffffffff8a8) at pi_ld.c:57
57          for ( j=0; j<sizeof(long double); j++ ) {
(gdb) print pi
$1 = 3.1415926535897932384626433832794812
(gdb) print &pi
$2 = (long double *) 0x3ffffffff440
(gdb) x/16xb 0x3ffffffff440
0x3ffffffff440: 0x40    0x09    0x21    0xfb    0x54    0x44    0x2d    0x18
0x3ffffffff448: 0x3c    0xa1    0xa6    0x26    0x33    0x14    0x5c    0x06
(gdb) cont
Continuing.
hex at memory addess &pi [ 0x3ffffffff440 ] ==  40 09 21 fb 54 44 2d 18 3c a1 a6 26 33 14 5c 06
[Inferior 1 (process 8222) exited normally]
(gdb) quit
deb8_ppc64$
Looks good to me.

Last edited by blastwave; 09-27-2017 at 09:05 PM.
 
  


Reply

Tags
gdb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Makefile: file not recognized:File format not recognized collect2: ld returned 1 exit Bringo Linux - Software 9 12-20-2010 04:08 AM
[SOLVED] can't debug with gdb: not in executable format: File format not recognized (squeeze) oddiofile Debian 1 08-24-2010 03:21 AM
Compiler error : /usr/lib/libc.so: file not recognized: File format not recognized kreena Solaris / OpenSolaris 7 12-14-2009 02:51 AM
not in executable format: File format not recognized ypy13 Linux - Newbie 9 07-09-2008 11:33 PM
gdb "not in executable format: File format not recognized" tcma Programming 9 07-18-2007 06:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration