Dynamically linked executables created by ld.1 contain data structures used by the dynamic link editor to finish link-editing the program during program execution. These data structures are described with a link_dynamic structure, as defined in the link.h file. ld always identifies the location of this structure in the executable file with the symbol __DYNAMIC. This symbol is ld-defined and if referenced in an executable that does not require dynamic linking will have the value zero.
The program stub linked with ``main'' programs by compiler drivers such as cc.1v (called crt0) tests the definition of __DYNAMIC to determine whether or not the dynamic link editor should be invoked. Programs supplying a substitute for crt0 must either duplicate this functionality or else require that the programs with which they are linked be linked statically. Otherwise, such replacement crt0's must open and map in the executable /usr/lib/ld.so using mmap.2 Care should be taken to ensure that the expected mapping relationship between the ``text'' and ``data'' segments of the executable is maintained in the same manner that the execve.2v system call does. The first location following the a.out header of this executable is the entry point to a function that begins the dynamic link-editing process. This function must be called and supplied with two arguments. The first argument is an integer representing the revision level of the argument list, and should have the value ``1''. The second should be a pointer to an argument list structure of the form:
struct { int crt_ba; /* base address of ld.so */ int crt_dzfd; /* open fd to /dev/zero */ int crt_ldfd; /* open fd to ld.so */ struct link_dynamic *crt_dp; /* pointer to program's __DYNAMIC */ char **crt_ep; /* environment strings */ caddr_t crt_bp; /* debugger hook */ }
The members of the structure are:
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97