26#include <unicorn/unicorn.h>
51typedef enum : uint32_t {
74typedef enum : uint8_t {
bool elf_string_foreach(const emu_elf_source_t *elf, uint64_t offset, emu_elf_string_fn fn, void *ctx)
Stream one NUL-terminated ELF string through bounded stack chunks.
bool(* elf_exec_segment_fn)(const elf_exec_segment_t *seg, void *ctx)
Per-segment callback for elf_foreach_exec_segment.
uint32_t elf_foreach_load_segment(const emu_elf_source_t *elf, elf_exec_segment_fn fn, void *ctx)
Walk every non-empty, bounds-checked PT_LOAD segment.
bool(* emu_elf_string_fn)(const char *bytes, size_t length, void *ctx)
Callback receiving one non-empty chunk of an ELF string.
uint32_t elf_sym_addr(const emu_elf_source_t *elf, const char *name, uint32_t *size_out)
Resolve a function symbol's entry address from the ELF .symtab.
uint32_t elf_foreach_symbol(const emu_elf_source_t *elf, emu_elf_symbol_fn fn, void *ctx)
Walk every symbol in every usable SHT_SYMTAB section.
emu_elf_layout_t
ELF32 file-layout constants (header sizes and field byte offsets).
@ k_elf_pf_x
PF_X: segment is executable.
@ k_elf_st_type_mask
Low nibble of st_info is the type.
@ k_elf_em_arm
e_machine == EM_ARM.
@ k_elf_ph_paddr_off
p_paddr in a program header.
@ k_elf_shentsize_min
ELF32 section-header entry size.
@ k_elf_ph_flags_off
p_flags in a program header.
@ k_elf_e_machine_off
e_machine in the file header.
@ k_elf_ph_vaddr_off
p_vaddr (VMA) in a program header.
@ k_elf_sh_entsize_off
sh_entsize in a section header.
@ k_elf_sym_info_off
st_info in a symbol-table entry.
@ k_elf_e_phentsize_off
e_phentsize in the file header.
@ k_elf_sh_link_off
sh_link in a section header.
@ k_elf_e_phoff_off
e_phoff in the file header.
@ k_elf_e_phnum_off
e_phnum in the file header.
@ k_elf_ph_filesz_off
p_filesz in a program header.
@ k_elf_ehdr_size
ELF32 file-header size.
@ k_elf_ph_offset_off
p_offset in a program header.
@ k_elf_sh_size_off
sh_size in a section header.
@ k_elf_pt_load
p_type == PT_LOAD.
uint32_t elf_foreach_exec_segment(const emu_elf_source_t *elf, elf_exec_segment_fn fn, void *ctx)
Walk every executable PT_LOAD segment of an ELF32 image.
int load_elf(uc_engine *uc, const emu_elf_source_t *elf)
Load ELF32 PT_LOAD segments into emulated memory at their LMA.
uint32_t warm_reboot(uc_engine *uc, const emu_elf_source_t *elf, bool trace)
Warm-reboot the firmware: re-run from the reset vector in place.
uint32_t elf_vector_base(const emu_elf_source_t *elf)
Vector-table base of an ELF: lowest executable PT_LOAD VMA.
bool(* emu_elf_symbol_fn)(const emu_elf_symbol_t *symbol, void *ctx)
Callback invoked for each bounds-checked ELF symbol entry.
emu_elf_io_status_t
Status for bounded raw-descriptor ELF source operations.
@ k_emu_elf_io_eof
The source ended during an exact read.
@ k_emu_elf_io_error
A host operation failed.
@ k_emu_elf_io_capacity
Caller scratch is smaller than required.
@ k_emu_elf_io_ok
The complete operation succeeded.
@ k_emu_elf_io_invalid
A pointer, descriptor, range, or path was bad.
Annotation-attribute framework macros for ra8-firmware.
One executable PT_LOAD segment, already bounds-checked against the image.
uint32_t offset
Segment file offset.
uint32_t filesz
Segment file byte count.
const emu_elf_source_t * source
Open source owning segment bytes.
uint32_t paddr
Segment physical load address.
uint32_t vaddr
Segment virtual address.
uint32_t flags
ELF program-header flags.
Exact result for source open and bounded view acquisition.
emu_elf_io_status_t status
Semantic completion status.
uint64_t supplied_bytes
Caller-provided scratch byte count.
int os_error
Captured host error, or zero.
uint64_t required_bytes
Source or requested range byte count.
One independently owned immutable raw-descriptor ELF source.
int fd
Owned regular-file descriptor, or -1 when closed.
uint64_t length
Stat-derived parsing bound.
One bounds-checked symbol-table entry plus its string offset.
uint64_t name_offset
Absolute source offset of the NUL-terminated name.
uint32_t size
Symbol byte extent.
uint32_t value
Symbol value.
uint8_t info
ELF st_info byte.
Transient view into caller-owned bounded scratch.
uint64_t offset
Starting source offset.
const uint8_t * bytes
Scratch containing the exact source bytes.
size_t length
Published exact byte count.