Encapsulation Symbols

Encapsulation symbols refer to a pair of symbols that can be generated, during the link-edit of a final object, that identify a unique section. These symbols are assigned the address of the beginning, and the address of the end, of the associated section, and thus encapsulate the section address range. The symbol pair are __start_<section_name> and __stop_<section_name> respectively. By default, both symbols are assigned a protected visibility.

Encapsulation symbols are created for a section when the following criteria are met.

  • The section is allocatable, and the section name does not start with the standard period (.) prefix.

  • A reference to the encapsulation symbol exists from the input relocatable objects provided with the link-edit.

Note:

There is no special attribute associated with the symbol reference that dictates they must be bound to a section range. If references to the symbols exist but no matching section exists in the input relocatable objects being processed, a fatal symbol resolution error can result. However, if references to the symbols exist, a matching section exists, but the matching section is discarded as unused, the symbols are assigned an address of 0.

The following section is a candidate for encapsulation symbols.

$ elfdump -cN_meta_data bar.o

Section Header[3]:  sh_name: _meta_data
    sh_addr:      0               sh_flags:   [ SHF_WRITE SHF_ALLOC ]
    sh_size:      0x4             sh_type:    [ SHT_PROGBITS ]
    sh_offset:    0xb8            sh_entsize: 0x4 (1 entry)
    ....

The following references trigger the creation of encapsulated symbols.

$ elfdump -s foo.o | fgrep __meta_
    [25]   0          0    NOTY GLOB  D  0 UNDEF       __start__meta_data
    [26]   0          0    NOTY GLOB  D  0 UNDEF       __stop__meta_data

$ cc -o main foo.o bar.o
$ elfdump -cN_meta_data main

Section Header[21]:  sh_name: _meta_data
    sh_addr:      0x8060e20       sh_flags:   [ SHF_WRITE SHF_ALLOC ]
    sh_size:      0x4             sh_type:    [ SHT_PROGBITS ]
    sh_offset:    0xe20           sh_entsize: 0x4 (1 entry)
    ....
$ elfdump -sN.symtab main | fgrep __meta_
    [32]   0x8060e20  0x4  OBJT GLOB  P  0 _meta_data  __start__meta_data
    [34]   0x8060e24    0  OBJT GLOB  P  0 _meta_data  __stop__meta_data