Skip to content

Latest commit

 

History

History
136 lines (113 loc) · 4.28 KB

FORMAT.md

File metadata and controls

136 lines (113 loc) · 4.28 KB

TIL Format

Here is a list of types used under the "Type" columns for reference.

Type Description
Integer types
uint8 Unsigned 8-bit value
uint16 Unsigned 16-bit value
uint32 Unsigned 32-bit value
uint64 Unsigned 64-bit value
String types
cstring Null terminated string
pstring Pascal string (length prefixed, no terminator byte)
plist Multiple pstring's joined together. The end of the plist is null terminated. Note that there are no separators between pstring's.
typestring Null terminated string that contains encoded type information

Header

ℹ️ See the TILHeader class in tilfile.py for implementation

Type Field
uint8[6] magic "IDATIL"
uint32 format flags/version
uint32 flags
pstring title
pstring base file name
uint8 compiler id (see comp_t in typeinfo.hpp)
uint8 memory model (see cm_t in typeinfo.hpp)
uint8 sizeof(int)
uint8 sizeof(bool)
uint8 sizeof(enum)
uint8 default alignment

This is read only if the TLD_ESI flag is set in flags.

Type Field
uint8 sizeof(short)
uint8 sizeof(long)
uint8 sizeof(long long)

This is read after only if the TLD_SLD flag is set in flags.

Type Field
uint8 sizeof(long double)

After this header follows 3 buckets that store type information.

Buckets

ℹ️ See the TILBucket class in tilfile.py for implementation

A til file has 3 buckets that contain symbols, types, and macros in order. The symbol bucket include typedefs and function signatures, the type bucket includes structs and enums, and the macro bucket contains macro definitions.

A til bucket's header structure depends on the til header's flags. If the TIL_ORD is set, then you'll find an extra uint32 for the number of ordinals at the beginning of the header and if the TIL_ZIP then you'll find an extra uint32 at the end of this header for the compressed size. TIL_ZIP also means that the data for all buckets is compressed. After this header follows the compressed or uncompressed type data. The first two buckets, for symbols and types, contain type information structured as TypeData while the macro bucket contains information structured as Macro.

Type Field
uint32 number of ordinals (this field only exists if TIL_ORD is set)
uint32 number of definitions
uint32 size of uncompressed data
uint32 size of compressed data (this field only exists if TIL_ZIP is set)

Type Data

ℹ️ See the TypeData class in tilfile.py for implementation

This data is present in both the symbol and type buckets (first and second). There is one of these per symbol/type.

Type Field
uint32 type flags (this needs more research)
cstring name
uint32 or uint64 ordinal (size depends on type flags)
typestring contains this type's encoded information
cstring type comment
plist fields
plist field comments
uint8 sclass

Decoding typestrings

ℹ️ See TypeString class in tilfile.py for implementation

ℹ️ See all deserialize methods in datatypes.py

TODO

Macro

ℹ️ See the Macro class in tilfile.py for implementation

This data is present in both the macro bucket. There is one of these per macro.

Type Field
cstring name
u8 number of arguments
u8 is function? (boolean)
cstring value; or expression where arguments are replaced with indexes