DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Object files

Dynamic section

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.

   typedef struct {
   	Elf32_Sword	d_tag;
      	union {
      		Elf32_Word	d_val;
      		Elf32_Addr	d_ptr;
   	} d_un;
   } Elf32_Dyn;
   

extern Elf32_Dyn _DYNAMIC[];

typedef struct { Elf64_Sxword d_tag; union { Elf64_Xword d_val; Elf64_Addr d_ptr; } d_un; } Elf64_Dyn;

extern Elf64_Dyn _DYNAMIC[];

Dynamic structure

For each object with this type, d_tag controls the interpretation of d_un.


d_val
These objects represent integer values with various interpretations.

d_ptr
These 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 dynamic 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.

To make it simpler for tools to interpret the contents of dynamic section entries, the value of each tag, except for those in two special compatibility ranges, will determine the interpretation of the d_un union. A tag whose value is an even number indicates a dynamic section entry that uses d_ptr. A tag whose value is an odd number indicates a dynamic section entry that uses d_val or that uses neither d_ptr nor d_val. Tags whose values are less than the special value DT_ENCODING and tags whose values fall between DT_HIOS and DT_LOPROC do not follow these rules.

The following table summarizes the tag requirements for executable and shared object files. If a tag is marked ``mandatory'', the dynamic linking array for an ABI-conforming file must have an entry of that type. Likewise, ``optional'' means an entry for the tag may appear but is not required.

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_BIND_NOW* 24 ignored optional optional
DT_INIT_ARRAY 25 d_ptr optional optional
DT_FINI_ARRAY 26 d_ptr optional optional
DT_INIT_ARRAYSZ 27 d_val optional optional
DT_FINI_ARRAYSZ 28 d_val optional optional
DT_RUNPATH 29 d_val optional optional
DT_FLAGS 30 d_val optional optional
DT_ENCODING 32 unspecified unspecified unspecified
DT_PREINIT_ARRAY 32 d_ptr optional ignored
DT_PREINIT_ARRAYSZ 33 d_val optional ignored
DT_LOOS 0x6000000D unspecified unspecified unspecified
DT_HIOS 0x6ffff000 unspecified unspecified unspecified
DT_LOPROC 0x70000000 unspecified unspecified unspecified
DT_HIPROC 0x7fffffff unspecified unspecified unspecified

Dynamic array tags, d_tag

* Signifies an entry that is at level 2.


DT_NULL
An entry with a DT_NULL tag marks the end of the _DYNAMIC array.

DT_NEEDED
This element holds the string table offset of a null-terminated string, giving the name of a needed library. The offset is an index into the table recorded in the code. See ``Shared object dependencies'' for more information about these names. The dynamic array may contain multiple entries with this type. These entries' relative order is significant, though their relation to entries of other types is not.

DT_PLTRELSZ
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.

DT_PLTGOT
This element holds an address associated with the procedure linkage table and/or the global offset table. See this section in the processor supplement for details.

DT_HASH
This element holds the address of the symbol hash table, described in ``Hash table''. This hash table refers to the symbol table referenced by the DT_SYMTAB element.

DT_STRTAB
This element holds the address of the string table, described in ``String table''. Symbol names, library names, and other strings reside in this table.

DT_SYMTAB
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 and Elf64_Sym entries for the 64-bit class of files.

DT_RELA
This element holds the address of a relocation table, described in ``Relocation''. Entries in the table have explicit addends, such as Elf32_Rela for the 32-bit file class or Elf64_Rela for the 64-bit file class. An object file may 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 dynamic linker sees a single table. When the dynamic 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 may occur (both are permitted but not required).

DT_RELASZ
This element holds the total size, in bytes, of the DT_RELA relocation table.

DT_RELAENT
This element holds the size, in bytes, of the DT_RELA relocation entry.

DT_STRSZ
This element holds the size, in bytes, of the string table.

DT_SYMENT
This element holds the size, in bytes, of a symbol table entry.

DT_INIT
This element holds the address of the initialization function, discussed in ``Initialization and termination functions''.

DT_FINI
This element holds the address of the termination function, discussed in ``Initialization and termination functions''.

DT_SONAME
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.

DT_RPATH
This element holds the string table offset of a null-terminated search library search path string discussed in ``Shared object dependencies''. The offset is an index into the table recorded in the DT_STRTAB entry. This entry is at level 2. Its use has been superseded by DT_RUNPATH.

DT_SYMBOLIC
This element's presence in a shared object library alters the dynamic linker's symbol resolution algorithm for references within the library. Instead of starting a symbol search with the executable file, the dynamic linker starts from the shared object itself. If the shared object fails to supply the referenced symbol, the dynamic linker then searches the executable file and other shared objects as usual. This entry is at level 2. Its use has been superseded by the flag.

