Skip to content

Array type object

Philippe Proulx edited this page Sep 10, 2020 · 3 revisions

A CTF array or sequence (dynamic array) type.

See also: Type object.

Properties

Property Type Description Required? Default value
class String Set to array Required N/A
element-type Type object or string (alias name) Type of array type's elements Required N/A
length Positive integer (static array) or string (dynamic array) Array type's length specification Required N/A

If the length property is the string dynamic, the array type has a variable length (CTF sequence).

The element-type property can only refer to the following type objects:

Examples

Static array of 16 bytes:

class: array
length: 16
element-type:
  class: int
  size: 8

Dynamic array of null-terminated strings:

class: array
length: dynamic
element-type:
  class: string

Dynamic array of static arrays of four double-precision floating point numbers:

class: array
length: dynamic
element-type:
  class: array
  length: 4
  element-type:
    class: float
    size:
      exp: 11
      mant: 53
    align: 64

Generated C types

Elements

For static and dynamic arrays, you pass the elements as a pointer to const TYPE, where TYPE is the generated C type of the element-type type object.

Examples:

Element type Generated C type
8-bit unsigned integer const uint8_t *
32-bit signed integer const int32_t *
Single-precision floating point number const float *
String const char * const *
Static array of 16-bit signed integers const int16_t * const *
Static array of double-precision floating point numbers const double * const *
Static array of strings const char * const * const *
Static array of static arrays of 32-bit unsigned integers const uint32_t * const * const *

Dynamic array length

For a dynamic array, barectf generates a uint32_t parameter before the element parameter to pass the dynamic array's length.

Example of generated parameters for a dynamic array of strings named array:

uint32_t __array_len, const char * const *array