fxos/doc/program-structure.md

1.9 KiB

Structure of programs in fxos

The loading and management of programs go through several layers that each have their own classes and concerns.

Loading layer

#include <fxos/vspace.h>
#include <fxos/memory.h>

The loading layer is concerned with emulating the virtual address space where the program is living. The address space is handled by VirtualSpace, which contains one or more Bindings of files or buffers to virtual addresses. The main methods in VirtualSpace are the read and search methods from the AbstractMemory typeclass.

General information about the address space in SuperH MPUs is available through <fxos/memory.h>, which lists MMU areas and their permissions in MemoryArea, and standard memory regions/chips in MemoryRegion.

(In previous versions of fxos, VirtualSpace was the entry point to find the disassembly, OS analysis, symbols, etc. This is now handled by Binary.)

While not explicitly supported yet, the loading layer could be used to load compiled add-ins or ELF files.

Binary layer

#include <fxos/binary.h>
#include <fxos/function.h>
#include <fxos/os.h>

The binary layer is concerned with reconstructing the source program from its binary code. The Binary object references a VirtualSpace and collects variable definitions, function definition, and analysis results.

Every reconstructed object in the program inherits from BinaryObject; this includes Variable, Function and the lightweight Mark. Functions are described in much greater detail in Functions.

Analysis results at the binary layer include:

  • OS analysis (in the future, maybe add-in analysis)
  • The function call graph (WIP)
  • Variable/function references and cross-references (WIP)

Project layer

#include <fxos/project.h>

The project layer collects multiple binaries in a same project (typically several versions of the same program) along with cross-binary analysis results.