UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: layersChapter 2
UNIX Commands
Next: Reference: ldd
 

ld

ld [options] objfiles

Combine several objfiles, in the specified order, into a single executable object module (a.out by default). ld is the link editor and is often invoked automatically by compiler commands such as cc.

Options

-a

Force default behavior for static linking (generate an object file and list undefined references). Do not use with -r.

-b

Ignore special processing for shared reference symbols (dynamic linking only); output becomes more efficient but less sharable.

-B mode

See description under cc.

-B symbolic

In dynamic linking, bind a symbol to its local definition, not to its global definition.

-d

Force the definition of common storage.

-d[c]

Link dynamically (c is y) or statically (c in n); dynamic linking is the default.

-e symbol

Set symbol as the address of the output file's entry point.

-G

In dynamic linking, create a shared object and allow undefined symbols.

-h name

Use name as the shared object file to search for during dynamic linking (default is UNIX object file).

-I name

Use name as the pathname of the loader (interpreter) to write into the program header. Default is none (static) or /usr/lib/libc.so.1 (dynamic).

-lx

Search a library named libx.so or libx.a (the placement of this option on the line affects when the library is searched).

-L dir

Search directory dir before standard search directories (this option must precede -l).

-m

List a memory profile for input/output sections.

-M mapfile

Invoke ld directives from mapfile (-M messes up the output and is discouraged).

-N

Put the data section immediately after the text section. (SVR3 only.)

-n

Create output file as read-only.

-ofile

Send the output to file (default is a.out).

-Qc

List version information about ld in the output (c = y, the default) or do not list (c = n).

-r

Allow output to be subject to another ld.

-s

Remove symbol table and relocation entries.

-t

Suppress warning about multiply-defined symbols of unequal size.

-u symbol

Enter symbol in symbol table; useful when loading from an archive library. symbol must precede the library that defines it (so -u must precede -l).

-V

Print the version of ld.

-YP, dirlist

Specify a comma-separated list of directories to use in place of the default search directories (see also -L).

-z defs | nodefs | text

Specify nodefs to allow undefined symbols. The default, defs, treats undefined symbols as a fatal error. Use text to produce an error when there are nonwritable relocations.

-x

Enter only external symbols in output.

-X

Save all local symbols except those whose first letter is L.

-ysym

Indicate each file in which sym appears, its type and whether the file defines or references it.

-z

Arrange the file to be loaded on demand from the resulting executable file.


Previous: Reference: layersUNIX in a Nutshell: System V EditionNext: Reference: ldd
Reference: layersBook IndexReference: ldd

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System