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.
-
ASSERT
attributes are not required when theSTUB_OBJECT
directive is not used. However, ifASSERT
attributes exist, their attributes are verified against the real values collected with the link-edit. Should anyASSERT
attributes not match their associated real values, the link-edit terminates unsuccessfully. -
When the
STUB_OBJECT
directive is used, and the-z stub
command line option is specified, the link-editor uses theASSERT
directives to define the attributes of the global symbols provided by the object. See Stub Objects. -
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 associatedASSERT
directive that declares it as data and supplies a size. In this mode, if theTYPE
ASSERT
attribute is not specified,GLOBAL
is assumed. Similarly, ifSH_ATTR
is not specified, a default value ofBITS
is assumed. These defaults ensure that the data attributes of the stub and real objects are compatible. The resultingASSERT
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 theTYPE
,SIZE
, andSH_ATTR
attributes. WhenALIAS
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 theSTB_
prefix removed. For example,GLOBAL
, orWEAK
. -
TYPE
-
Specifies an ELF symbol_type, which can be any of the
STT_
constants defined in<sys/elf.h>
, with theSTT_
prefix removed. For example,OBJECT
,COMMON
, orFUNC
. In addition, for compatibility with othermapfile
usage,FUNCTION
andDATA
can be specified forSTT_FUNC
andSTT_OBJECT
, respectively.TYPE
cannot be used withALIAS
. -
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 withALIAS
. -
SIZE
-
Specifies the expected symbol size.
SIZE
cannot be used withALIAS
. The syntax for the size_value argument is as described in the discussion of theSIZE
attribute. See SIZE Attribute. -
VALUE
-
Specifies the expected symbol value.
Table 10-9
SH_ATTR
Values
Section Attribute | Meaning |
---|---|
|
Section is not of type
|
|
Section is of type |