GNU Info

Info Node: (bfd.info)Reading Symbols

(bfd.info)Reading Symbols


Next: Writing Symbols Prev: Symbols Up: Symbols
Enter node , (file) or (file)node

Reading symbols
---------------

   There are two stages to reading a symbol table from a BFD:
allocating storage, and the actual reading process. This is an excerpt
from an application which reads the symbol table:

              long storage_needed;
              asymbol **symbol_table;
              long number_of_symbols;
              long i;
     
              storage_needed = bfd_get_symtab_upper_bound (abfd);
     
              if (storage_needed < 0)
                FAIL
     
              if (storage_needed == 0) {
                 return ;
              }
              symbol_table = (asymbol **) xmalloc (storage_needed);
                ...
              number_of_symbols =
                 bfd_canonicalize_symtab (abfd, symbol_table);
     
              if (number_of_symbols < 0)
                FAIL
     
              for (i = 0; i < number_of_symbols; i++) {
                 process_symbol (symbol_table[i]);
              }

   All storage for the symbols themselves is in an objalloc connected
to the BFD; it is freed when the BFD is closed.


automatically generated by info2www version 1.2.2.9