Initializing libdwarf
This topic describes how the consumer application
initializes libdwarf to process the information within
an ELF object file or GOFF program object file.
Steps to initialize libdwarf for an ELF object file
If
the object format ELF, and the ELF descriptor object is available,
use the dwarf_elf_init operation to initialize the
libdwarf object. For example:
Dwarf_Error err;
Dwarf_Debug dbg;
int rc;
rc = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &dbg, &err);It
is important to check the return code to ensure that the processing
succeeded. dwarf_elf_init returns DW_DLV_OK on
successful completion. It returns DW_DLV_ERROR if an error occurs. dwarf_elf_init returns
DW_DLV_NO_ENTRY if the ELF descriptor does not contain DWARF data.
If
the processing was successful, then dbg contains
the Dwarf_Debug object which is used to interact
with libdwarf.
dwarf_elf_init_b. Consult the libdwarf
documentation for details on using these operations.Steps to initialize libdwarf for an GOFF program object
If
reading a GOFF program object, use the dwarf_goff_init_with_PO_filename operation
to initialize the libdwarf object. For example:
Dwarf_Error err;
Dwarf_Debug dbg;
int rc;
rc = dwarf_goff_init_with_PO_filename (file_name, NULL, NULL, 0, &dbg, &err);It
is important to check the return code to ensure that the processing
succeeded. dwarf_elf_init returns DW_DLV_OK on
successful completion. It returns DW_DLV_ERROR if an error occurs. dwarf_elf_init returns
DW_DLV_NO_ENTRY if the ELF descriptor does not contain DWARF. data.
dwarf_goff_init_with_PO_filename returns DW_DLV_NO_ENTRY
if the GOFF program object file does not contain DWARF data.
Unlike ELF object, when handling GOFF program object, the relocation logic is handled by the libdwarf initialization processing.
dwarf_goff_init_with_csvquery_token.
Consult the libdwarf documentation for details on using these operations.