Object constructor.
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);
66 throw exception(
"file '%s' is stripped",
m_path);
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);
82 throw exception(
"file '%s' is stripped",
m_path);
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
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.
int i32
32-bit signed integer
virtual const i8 * path() const
Get the objective code file path.
chain< symbol > * m_table
Function symbol table.
unsigned long long mem_addr_t
64-bit memory address
i8 * m_path
Objective code file path.
#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.