1.4. Tools

Peering into the world of object files is made easier using the tools:

All of which are part of the binutils package.

1.4.1. "objdump -t" output format

I often dump the symbols of a file using objdump -t. I can't seem to easily locate any documentation on the output format so I've included some quick notes here. A typical use of this tool would look something like the following:

[trevor]$ objdump -t add.o      
add.o:     file format elf32-i386
SYMBOL TABLE:
00000000 l    df *ABS*     00000000 add.c
00000000 l    d  .text     00000000 
00000000 l    d  .data     00000000 
00000000 l    d  .bss      00000000 
00000000 l    d  .comment  00000000 
00000000 g     F .text     0000000b add
        

Here is my understanding of the column descriptions. This information comes from browsing through bfd/syms.c:bfd_print_symbol_vandf() (where "vandf" stands for "value and flags").

Figure 1-1. objdump -t Output

The flags which are described above are part of a larger set of symbols and attributes which are defined in bfd/bfd.h. The entire set of flags (or attributes) and their meanings are given below.

Note

Notice that objdump -t doesn't try to display the values of all the possible flags, just the ones mentioned above.

Table 1-1. BSF_ flags/attributes

DefinitionSymbolDescription
0x00000BSF_NO_FLAGSplaceholder for no defined flags
0x00001BSF_LOCALThe symbol has local scope (i.e. a static in C). VALUE(1) is this symbol's offset into the data section.
0x00002BSF_GLOBALThe symbol has global scope (i.e. initialized data in C). VALUE(2) is this symbol's offset into the data section.
BSF_GLOBALBSF_EXPORTThis symbol has global scope and is exported. Same as BSF_GLOBAL.
0x00008BSF_DEBUGGINGThe symbol is a debugging record. The VALUEs are arbitrary, unless BSF_DEBUGGING_RELOC is set.
0x00010ELFBSF_FUNCTIONFunction entry point.
0x00020BSF_KEEPused by the linker
0x00040BSF_KEEP_G
0x00080BSF_WEAKWeak global symbol. This symbol is overridable (without warning) by a regular global symbol of the same name.
0x00100ELFBSF_SECTION_SYMThis symbol points to a section.
0x00200BSF_OLD_COMMONThis symbol used to be *COM*, but is now allocated.
0x00400COFFBSF_NOT_AT_ENDThis symbol appears where it is declared and not at the end of a section.
0x00800BSF_CONSTRUCTORThis symbol indicates the start of the constructor section.
0x01000BSF_WARNINGThe presence of this symbol acts to indicate that there is a warning on the next symbol.
0x02000BSF_INDIRECTThis symbol is an indirect pointer to the symbol with the same name as the next symbol.
0x04000ELFBSF_FILEThis symbol contains a filename.
0x08000ELFBSF_DYNAMICThis symbol is associated with dynamic linking.
0x10000ELFBSF_OBJECTThis symbol denotes a data object.
0x20000BSF_DEBUGGING_RELOCThis is a debugging symbol. VALUE(1) is the offset into the data section. BSF_DEBUGGING should be set too.
0x40000ELFBSF_THREAD_LOCALThis symbol is used for thread local storage.