Operating System - Linux
1819796 Members
3106 Online
109607 Solutions
New Discussion юеВ

need to find the source files of a binary

 
sathis kumar
Frequent Advisor

need to find the source files of a binary

Hello,

I want to find the list of files/size in a binary file.

Is there any command to find the list of files(with file size) used to create a particular binary file?

Thanks,
Sathish
10 REPLIES 10
Yogeeraj_1
Honored Contributor

Re: need to find the source files of a binary

hi Sathish,

Which binary file are you referring to?

If it is an open source software, you find it by doing a google search otherwise it is practically impossible to find the source of a proprietary software.


revert!
kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
sathis kumar
Frequent Advisor

Re: need to find the source files of a binary

Hi,

In UNIX, I have used source programs 1.c, 2.c and 3.c and created a binary file(sample) using those programs.

With this binary file, if I want to know what all the source programs used to build this binary then what command can be used?

Regards,
Sathish
Dennis Handly
Acclaimed Contributor

Re: need to find the source files of a binary

Unless you have compiled with -g or are on IPF, this info isn't there. And the filesize isn't kept in any case.

If you were using clearcase and you were in the view, you could do "ct catcr".
OldSchool
Honored Contributor

Re: need to find the source files of a binary

unless you're using some kind of source code control system, you may not be able to.

most such systems have the ability to embed the source file name and version number as comments in the code. using those, you could get the file size of each given revision of the file.

such source control systems vary in complexity, ease of use and features, and each seem to have their own very vocal supporters.

rcs or sccs is usually available on most systems and should suffice for the stated need
Bill Hassell
Honored Contributor

Re: need to find the source files of a binary

There is nothing in the compiler that will put source code filenames into the executable. As mentioned before, there are a number of systems to track source code but there is nothing that will prevent someone from renaming the executable or the source code, or both. In your source code, you could provide some useful text in the what-string (source code name, revision, size, etc) but this all handwork prior to compiling the code.

I'm not sure why the size of the source code has any meaning. The simplest program (such as the typical "Hello world" example) may be 4 lines long or 50 lines long full of comments.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: need to find the source files of a binary

>Bill: There is nothing in the compiler that will put source code filenames into the executable.

Sure there is. :-)
This is the default on IPF and for PA, you need -g.
Though the comp unit record on PA may also have it.
sathis kumar
Frequent Advisor

Re: need to find the source files of a binary

Hi Dennis,

Could you please let me know the command that needs to be used ?

Thanks,
Sathish
Dennis Handly
Acclaimed Contributor

Re: need to find the source files of a binary

>Could you please let me know the command that needs to be used?

For PA, you can use:
32: odump -comp binary
64: elfdump -dc binary

You are going to have to parse the output and put the file path components together.
sathis kumar
Frequent Advisor

Re: need to find the source files of a binary

Hi Dennis,

Thanks for the information. We have compiled & created the binary in HP-UX 11i version and using the same executable in HP-UX 11V2 version. The current operating system version is 11V2 only. Could you please let me know which command we can make use to see the source files used in a binary(11i executable) in a 11V2 server?

Thanks.
Dennis Handly
Acclaimed Contributor

Re: need to find the source files of a binary

>We have compiled & created the binary in HP-UX 11i version and using the same executable in HP-UX 11V2 version. Could you please let me know which command ...

I told you how to do it for a PA system.