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 link editor and is often invoked automatically by compiler commands. ld accepts many options, the most common of which are listed here.

Options

-b format, --format= format

If ld is configured to accept more than one kind of object file, this command can be used to specify the input format. format should be a GNU Binary File Descriptor (BFD) as described in the BFD library. Use objdump -i to list available formats.

-call_shared

Link with dynamic libraries.

-d, -dc, -dp

Force the assignment of space to common symbols.

-defsym symbol=expression

Create the global symbol with the value expression.

-demangle[= style]

Force demangling of symbol names. Optionally set the demangling style. Turn off demangling with -nodemangle.

-e symbol

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

-f name

Set the DT_AUXILIARY field of ELF shared object to name.

-fini name

Set the DT_FINI field of ELF shared object to the address of function name. The default function is _fini.

-h name

Set the DT_SONAME field of ELF shared object to name.

--help

Print help message, then exit.

-i

Produce a linkable output file; attempt to set its magic number to OMAGIC.

-init name

Set the DT_INIT field of ELF shared object to the address of function name. The default function is _init.

-l arch, --library= archive

Include the archive file arch in the list of ...

Get Linux in a Nutshell, Fourth 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.