riscemu.types.program module

class riscemu.types.program.Program(name: str, base: Optional[int] = None)

Bases: object

This represents a collection of sections which together form an executable program

When you want to create a program which can be located anywhere in memory, set base to None, this signals the other components, that this is relocatable. Set the base of each section to the offset in the program, and everything will be taken care of for you.

property size
__init__(name: str, base: Optional[int] = None)
name: str
context: InstructionContext
sections: List[MemorySection]
global_labels: Set[str]
relative_labels: Set[str]
base: Optional[int]
is_loaded: bool
add_section(sec: MemorySection)
property entrypoint
loaded_trigger(at_addr: int)

This trigger is called when the binary is loaded and its final address in memory is determined

This will do a small sanity check to prevent programs loading twice, or at addresses they don’t expect to be loaded.

Then it will finalize all relative symbols defined in it to point to the correct addresses.

Parameters:

at_addr – the address where the program will be located