Linker and Libraries Guide

Versioning Information

Objects created by the link-editor can contain two types of versioning information:

The structures that form these sections are defined in sys/link.h. Sections that contain versioning information are named .SUNW_version.

Version Definition Section

This section is defined by the type SHT_SUNW_verdef. If this section exists, a SHT_SUNW_versym section must also exist. Using these two structures, an association of symbols-to-version definitions is maintained within the file (see "Creating a Version Definition" for more details). Elements of this section have the following structure:


typedef struct {
        Elf32_Half      vd_version;
        Elf32_Half      vd_flags;
        Elf32_Half      vd_ndx;
        Elf32_Half      vd_cnt;
        Elf32_Word      vd_hash;
        Elf32_Word      vd_aux;
        Elf32_Word      vd_next;
} Elf32_Verdef;
 
typedef struct {
        Elf32_Word      vda_name;
        Elf32_Word      vda_next;
} Elf32_Verdaux;

typedef struct {
        Elf64_Half      vd_version;
        Elf64_Half      vd_flags;
        Elf64_Half      vd_ndx;
        Elf64_Half      vd_cnt;
        Elf64_Word      vd_hash;
        Elf64_Word      vd_aux;
        Elf64_Word      vd_next;
} Elf64_Verdef;
 
typedef struct {
        Elf64_Word      vda_name;
        Elf64_Word      vda_next;
} Elf64_Verdaux;
vd_version

This member identifies the version of the structure itself.

Table 7-29 Version Definition Structure Versions

Name 

Value 

Meaning  

VER_DEF_NONE

0

Invalid version  

VER_DEF_CURRENT

>=1

Current version  

The value 1 signifies the original section format; extensions will create new versions with higher numbers. The value of VER_DEF_CURRENT changes as necessary to reflect the current version number.

vd_flags

This member holds version definition-specific information.

Table 7-30 Version Definition Section Flags

Name 

Value 

Meaning  

VER_FLG_BASE

0x1

Version definition of the file itself  

VER_FLG_WEAK

0x2

Weak version identifier  

The base version definition is always present when version definitions, or symbol auto-reduction, has been applied to the file. The base version provides a default version for the files reserved symbols (see "Generating the Output Image"). A weak version definition has no symbols associated with it (see "Creating a Weak Version Definition" for more details).

vd_ndx

This member holds the version index. Each version definition has a unique index that is used to associate SHT_SUNW_versym entries to the appropriate version definition.

vd_cnt

This member indicates the number of elements in the Elf32_Verdaux array.

vd_hash

This member holds the hash value of the version definition name (this value is generated using the same hashing function described in "Hash Table").

vd_aux

This member holds the byte offset, from the start of this Elf32_Verdef entry, to the Elf32_Verdaux array of version definition names. The first element of the array must exist and points to the version definition string this structure defines. Additional elements can be present, the number being indicated by the vd_cnt value. These elements represent the dependencies of this version definition. Each of these dependencies will have its own version definition structure.

vd_next

This member holds the byte offset, from the start of this Elf32_Verdef structure, to the next Elf32_Verdef entry.

vda_name

This member holds a string table offset to a null-terminated string, giving the name of the version definition.

vda_next

This member holds the byte offset, from the start of this Elf32_Verdaux entry, to the next Elf32_Verdaux entry.

Version Symbol Section

This section is defined by the type SHT_SUNW_versym, and consists of an array of elements having the following structure:


typedef Elf32_Half      Elf32_Versym;
typedef Elf64_Half      Elf64_Versym;

The number of elements of the array must equal the number of symbol table entries contained in the associated symbol table (determined by the sections sh_link value). Each element of the array contains a single index that can have the following values:

Table 7-31 Version Dependency Indexes

Name 

Value 

Meaning  

VER_NDX_LOCAL

0

Symbol has local scope  

VER_NDX_GLOBAL

1

Symbol has global scope (assigned to base version definition) 

 

>1

Symbol has global scope (assigned to user-defined version definition) 

Any index values greater than VER_NDX_GLOBAL must correspond to the vd_ndx value of an entry in the SHT_SUNW_verdef section. If no index values greater than VER_NDX_GLOBAL exist, then no SHT_SUNW_verdef section need be present.

Version Dependency Section

This section is defined by the type SHT_SUNW_verneed. This section compliments the dynamic dependency requirements of the file by indicating the version definitions required from these dependencies. Only if a dependency contains version definitions will a recording be made in this section. Elements of this section have the following structure:


typedef struct {
        Elf32_Half      vn_version;
        Elf32_Half      vn_cnt;
        Elf32_Word      vn_file;
        Elf32_Word      vn_aux;
        Elf32_Word      vn_next;
} Elf32_Verneed;
 
typedef struct {
        Elf32_Word      vna_hash;
        Elf32_Half      vna_flags;
        Elf32_Half      vna_other;
        Elf32_Word      vna_name;
        Elf32_Word      vna_next;
} Elf32_Vernaux;

typedef struct {
        Elf64_Half      vn_version;
        Elf64_Half      vn_cnt;
        Elf64_Word      vn_file;
        Elf64_Word      vn_aux;
        Elf64_Word      vn_next;
} Elf64_Verneed;
 
typedef struct {
        Elf64_Word      vna_hash;
        Elf64_Half      vna_flags;
        Elf64_Half      vna_other;
        Elf64_Word      vna_name;
        Elf64_Word      vna_next;
} Elf64_Vernaux;
vn_version

This member identifies the version of the structure itself.

Table 7-32 Version Dependency Structure Versions

Name 

Value 

Meaning  

VER_NEED_NONE

0

Invalid version  

VER_NEED_CURRENT

>=1

Current version  

The value 1 signifies the original section format; extensions will create new versions with higher numbers. The value of VER_NEED_CURRENT changes as necessary to reflect the current version number.

vn_cnt

This member indicates the number of elements in the Elf32_Vernaux array.

vn_file

This member holds a string table offset to a null-terminated string, giving the filename having a version dependency. This name will match one of the .dynamic dependencies (refer to "Dynamic Section") found in the file.

vn_aux

This member holds the byte offset, from the start of this Elf32_Verneed entry, to the Elf32_Vernaux array of version definitions required from the associated file dependency. There must exist at least one version dependency. Additional version dependencies can be present, the number being indicated by the vn_cnt value.

vn_next

This member holds the byte offset, from the start of this Elf32_Verneed entry, to the next Elf32_Verneed entry.

vna_hash

This member holds the hash value of the version dependency name (this value is generated using the same hashing function described in "Hash Table").

vna_flags

This member holds version dependency specific information.

Table 7-33 Version Dependency Structure Flags

Name 

Value 

Meaning  

VER_FLG_WEAK

0x2

Weak version identifier  

A weak version dependency indicates an original binding to a weak version definition. See "Creating a Version Definition" for more details.

vna_other

This member is presently unused.

vna_name

This member holds a string table offset to a null-terminated string, giving the name of the version dependency.

vna_next

This member holds the byte offset, from the start of this Elf32_Vernaux entry, to the next Elf32_Vernaux entry.