This interface has functions for operating directly on symbol files, instead
of using contexts related to processes or processors. Files opened with this
interface can be used together with functions in the
debug_symbol
interface that do not require any stack or
location information. There are also functions for getting information about
the symbol file, such as listing sections or segments.
For all functions that return an attr_value_t
, that return value
will consists of a list with two elements. The first element is an error code
of debugger_error_t
type (see debug_query
interface documentation for definition). The second element depends on the
first. If the first element is Debugger_No_Error
, meaning that
the function went well, then the second element will contain the expected
return value that is specified per function below. If the first element is
another error code, then the second element will be a string describing the
error that occurred.
All function but open_symbol_file has to act on a context id,
ctx_id, that has been returned by open_symbol_file,
otherwise a Debugger_Not_Supported_For_Context
error will be
returned.
open_symbol_file opens a symbol file, specified by the
filename argument, as a context so that this can be used with
many of the symbol lookup functions in the debug_symbol
interface. The address is the offset for which to load the symbol
file if absolute_address is false. If absolute_address
is true, address will instead be the absolute address to load the
symbol file on. The returned value will be a context id that can be used as
argument where a ctx_id is required. Functions that take a stack
frame can only be accessed with no stack (value -1) when used with a symbol
file context. Files that read or write memory cannot be used.
Errors specific to this function:
open_symbol_section opens a symbol file in the same way as open_symbol_file, but only adds symbols from the specified section. Other arguments and return value are as for open_symbol_file. The symbol section is closed using close_symbol_file. This method can only handle ELF binaries. In addition to errors reported by open_symbol_file this function can report Debugger_Section_Not_Found if the section cannot be found.
close_symbol_file closes a symbol file that was opened with open_symbol_file. The ctx_id should be the context id returned from that function. The returned value will just be nil when this goes well.
symbol_file_info returns a list containing a string describing the file format and a dictionary with information about the file. The ctx_id argument should be the context id returned from the open_symbol_file. The returned information depends on which file format the file has. For ELF files the string is "ELF" and the returned entries are:
(uint64)
- Set to 1 if the binary is
built for big endian, otherwise 0.(uint64)
- The ELF machine
identifier number (e_machine
) in the ELF header. This is usually
prefixed with EM_
in headers. For example EM_386 = 3
and
EM_X86_64 = 62.
For PE files the string is "PE" and the returned entries are:
(uint64)
- The size of the PE image in
memory.(uint64)
- The recommended address for
the image to be loaded at.Both PE and ELF files will include the following entries:
(uint64)
- The program counter for
where the execution in the file should begin.(uint64)
- The file size in bytes.(string)
- The type of machine the binary
is built for, for example "X86-64", "X86" or "ARM".(uint64)
- The address width the
file was built for, should be 32 or 64, but 0 specifies unknown.sections_info provides information about the sections in the symbol file. The ctx_id must be an id for a file opened with open_symbol_file or open_symbol_section in this interface. The returned result is a list with two elements, the first a string specifying the format of the file, "ELF" or "PE", and the second a list of dictionaries where each dictionary contains information about the section. If an id from open_symbol_section is used then only the opened section will be included in the list. The following keys exist in the dictionary:
(string)
- The name of the section. This key
could potentially be left out if the sections does not have a name.(uint64)
- The address in memory.(uint64)
- The offset in the file.(uint64)
- The section size in the file
image.(boolean)
- A boolean telling if the
section is executable or not.(uint64)
- Only available for ELF
files. The section index.(uint64)
- Only available for ELF
files. The value of sh_flags
in the ELF section header.(uint64)
- Only available for PE
files. The value of Characteristics
in the PE section
IMAGE_SECTION_HEADER
structure.segments_info provides information about the segments in the symbol file, this is only supported for ELF. The ctx_id must be an id for a file opened with open_symbol_file in this interface. The returned result is a list where each entry represent a segment. Each entry is in turn a dictionary with the following keys:
(uint64)
- Virtual address in
memory.(uint64)
- The segment size in
memory, specified in bytes.(uint64)
- Offset into the segment
location on file.(uint64)
- Flags, depending on segment
type, corresponds to p_flags
in the ELF program header table.(uint64)
- The type of the segment,
corresponds to p_type
in the ELF program header table.(uint64)
- Physical address in
memory, if applicable.(uint64)
- The size of the segment in
file.([string,...])
- A list of sections
included in the segment, presented by the section name.
SIM_INTERFACE(debug_symbol_file) { attr_value_t (*open_symbol_file)(conf_object_t *NOTNULL obj, const char *NOTNULL filename, uint64 address, bool absolute_address); attr_value_t (*close_symbol_file)(conf_object_t *NOTNULL obj, const char *NOTNULL ctx_id); attr_value_t (*symbol_file_info)(conf_object_t *NOTNULL obj, const char *NOTNULL ctx_id); attr_value_t (*sections_info)(conf_object_t *NOTNULL obj, const char *NOTNULL ctx_id); attr_value_t (*segments_info)(conf_object_t *NOTNULL obj, const char *NOTNULL ctx_id); attr_value_t (*open_symbol_section)(conf_object_t *NOTNULL obj, const char *NOTNULL filename, const char *NOTNULL section, uint64 address, bool absolute_address); }; #define DEBUG_SYMBOL_FILE_INTERFACE "debug_symbol_file"