ld(1) - NetBSD Manual Pages

LD(1)                       NetBSD Reference Manual                      LD(1)


NAME
ld - link editor
SYNOPSIS
ld [-MNnrSstXxz] [-A symbol-file] [-assert keyword] [-Blinkmode] [-D datasize] [-d c] [-d p] [-e entry] [-llibrary-specifier] [-Llibrary-search-path] [-nostdlib] [-o filename] [-T address] [-u symbol] [-V shlib-version] [-y symbol]
DESCRIPTION
ld 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 ld. Object files and archives are pro- cessed in the order given on the command line. The options are as follows: -A symbol-file The symbol-file is taken as a base for link-editing the object files on the command line. -assert keyword This option has currently no effect. It is here for compatibility with SunOS ld. All conditions which would cause a Sun assertion to fail will currently always cause error or warning messages from ld. -Bdynamic Specifies that linking against dynamic libraries can take place. If a library specifier of the form -lx appears on the command line, ld searches for a library of the from libx.so.n.m (see the -l option) according to the search rules in effect. If such a file can not be found a traditional archive is looked for. This options can appear anywhere on the command line and is complemen- tary to -Bstatic. -Bstatic The counterpart of -Bdynamic. This option turns off dynamic linking for all library specifiers until a -Bdynamic is once again given. Any explicitly mentioned shared object encountered on the command line while this option is in effect is flagged as an error. -Bshareable Instructs the linker to build a shared object from the object files rather than a normal executable image. -Bsymbolic Causes symbolic references to symbols within the object to be re- solved and changed to base-relative references. This can be used, e.g., to make a shared library use an internal symbol when the executable that loads it has its own definition. References to undefined symbols are not affected by this flag. -Bforcearchive 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 with- out having to unpack the archive. -Bsilly Search for .sa silly archive companions of shared objects. Useful for compatibility with version 3 shared objects. -D 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. -d c Force allocation of commons even producing relocatable output. -d p Force alias definitions of procedure calls in non-PIC code. Use- ful to obtain shareable code in the presence of run-time reloca- tions as such calls will be re-directed through the Procedure Linkage Table (see link(5)) -e entry-symbol Specifies the entry symbol for an executable. -Lpath Add path to the list of directories to search for libraries spec- ified with the -l option. -llib-spec This option specifies a library to be considered for inclusion in the output. If the -Bdynamic option is in effect, a shared li- brary of the form lib<spec>.so.m.n (where m is the major, and n is the minor version number, respectively) is searched for first. The library with the highest version found in the search path is selected. If no shared library is found or the -Bstatic option is in effect, an archive of the form lib<spec>.a is looked for in the library search path. -M Produce output about the mapping of segments of the input files and the values assigned to (global) symbols in the output file. -N Produce a OMAGIC output file. -n Produce a NMAGIC output file. -nostdlib Do not search the built-in path (usually ``/usr/lib'') for -l specified libraries. -o filename Specifies the name of the output file. Defaults to ``a.out''. -Q Produce a QMAGIC output file. -r Produce relocatable object file, suitable for another pass through ld. -R Record the given path within the executable for run-time library search. This only applies to dynamically linked executables. -S Strip all debugger symbols from the output. -s Strip all symbols from the output. -T Specifies the start address of the text segment, with respect to which all input files will be relocated. -t Leave a trace of the input files as they are processed. -u symbol Force symbol to be marked as undefined. Useful to force loading of an archive member in the absence of any other references to that member. -V version Put the given version number into the output shared library (if one is created). Useful to make shared libaries compatible with other operating systems. Eg. SunOS 4.x libraries use version num- ber 3. Defaults to 8. -X Discard local symbols in the input files that start with the let- ter ``L'' -x Discard all local symbols in the input files. -y symbol Trace the manipulations inflicted on symbol -z Make a ZMAGIC output file. This is the default. Transitional Compatibility Use of the following directives is required on ELF systems and is recom- mended on all others in order to prepare for the planned transition from COFF to ELF. -rpath dir Record the given dir within the executable for run-time library search, as for -R. Ignored on COFF systems. -shared Instructs the linker to build a shared object from the object files rather than a normal executable image. -soname library-name The linker input file name is usually the plain ``.so'' file with no version number. On ELF systems, this option sets the DT_SON- AME field of a shared library to libraryname, which should be specified with the major number and without the minor number. A program image linked with this library will use at run time the file name specified here rather than the linker input file name. --whole-archive A positional qualifier to force loading from archives. For each archive mentioned on the commandline after this option, include every object file from the archive in the link, rather than searching the archive for the required object files. This is nor- mally used when building shared libraries. On COFF systems, the positional syntax is not currently imple- mented; --whole-archive is treated exactly as -Bforcearchive. --no-whole-archive This option turns off the effect of a preceding --whole-archive for any subsequent archive files on the command line. It is cur- rently ignored on COFF systems. --export-dynamic Specifies that all symbols should be added to the dynamic symbol table. This option is needed only by programs that make run-time decisions to load modules they were never linked with. Ignored on COFF systems.
ENVIRONMENT
ld utilizes the following environment variables: LD_LIBRARY_PATH This colon-separated list of directories is inserted in- to the search path for libraries following any directo- ries specified via -L options and preceding the built-in path. LD_NOSTD_PATH When set, do not search the built-in path for libraries. This is an alternative to the -nostdlib command-line flag.
SEE ALSO
ld.so(1), link(5), ldconfig(8)
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 ld.
BUGS
Shared objects are not properly checked for undefined symbols. Cascading of shared object defeats the ``-Bstatic'' option. All shared objects presented to ld are marked for run-time loading in the output file, even if no symbols are needed from them.
HISTORY
The shared library model employed by ld appeared first in SunOS 4.0. NetBSD 1.4 October 14, 1993 4

Powered by man-cgi (2024-08-26). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.