1 #include "../include/symtab.hpp" 
    2 #include "../include/util.hpp" 
   28     throw exception(
"invalid argument: path (=%p)", path);
 
   41     fd = bfd_openr(
m_path, NULL);
 
   43       bfd_error bfd_errno = bfd_get_error();
 
   45         "failed to open file '%s' (bfd errno %d - %s)",
 
   53     if ( 
unlikely(!bfd_check_format(fd, bfd_object)) ) {
 
   54       bfd_error bfd_errno = bfd_get_error();
 
   56         "failed to verify file '%s' (bfd errno %d - %s)",
 
   64     i32 sz = bfd_get_symtab_upper_bound(fd);
 
   69       bfd_error bfd_errno = bfd_get_error();
 
   71         "failed to parse file '%s' (bfd errno %d - %s)",
 
   79     tbl = 
new asymbol*[sz];
 
   80     i32 cnt = bfd_canonicalize_symtab(fd, tbl);
 
   85       bfd_error bfd_errno = bfd_get_error();
 
   87         "failed to canonicalize the symbol table of '%s' (bfd errno %d - %s)",
 
   97       const asymbol *cur = tbl[i];
 
  100       if ( 
likely((cur->section->flags & SEC_CODE) == 0) )
 
  104       if ( 
likely((cur->flags & BSF_FUNCTION) == 0) )
 
  112       addr += bfd_get_section_vma(fd, cur->section);
 
  116       nm = abi::__cxa_demangle(cur->name, NULL, NULL, NULL);
 
  117       if ( 
likely(nm != NULL) ) {
 
  118         sym = 
new symbol(addr, nm);
 
  123         sym = 
new symbol(addr, cur->name);
 
  132 #if CSDBG_DBG_LEVEL & CSDBG_DBGL_INFO 
  245   if (len > strlen(
m_path)) {
 
  303   return lookup(addr) != NULL;
 
  317   return const_cast<symtab&
> (*this);
 
virtual bool exists(mem_addr_t) const 
Probe if a symbol exists. 
 
virtual symtab & foreach(void(*)(u32, symbol *)) const 
Traverse the symbol table with a callback for each symbol. 
 
This class represents a program/library function symbol. 
 
virtual symtab & operator=(const symtab &)
Assignment operator. 
 
Lightweight, templated, doubly-linked list (using XOR linking) 
 
virtual ~symtab()
Object destructor. 
 
char i8
8-bit signed integer 
 
mem_addr_t m_base
Load base address. 
 
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor. 
 
This class represents a program/library symbol table (symtab section) 
 
virtual const i8 * lookup(mem_addr_t) const 
Lookup an address to resolve a symbol. 
 
virtual mem_addr_t addr() const 
Get the symbol address. 
 
virtual const i8 * name() const 
Get the symbol name. 
 
unsigned int u32
32-bit unsigned integer 
 
virtual symtab * clone() const 
Object virtual copy constructor. 
 
int i32
32-bit signed integer 
 
virtual const i8 * path() const 
Get the objective code file path. 
 
chain< symbol > * m_table
Function symbol table. 
 
virtual u32 size() const 
Get the number of symbols. 
 
unsigned long long mem_addr_t
64-bit memory address 
 
i8 * m_path
Objective code file path. 
 
This class is a throwable with a textual description of an error. 
 
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor. 
 
static void dbg_info(const i8 *,...)
Print an informational debug message on the standard error stream. 
 
virtual mem_addr_t base() const 
Get the load base address. 
 
symtab(const i8 *, mem_addr_t=0)
Object constructor.