A.4 Executable File Formats
Both formats that are supported for the moment, start with the unsigned 8-bit
integer version number and are big-endian (bytes are read from left to right).
Version 0: small and simple, but inflexible. File consists of:
• Version (8-bit unsigned integer), followed by 8-bit padding
• Global/static data length in words (32-bit unsigned integer)
• Global/static data fixed-size section
• Code and code data fixed-size section
In this case, we simply read as many words as specified in Data Length section, and
then read the rest as a Code. This method has few possibilities to break, but doesn’t
allow the user to place the sections in an arbitrary order while also being poorly
adaptable and not allowing additional metadata to be inserted into the file.
File structure example (version 0, Table 20.2).
Please notice that data and code are nonsensical, and are here just for example.
Version 1: more comprehensive and much more flexible version, even allowing
for compiler/debug metadata:
• Version number (8-bit unsigned integer), followed by 8-bit padding
• Global/static data start position relative to the beginning of the file in bytes
(32-bit unsigned integer)
• Global/static data length in words (32-bit unsigned integer)
• Code start position relative to the beginning of the file in bytes (32-bit unsigned
integer)
• Code length in words (32-bit unsigned integer)
• Global/static data fixed-size section, code and code data fixed-size section in any
order
This version is very flexible. Sections can be put anywhere and in any order.
Additional elements, such as additional headers and meta-information, can be put in
enum format_t {
F_8_BIT,
F_16_BIT,
F_32_BIT,
};
Fig. 20.5 Format types
Table 20.2 File structure
example
2 bytes Version + Padding
00 00
4 bytes data length
00 00 00 02
4 bytes static data
FF F2 FF F4
6 bytes code
AD DC 56 69 F7 B1
Appendix 1: Internal Structure of ERRIC Interpreter and API Description
301
Both formats that are supported for the moment, start with the unsigned 8-bit
integer version number and are big-endian (bytes are read from left to right).
Version 0: small and simple, but inflexible. File consists of:
• Version (8-bit unsigned integer), followed by 8-bit padding
• Global/static data length in words (32-bit unsigned integer)
• Global/static data fixed-size section
• Code and code data fixed-size section
In this case, we simply read as many words as specified in Data Length section, and
then read the rest as a Code. This method has few possibilities to break, but doesn’t
allow the user to place the sections in an arbitrary order while also being poorly
adaptable and not allowing additional metadata to be inserted into the file.
File structure example (version 0, Table 20.2).
Please notice that data and code are nonsensical, and are here just for example.
Version 1: more comprehensive and much more flexible version, even allowing
for compiler/debug metadata:
• Version number (8-bit unsigned integer), followed by 8-bit padding
• Global/static data start position relative to the beginning of the file in bytes
(32-bit unsigned integer)
• Global/static data length in words (32-bit unsigned integer)
• Code start position relative to the beginning of the file in bytes (32-bit unsigned
integer)
• Code length in words (32-bit unsigned integer)
• Global/static data fixed-size section, code and code data fixed-size section in any
order
This version is very flexible. Sections can be put anywhere and in any order.
Additional elements, such as additional headers and meta-information, can be put in
enum format_t {
F_8_BIT,
F_16_BIT,
F_32_BIT,
};
Fig. 20.5 Format types
Table 20.2 File structure
example
2 bytes Version + Padding
00 00
4 bytes data length
00 00 00 02
4 bytes static data
FF F2 FF F4
6 bytes code
AD DC 56 69 F7 B1
Appendix 1: Internal Structure of ERRIC Interpreter and API Description
301
