V4/usr/man/man1/ld.1
.th LD I 8/16/73
.sh NAME
ld \*- link editor
.sh SYNOPSIS
.bd ld
[
.bd \*-sulxrnd
] name ...
.sh DESCRIPTION
.it Ld
combines several
object programs into one; resolves external
references; and searches libraries.
In the simplest case the names of several object
programs are given, and
.it d
combines them, producing
an object module which can be either executed or
become the input for a further
.it ld
run.
(In the latter case, the
.bd \*-r
option must be given
to preserve the relocation bits.)
The output of
.it ld
is left on
.bd a.out.
This file is executable
only if no errors occurred during the load.
.s3
The argument routines are concatenated in the order
specified. The entry point of the output is the
beginning of the first routine.
.s3
If any argument is a library, it is searched exactly once
at the point it is encountered in the argument list.
Only those routines defining an unresolved external
reference are loaded.
If a routine from a library
references another routine in the library,
the referenced routine must appear after the
referencing routine in the library.
Thus the order of programs within libraries
is important.
.s3
.it Ld
understands several flag arguments which are written
preceded by a `\*-'.
Except for \fB\*-l\fR,
they should appear before the file names.
.s3
.lp +4 4
\fB\*-s\fR `squash' the output, that is, remove the symbol table
and relocation bits to save space (but impair the
usefulness of the debugger).
This information can also be removed by
.it strip.
.s3
.lp +4 4
\fB\*-u\fR take the following argument as a symbol and enter
it as undefined in the symbol table. This is useful
for loading wholly from a library, since initially the symbol
table is empty and an unresolved reference is needed
to force the loading of the first routine.
.s3
.lp +4 4
\fB\*-l\fR This
option is an abbreviation for a library name.
\fB\*-l\fR
alone stands for `/lib/liba.a', which
is the standard system library for assembly language
programs.
\fB\*-l\fIx\fR
stands for `/lib/lib\fIx\fR.a' where \fIx\fR is any character.
There are libraries for Fortran (\fIx\fR = \fBf\fR),
and C (\fIx\fR = \fBc\fR).
A library is searched when its name is encountered,
so the placement of a \fB\*-l\fR
is significant.
.s3
.lp +4 4
\fB\*-x\fR do not preserve local
(non-.globl) symbols in the output symbol table; only enter
external symbols.
This option saves some space in the output file.
.s3
.lp +4 4
\fB\*-r\fR generate relocation bits in the output file
so that it can be the subject of another
.it ld
run.
This flag also prevents final definitions from being
given to common symbols.
.s3
.lp +4 4
\fB\*-d\fR force definition of common storage
even if the
.bd \*-r
flag is present (used for reloc (VIII)).
.s3
.lp +4 4
\fB\*-n\fR Arrange that
when the output file is executed,
the text portion will be read-only and shared
among all users executing the file.
This involves moving the data areas up the the first
possible 4K word boundary following the
end of the text.
.i0
.sh FILES
/lib/lib?.a libraries
.br
a.out output file
.sh "SEE ALSO"
as(I), ar(I)
.sh BUGS