Re: How to list objects files in an executable



"Sashi" <smalladi@xxxxxxxxx> writes:

Måns Rullgård wrote:
"Sashi" <smalladi@xxxxxxxxx> writes:

vasudevram wrote:
Sashi wrote:
Hello All,

I have an executable file that was generated by make. How can I see
what all object files have been linked into this executable?

I'm using Solaris 5.8.

Thanks,
Sashi

Hi,

I'm not at a Linux machine right now, so can't check this first, but
try runnng the nm command (the name nm stands for "name" - since it
displays names of items in an executable file).

Syntax should be something like:

nm exe_filename

I've already investigated nm but it doesn't suit my purpose. It gives
information about the symbols therein but I'd like a clear listing of
all the object files linked into this executable.
Maybe I need to spend a little more time on nm and see if I can parse
nm's output and glean what I need.

What you are asking for is impossible in general. If your executable
has debugging symbols, a debugger should be able to tell you the
source files that were used. These need of course not correspond
directly to object files used in the final link.

--
Måns Rullgård
mru@xxxxxxxxxxxxx

Perhaps my question is such but this is the first ever time that I've
heard someone say "impossible" for something in UNIX.

Nothing is impossible, if you accept to do what it takes.

If you want to know what source files were used in building an
executable, you'll have to do something to record that information.


For example, you could put in each source a literal string containing
the path to the source file, and ensure that this string is linked in,
then use a command such as:

$ strings /usr/local/bin/BpClassTest | grep '$Id:'
$Id: BcExcept.c,v 1.2 2004/01/02 00:59:24 pjbpjb Exp $
$Id: BcMem.c,v 1.2 2004/01/02 00:59:24 pjbpjb Exp $


Or you could add to the Makefile commands to record the input files to
each rules and deliver the executable with a bill of materials.


But if you want to "magically" retrieve information that has been
destroyed, no, it's not possible.

--
__Pascal Bourguignon__ http://www.informatimago.com/

This is a signature virus. Add me to your signature and help me to live.
.



Relevant Pages

  • Re: C++ Project Files?????
    ... The C preprocessor *merges* the header files with the source files ... > What the is a library file? ... > files have been turned into object files, ... that came with your compiler. ...
    (comp.lang.cpp)
  • Re: what are binaries? not in index of "Running Linux"
    ... are theses rpm packages? ... You have program source files. ... You compile the source files into object files. ...
    (comp.os.linux.setup)
  • Re: Makefile and $(addprefix)
    ... I'm trying to use $build lists of source files and ... object files containing the relative paths for each. ... is that $(addprefix) never seems to be evaluated. ...
    (freebsd-questions)
  • Re: Cant build loadable module for 2.6.kernel
    ... > I'm trying to build a loadable module for a telephony card that includes ... Some of the files are source files and ... > some are object files. ... > the vendor object files with the target. ...
    (Linux-Kernel)
  • does csc.exe rebuild source files every time?
    ... I've just read that there are no object files ... in C#. So a command such as this will build my.exe straight ... Does csc.exe build every source file everytime this command is issued? ... Or does it somehow know which source files are newer and build ...
    (microsoft.public.dotnet.languages.csharp)