Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
LD(1)			FreeBSD	General	Commands Manual			 LD(1)

     ld	-- link	editor

     ld	[-fMNnrSstXxz] [-A symbol-file]	[-assert keyword] [-Blinkmode]
	[-D datasize] [-d c] [-d p] [-e	entry] [-llibrary-specifier]
	[-Llibrary-search-path]	[-nostdlib] [-O	filename] [-o filename]
	[-Rrecord-library-search-path] [-T address] [-u	symbol]
	[-V shlib-version] [-y symbol]

     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 the symbol-file is taken as a base for	link-editing the
	     object files on the command line.

     -assert keyword
	     This option is here mainly	for compatibility with SunOS ld.  Most
	     conditions	which would cause a Sun	assertion to fail will cur-
	     rently always cause error or warning messages from	ld.  The only
	     keyword implemented by ld is pure-text, which generates a warning
	     if	a position independent object is being created and some	of the
	     files being linked	are not	position independent.

	     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 (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.

	     This is similar to	-Bdynamic except that if no dynamic libraries
	     are linked	against, ld will still produce a dynamic executable.
	     This is useful for	programs which are static but still need to
	     load dynamic objects at runtime.

	     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.

	     Instructs the linker to build a shared object from	the object
	     files rather than a normal	executable image.

	     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 base-relative relocations, ie.	trans-
	     lation with respect to the	load address. Failure to resolve any
	     symbolic reference	causes an error	to be reported.

	     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.

	     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.

     -f	     List the resolved paths of	all the	object files and libraries on
	     the standard output, and exit.

     -Lpath  Add path to the list of directories to search for libraries spec-
	     ified with	the -l option.

	     This option specifies a library to	be considered for inclusion in
	     the output. If the	-Bdynamic option is in effect, a shared
	     library 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
	     options 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.

	     Do	not search the built-in	path (usually ``/usr/lib'') for	-l
	     specified libraries.

     -O	filename
	     Specifies the name	of the output file.  The file is created as
	     filename .tmp and when output is complete renamed to filename.

     -o	filename
	     Specifies the name	of the output file. Defaults to	``a.out.''

     -Q	     Produce a QMAGIC (FreeBSD/BSDi-i386) output file.	This is	the

     -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 libraries compatible with
	     other operating systems. E.g., SunOS 4.x libraries	use version
	     number 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 386BSD ZMAGIC output file.

     -z	     Make a NetBSD ZMAGIC output file.

     ld	utilizes the following environment variables:

     LD_LIBRARY_PATH  This colon-separated list	of directories is inserted
		      into the search path for libraries following any direc-
		      tories specified via -L options and preceding the	built-
		      in path.

     rtld(1), link(5), ldconfig(8)

     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.

     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.

     A ld command appeared in Version 1	AT&T UNIX.  The	shared library model
     employed by ld appeared first in SunOS 4.0

FreeBSD			       October 14, 1993			       FreeBSD


Want to link to this manual page? Use this URL:

home | help