ASSERT Attribute

The ASSERT attribute is used to specify the expected characteristics of the symbol. The link-editor compares the symbol characteristics that result from the link-edit to those given by ASSERT attributes. If the real and asserted attributes do not agree, a fatal error is issued and the output object is not created.

The interpretation of the ASSERT attribute is dependent on whether the STUB_OBJECT directive or -z stub command line option are used. The three possible cases are as follows.

  1. ASSERT attributes are not required when the STUB_OBJECT directive is not used. However, if ASSERT attributes exist, their attributes are verified against the real values collected with the link-edit. Should any ASSERT attributes not match their associated real values, the link-edit terminates unsuccessfully.

  2. When the STUB_OBJECT directive is used, and the -z stub command line option is specified, the link-editor uses the ASSERT directives to define the attributes of the global symbols provided by the object. See Stub Objects.

  3. When the STUB_OBJECT directive is used, and -z stub command line option is not specified, the link-editor requires that all global data in the resulting object have an associated ASSERT directive that declares it as data and supplies a size. In this mode, if the TYPE ASSERT attribute is not specified, GLOBAL is assumed. Similarly, if SH_ATTR is not specified, a default value of BITS is assumed. These defaults ensure that the data attributes of the stub and real objects are compatible. The resulting ASSERT statements are evaluated in the same manner as in the first case. See STUB_OBJECT Directive.

ASSERT accepts the following attributes.

ALIAS

Defines an alias for a previously defined symbol. An alias symbol has the same type, value, and size as the main symbol. The ALIAS attribute cannot be used with the TYPE, SIZE, and SH_ATTR attributes. When ALIAS is specified, the type, size, and section attributes are obtained from the alias symbol.

BINDING

Specifies an ELF symbol_binding, which can be any of the STB_ values defined in <sys/elf.h>, with the STB_ prefix removed. For example, GLOBAL, or WEAK.

TYPE

Specifies an ELF symbol_type, which can be any of the STT_ constants defined in <sys/elf.h>, with the STT_ prefix removed. For example, OBJECT, COMMON, or FUNC. In addition, for compatibility with other mapfile usage, FUNCTION and DATA can be specified for STT_FUNC and STT_OBJECT, respectively. TYPE cannot be used with ALIAS.

SH_ATTR

Specifies attributes of the section associated with the symbol. The section_attributes that can be specified are given in Table 10-9. SH_ATTR cannot be used with ALIAS.

SIZE

Specifies the expected symbol size. SIZE cannot be used with ALIAS. The syntax for the size_value argument is as described in the discussion of the SIZE attribute. See SIZE Attribute.

VALUE

Specifies the expected symbol value.

Table 10-9 SH_ATTR Values

Section Attribute Meaning

BITS

Section is not of type SHT_NOBITS

NOBITS

Section is of type SHT_NOBITS