UNIX in a Nutshell: System V Edition

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

ld

/usr/ccs/bin/ld [options] objfiles

Combine several objfiles, in the specified order, into a single executable object module (a.out by default). ld is the loader and is usually 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 directive

Obey one of the following directives:

dynamic

When loading, use both dynamic (lib.so) and static (lib.a) libraries to resolve unknown symbols.

eliminate

Remove symbols not assigned a version definition. Solaris only.

group

Treat a shared object and its dependencies as a group. Implies -z defs. Solaris only.

local

Treat any global symbols that are not assigned a version definition as local symbols. Solaris only.

reduce

Perform the reduction of symbolic information specified by version definitions. Solaris only.

static

When loading, use only static (lib.a) libraries to resolve unknown symbols.

symbolic

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

-d[c]

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

-Dtoken,...

Print debugging information as specified by token; use help to get a list of possible values. Solaris only.

-e symbol

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

-f obj

Use the symbol table of the shared object being built as an auxiliary filter on shared object obj. Do not use with -F. Solaris only.

-F obj

Use the symbol table of the shared object being built as a filter on shared object obj. Do not use with -f. Solaris only.

-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

Ignore LD_LIBRARY_PATH. Useful for avoiding unwanted effects on the runtime search of the executable being built. Solaris only.

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

-Nstring

Add a DT_NEEDED entry with the value string to the .dynamic section of the object being built. Solaris only.

-o file

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. (Retain relocation information.)

-R path

Record the colon-separated list of directories in path in the object file for use by the runtime loader. Multiple instances may be supplied; the values are concatenated together.

-s

Remove (strip) symbol table and relocation entries.

-t

Suppress warnings 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.

-z directive

Solaris only. Obey one of the following directives:

allextract

Extract all archive members.

combreloc

Combine multiple relocation sections.

defaultextract

Return to the default archive extraction rules.

ignore

Ignore dynamic dependencies that are not referenced as part of the linking.

initfirst

Shared objects only. This object's initialization runs before that of others added to the process at the same time. Similarly, its "finalization" runs after that of other objects.

lazyload

Mark dynamic dependencies for lazy loading. Lazily loaded objects are loaded when the first binding to the object is made, not at process startup.

loadfltr

Mark the filter object for immediate processing at runtime, instead of at the first binding.

muldefs

Allow multiple symbol definitions, using the first one that occurs. Otherwise, multiple symbol definitions are a fatal error.

nodefs

Allow undefined symbols. This is the default for shared objects. The behavior is undefined for executables.

nodelete

Mark the object as not being deletable at runtime.

nodlopen

Shared objects only. The object is not available from dlopen(3x).

nolazyload

Don't mark dynamic dependencies for lazy loading. Lazily loaded objects are loaded when the first binding to the object is made, not at process startup.

nopartial

Expand partially initialized symbols in input relocatable objects into the generated output file.

noversion

Do not include any versioning sections.

now

Force nonlazy runtime binding for the object.

origin

The object requires immediate $ORIGIN processing at runtime.

record

Record dynamic dependencies that are not referenced as part of the linking. This is the default.

redlocsym

Remove all local symbols except for the SECT symbols from the SHT_SYMTAB symbol table.

textoff

In dynamic mode, allow relocations against all sections, including those that are not writable. This is the default for shared objects.

textwarn

Dynamic mode only. Warn if there remain any relocations against nonwritable, allocatable sections. This is the default for executables.

weakextract

Allow "weak" definitions to trigger archive extraction.


Previous: Reference: kshUNIX in a Nutshell: System V EditionNext: Reference: ldd
Reference: kshBook 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