|LD.LLD(1)||General Commands Manual||LD.LLD(1)|
||[options] objfile ...|
DESCRIPTION¶A linker takes one or more object, archive, and library files, and combines them into an output file (an executable, a shared library, or another object file). It relocates code and data from the input files and resolves symbol references between them.
ld.lld is a drop-in replacement for the
GNU BFD and gold linkers. It accepts most of the same command line arguments
and linker scripts as GNU linkers.
ld.lld currently supports i386, x86-64,
ARM, AArch64, PowerPC32, PowerPC64, MIPS32, MIPS64, RISC-V, AMDGPU, Hexagon
and SPARC V9 targets.
ld.lld acts as a Microsoft
link.exe-compatible linker if invoked as
and as macOS's ld if invoked as
ld.ld64. All these
targets are always supported however
built, so you can always use
ld.lld as a native
linker as well as a cross linker.
- Do not error if a symbol is defined multiple times. The first definition will be used.
- Apply link-time values for dynamic relocations.
- Only set
DT_NEEDEDfor shared libraries if used.
- Set the
DT_AUXILIARYfield to the specified name.
- Link against shared libraries.
- Do not link against shared libraries.
- Bind defined symbols locally.
- Bind defined function symbols locally.
- Generate a build ID note. value may be one of
treeis an alias for
sha1. Build-IDs of type
treeare calculated from the object contents.
fastis not intended to be cryptographically secure.
- Synonym for
- Use colors in diagnostics. value may be one of
autoenables color if and only if output is to a terminal.
- Alias for
- Compress DWARF debug sections. value may be
- Output cross reference table.
- Assign space to common symbols.
- Define a symbol alias. expression may be another
symbol or a linker script expression. For example,
--defsym=foo=bar’ or ‘
- Demangle symbol names.
- Disable new dynamic tags.
- Delete all local symbols.
- Delete temporary local symbols.
- Keep all symbols in the symbol table.
- Specify the dynamic linker to be used for a dynamically linked executable.
This is recorded in an ELF segment of type
- Read a list of dynamic symbols from file.
- Request creation of
- Generate relocations in the output.
- Enable new dynamic tags.
- End a grouping of objects that should be treated as if they were together in an archive.
- Name of entry point symbol.
- Maximum number of errors to emit before stopping. A value of zero indicates that there is no limit.
- Report unresolved symbols as errors.
- Mark executable sections unreadable. This option is currently only supported on AArch64.
- Exclude static libraries from automatic export.
- Put symbols in the dynamic symbol table.
- Include symbol in the dynamic symbol table.
- Treat warnings as errors.
- Set the
DT_FILTERfield to the specified value.
- Specify a finalizer function.
- Specify the format of the inputs following this option.
input-format may be one of
defaultis a synonym for
- Enable garbage collection of unused sections.
- Specify hash style. value may be
bothis the default.
- Print a help message.
- Enable identical code folding.
- Enable safe identical code folding.
- Disable identical code folding.
- Set the base address to value.
- Specify an initializer function.
- Do not fold symbol during ICF.
- Root name of library to use.
- Add a directory to the library search path.
- AA pipeline to run during LTO. Used in conjunction with
- Passes to run during LTO.
- Optimization level for LTO.
- Number of LTO codegen partitions.
- Set target emulation.
- Print a link map to file.
- Always set
DT_NEEDEDfor shared libraries.
- Do not use colors in diagnostics.
- Do not assign space to common symbols.
- Do not demangle symbol names.
- Inhibit output of an
- Disable garbage collection of unused sections.
- Disable STB_GNU_UNIQUE symbol binding.
- Do not put read-only non-executable sections in their own segment.
- Do not run the linker multi-threaded.
- Report version scripts that refer undefined symbols.
- Report unresolved symbols even if the linker is creating a shared library.
- Restores the default behavior of loading archive members.
- Do not create a position independent executable.
- Retain the executable output file whenever it is still usable.
- Only search directories specified on the command line.
- Write the output executable, library, or object to
path. If not specified,
a.outis used as a default.
- Optimize output file size. value may be:
1is the default.
- Specify the format for the output object file. The only supported
binary, which produces output with no ELF header.
- Set the text and data sections to be readable and writable.
- Write optimization remarks in YAML format to file.
- Include hotness information in the optimization remarks file.
- Always generate position independent thunks.
- Create a position independent executable.
- List removed unused sections.
- List identical folded sections.
- Print a link map to the standard output.
- Save the current state of
- Undo the effect of
- Create relocatable object file.
- Dump linker invocation and input files for debugging.
- Retain only the symbols listed in the file.
- Add a
DT_RUNPATHto the output.
- Quoting style for response files. The supported values are
- Read linker script from file.
- Set address of section.
- Build a shared object.
- Specifies sections sorting rule when linkerscript is used.
- Start a grouping of objects that should be treated as if they were together in an archive.
- Strip all symbols.
- Strip debugging information.
- Lay out sections in the order specified by file.
- Set the system root.
R_ARM_TARGET2as type, where type is one of
- Same as
.bssas the sectionname.
- Same as
.dataas the sectionname.
- Same as
.textas the sectionname.
- Path to ThinLTO cached object file directory.
- Pruning policy for the ThinLTO cache.
- Number of ThinLTO jobs.
- Run the linker multi-threaded. This option is enabled by default.
- Print the names of the input files.
- Trace references to symbol.
- Force symbol to be an undefined symbol during linking.
- Determine how to handle unresolved symbols.
- Display the version number and proceed with linking if object files are specified.
- Display the version number and exit.
- Verbose mode.
- Read version script from file.
- Warn about reverse or cyclic dependencies to or between static archives. This can be used to ensure linker invocation remains compatible with traditional Unix-like linkers.
- Warn about duplicate common symbols.
- Warn about using ifunc symbols in conjunction with text relocations. Older versions of glibc library (2.28 and earlier) has a bug that causes the segment that includes ifunc symbols to be marked as not executable when they are relocated. As a result, although the program compiles and links successfully, it gives segmentation fault when the instruction pointer reaches an ifunc symbol. Use -warn-ifunc-textrel to let lld give a warning, if the code may include ifunc symbols, may do text relocations and be linked with an older glibc version. Otherwise, there is no need to use it, as the default value does not give a warning. This flag has been introduced in late 2018, has no counter part in ld and gold linkers, and may be removed in the future.
- Report unresolved symbols as warnings.
- Force load of all members in a static library.
- Use wrapper functions for symbol.
- Linker option extensions.
- Make the main stack executable. Stack permissions are recorded in the
- Sets the
DF_1_GLOBAL flag in the
DYNAMICsection. Different loaders can decide how to handle this flag on their own.
- Sets the
DF_1_INITFIRSTflag to indicate the module should be initialized first.
- Set the
DF_1_INTERPOSEflag to indicate to the runtime linker that the object is an interposer. During symbol resolution interposers are searched after the application but before other dependencies.
- Do not error if a symbol is defined multiple times. The first
definition will be used. This is a synonym for
- Disable combining and sorting multiple relocation sections.
- Disable the creation of copy relocations.
- Set the
DF_1_NODEFLIBflag to indicate that default library search paths should be ignored.
- Set the
DF_1_NODELETEflag to indicate that the object cannot be unloaded from a process.
- Set the
DF_1_NOOPENflag to indicate that the object may not be opened by dlopen(3).
- Do not indicate that portions of the object shold be mapped read-only
after initial relocation processing. The object will omit the
- Allow relocations against read-only segments. Sets the
DT_TEXTREL flag in the
- Set the
DF_BIND_NOWflag to indicate that the run-time loader should perform all relocation processing as part of object initialization. By default relocations may be performed on demand.
- Set the
DF_ORIGINflag to indicate that the object requires $ORIGIN processing.
- Emit retpoline format PLT entries as a mitigation for CVE-2017-5715.
- Make the
.dynamicsection read-only. The
DT_DEBUGtag will not be emitted.
- Set the main thread's stack size to size. The
stack size is recorded as the size of the size.
- Do not allow relocations against read-only segments. This is the default.
- Create a
ld.lld's handing of archive files (those with a .a file extension) is different from traditional linkers used on Unix-like systems.
Traditional linkers maintain a set of undefined symbols during linking. The linker processes each file in the order in which it appears on the command line, until the set of undefined symbols becomes empty. An object file is linked into the output object when it is encountered, with its undefined symbols added to the set. Upon encountering an archive file a traditional linker searches the objects contained therein, and processes those that satisfy symbols in the unresolved set.
Handling mutually dependent archives may be awkward when using a
traditional linker. Archive files may have to be specified multiple times,
or the special command line options
--end-group may be used to have the linker loop
over the files in the group until no new symbols are added to the set.
ld.lld records all symbols found in
objects and archives as it iterates over command line arguments. When
ld.lld encounters an undefined symbol that can be
resolved by an object file contained in a previously processed archive file,
it immediately extracts and links it into the output object.
With certain archive inputs
produce different results compared to traditional linkers. In practice,
large bodies of third party software have been linked with
ld.lld without material issues.
--warn-backrefs option may be used to
identify a linker invocation that may be incompatible with traditional
Unix-like linker behavior.
|September 26, 2018||Linux 4.19.0-10-amd64|