If an object file participates in dynamic linking, its program header table will have an element of type PT_DYNAMIC. This segment contains the .dynamic section. A special symbol, _DYNAMIC, labels the section, which contains an array of the following structures (defined in sys/link.h):
typedef struct { Elf32_Sword d_tag; union { Elf32_Word d_val; Elf32_Addr d_ptr; Elf32_Off d_off; } d_un; } Elf32_Dyn; typedef struct { Elf64_Xword d_tag; union { Elf64_Xword d_val; Elf64_Addr d_ptr; } d_un; } Elf64_Dyn; |
For each object with this type, d_tag controls the interpretation of d_un.
These Elf32_Word objects represent integer values with various interpretations.
These Elf32_Addr objects represent program virtual addresses. As mentioned previously, a file's virtual addresses might not match the memory virtual addresses during execution. When interpreting addresses contained in the dynamic structure, the runtime linker computes actual addresses, based on the original file value and the memory base address. For consistency, files do not contain relocation entries to correct addresses in the dynamic structure.
The following table summarizes the tag requirements for executable and shared object files. If a tag is marked mandatory, then the dynamic linking array must have an entry of that type. Likewise, optional means an entry for the tag can appear but is not required.
Table 7-41 Dynamic Array Tags, d_tag
Name |
Value |
d_un |
Executable |
Shared Object |
---|---|---|---|---|
DT_NULL |
0 |
Ignored |
Mandatory |
Mandatory |
DT_NEEDED |
1 |
d_val |
Optional |
Optional |
DT_PLTRELSZ |
2 |
d_val |
Optional |
Optional |
DT_PLTGOT |
3 |
d_ptr |
Optional |
Optional |
DT_HASH |
4 |
d_ptr |
Mandatory |
Mandatory |
DT_STRTAB |
5 |
d_ptr |
Mandatory |
Mandatory |
DT_SYMTAB |
6 |
d_ptr |
Mandatory |
Mandatory |
DT_RELA |
7 |
d_ptr |
Mandatory |
Optional |
DT_RELASZ |
8 |
d_val |
Mandatory |
Optional |
DT_RELAENT |
9 |
d_val |
Mandatory |
Optional |
DT_STRSZ |
10 |
d_val |
Mandatory |
Mandatory |
DT_SYMENT |
11 |
d_val |
Mandatory |
Mandatory |
DT_INIT |
12 |
d_ptr |
Optional |
Optional |
DT_FINI |
13 |
d_ptr |
Optional |
Optional |
DT_SONAME |
14 |
d_val |
Ignored |
Optional |
DT_RPATH |
15 |
d_val |
Optional |
Ignored |
DT_SYMBOLIC |
16 |
Ignored |
Ignored |
Optional |
DT_REL |
17 |
d_ptr |
Mandatory |
Optional |
DT_RELSZ |
18 |
d_val |
Mandatory |
Optional |
DT_RELENT |
19 |
d_val |
Mandatory |
Optional |
DT_PLTREL |
20 |
d_val |
Optional |
Optional |
DT_DEBUG |
21 |
d_ptr |
Optional |
Ignored |
DT_TEXTREL |
22 |
Ignored |
Optional |
Optional |
DT_JMPREL |
23 |
d_ptr |
Optional |
Optional |
DT_VALRNGLO |
0x6ffffd00 |
Unspecified |
Unspecified |
Unspecified |
DT_MOVEENT |
0x6ffffdfa |
d_val |
Optional |
Optional |
DT_MOVESZ |
0x6ffffdfb |
d_val |
Optional |
Optional |
DT_FEATURE |
0x6ffffdfc |
d_val |
Optional |
Optional |
DT_POSFLAG_1 |
0x6ffffdfd |
d_val |
Optional |
Optional |
DT_SYMINSZ |
0x6ffffdfe |
d_val |
Optional |
Optional |
DT_SYMINENT |
0x6ffffdff |
d_val |
Optional |
Optional |
DT_VALRNGHI |
0x6ffffdff |
Unspecified |
Unspecified |
Unspecified |
DT_ADDRRNGLO |
0x6ffffe00 |
Unspecified |
Unspecified |
Unspecified |
DT_MOVETAB |
0x6ffffefe |
d_ptr |
Optional |
Optional |
DT_SYMINFO |
0x6ffffeff |
d_ptr |
Optional |
Optional |
DT_ADDRRNGHI |
0x6ffffeff |
Unspecified |
Unspecified |
Unspecified |
DT_RELACOUNT |
0x6ffffff9 |
d_val |
Optional |
Optional |
DT_RELCOUNT |
0x6ffffffa |
d_val |
Optional |
Optional |
DT_FLAGS_1 |
0x6ffffffb |
d_val |
Optional |
Optional |
DT_VERDEF |
0x6ffffffc |
d_ptr |
Optional |
Optional |
DT_VERDEFNUM |
0x6ffffffd |
d_val |
Optional |
Optional |
DT_VERNEED |
0x6ffffffe |
d_ptr |
Optional |
Optional |
DT_VERNEEDNUM |
0x6fffffff |
d_val |
Optional |
Optional |
DT_AUXILIARY |
0x7ffffffd |
d_val |
Unspecified |
Optional |
DT_USED |
0x7ffffffe |
d_val |
Optional |
Optional |
DT_FILTER |
0x7fffffff |
d_val |
Unspecified |
Optional |
DT_LOPROC |
0x70000000 |
Unspecified |
Unspecified |
Unspecified |
DT_SPARC_REGISTER |
0x70000001 |
d_val |
Optional |
Optional |
DT_HIPROC |
0x7fffffff |
Unspecified |
Unspecified |
Unspecified |
An entry with a DT_NULL tag marks the end of the _DYNAMIC array.
This element holds the string table offset of a null-terminated string, giving the name of a needed dependency. The offset is an index into the table recorded in the DT_STRTAB entry. See "Shared Object Dependencies" for more information about these names. The dynamic array can contain multiple entries with this type. These entries' relative order is significant, though their relation to entries of other types is not.
This element holds the total size, in bytes, of the relocation entries associated with the procedure linkage table. If an entry of type DT_JMPREL is present, a DT_PLTRELSZ must accompany it.
This element holds an address associated with the procedure linkage table and/or the global offset table.
This element points to the symbol hash table, described in "Hash Table". This hash table refers to the symbol table indicated by the DT_SYMTAB element.
This element holds the address of the string table, described in the first part of this chapter. Symbol names, dependency names, and other strings required by the runtime linker reside in this table.
This element holds the address of the symbol table, described in the first part of this chapter, with Elf32_Sym entries for the 32-bit class of files.
This element holds the address of a relocation table, described in the first part of this chapter. Entries in the table have explicit addends, such as Elf32_Rela for the 32-bit file class.
An object file can have multiple relocation sections. When building the relocation table for an executable or shared object file, the link-editor catenates those sections to form a single table. Although the sections remain independent in the object file, the runtime linker sees a single table. When the runtime linker creates the process image for an executable file or adds a shared object to the process image, it reads the relocation table and performs the associated actions.
If this element is present, the dynamic structure must also have DT_RELASZ and DT_RELAENT elements. When relocation is mandatory for a file, either DT_RELA or DT_REL can occur (both are permitted but not required).
This element holds the total size, in bytes, of the DT_RELA relocation table.
This element holds the size, in bytes, of the DT_RELA relocation entry.
This element holds the size, in bytes, of the string table.
This element holds the size, in bytes, of a symbol table entry.
This element holds the address of the SHT_SUNW_syminfo section.
This element holds the size, in bytes, of a SHT_SUNW_syminfo table entry.
This element holds the size, in bytes, of a SHT_SUNW_syminfo section.
This element holds the address of the initialization function, discussed in "Initialization and Termination Functions".
This element holds the address of the termination function, discussed in "Initialization and Termination Functions".
This element holds the string table offset of a null-terminated string, giving the name of the shared object. The offset is an index into the table recorded in the DT_STRTAB entry. See "Shared Object Dependencies" for more information about these names.
This element holds the string table offset of a null-terminated search library search path string, discussed in "Shared Objects With Dependencies". The offset is an index into the table recorded in the DT_STRTAB entry.
This element's presence in a shared object library alters the runtime linker's symbol resolution algorithm for references within the library. Instead of starting a symbol search with the executable file, the runtime linker starts from the shared object itself. If the shared object fails to supply the referenced symbol, the runtime linker then searches the executable file and other shared objects as usual.
This element is similar to DT_RELA, except its table has implicit addends, such as Elf32_Rel for the 32-bit file class. If this element is present, the dynamic structure must also have DT_RELSZ and DT_RELENT elements.
This element holds the total size, in bytes, of the DT_REL relocation table.
This element holds the size, in bytes, of the DT_REL relocation entry.
This member specifies the type of relocation entry to which the procedure linkage table refers. The d_val member holds DT_REL or DT_RELA, as appropriate. All relocations in a procedure linkage table must use the same relocation.
This member is used for debugging.
This member's absence signifies that no relocation entry should cause a modification to a non-writable segment, as specified by the segment permissions in the program header table. If this member is present, one or more relocation entries might request modifications to a non-writable segment, and the runtime linker can prepare accordingly.
If present, this entry's d_val member holds various state flags. See Table 7-42.
If present, this entry's d_val member holds various state flags. These flags are to be applied to the immediatly following DT_* entry in the .dynamic section.
If present, this entry's d_ptr member holds the address of relocation entries associated solely with the procedure linkage table. Separating these relocation entries lets the runtime linker ignore them during process initialization, if lazy binding is enabled. If this entry is present, the related entries of types DT_PLTRELSZ and DT_PLTREL must also be present.
Holds the address of the version definition table, described in the first part of this chapter, with Elf32_Verdef entries for the 32-bit class of files. See section "Version Definition Section" for more information. Elements within these entries contain indexes into the table recorded in the DT_STRTAB entry.
This element specifies the number of entries in the version definition table.
Holds the address of the version dependency table, described in the first part of this chapter, with Elf32_Verneed entries for the 32-bit class of files. See section "Version Dependency Section" for more information. Elements within these entries contain indexes into the table recorded in the DT_STRTAB entry.
This element specifies the number of entries in the version dependency table.
All Elf32_Rela R_*_RELATIVE relocations have been placed into a single block and this entry specifies the number of entries in that block. This permits ld.so.1 to streamline the processing of RELATIVE relocations.
All Elf32_Rel R_*_RELATIVE relocations have been placed into a single block and this entry specifies the number of entries in that block. This permits ld.so.1 to streamline the processing of RELATIVE relocations.
Holds the string table offset of a null-terminated string that names an object. The offset is an index into the table recorded in the DT_STRTAB entry. Symbols in the auxiliary object will be used in preference to the symbols within this object.
Holds the string table offset of a null-terminated string that names an object. The offset is an index into the table recorded in the DT_STRTAB entry. The symbol table of this object acts as a filter for the symbol table of the named object.
This element holds the total size of the section defined by SHT_SUNW_move. See "Move Section".
This element holds the size, in bytes, of the DT_MOVETAB move entry.
This element holds the address of a move table, described in the first part of this chapter. Entries in the table have Elf32_Move entries for the 32-bit class of files.
If present, this entry's d_val member holds various feature flags defined by DTF_1_*. The feature values are used by the check_rtld_feature() function called by application at runtime to check if the features needed are supported or not.
Values in this inclusive range use the Dyn.d_un.d_val field of the Dynamic structure.
Values in this inclusive range use the Dyn.d_un.d_ptr field of the Dynamic structure. If any adjustment is made to the ELF object after it has been built these entries will need to be adjusted.
This element contains the index of an STT_SPARC_REGISTER symbol. There is one of these entries for every STT_SPARC_REGISTER symbol table entry in the symbol table.
Values in this inclusive range are reserved for processor-specific semantics.
The following dynamic state flags are presently available:
Table 7-42 Dynamic Tags, DT_FLAGS_1
Name |
Value |
Meaning |
---|---|---|
DF_1_NOW |
0x1 |
Perform complete relocation processing |
DT_1_GLOBAL |
0x2 |
Unused |
DT_1_GROUP |
0x4 |
Indicate object is a member of a group |
DT_1_NODELETE |
0x8 |
Object cannot be deleted from a process |
DT_1_LOADFLTR |
0x10 |
Ensure immediate loading of filtee(s) |
DT_1_INITFIRST |
0x20 |
Run objects' initialization first |
DT_1_NOOPEN |
0x40 |
Object can not be used with dlopen(3X) |
DT_1_DIRECT |
0x100 |
Direct bindings enabled |
DT_1_INTERPOSE |
0x400 |
Object is an interposer |
When the object is loaded, all relocation processing is completed; see "When Relocations Are Performed". This state is recorded in the object using the link-editors' -z now option.
Indicates that the object is a member of a group; see "Symbol Lookup". This state is recorded in the object using the link-editors' -B group option.
Indicates that the object cannot be deleted from a process. Thus, if the object is loaded in a process, either directly or as a dependency, with dlopen(3X), it cannot be unloaded with dlclose(3X). This state is recorded in the object using the link-editors' -z nodelete option.
This state is only meaningful for filters (see "Shared Objects as Filters"). When the filter is loaded, all associated filtees are immediately processe; see "Filtee Processing". This state is recorded in the object using the link-editors' -z loadfltr option.
When the object is loaded, its initialization section is run before any other objects loaded with it; see "Initialization and Termination Routines". This specialized state is intended for libthread.so.1. This state is recorded in the object using the link-editors' -z initfirst option.
Indicates that the object cannot be added to a running process with dlopen(3X). This state is recorded in the object using the link-editors' -z nodlopen option.
Object has direct bindings information. This state is recorded in the object using the link-editors' -B direct option
The objects symbol table is to interpose before all symbols but the primary executable. This is enabled with the link-editors' -z interpose option.
Name |
Value |
Meaning |
---|---|---|
DF_P1_LAZYLOAD |
0x1 |
The following object is to be lazily loaded |
DT_P1_GROUPPERM |
0x2 |
The following object is to be loaded with groupperms |
The following DT_* entry identifies an object to be loaded. The loading of this object is to be delayed until a symbol binding identified by a Syminfo table entry specifically references this object.
The following DT_* entry identifies an object to be loaded. The symbols in this object are not available for general symbol resolution, instead they are only available to the object(s) which caused it to be loaded.
The following dynamic feature flags are presently available:
Table 7-44 Dynamic Feature Flags, DT_FEATURE
Name |
Value |
Meaning |
---|---|---|
DTF_1_PARINIT |
0x1 |
The partially initialization feature is required. |
Except for the DT_NULL element at the end of the dynamic array and the relative order of DT_NEEDED and DT_POSFLAG_1 elements, entries can appear in any order. Tag values not appearing in the table are reserved.