TEMU
4.4
The Terma Emulator
|
Go to the source code of this file.
Typedefs | |
typedef void | temu_Symtab |
Functions | |
TEMU_API int | temu_loadImage (void *mem, const char *file) |
TEMU_API int | temu_loadImageAndStartAddr (void *Mem, const char *FileName, uint64_t *StartAddr TEMU_NONNULL) |
TEMU_API int | temu_loadBinaryImage (void *mem, const char *file, uint64_t pa) |
TEMU_API int | temu_loadElfImage (void *mem, const char *file, uint64_t pa) |
TEMU_API int | temu_loadElfImageAndStartAddr (void *Mem, const char *FileName, uint64_t *StartAddr TEMU_NONNULL) |
TEMU_API int | temu_imageIsELF (const char *file) |
TEMU_API int | temu_elfHasDwarf (const char *file) |
TEMU_API int | temu_loadSymtab (const char *FileName, temu_Symtab **Sym TEMU_NONNULL) |
TEMU_API void | temu_symtabGetFuncName (temu_Symtab *Sym TEMU_NONNULL, const char **LocalFile TEMU_NONNULL, const char **Symbol TEMU_NONNULL, uint64_t Addr) |
TEMU_API void | temu_symtabGetObjName (temu_Symtab *Sym TEMU_NONNULL, const char **LocalFile TEMU_NONNULL, const char **Symbol TEMU_NONNULL, uint64_t Addr) |
TEMU_API int | temu_symtabGetGlobalFuncRange (temu_Symtab *Sym TEMU_NONNULL, const char *FuncName TEMU_NONNULL, uint64_t *Addr TEMU_NONNULL, uint64_t *Size) |
TEMU_API int | temu_symtabGetLocalFuncRange (temu_Symtab *Sym TEMU_NONNULL, const char *FileName TEMU_NONNULL, const char *FuncName TEMU_NONNULL, uint64_t *Addr TEMU_NONNULL, uint64_t *Size TEMU_NONNULL) |
TEMU_API int | temu_symtabGetGlobalObjRange (temu_Symtab *Sym TEMU_NONNULL, const char *ObjectName TEMU_NONNULL, uint64_t *Addr TEMU_NONNULL, uint64_t *Size TEMU_NONNULL) |
TEMU_API int | temu_symtabGetLocalObjRange (temu_Symtab *Sym TEMU_NONNULL, const char *FileName TEMU_NONNULL, const char *ObjectName TEMU_NONNULL, uint64_t *Addr TEMU_NONNULL, uint64_t *Size TEMU_NONNULL) |
TEMU_API void | temu_disposeSymtab (temu_Symtab *Sym) |
TEMU_API int | temu_loadSrecImage (void *mem, const char *file, uint64_t pa) |
TEMU_API int | temu_loadSrecImageAndStartAddr (void *mem, const char *fileName, uint32_t *startAddr TEMU_NONNULL) |
typedef void temu_Symtab |
TEMU_API void temu_disposeSymtab | ( | temu_Symtab * | Sym | ) |
Dispose (deallocate) the symbol table
Sym | Symbol table pointer to free. |
TEMU_API int temu_elfHasDwarf | ( | const char * | file | ) |
Return non-zero if file has DWARF data
file | Path to file to check for DWARF-info. |
TEMU_API int temu_imageIsELF | ( | const char * | file | ) |
Return non-zero if file is an ELF file
file | Path to file to check for ELFiness. |
TEMU_API int temu_loadBinaryImage | ( | void * | mem, |
const char * | file, | ||
uint64_t | pa | ||
) |
Loads a raw binary image to the memory object at the given address.
The function will assume that the file is a raw binary. This way you can load an ELF file as is to memory (e.g. where it is expected by the boot loader).
mem | Memory object, must conform to the mem interface. |
file | Path to file to load. |
pa | Physical address where to load the image. |
TEMU_API int temu_loadElfImage | ( | void * | mem, |
const char * | file, | ||
uint64_t | pa | ||
) |
Loads an ELF file without going through filetype detection
mem | Memory object, must conform to the mem interface. |
file | Path to file to load. |
pa | Unused argument |
TEMU_API int temu_loadElfImageAndStartAddr | ( | void * | Mem, |
const char * | FileName, | ||
uint64_t *StartAddr | TEMU_NONNULL | ||
) |
Loads an ELF file without going through filetype detection
Mem | Memory object, must conform to the mem interface. |
FileName | Path to file to load. |
StartAddr | Pointer where to place the start address of the elf file |
TEMU_API int temu_loadImage | ( | void * | mem, |
const char * | file | ||
) |
Loads a binary image to the memory object.
The function will autodetect the file type (based on extensions and magic headers in the file).
Binary images will be placed at address 0.
The image can be one of the supported file formats.
mem | Memory object, must conform to the mem interface. |
file | Path to file to load. |
TEMU_API int temu_loadImageAndStartAddr | ( | void * | Mem, |
const char * | FileName, | ||
uint64_t *StartAddr | TEMU_NONNULL | ||
) |
Loads a binary image to the memory object.
The function will autodetect the file type (based on extensions and magic headers in the file).
Binary images will be placed at address 0.
The image can be one of the supported file formats.
This specific variant, will return the start address of the binary, the StartAddr is typically embedded in the ELF or SREC files. The function therefore allows you to set the program counter to the correct start address after the function has been called.
Mem | Memory object, must conform to the mem interface. |
FileName | Path to file to load. |
StartAddr | Pointer to location to store the start address. |
TEMU_API int temu_loadSrecImage | ( | void * | mem, |
const char * | file, | ||
uint64_t | pa | ||
) |
Loads an SREC file without going through filetype detection.
mem | Memory object, must conform to the mem interface. |
file | Path to file to load. |
pa | Unused argument |
TEMU_API int temu_loadSrecImageAndStartAddr | ( | void * | mem, |
const char * | fileName, | ||
uint32_t *startAddr | TEMU_NONNULL | ||
) |
Loads an SREC file without going through filetype detection.
mem | Memory object, must conform to the mem interface. |
fileName | Path to file to load. |
startAddr | Start address, will be set if result is 0 |
TEMU_API int temu_loadSymtab | ( | const char * | FileName, |
temu_Symtab **Sym | TEMU_NONNULL | ||
) |
Loads the symbol table from a given ELF file.
The symbol table is allocated and the pointer of the allocated symbol table is placed in Sym. The user is responsible for disposing the symbol table with temu_disposeSymtab().
FileName | Name of ELF file |
Sym | Address of your symtab pointer. |
TEMU_API void temu_symtabGetFuncName | ( | temu_Symtab *Sym | TEMU_NONNULL, |
const char **LocalFile | TEMU_NONNULL, | ||
const char **Symbol | TEMU_NONNULL, | ||
uint64_t | Addr | ||
) |
Get the function name associated with the given address
The address can be any address within the range of the function, i.e. from the start to othe end of the function. Thus this serves as a way to find the name of the current function given a PC value.
The function first searches for local symbols (e.g. static symbols in C). It then searches for global symbols and last for weak symbols.
If a local symbol is found, the LocalFile pointer will point at a string with the file name it is associated to, otherwise the local file pointer will be set to null.
The returned pointers are valid until the symbol table is disposed.
Sym | Symboltable |
LocalFile | The pointer it refers to will be set to NULL if the symbol found is global. |
Symbol | The pointer will be set to NULL if a function cannot be found at the address. |
Addr | Virtual address to find a function name for. |
TEMU_API int temu_symtabGetGlobalFuncRange | ( | temu_Symtab *Sym | TEMU_NONNULL, |
const char *FuncName | TEMU_NONNULL, | ||
uint64_t *Addr | TEMU_NONNULL, | ||
uint64_t * | Size | ||
) |
Get the range of a global function
On success, the Addr and the Size references will be set to the starting virtual address of the function and the size in bytes respectively.
Sym | The Symbol table, from which the function is to be retrieved |
FuncName | The function, whose range is required |
Addr | On success, gives the address of the function |
Size | On success, gives the size of the function start from Addr |
TEMU_API int temu_symtabGetGlobalObjRange | ( | temu_Symtab *Sym | TEMU_NONNULL, |
const char *ObjectName | TEMU_NONNULL, | ||
uint64_t *Addr | TEMU_NONNULL, | ||
uint64_t *Size | TEMU_NONNULL | ||
) |
Get the range of a global object
On success, the Addr and the Size references will be set to the starting virtual address of the object and the size in bytes respecivelly.
Sym | The Symbol table, from which the object to be retrieved |
ObjectName | Name of the object, whose address range is to be obtained |
Addr | On success, gives the address of the object |
Size | On success, gives the size of the object start from Addr |
TEMU_API int temu_symtabGetLocalFuncRange | ( | temu_Symtab *Sym | TEMU_NONNULL, |
const char *FileName | TEMU_NONNULL, | ||
const char *FuncName | TEMU_NONNULL, | ||
uint64_t *Addr | TEMU_NONNULL, | ||
uint64_t *Size | TEMU_NONNULL | ||
) |
Get the range of a local/static function
On success, the Addr and the Size references will be set to the starting virtual address of the function and the size in bytes respectively.
Sym | The Symbol table, from which the function to be retrieved |
FileName | The file/compilation unit that contains the function |
FuncName | The function, whose range is required |
Addr | On success, gives the address of the function |
Size | On success, gives the size of the function start from Addr |
TEMU_API int temu_symtabGetLocalObjRange | ( | temu_Symtab *Sym | TEMU_NONNULL, |
const char *FileName | TEMU_NONNULL, | ||
const char *ObjectName | TEMU_NONNULL, | ||
uint64_t *Addr | TEMU_NONNULL, | ||
uint64_t *Size | TEMU_NONNULL | ||
) |
Get the range of a local/static object
On success, the Addr and the Size references will be set to the starting virtual address of the object and the size in bytes respecivelly.
Sym | The Symbol table, from which the object to be retrieved |
FileName | The file/compilation unit that contains the function |
ObjectName | The object, whose range is required |
Addr | On success, gives the address of the object |
Size | On success, gives the size of the object start from Addr |
TEMU_API void temu_symtabGetObjName | ( | temu_Symtab *Sym | TEMU_NONNULL, |
const char **LocalFile | TEMU_NONNULL, | ||
const char **Symbol | TEMU_NONNULL, | ||
uint64_t | Addr | ||
) |
Get the object name associated with the given address
The address can be any address within the range of the object. Thus this serves as a way to find the name of a global or static object given an address.
The function first searches for local symbols (e.g. static symbols in C). It then searches for global symbols and last for weak symbols.
If a local symbol is found, the LocalFile pointer will point at a string with the file name it is associated to, otherwise the local file pointer will be set to NULL.
The returned pointers are valid until the symbol table is disposed.
Sym | Symboltable |
LocalFile | The pointer it refers to will be set to NULL if the symbol found is global. |
Symbol | The pointer will be set to NULL if an object cannot be found at the address. |
Addr | Virtual address to find an object name for. |