LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-03-2009, 11:22 AM   #1
yince
LQ Newbie
 
Registered: Jul 2009
Posts: 3

Rep: Reputation: 0
Retrieve source file names in binary executable or library


Hello,
I would like to know how can I obtain source file names inside an executable or library using the debugging information.

Thanks,
Vince
 
Old 07-04-2009, 09:37 PM   #2
daidoji
LQ Newbie
 
Registered: Nov 2005
Location: Oakland, CA
Distribution: Slackware
Posts: 11

Rep: Reputation: 0
Debugging using gdb or something like strace? See the thing is this is harder than it looks. The reason is that unless the maintainers in the source used descriptive functional names in their libraries and calls, or descriptive hard coded strings in the compiled binary there's no way to find source file names. However, a lot of programs you can find this kind of information. Learn how to use a disassembler (special program to view binary files) and you might find the information that you seek. A reverse engineering forum might be better able to help you with something like this though.

Quote:
Originally Posted by yince View Post
Hello,
I would like to know how can I obtain source file names inside an executable or library using the debugging information.

Thanks,
Vince
 
Old 07-05-2009, 12:06 AM   #3
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by yince View Post
Hello,
I would like to know how can I obtain source file names inside an executable or library using the debugging information.

Thanks,
Vince
You can have a look at gdb source for inspiration.
But what do you need those source file names for ?
Do you write your own debugger ?
 
Old 07-05-2009, 01:54 AM   #4
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
If your executable hasn't been stripped, you can use the

nm -a <executable_name>

to dump all symbols in it, including source filenames. Source file names are debugging-only symbols, hence the -a switch. They will be somewhere at the end of the output.
 
Old 07-08-2009, 08:07 AM   #5
yince
LQ Newbie
 
Registered: Jul 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Valery Reznic View Post
You can have a look at gdb source for inspiration.
But what do you need those source file names for ?
Do you write your own debugger ?
I'm rewriting a makefile from a complicated one.
The executables contains the file names needed to be build.
 
Old 07-08-2009, 08:25 AM   #6
yince
LQ Newbie
 
Registered: Jul 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Uncle_Theodore View Post
If your executable hasn't been stripped, you can use the

nm -a <executable_name>

to dump all symbols in it, including source filenames. Source file names are debugging-only symbols, hence the -a switch. They will be somewhere at the end of the output.
Thanks,
nm -al <executable_name>
did the trick.

I also found:
objdump -dl <executable_name>

I don't know yet if I will get the same result with the two commands above but the first one is faster.

Thanks
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Library issues while installing from a binary executable file kliew Red Hat 4 03-18-2009 07:34 PM
LXer: Practical Steganography Part-1: Hiding information in Binary Executable File LXer Syndicated Linux News 0 02-14-2008 11:41 AM
Exec format error. binary file not executable. kaz2100 Linux - General 2 08-19-2006 05:26 PM
recover source file from binary linux_lover2005 Programming 1 04-28-2005 11:34 AM
Java SDK won't install, binary file not executable, yoper linux 2.6 kernel lopoetve Linux - Software 8 10-30-2004 03:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:07 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