1993-11-03 23:41:59 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1993 Paul Kranenburg
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by Paul Kranenburg.
|
|
|
|
.\" 3. The name of the author may not be used to endorse or promote products
|
1994-02-13 20:43:13 +00:00
|
|
|
.\" derived from this software without specific prior written permission
|
1993-11-03 23:41:59 +00:00
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-27 23:37:10 +00:00
|
|
|
.\" $FreeBSD$
|
1993-11-03 23:41:59 +00:00
|
|
|
.\"
|
|
|
|
.Dd October 14, 1993
|
1994-12-11 21:39:31 +00:00
|
|
|
.Dt LD 1
|
2001-07-10 10:42:19 +00:00
|
|
|
.Os
|
1993-11-03 23:41:59 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm ld
|
|
|
|
.Nd link editor
|
|
|
|
.Sh SYNOPSIS
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm
|
1997-03-22 02:59:40 +00:00
|
|
|
.Op Fl fMNnrSstXxz
|
1993-11-03 23:41:59 +00:00
|
|
|
.Bk -words
|
|
|
|
.Op Fl A Ar symbol-file
|
|
|
|
.Op Fl assert Ar keyword
|
1996-10-01 01:22:51 +00:00
|
|
|
.Op Fl B Ns Ar linkmode
|
1993-11-03 23:41:59 +00:00
|
|
|
.Op Fl D Ar datasize
|
|
|
|
.Op Fl d Ar c
|
|
|
|
.Op Fl d Ar p
|
|
|
|
.Op Fl e Ar entry
|
1996-10-01 01:22:51 +00:00
|
|
|
.Op Fl l Ns Ar library-specifier
|
|
|
|
.Op Fl L Ns Ar library-search-path
|
1994-12-23 22:31:35 +00:00
|
|
|
.Op Fl nostdlib
|
1996-05-28 16:17:48 +00:00
|
|
|
.Op Fl O Ar filename
|
1993-11-03 23:41:59 +00:00
|
|
|
.Op Fl o Ar filename
|
1996-10-01 01:22:51 +00:00
|
|
|
.Op Fl R Ns Ar record-library-search-path
|
1993-11-03 23:41:59 +00:00
|
|
|
.Op Fl T Ar address
|
|
|
|
.Op Fl u Ar symbol
|
|
|
|
.Op Fl V Ar shlib-version
|
|
|
|
.Op Fl y Ar symbol
|
|
|
|
.Ek
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Nm
|
|
|
|
combines the object and archive files given on the command line into a new
|
|
|
|
object file. The output object file is either an executable program, a
|
|
|
|
shared object suitable for loading at run-time, or an object file that can
|
|
|
|
once again be processed by
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm .
|
1993-11-03 23:41:59 +00:00
|
|
|
Object files and archives are processed in the order given on the command line.
|
|
|
|
.Pp
|
|
|
|
The options are as follows:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Fl A Ar symbol-file
|
|
|
|
The the symbol-file is taken as a base for link-editing the object files
|
|
|
|
on the command line.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl assert Ar keyword
|
1997-05-29 15:34:34 +00:00
|
|
|
This option is here mainly for compatibility with SunOS
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm .
|
1997-05-29 15:34:34 +00:00
|
|
|
Most conditions which would cause a Sun assertion to fail will
|
1993-11-03 23:41:59 +00:00
|
|
|
currently always cause error or warning messages from
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm .
|
1997-05-29 15:34:34 +00:00
|
|
|
The only keyword implemented by
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm
|
1997-05-29 15:34:34 +00:00
|
|
|
is
|
2000-11-20 12:18:54 +00:00
|
|
|
.Ar pure-text ,
|
1997-05-29 15:34:34 +00:00
|
|
|
which generates a warning if a position independent object is being
|
|
|
|
created and some of the files being linked are not position
|
|
|
|
independent.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl B Ns Ar dynamic
|
1993-11-03 23:41:59 +00:00
|
|
|
Specifies that linking against dynamic libraries can take place. If a library
|
|
|
|
specifier of the form -lx appears on the command line,
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm
|
1996-10-01 01:22:51 +00:00
|
|
|
searches for a library of the from libx.so.n.m
|
2001-02-01 16:38:02 +00:00
|
|
|
(see the
|
1996-10-01 01:22:51 +00:00
|
|
|
.Fl l
|
2001-02-01 16:38:02 +00:00
|
|
|
option)
|
1996-10-01 01:22:51 +00:00
|
|
|
according to the search rules in effect. If such a file can not be
|
1993-11-03 23:41:59 +00:00
|
|
|
found a traditional archive is looked for.
|
|
|
|
This options can appear anywhere on the command line and is complementary
|
1996-10-01 01:22:51 +00:00
|
|
|
to
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fl B Ns Ar static .
|
1997-05-29 15:34:34 +00:00
|
|
|
.It Fl B Ns Ar forcedynamic
|
|
|
|
This is similar to
|
|
|
|
.Fl B Ns Ar dynamic
|
|
|
|
except that if no dynamic libraries are linked against,
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm
|
1997-05-29 15:34:34 +00:00
|
|
|
will still produce a dynamic executable. This is useful for programs
|
|
|
|
which are static but still need to load dynamic objects at runtime.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl B Ns Ar static
|
|
|
|
The counterpart of
|
|
|
|
.Fl B Ns Ar dynamic .
|
|
|
|
This option turns off dynamic linking for
|
|
|
|
all library specifiers until a
|
|
|
|
.Fl B Ns Ar dynamic
|
|
|
|
is once again given. Any explicitly
|
1993-11-03 23:41:59 +00:00
|
|
|
mentioned shared object encountered on the command line while this option is
|
|
|
|
in effect is flagged as an error.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl B Ns Ar shareable
|
1993-11-03 23:41:59 +00:00
|
|
|
Instructs the linker to build a shared object from the object files rather
|
|
|
|
than a normal executable image.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl B Ns Ar symbolic
|
1993-11-03 23:41:59 +00:00
|
|
|
This option causes all symbolic references in the output to be resolved in
|
|
|
|
this link-edit session. The only remaining run-time relocation requirements are
|
|
|
|
.Em base-relative
|
|
|
|
relocations, ie. translation with respect to the load address. Failure to
|
|
|
|
resolve any symbolic reference causes an error to be reported.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl B Ns Ar forcearchive
|
1993-11-03 23:41:59 +00:00
|
|
|
Force all members of archives to be loaded, whether or not such members
|
|
|
|
contribute a definition to any plain object files. Useful for making a
|
|
|
|
shared library from an archive of PIC objects without having to unpack
|
|
|
|
the archive.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl B Ns Ar silly
|
1994-06-15 22:41:19 +00:00
|
|
|
Search for
|
|
|
|
.Em \.sa
|
|
|
|
silly archive companions of shared objects. Useful for compatibility with
|
|
|
|
version 3 shared objects.
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl D Ar data-size
|
|
|
|
Set the size of the data segment. For sanity's sake, this should be larger
|
|
|
|
than the cumulative data sizes of the input files.
|
|
|
|
.It Fl d Ar c
|
|
|
|
Force allocation of commons even producing relocatable output.
|
|
|
|
.It Fl d Ar p
|
|
|
|
Force alias definitions of procedure calls in non-PIC code. Useful to
|
|
|
|
obtain shareable code in the presence of run-time relocations as such
|
|
|
|
calls will be re-directed through the Procedure Linkage Table (see
|
2001-02-01 16:38:02 +00:00
|
|
|
.Xr link 5 )
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl e Ar entry-symbol
|
|
|
|
Specifies the entry symbol for an executable.
|
1997-03-22 02:59:40 +00:00
|
|
|
.It Fl f
|
|
|
|
List the resolved paths of all the object files and libraries on the
|
|
|
|
standard output, and exit.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl L Ns Ar path
|
1993-11-03 23:41:59 +00:00
|
|
|
Add
|
|
|
|
.Ar path
|
|
|
|
to the list of directories to search for libraries specified with the
|
1997-08-23 21:59:41 +00:00
|
|
|
.Fl l
|
1993-11-03 23:41:59 +00:00
|
|
|
option.
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl l Ns Ar lib-spec
|
1993-11-03 23:41:59 +00:00
|
|
|
This option specifies a library to be considered for inclusion in the
|
1996-10-01 01:22:51 +00:00
|
|
|
output. If the
|
|
|
|
.Fl B Ns Ar dynamic
|
|
|
|
option is in effect, a shared library of the
|
|
|
|
form lib<spec>.so.m.n
|
2001-02-01 16:38:02 +00:00
|
|
|
(where
|
1993-11-03 23:41:59 +00:00
|
|
|
.Em m
|
|
|
|
is the major, and
|
|
|
|
.Em n
|
2001-02-01 16:38:02 +00:00
|
|
|
is the minor version number, respectively)
|
|
|
|
is searched for first. The
|
1993-11-03 23:41:59 +00:00
|
|
|
library with the highest version found in the search path is selected.
|
1996-10-01 01:22:51 +00:00
|
|
|
If no shared library is found or the
|
|
|
|
.Fl B Ns Ar static
|
|
|
|
options is in effect, an archive of the form lib<spec>.a is looked for in
|
1997-05-31 04:28:53 +00:00
|
|
|
the library search path.
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl M
|
|
|
|
Produce output about the mapping of segments of the input files and the
|
1996-10-01 01:22:51 +00:00
|
|
|
values assigned to
|
2001-08-07 15:48:51 +00:00
|
|
|
(global)
|
1996-10-01 01:22:51 +00:00
|
|
|
symbols in the output file.
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl N
|
1996-10-01 01:22:51 +00:00
|
|
|
Produce a
|
|
|
|
.Dv OMAGIC
|
|
|
|
output file.
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl n
|
1996-10-01 01:22:51 +00:00
|
|
|
Produce a
|
|
|
|
.Dv NMAGIC
|
|
|
|
output file.
|
1994-12-23 22:31:35 +00:00
|
|
|
.It Fl nostdlib
|
|
|
|
Do not search the built-in path
|
2001-02-01 16:38:02 +00:00
|
|
|
(usually
|
|
|
|
.Dq /usr/lib )
|
1994-12-23 22:31:35 +00:00
|
|
|
for
|
1996-10-01 01:22:51 +00:00
|
|
|
.Fl l
|
1994-12-23 22:31:35 +00:00
|
|
|
specified libraries.
|
1996-05-28 16:17:48 +00:00
|
|
|
.It Fl O Ar filename
|
|
|
|
Specifies the name of the output file.
|
|
|
|
The file is created as
|
2001-02-01 16:38:02 +00:00
|
|
|
.Ar filename Ns Pa .tmp
|
1996-05-28 16:17:48 +00:00
|
|
|
and when output is complete renamed to
|
|
|
|
.Ar filename .
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl o Ar filename
|
|
|
|
Specifies the name of the output file. Defaults to
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dq Pa a.out .
|
1994-01-03 23:52:35 +00:00
|
|
|
.It Fl Q
|
1996-10-01 01:22:51 +00:00
|
|
|
Produce a
|
|
|
|
.Dv QMAGIC
|
2000-11-14 11:20:58 +00:00
|
|
|
.Pq Fx Ns / Ns Tn BSDi Ns -i386
|
|
|
|
output file. This is the default.
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl r
|
|
|
|
Produce relocatable object file, suitable for another pass through
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm .
|
1996-10-01 01:22:51 +00:00
|
|
|
.It Fl R
|
1997-05-31 04:28:53 +00:00
|
|
|
Record the given path within the executable for run-time library search.
|
1996-10-01 01:22:51 +00:00
|
|
|
This only applies to dynamically linked executables.
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl S
|
|
|
|
Strip all debugger symbols from the output.
|
|
|
|
.It Fl s
|
|
|
|
Strip all symbols from the output.
|
|
|
|
.It Fl T
|
|
|
|
Specifies the start address of the text segment, with respect to which
|
|
|
|
all input files will be relocated.
|
|
|
|
.It Fl t
|
|
|
|
Leave a trace of the input files as they are processed.
|
|
|
|
.It Fl u Ar symbol
|
|
|
|
Force
|
|
|
|
.Ar symbol
|
|
|
|
to be marked as undefined. Useful to force loading of an archive member
|
|
|
|
in the absence of any other references to that member.
|
|
|
|
.It Fl V Ar version
|
1996-10-01 01:22:51 +00:00
|
|
|
Put the given version number into the output shared library
|
2001-08-07 15:48:51 +00:00
|
|
|
(if one is created).
|
1997-05-31 04:28:53 +00:00
|
|
|
Useful to make shared libraries compatible with other operating
|
|
|
|
systems. E.g., SunOS 4.x libraries use version number 3. Defaults to 8.
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl X
|
|
|
|
Discard local symbols in the input files that start with the letter
|
|
|
|
.Dq L
|
|
|
|
.It Fl x
|
|
|
|
Discard all local symbols in the input files.
|
1994-02-13 20:43:13 +00:00
|
|
|
.It Fl y Ar symbol
|
1993-11-03 23:41:59 +00:00
|
|
|
Trace the manipulations inflicted on
|
|
|
|
.Ar symbol
|
1994-03-09 14:28:02 +00:00
|
|
|
.It Fl Z
|
2001-08-14 10:01:54 +00:00
|
|
|
Make a
|
|
|
|
.Bx 386
|
1996-10-01 01:22:51 +00:00
|
|
|
.Dv ZMAGIC
|
|
|
|
output file.
|
1993-11-03 23:41:59 +00:00
|
|
|
.It Fl z
|
2001-08-13 17:00:36 +00:00
|
|
|
Make a
|
|
|
|
.Nx
|
1996-10-01 01:22:51 +00:00
|
|
|
.Dv ZMAGIC
|
|
|
|
output file.
|
2000-12-27 13:59:17 +00:00
|
|
|
.El
|
1996-10-01 01:22:51 +00:00
|
|
|
.Sh ENVIRONMENT
|
|
|
|
.Nm
|
|
|
|
utilizes the following environment variables:
|
|
|
|
.Bl -tag -width "LD_LIBRARY_PATH"
|
|
|
|
.It Ev LD_LIBRARY_PATH
|
|
|
|
This colon-separated list of directories is inserted into the search
|
|
|
|
path for libraries following any directories specified via
|
|
|
|
.Fl L
|
|
|
|
options and preceding the built-in path.
|
|
|
|
.\" .It Ev LD_NOSTD_PATH
|
|
|
|
.\" When set, do not search the built-in path for libraries.
|
|
|
|
.\" This is an alternative to the
|
|
|
|
.\" .Fl nostdlib
|
|
|
|
.\" command-line flag.
|
|
|
|
.El
|
1993-11-03 23:41:59 +00:00
|
|
|
.Sh FILES
|
|
|
|
.Sh SEE ALSO
|
1998-07-26 04:16:04 +00:00
|
|
|
.Xr ldd 1 ,
|
1997-01-13 00:25:51 +00:00
|
|
|
.Xr rtld 1 ,
|
1996-10-01 01:22:51 +00:00
|
|
|
.Xr link 5 ,
|
1997-01-13 00:25:51 +00:00
|
|
|
.Xr ldconfig 8
|
1993-11-03 23:41:59 +00:00
|
|
|
.Sh CAVEATS
|
|
|
|
An entry point must now explicitly be given if the output is intended to be
|
|
|
|
a normal executable program. This was not the case for the previous version of
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm .
|
1994-02-13 20:43:13 +00:00
|
|
|
.Sh BUGS
|
|
|
|
Shared objects are not properly checked for undefined symbols.
|
|
|
|
.Pp
|
|
|
|
Cascading of shared object defeats the
|
|
|
|
.Dq -Bstatic
|
|
|
|
option.
|
|
|
|
.Pp
|
|
|
|
All shared objects presented to
|
2000-11-20 12:18:54 +00:00
|
|
|
.Nm
|
1994-02-13 20:43:13 +00:00
|
|
|
are marked for run-time loading in the output file, even if no symbols
|
|
|
|
are needed from them.
|
1993-11-03 23:41:59 +00:00
|
|
|
.Sh HISTORY
|
1996-08-29 18:06:19 +00:00
|
|
|
A
|
|
|
|
.Nm
|
|
|
|
command appeared in
|
|
|
|
.At v1 .
|
1993-11-03 23:41:59 +00:00
|
|
|
The shared library model employed by
|
1996-08-29 18:06:19 +00:00
|
|
|
.Nm
|
1993-11-03 23:41:59 +00:00
|
|
|
appeared first in SunOS 4.0
|