summaryrefslogtreecommitdiff
path: root/share/man/man5/link.5
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2000-03-19 19:25:38 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2000-03-19 19:25:38 +0000
commit9f999e1597f06b9b6655fec1fc8f4a474294c382 (patch)
tree22dfa891a17e56abf23c745288f782d5b424c104 /share/man/man5/link.5
parent480390dc59325200978ed49a1b26f00a94c91baa (diff)
Various cleanups.
Diffstat (limited to 'share/man/man5/link.5')
-rw-r--r--share/man/man5/link.587
1 files changed, 54 insertions, 33 deletions
diff --git a/share/man/man5/link.5 b/share/man/man5/link.5
index 7f0d6cf4524..0e966ab9b9b 100644
--- a/share/man/man5/link.5
+++ b/share/man/man5/link.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: link.5,v 1.6 1998/11/26 04:25:58 aaron Exp $
+.\" $OpenBSD: link.5,v 1.7 2000/03/19 19:25:30 aaron Exp $
.\" $NetBSD: link.5,v 1.5 1996/01/09 00:14:32 pk Exp $
.\"
.\" Copyright (c) 1993 Paul Kranenburg
@@ -43,14 +43,17 @@ The include file
declares several structures that are present in dynamically linked
programs and libraries.
The structures define the interface between several components of the
-link editor and loader mechanism. The layout of a number of these
+link editor and loader mechanism.
+The layout of a number of these
structures within the binaries resembles the
.Xr a.out 5
format in many places
as it serves such similar functions as symbol definitions (including the
accompanying string table) and relocation records needed to resolve
-references to external entities. It also records a number of data structures
-unique to the dynamic loading and linking process. These include references
+references to external entities.
+It also records a number of data structures
+unique to the dynamic loading and linking process.
+These include references
to other objects that are required to complete the link-editing process and
indirection tables to facilitate
.Em Position Independent Code
@@ -64,39 +67,47 @@ format offers no room for it elsewhere.
.Pp
Several utilities co-operate to ensure that the task of getting a program
ready to run can complete successfully in a way that optimizes the use
-of system resources. The compiler emits PIC code from which shared libraries
-can be built by
+of system resources.
+The compiler emits PIC code from which shared libraries can be built by
.Xr ld 1 .
The compiler also includes size information of any initialized data items
through the
.Dq .size
-assembler directive. PIC code differs from conventional code
+assembler directive.
+PIC code differs from conventional code
in that it accesses data variables through an indirection table, the
Global Offset Table, by convention accessible by the reserved name
.Dv _GLOBAL_OFFSET_TABLE_ .
The exact mechanism used for this is machine dependent, usually a machine
-register is reserved for the purpose. The rational behind this construct
-is to generate code that is independent of the actual load address. Only
+register is reserved for the purpose.
+The rational behind this construct
+is to generate code that is independent of the actual load address.
+Only
the values contained in the Global Offset Table may need updating at run-time
depending on the load addresses of the various shared objects in the address
space.
.Pp
Likewise, procedure calls to globally defined functions are redirected through
the Procedure Linkage Table (PLT) residing in the data segment of the core
-image. Again, this is done to avoid run-time modifications to the text segment.
+image.
+Again, this is done to avoid run-time modifications to the text segment.
.Pp
The linker-editor allocates the Global Offset Table and Procedure Linkage Table
when combining PIC object files into an image suitable for mapping into the
-process address space. It also collects all symbols that may be needed by the
+process address space.
+It also collects all symbols that may be needed by the
run-time link editor and stores these along with the image's text and data bits.
Another reserved symbol,
.Dv _DYNAMIC
-is used to indicate the presence of the run-time linker structures. Whenever
+is used to indicate the presence of the run-time linker structures.
+Whenever
.Dv _DYNAMIC
is relocated to 0, there is no need to invoke the run-time
-link editor. If this symbol is non-zero, it points at a data structure from
+link editor.
+If this symbol is non-zero, it points at a data structure from
which the location of the necessary relocation and symbol information can
-be derived. This is most notably used by the start-up module,
+be derived.
+This is most notably used by the start-up module,
.Em crt0 .
The
.Dv _DYNAMIC
@@ -118,17 +129,18 @@ structure:
.Bd -literal -offset indent
struct _dynamic {
int d_version;
- struct so_debug *d_debug;
+ struct so_debug *d_debug;
union {
struct section_dispatch_table *d_sdt;
} d_un;
- struct ld_entry *d_entry;
+ struct ld_entry *d_entry;
};
.Ed
.Bl -tag -width d_version
.It Fa d_version
This field provides for different versions of the dynamic linking
-implementation. The current version numbers understood by ld and
+implementation.
+The current version numbers understood by ld and
.Xr ld.so
are LD_VERSION_SUN(3),
which is used by the SunOS 4.x releases, and LD_VERSION_BSD(8),
@@ -177,7 +189,8 @@ struct section_dispatch_table {
.Pp
.Bl -tag -width sdt_loaded
.It Fa sdt_loaded
-A pointer to the first link map loaded (see below). This field is set by
+A pointer to the first link map loaded (see below).
+This field is set by
.Xr ld.so
for the benefit of debuggers that may use it to load a shared object's
symbol table.
@@ -185,8 +198,8 @@ symbol table.
The start of a (linked) list of shared object descriptors needed by
this object.
.It Fa sdt_paths
-Library search rules. A colon separated list of directories corresponding
-to the
+Library search rules.
+A colon separated list of directories corresponding to the
.Fl R
option of
.Xr ld 1 .
@@ -316,12 +329,15 @@ structure.
Hook for attaching private data maintained by the run-time link editor.
.El
.Pp
-Symbol description with size. This is simply an
+Symbol description with size.
+This is simply an
.Fa nlist
structure with one field
.Pq Fa nz_size
-added. Used to convey size information on items in the data segment
-of shared objects. An array of these lives in the shared object's
+added.
+Used to convey size information on items in the data segment
+of shared objects.
+An array of these lives in the shared object's
text segment and is addressed by the
.Fa sdt_nzlist
field of
@@ -370,14 +386,15 @@ The index of the symbol in the shared object's symbol table (as given by the
field).
.It Fa rh_next
In case of collisions, this field is the offset of the next entry in this
-hash table bucket. It is zero for the last bucket element.
+hash table bucket.
+It is zero for the last bucket element.
.El
.Pp
The
.Fa rt_symbol
structure is used to keep track of run-time allocated commons
-and data items copied from shared objects. These items are kept on linked list
-and is exported through the
+and data items copied from shared objects.
+These items are kept on linked list and is exported through the
.Fa dd_cc
field in the
.Fa so_debug
@@ -399,7 +416,8 @@ The symbol description.
Virtual address of next
.Fa rt_symbol .
.It Fa rt_link
-Next in hash bucket. Used by internally by
+Next in hash bucket.
+Used by internally by
.Xr ld.so .
.It Fa rt_srcaddr
Location of the source of initialized data within a shared object.
@@ -412,7 +430,8 @@ The
.Fa so_debug
structure is used by debuggers to gain knowledge of any shared objects
that have been loaded in the process's address space as a result of run-time
-link-editing. Since the run-time link editor runs as a part of process
+link-editing.
+Since the run-time link editor runs as a part of process
initialization, a debugger that wishes to access symbols from shared objects
can only do so after the link editor has been called from
.Em crt0 .
@@ -427,7 +446,7 @@ struct so_debug {
int dd_version;
int dd_in_debugger;
int dd_sym_loaded;
- char *dd_bpt_addr;
+ char *dd_bpt_addr;
int dd_bpt_shadow;
struct rt_symbol *dd_cc;
};
@@ -443,8 +462,8 @@ run under control of a debugger.
Set by the run-time linker whenever it adds symbols by loading shared objects.
.It Fa dd_bpt_addr
The address where a breakpoint will be set by the run-time linker to
-divert control to the debugger. This address is determined by the start-up
-module,
+divert control to the debugger.
+This address is determined by the start-up module,
.Em crt0.o ,
to be some convenient place before the call to
.Fa _main .
@@ -507,7 +526,8 @@ was loaded by
.It Fa crt_dzfd
On SunOS systems, this field contains an open file descriptor to
.Pa /dev/zero
-used to get demand paged zeroed pages. On
+used to get demand paged zeroed pages.
+On
.Ox
systems it contains -1.
.It Fa crt_ldfd
@@ -584,7 +604,8 @@ Size of strings.
Maximum usable offset in hints file.
.It Fa hh_dirlist
Offset in string table of a colon-separated list of directories that was
-used in constructing the hints file. See also
+used in constructing the hints file.
+See also
.Xr ldconfig 8 .
This field is only available with interface version number
.Dv LD_HINTS_VERSION_2