Re: Finding Source file name from object or executable (310 Views)
Reply
Occasional Contributor
amit1209
Posts: 7
Registered: ‎09-11-2007
Message 1 of 9 (310 Views)

Finding Source file name from object or executable

Is it possible to find the source file name [including path] from the either the object or executable. The code doesn't have debug information so gdb also did not work.

Amit
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 2 of 9 (310 Views)

Re: Finding Source file name from object or executable

Hi Amit:

You could try:

# what filename

Regards!

...JRF...
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 3 of 9 (310 Views)

Re: Finding Source file name from object or executable

Hi (again) Amit:

Another useful view would be provided by:

# nm filename

Regards!

...JRF...
Acclaimed Contributor
A. Clay Stephenson
Posts: 17,825
Registered: ‎07-16-1998
Message 4 of 9 (310 Views)

Re: Finding Source file name from object or executable

As a general rule, no. That's the kind of information that compiling with -g does provide. You can try the nm command and what but unless -g was used in the compile then no references to the source files exist. Normally, that name of the source file can be inferred from the object but that is not definitive and certainly does not include the full path.
If it ain't broke, I can fix that.
Occasional Contributor
amit1209
Posts: 7
Registered: ‎09-11-2007
Message 5 of 9 (310 Views)

Re: Finding Source file name from object or executable

nm also only works when the compilation is done by using -g option. Unfortunately the option wasn't used.

Amit
Honored Contributor
OldSchool
Posts: 3,372
Registered: ‎09-09-2004
Message 6 of 9 (310 Views)

Re: Finding Source file name from object or executable

"what" (sccs) or "ident" (rcs) might shed some light, but its a longshot.
Acclaimed Contributor
Dennis Handly
Posts: 25,277
Registered: ‎03-06-2006
Message 7 of 9 (310 Views)

Re: Finding Source file name from object or executable

[ Edited ]

See my answer to your question in your other thread:

http://h30499.www3.hp.com/t5/Languages-and-Scripting/Extracing-function-names-from-a-C-object-file/m...

 

>The code doesn't have debug information so gdb also did not work.

If you are on IPF, you can usually get this info, even if -g isn't used. Unless the executable is stripped.

>Clay: As a general rule, no. That's the kind of information that compiling with -g does provide.

This info is available with commands mentioned in the link above.
Compiler option summary is available with footprints(1).

>nm also only works when the compilation is done by using -g option.

-g has nothing to do with nm(1), it doesn't look at debug info.

Occasional Contributor
amit1209
Posts: 7
Registered: ‎09-11-2007
Message 8 of 9 (310 Views)

Re: Finding Source file name from object or executable

The odump does provide the filenames but without absolute path. However, the elfdump -dc option does not work and exits with Bad input file type -elfdumperr 2003

Regards,
Amit
Acclaimed Contributor
Dennis Handly
Posts: 25,277
Registered: ‎03-06-2006
Message 9 of 9 (310 Views)

Re: Finding Source file name from object or executable

>The odump does provide the filenames but without absolute path.

Sure it does. You just have to glue the base name to the CWD on the next line.

>the elfdump -dc option does not work

Sure it does. ;-)
elfdump works on ELF files (IPF and PA64). odump works on SOM files, PA32.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.