DT_REL
This element is similar to DT_RELA, except its table has implicit addends, such as Elf32_Rel for the 32-bit file class or Elf64_Rel for the 64-bit file class. If this element is present, the dynamic structure must also have DT_RELSZ and DT_RELENT elements.

DT_RELSZ
This element holds the total size, in bytes, of the DT_REL relocation table.

DT_RELENT
This element holds the size, in bytes, of the DT_REL relocation entry.

DT_PLTREL
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.

DT_DEBUG
This member is used for debugging. Its contents are not specified for the ABI; programs that access this entry are not ABI-conforming.

DT_TEXTREL
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 dynamic linker can prepare accordingly. This entry is at level 2. Its use has been superseded by the DF_TEXTREL flag.

DT_JMPREL
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 dynamic 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.

DT_BIND_NOW
If present in a shared object or executable, this entry instructs the dynamic linker to process all relocations for the object containing this entry before transferring control to the program. The presence of this entry takes precedence over a directive to use lazy binding for this object when specified through the environment or via dlopen(BA_LIB). This entry is at level 2. Its use has been superseded by the DF_BIND_NOW flag.

DT_INIT_ARRAY
This element holds the address of the array of pointers to initialization functions, discussed in ``Initialization and termination functions''.

DT_FINI_ARRAY
This element holds the address of the array of pointers to termination functions, discussed in ``Initialization and termination functions''.

DT_INIT_ARRAYSZ
This element holds the size in bytes of the array of initialization functions pointed to by the DT_INIT_ARRAY entry. If an object has a DT_INIT_ARRAY entry, it must also have a DT_INIT_ARRAYSZ entry.

DT_FINI_ARRAYSZ
This element holds the size in bytes of the array of termination functions pointed to by the DT_FINI_ARRAY entry. If an object has a DT_FINI_ARRAY entry, it must also have a DT_FINI_ARRAYSZ entry.

DT_RUNPATH
This element holds the string table offset of a null-terminated library search path string discussed in ``Shared object dependencies''. The offset is an index into the table recorded in the DT_STRTAB entry.

DT_FLAGS
This element holds flag values specific to the object being loaded. Each flag value will have the name DF_flag_name. Defined values and their meanings are described below. All other values are reserved.

DT_PREINIT_ARRAY
This element holds the address of the array of pointers to pre-initialization functions, discussed in ``Initialization and termination functions''. The DT_PREINIT_ARRAY table is processed only in an executable file; it is ignored if contained in a shared object.

DT_PREINIT_ARRAYSZ
This element holds the size in bytes of the array of pre-initialization functions pointed to by the DT_PREINIT_ARRAY entry. If an object has a DT_PREINIT_ARRAY entry, it must also have a DT_PREINIT_ARRAYSZ entry. As with DT_PREINIT_ARRAY, this entry is ignored if it appears in a shared object.

DT_ENCODING
Values greater than or equal to DT_ENCODING and less than DT_LOOS follow the rules for the interpretation of the d_un union described above.

DT_LOOS through DT_HIOS
Values in this inclusive range are reserved for operating system-specific semantics. All such values follow the rules for the interpretation of the d_un union described above.

DT_LOPROC through DT_HIPROC
Values in this inclusive range are reserved for processor-specific semantics. If meanings are specified, the processor supplement explains them. All such values follow the rules for the interpretation of the d_un union described above.

Except for the DT_NULL element at the end of the array, and the relative order of DT_NEEDED elements, entries may appear in any order. Tag values not appearing in the table are reserved.

Name Value
DF_ORIGIN 0x1
DF_SYMBOLIC 0x2
DF_TEXTREL 0x4
DF_BIND_NOW 0x8

DT_FLAGS values


DF_ORIGIN
This flag signifies that the object being loaded may make reference to the $ORIGIN substitution string (see ``Substitution sequences''). The dynamic linker must determine the pathname of the object containing this entry when the object is loaded.

DF_SYMBOLIC
If this flag is set in a shared object library, the dynamic linker's symbol resolution algorithm for references within the library is changed. Instead of starting a symbol search with the executable file, the dynamic linker starts from the shared object itself. If the shared object fails to supply the referenced symbol, the dynamic linker then searches the executable file and other shared objects as usual.

DF_TEXTREL
If this flag is not set, 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 flag is set, one or more relocation entries might request modifications to a non-writable segment, and the dynamic linker can prepare accordingly.

DF_BIND_NOW
If set in a shared object or executable, this flag instructs the dynamic linker to process all relocations for the object containing this entry before transferring control to the program. The presence of this entry takes precedence over a directive to use lazy binding for this object when specified through the environment or via dlopen(BA_LIB).

Next topic: Shared object dependencies
Previous topic: Dynamic linker

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004