Update (incl. PR#1547).

This commit is contained in:
pk 1995-09-30 21:28:19 +00:00
parent 1fbe81825a
commit 996bd19dd0
1 changed files with 38 additions and 21 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: link.5,v 1.3 1994/11/30 19:31:21 jtc Exp $
.\" $NetBSD: link.5,v 1.4 1995/09/30 21:28:19 pk Exp $
.\"
.\" Copyright (c) 1993 Paul Kranenburg
.\" All rights reserved.
@ -59,16 +59,16 @@ linked program or shared object image as the existing
.Xr a.out
format offers no room for it elsewhere.
.Pp
Several utilities cooperate to ensure that the task of getting a program
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 build by
.Xr ld 1.
can be built by
.Xr ld 1 .
The compiler also includes size information of any initialized data items
through the .size assembler directive. PIC code differs from conventional code
in that it accesses data variables through an indirection table, the
Global Offset Table, by convention accessable by the reserved name
.Em _GLOBAL_OFFSET_TABLE_.
.Em _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
@ -91,7 +91,7 @@ _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
which the location of the necessary relocation- and symbol information can
be derived. This is most notably used by the start-up module,
.Em crt0.
.Em crt0 .
The _DYNAMIC structure is conventionally located at the start of the data
segment of the image to which it pertains.
.Pp
@ -122,14 +122,18 @@ implementation. The current version numbers understood by ld and ld.so are
.Em LD_VERSION_SUN (3),
which is used by the SunOS 4.x releases, and
.Em LD_VERSION_BSD (8),
which is currently in use by NetBSD release 0.9B.
which is currently in use by NetBSD.
.It Fa d_un
Refers to a
.Em d_version
dependent data structure.
.It Fa so_debug
.It Fa d_debug
this field provides debuggers with a hook to access symbol tables of shared
objects loaded as a result of the actions of the run-time link-editor.
.It Fa d_entry
this field is obsoleted by CRT interface version CRT_VERSION_BSD4, and is
replaced by the crt_ldentry in
.Fa crt_ldso .
.El
.Pp
The
@ -142,7 +146,7 @@ and relocation information is located.
struct section_dispatch_table {
struct so_map *sdt_loaded;
long sdt_sods;
long sdt_filler1;
long sdt_paths;
long sdt_got;
long sdt_plt;
long sdt_rel;
@ -157,16 +161,22 @@ struct section_dispatch_table {
};
.Ed
.Pp
.Bl -tag -width sdt_filler1
.Bl -tag -width sdt_loaded
.It Fa sdt_loaded
A pointer to the first link map loaded (see below). This field is set by
.Xr ld.so.
.Xr ld.so
for the benefit of debuggers that may use it to load a shared object's
symbol table.
.It Fa sdt_sods
The start of a (linked) list of shared object descriptors needed by
.Em this
object.
.It Fa sdt_filler1
Depricated (used by SunOS to specify library search rules).
.It Fa sdt_paths
Library search rules. A colon separated list of directories corresponding
to the
.Fl R
option of
.Xr ld 1 .
.It Fa sdt_got
The location of the Global Offset Table within this image.
.It Fa sdt_plt
@ -192,7 +202,7 @@ The number of buckets in
.Fa sdt_hash
.It Fa sdt_strings
The location of the symbol string table that goes with
.Fa sdt_nzlist.
.Fa sdt_nzlist .
.It Fa sdt_str_sz
The size of the string table.
.It Fa sdt_text_sz
@ -238,7 +248,7 @@ see also
.Xr ldconfig 8
.Pc
for a shared object matching
.Em lib\&<sod_name>\&.so.n.m.
.Em lib\&<sod_name>\&.so.n.m .
If not set,
.Fa sod_name
should point at a full path name for the desired shared object.
@ -298,7 +308,7 @@ 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
.Fa section_dispatch_table.
.Fa section_dispatch_table .
.Bd -literal -offset indent
struct nzlist {
struct nlist nlist;
@ -392,7 +402,7 @@ A dynamically linked binary contains a
structure which can be located by means of the
.Fa d_debug
field in
.Fa _dynamic.
.Fa _dynamic .
.Bd -literal -offset indent
struct so_debug {
int dd_version;
@ -420,7 +430,7 @@ module,
to be some convenient place before the call to _main.
.It Fa dd_bpt_shadow
Contains the original instruction that was at
.Fa dd_bpt_addr.
.Fa dd_bpt_addr .
The debugger is expected to put this instruction back before continuing the
program.
.It Fa dd_cc
@ -431,7 +441,7 @@ may be interested in.
The
.Em ld_entry
structure defines a set of service routines within ld.so. See
.Xr libdl.a
.Xr dlfcn 3
for more information.
.Bd -literal -offset indent
struct ld_entry {
@ -439,12 +449,13 @@ struct ld_entry {
int (*dlclose)(void *);
void *(*dlsym)(void *, char *);
int (*dlctl)(void *, int, void *);
void (*dlexit) __P((void));
};
.Ed
The
.Fa crt_ldso
structure defines the interface between the start-up code in crt0 and ld.so.
structure defines the interface between ld.so and the start-up code in crt0.
.Bd -literal -offset indent
struct crt_ldso {
int crt_ba;
@ -455,10 +466,12 @@ struct crt_ldso {
caddr_t crt_bp;
char *crt_prog;
char *crt_ldso;
char *crt_ldentry;
};
#define CRT_VERSION_SUN 1
#define CRT_VERSION_BSD2 2
#define CRT_VERSION_BSD3 3
#define CRT_VERSION_BSD4 4
.Ed
.Bl -tag -width crt_dzfd
.It Fa crt_ba
@ -484,6 +497,10 @@ See
The name of the main program as determined by crt0 (CRT_VERSION_BSD3 only).
.It Fa crt_ldso
The path of the run-time linker as mapped by crt0 (CRT_VERSION_BSD4 only).
.It Fa crt_ldentry
The
.Xr dlfcn 3
entry points provided by the run-time linker (CRT_VERSION_BSD4 only).
.El
.Pp
The
@ -549,7 +566,7 @@ Index of the string representing the full path name of the library.
The version numbers of the shared library.
.It Fa hi_ndewey
The number of valid entries in
.Fa hi_dewey.
.Fa hi_dewey .
.It Fa hi_next
Next bucket in case of hashing collisions.
.El