Name

ld

Synopsis

    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.

Solaris: ld is in /usr/ccs/bin.

Tip

Options for ld vary wildly across systems. Furthermore, in the 21st century, no matter what system you work on, the loader is one of the most complicated commands. We have chosen here to document only those options that are commonly available. You will need to check your local documentation for complete information.

Options

-e symbol

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

-l x

Search a library named lib x .so or lib x .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).

-o file

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

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

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

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.