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	[-MNnrSstXxz] [-A symbol-file] [-assert	keyword] [-B linkmode]
	[-D datasize] [-d c] [-d p] [-e	entry] [-l library-specifier]
	[-L library-search-path] [-nostdlib] [-o filename] [-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 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.

     -B	dynamic
	     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.

     -B	static
	     The counterpart of	-Bdynamic. This	option turns off dynamic link-
	     ing 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

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

     -B	symbolic
	     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.

     -B	forcearchive
	     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.

     -B	silly
	     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.

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

     -l	lib-spec
	     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 seach 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. 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.

     -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 386BSD ZMAGIC output file.

     -z	     Make a NetBSD ZMAGIC output file.

     ldconfig(8), link(5)

     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.

     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