Next: , Previous: , Up: CTF dictionaries   [Contents][Index]


2.2 CTF header

The CTF header is the first part of a CTF dictionary, including the preamble. All parts of it other than the preamble (see section CTF Preamble) can vary between CTF file versions and are never compressed. It contains things that apply to the dictionary as a whole, and a table of the sections into which the rest of the dictionary is divided. The sections tile the file: each section runs from the offset given until the start of the next section. Only the last section cannot follow this rule, so the header has a length for it instead.

All section offsets, here and in the rest of the CTF file, are relative to the end of the header. (This is annoyingly different to how offsets in CTF archives are handled.)

This is the first structure to include offsets into the string table, which are not straight references because CTF dictionaries can include references into the ELF string table to save space, as well as into the string table internal to the CTF dictionary. See section The string section for more on these. Offset 0 is always the null string.

typedef struct ctf_header
{
  ctf_preamble_t cth_preamble;
  uint32_t cth_parlabel;
  uint32_t cth_parname;
  uint32_t cth_cuname;
  uint32_t cth_lbloff;
  uint32_t cth_objtoff;
  uint32_t cth_funcoff;
  uint32_t cth_objtidxoff;
  uint32_t cth_funcidxoff;
  uint32_t cth_varoff;
  uint32_t cth_typeoff;
  uint32_t cth_stroff;
  uint32_t cth_strlen;
} ctf_header_t;

In detail:

OffsetNameDescription
0x00ctf_preamble_t cth_preamble The preamble (conceptually embedded in the header). See section CTF Preamble
0x04uint32_t cth_parlabel The parent label, if deduplication happened against a specific label: a strtab offset. See section The label section. Currently unused and always 0, but may be used in future when semantics are attached to the label section.
0x08uint32_t cth_parname The name of the parent dictionary deduplicated against: a strtab offset. Interpretation is up to the consumer (usually a CTF archive member name). 0 (the null string) if this is not a child dictionary.
0x1cuint32_t cth_cuname The name of the compilation unit, for consumers like GDB that want to know the name of CUs associated with single CUs: a strtab offset. 0 if this dictionary describes types from many CUs.
0x10uint32_t cth_lbloff The offset of the label section, which tiles the type space into named regions. See section The label section.
0x14uint32_t cth_objtoff The offset of the data object symtypetab section, which maps ELF data symbols to types. See section The symtypetab sections.
0x18uint32_t cth_funcoff The offset of the function info symtypetab section, which maps ELF function symbols to a return type and arg types. See section The symtypetab sections.
0x1cuint32_t cth_objtidxoff The offset of the object index section, which maps ELF object symbols to entries in the data object section. See section The symtypetab sections.
0x20uint32_t cth_funcidxoff The offset of the function info index section, which maps ELF function symbols to entries in the function info section. See section The symtypetab sections.
0x24uint32_t cth_varoff The offset of the variable section, which maps string names to types. See section The variable section.
0x28uint32_t cth_typeoff The offset of the type section, the core of CTF, which describes types using variable-length array elements. See section The type section.
0x2cuint32_t cth_stroff The offset of the string section. See section The string section.
0x30uint32_t cth_strlen The length of the string section (not an offset!). The CTF file ends at this point.

Everything from this point on (until the end of the file at cth_stroff + cth_strlen) is compressed with zlib if CTF_F_COMPRESS is set in the preamble’s ctp_flags.


Next: , Previous: , Up: CTF dictionaries   [Contents][Index]