finding the file of a local symbol in BFD

Jim Blandy jimbATcygnus.com
Mon Sep 13 15:58:00 GMT 1999


In an ELF symbol table, all local symbols (e.g., C static things) come
at the beginning of the symbol table.  As I understand it, all the
local symbols from a given compilation unit come in a clump, preceded
by an STT_FILE symbol whose name is the name of the source file for
that compilation unit.  So, given this information, you can discover
which compilation unit a symbol is local to, and thus you can reliably
distinguish between local symbols with the same name.

Is this correct?

In BFD, STT_FILE symbols have the BSF_FILE flag associated with them.
Does BFD guarantee to preserve the order of the symbols?  That is,
will the symbols as I retrieve them from BFD still appear ordered by
compilation unit and preceded by a BSF_FILE symbol?

How portable is this information?  Is there any way to determine the
compilation unit to which a local symbol belongs that works regardless
of the underlying object file format?


More information about the Binutils mailing list