-
Notifications
You must be signed in to change notification settings - Fork 1
Executable Format
The executable format used by ParaVM is called PVC (Parallella Virtual Code). It's a simple binary representation of the PVA (Parallella Virtual Assembly) assembly language.
The format encodes all integers as little endian. Strings are stored as a 32-bit unsigned length followed by the string's characters (without the null terminator).
The file header can be expressed as a pseudo-C structure like this:
struct PVCHeader
{
uint32_t fourcc;
uint32_t version;
};
The fourcc
field must equal 0x43565000
("PVC\0"
). It identifies the file format.
The version
field identifies the version of ParaVM the module was written by/for. A virtual machine or tool is allowed to reject the module if the version is not supported.
The main structure of the format can be expressed as a pseudo-C structure like this:
struct PVCModule
{
uint32_t function_count;
struct
{
char *function_name;
uint32_t register_count;
struct
{
char *register_name;
uint8_t is_argument;
} registers[register_count];
uint32_t block_count;
struct
{
char *block_name;
} block_names[block_count];
struct
{
char *block_name;
uint8_t has_handler_block;
if (has_handler_block)
{
char *handler_block_name;
}
uint8_t has_exception_register;
if (has_exception_register)
{
char *exception_register_name;
}
uint32_t instruction_count;
struct
{
uint8_t code;
uint32_t instruction_register_count;
struct
{
char *instruction_register_name;
} instruction_registers[instruction_register_count];
union
{
char *string;
char *block;
char *blocks[2];
} operand;
} instructions[instruction_count];
} blocks[block_count];
} functions[function_count];
};
The purpose of the block name array is so that the program reading the file can create the blocks before reading instructions that refer to them.