• Aucun résultat trouvé

Initialization and Termination Functions

Dans le document DEC aSF/1 (Page 192-196)

Program Loading and Dynamic Linking 9

9.3 Dynamic Linking

9.3.10 Initialization and Termination Functions

bucket[nbucket -1]

chain[O]

...

chain[nchain - 1]

ZK-07S6U-R

The hashing function accepts a symbol name and returns a value that can be used to compute a bucket index. If the hashing function returns the value X for a name, bucket [X % nbucket] gives an index, Y, into the symbol table and chain array. If the symbol table entry indicated is not the correct one, chain [Y] indicates the next symbol table entry with the same hash value. The chain links can be followed until either the desired symbol table entry is located or the chain entry contains the value STN_ UNDEF.

The DT HASH entry of the dynamic section contains the address of the hash table section.

9.3.9 Dynamic String Section (.dynstr)

The dynamic string section is the repository for all strings referenced by the dynamic linking sections. Strings are referenced by a byte offset within the dynamic string section. The end of the string is denoted by a byte containing the value zero.

The DT STRTAB and DT STRSZ entries of the dynamic section describe the attributes of the dynarillc string section.

9.3.10 Initialization and Termination Functions

After the dynamic loader has created the process image and performed relocations, each shared object gets the opportunity to execute initialization code. The initialization functions are called in reverse-dependency order.

Each shared object's initialization functions are called only after the

which initialization functions are called.

Shared objects designate initialization and termination functions through the DT INIT and DT FINI entries in the dynamic structure. Typically, the code for these functions resides in the • ini t and • f ini sections.

Note

Although atexi t termination processing normally is done, it is not guaranteed to have executed when the process terminates. In particular, the process does not execute the termination

processing if it calls exi t or if the process terminates because it received a signal that it neither caught nor ignored.

9.3.11 Quickstart

The quickstart capability provided by the assembler supports several sections that are useful for faster startup of programs that have been linked with shared objects. Some ordering constraints are imposed on these sections.

The group of structures defined in these sections and the ordering constraints allow the dynamic linker to operate more efficiently. These additional sections are also used for more complete dynamic shared object version control.

9.3.11.1 Shared Object List (.liblist)

A shared object list section is an array of Elf 3 2 Lib structures that contains information about the various dynamic shared objects used to statically link the object file. Each shared object used has an entry in the array. Each entry has the following format:

typedef struct { Elf32 Word 1 name;

Elf32 Word l-time stamp;

Elf32 Word l-checksum;

Elf32 Word l=version;

Elf32 Word l_flags;

} Elf32_LIb;

The structure members in the preceding definition provide the following information:

1 name

Specifies the name of a shared object. Its value is a string table index.

This name can be a full pathname, a name containing'/' s which is relative to '.', or a trailing component of the pathname to be used with RPATH or LD LIBRARY PATH.

1 time stamp

- Contains a 32-bit time stamp. The value can be combined with the 1 checksum value and the 1 version string to form a unique identifier for this shared

object.-1 checksum

Contains the sum of all common sizes and all string names of externally visible symbols.

1 version

Specifies the interface version. Its value is a string table index. The interface version is a string containing no colons. It is compared to a colon separated string of versions pointed to by a dynamic section entry of the shared object. Shared objects with matching names may be considered incompatible if the interface version strings are deemed incompatible. An index value of zero means no version string is specified and is equivalent to the string _null.

1 flags

- Specifies a set of I-bit flags.

The 1_ flags field can have one or both of the following flags set:

LL EXACT MATCH At run time, use a unique id composed of the 1 time stamp, 1 checksum,and

I-versIon fields to demand that the run-time dynamic shared object match exactly the shared object used at static link time.

LL IGNORE INT VER At run time, ignore any version incompatibility between the dynamic shared object and the object used at static link time.

Normally, if neither LL EXACT MATCH nor LL IGNORE INT VER bits areset, the dynamic linker reqUires that the version of the dynamic shared library match at least one of the colon separated version strings indexed by the I_version string table index.

The DT MIPS LIBLIST and DT MIPS LIBLISTNO entries of the dynamic section describe the attributes of the shared object list section.

on which it depends, either in type or size, such that this definition preempts the shared object's definition. The dependent shared object is identified at static link time. The. conflict section is an array of Elf32 Conflict

elements:

-typedef Elf32_Word Elf32_Conflict;

The DT MIPS CONFLICT and DT MIPS CONFLICTNO entries of the dynamic section describe the attributes of the conflict section.

9.3.11.3 Ordering of Sections

In order to take advantage of the quickstart capability, ordering constraints are imposed on the • dynsym and. rel. dyn sections:

• The. dynsym section must be ordered on increasing values of the st value field. Note that this requires the. got section to be ordered in fue same way; it must correspond to the. dynsym section.

• The. rel. dyn section must have all local entries first, followed by the external entries. Within these subsections, the entries must be ordered by symbol index. This groups each symbol's relocations together.

Dans le document DEC aSF/1 (Page 192-196)