Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Symbol names in an object file

 
SOLVED
Go to solution
Jimson_1
Frequent Advisor

Symbol names in an object file

Hi,

I'm trying to find a way of listing all the function names associated with an object file, both globally and statically defined (complied in C).

I thought ANAL/OBJ would do it, but I couldn't manage to do it.

Also, I tried loading the object into a library and then doing LIB/LIST/NAMES but obviously this only shows the globally defined symbols.

Does anyone know of an easy way of doing this?
6 REPLIES 6
H.Becker
Honored Contributor

Re: Symbol names in an object file

As you experienced, librarian only knows about global symbols, nothing else. On I64 static functions may end up in LOCAL symbols. There are no local symbols defined in the Alpha object language.

In general, static functions are not visible from the outside (and, as we know, they are also good candidates for inlining).

On I64 it depends on the source code if the compiler sees a need to create a local symbol. It depends on the compiler if it creates an unamed local symbol or one with the name of the static function.

On I64 use ANAL/OBJ/section=symtab and look for "Symbol Type:" and STT_FUNC. ANAL/OBJ is the supported tool. There may be other tools to just list the Elf symbol table.

What problem are you trying to solve?
Hoff
Honored Contributor

Re: Symbol names in an object file

The typical approach is the preservation of and use of the /MAP from the LINK and the machine-code /LIST from the compilation.

Here's how these pieces are used during (for instance) an access violation (ACCVIO) stackdump and the resulting traceback:

http://labs.hoffmanlabs.com/node/800

There's also the ANA analysis files, but those AFAIK aren't documented.

Static function declarations don't (by default and by definition) don't get propagated downstream. Static functions might get entirely in-lined into the code.
John Gillings
Honored Contributor
Solution

Re: Symbol names in an object file

James,

Disk space is cheap. Always compile with /LIST and add language specific options to include symbol tables, cross reference etc... Similarly, always generate a full link map with cross reference and a DSF file.

The time you save the first time you find a need to refer back to a listing or map will pay for the cost of disk space by several orders of magnitude.

Obviously the compilation cross reference listing will include "all the function names associated with an object file, both globally and statically defined"
A crucible of informative mistakes
Jimson_1
Frequent Advisor

Re: Symbol names in an object file

cc /list /show=(symbols,cross_reference) is what I need.

Thanks

JP
Jimson_1
Frequent Advisor

Re: Symbol names in an object file

closed
Hoff
Honored Contributor

Re: Symbol names in an object file

If you're contending with diagnosing application crashes once the application is built and running, then you want to include the machine code in the listing, too.