Elf File ======== After parsing (:any:`_elf.parse_elf`) the list of all instruction encodings the provided elf file is parsed to generate the dictionary of \ the specific instructions compiled for this application. Header and Attributes --------------------- From the elf file the header and attribute sections are read. This provides details of: 1. The machine type - this must match RISCV, otherwise an error is generated. 2. The base and extensions provided to the compiler. As mentioned previously, the base and extensions are used to prune the dict of available instruction encodings. Details of supported base and extensions (with versions) are available in :any:`_elf.EXTENSIONS`. Instructions ------------ All instructions (:any:`_instr.Instruction`), indexed by program counter are extracted into :any:`_elf.INSTRUCTIONS`. This class provides the details of the pc, instruction encoding, operand values and previous / next instruction in programmatic order. This effectively provides a doubly linked list allowing the user to traverse forwards and backwards across the application. This is useful when needing the context of a given instruction for example: 1. Is a compressed instruction half or word aligned? 2. Would a jump have been followed by a given instruction? .. graphviz:: digraph DLL { rankdir=LR; node [shape=record]; /* List nodes */ n1 [label="1st in program"]; n2 [label="2nd in program"]; n3 [label="3rd in program"]; n1 -> n2 [label="next"]; n2 -> n3 [label="next"]; n2 -> n1 [label="prev"]; n3 -> n2 [label="prev"]; }