4. Application Binary Interface

4.1. Name Mangling

4.1.1. Functions

Function mangled name is composed of the following sequence:

  1. A literal _P
  2. Function name encoding:
    1. Number of characters in the function’s base name
    2. The function’s base name, verbatim
  3. Function’s return type
    1. A literal R
    2. mangled name of return type
    3. A literal E
  4. Function’s parameters
    1. A literal P
    2. All positional parameters’ mangled type name in sequence.
    3. A literal E

4.1.2. Types Modifiers

  • Mutable types have a prefix m
  • Reference types begin with r Scalar (built-in) types

Built-in types mangle according to the following table:

Type Mangled name
Void v
Bool b
Signed integer s followed by number of bytes (S8 is s1)
Unsigned integer u followed by number of bytes
Character c followed by number of bytes Pointers

Pointer type is mangled as p followed by the pointed to type mangling Arrays

  1. A literal A
  2. Number signifying the array’s dimensions
  3. Mangled name of element type