NAME
ld.lld —
ELF linker from the LLVM
project
SYNOPSIS
ld.lld |
[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.
Many options have both a single-letter and long form. When using
the long form options other than those beginning with the letter
o may be specified using either one or two dashes
preceeding the option name. Long options beginning with
o require two dashes to avoid confusion with the
-o path option.
These options are available:
--allow-multiple-definition- Do not error if a symbol is defined multiple times. The first definition will be used.
--as-needed- Only set
DT_NEEDEDfor shared libraries if used. --auxiliaryvalue- Set the
DT_AUXILIARYfield to the specified name. --Bdynamic- Link against shared libraries.
--Bstatic- Do not link against shared libraries.
--Bsymbolic-functions- Bind defined function symbols locally.
--Bsymbolic- Bind defined symbols locally.
--build-id=value- Generate a build ID note. value may be one of
md5,sha1,tree,uuid,0xhex-string, andnone.treeis an alias forsha1. Build-IDs of typemd5,sha1, andtreeare calculated from the object contents. --build-id- Generate a build ID note.
--color-diagnostics=value- Use colors in diagnostics. value may be one of
always,auto, andnever.autoenables color if and only if output is to a terminal. --color-diagnostics- Alias for
--color-diagnostics=auto. --compress-debug-sections=value- Compress DWARF debug sections. value may be
noneorzlib. --define-common- Assign space to common symbols.
--defsym=symbol=expression- Define a symbol alias. expression may be another
symbol or a linker script expression. For example,
--defsym=foo=baror--defsym=foo=bar+0x100. --demangle- Demangle symbol names.
- Disable new dynamic tags.
--discard-all- Delete all local symbols.
--discard-locals- Delete temporary local symbols.
--discard-none- Keep all symbols in the symbol table.
--dynamic-linkervalue- Specify the dynamic linker to be used for a dynamically linked executable.
This is recorded in an ELF segment of type
PT_INTERP. --dynamic-listfile- Read a list of dynamic symbols from file.
--eh-frame-hdr- Request creation of
.eh_frame_hdrsection andPT_GNU_EH_FRAMEsegment header. --emit-relocs- Generate relocations in the output.
- Enable new dynamic tags.
--end-lib- End a grouping of objects that should be treated as if they were together in an archive.
--entryentry- Name of entry point symbol.
--error-limitvalue- Maximum number of errors to emit before stopping. A value of zero indicates that there is no limit.
--error-unresolved-symbols- Report unresolved symbols as errors.
--exclude-libsvalue- Exclude static libraries from automatic export.
--export-dynamic-symbolsymbol- Include symbol in the dynamic symbol table.
--export-dynamic- Put symbols in the dynamic symbol table.
--fatal-warnings- Treat warnings as errors.
--filter=value- Set the
DT_FILTERfield to the specified value. --finisymbol- Specify a finalizer function.
--format=input-format- Specify the format of the inputs following this option.
input-format may be one of
binary,elf, anddefault.defaultis a synonym forelf. --gc-sections- Enable garbage collection of unused sections.
--gdb-index- Generate
.gdb_indexsection. --hash-stylevalue- Specify hash style. value may be
sysv,gnu, orboth.bothis the default. --help- Print a usage message.
--icf=all- Enable identical code folding.
--icf=none- Disable identical code folding.
--image-base=value- Set the base address to value.
--initsymbol- Specify an initializer function.
--lto-aa-pipeline=value- AA pipeline to run during LTO. Used in conjunction with
--lto-newpm-passes. --lto-newpm-passes=value- Passes to run during LTO.
--lto-Oopt-level- Optimization level for LTO.
--lto-partitions=value- Number of LTO codegen partitions.
-Ldir- Add a directory to the library search path.
-llibName- Root name of library to use.
--Mapfile- Print a link map to file.
-mvalue- Set target emulation.
--no-as-needed- Always set
DT_NEEDEDfor shared libraries. --no-color-diagnostics- Do not use colors in diagnostics.
--no-define-common- Do not assign space to common symbols.
--no-demangle- Do not demangle symbol names.
--no-dynamic-linker- Inhibit output of an
.interpsection. --no-gc-sections- Disable garbage collection of unused sections.
--no-gnu-unique- Disable STB_GNU_UNIQUE symbol binding.
--no-rosegment- Do not put read-only non-executable sections in their own segment.
--no-threads- Do not run the linker multi-threaded.
--no-undefined-version- Report version scripts that refer undefined symbols.
--no-undefined- Report unresolved symbols even if the linker is creating a shared library.
--no-whole-archive- Restores the default behavior of loading archive members.
--noinhibit-exec- Retain the executable output file whenever it is still usable.
--no-pie- Do not create a position independent executable.
--nostdlib- Only search directories specified on the command line.
--oformatformat- Specify the format for the output object file. The only supported
format is
binary, which produces output with no ELF header. --omagic- Set the text and data sections to be readable and writable.
--opt-remarks-filenamefile- Write optimization remarks in YAML format to file.
--opt-remarks-with-hotness- Include hotness information in the optimization remarks file.
-Ovalue- Optimize output file size. value may be:
O0- Disable string merging.
O1- Enable string merging.
O2- Enable string tail merging.
O1is the default. -opath- Write the output executable, library, or object to
path. If not specified,
a.outis used as a default. --pie- Create a position independent executable.
--print-gc-sections- List removed unused sections.
--print-map- Print a link map to the standard output.
--relocatable- Create relocatable object file.
--reproducevalue- Dump linker invocation and input files for debugging.
--retain-symbols-file=file- Retain only the symbols listed in the file.
--rpathvalue- Add a
DT_RUNPATHto the output. --rsp-quoting=value- Quoting style for response files. The supported values are windows and posix.
--scriptfile- Read linker script from file.
--section-startaddress- Set address of section.
- Build a shared object.
--soname=value- Set
DT_SONAMEto value. --sort-sectionvalue- Specifies sections sorting rule when linkerscript is used.
--start-lib- Start a grouping of objects that should be treated as if they were together in an archive.
--strip-all- Strip all symbols.
--strip-debug- Strip debugging information.
--symbol-ordering-filefile- Lay out sections in the order specified by file.
--sysroot=value- Set the system root.
--target1-abs- Interpret
R_ARM_TARGET1asR_ARM_ABS32. --target1-rel- Interpret
R_ARM_TARGET1asR_ARM_REL32. --target2=type- Interpret
R_ARM_TARGET2as type, where type is one ofrel,abs, orgot-rel. --Tbssvalue- Same as
--section-startwith.bssas the sectionname. --Tdatavalue- Same as
--section-startwith.dataas the sectionname. --thinlto-cache-dir=value- Path to ThinLTO cached object file directory.
--thinlto-cache-policyvalue- Pruning policy for the ThinLTO cache.
--thinlto-jobs=value- Number of ThinLTO jobs.
--threads- Run the linker multi-threaded. This option is enabled by default.
--trace-symbolsymbol- Trace references to symbol.
--trace- Print the names of the input files.
--Ttextvalue- Same as
--section-startwith.textas the sectionname. --undefinedsymbol- Force symbol to be an undefined symbol during linking.
--unresolved-symbols=value- Determine how to handle unresolved symbols.
--verbose- Verbose mode.
--version-scriptfile- Read version script from file.
-V,--version- Display the version number and exit.
-v- Display the version number and proceed with linking if object files are specified.
--warn-common- Warn about duplicate common symbols.
--warn-unresolved-symbols- Report unresolved symbols as warnings.
--whole-archive- Force load of all members in a static library.
--wrapsymbol- Use wrapper functions for symbol.
-zoption- Linker option extensions.
execstack- Make the main stack executable. Stack permissions are recorded in the
PT_GNU_STACKsegment. ifunc-noplt- Do not emit PLT entries for GNU ifuncs. Instead, preserve relocations for ifunc call sites so that they may be applied by a run-time loader. Note that this feature requires special loader support and will generally result in application crashes when used outside of freestanding environments.
interpose- Set the
DF_1_INTERPOSEflag to indicate that the object is an interposer. Runtime linkers perform symbol resolution by first searching the application, followed by interposers, and then any other dependencies. muldefs- Do not error if a symbol is defined multiple times. The first
definition will be used. This is a synonym for
--allow-multiple-definition. nocombreloc- Disable combining and sorting multiple relocation sections.
nocopyreloc- Disable the creation of copy relocations.
nodelete- Set the
DF_1_NODELETEflag to indicate that the object cannot be unloaded from a process. nodlopen- Set the
DF_1_NOOPENflag to indcate that the object may not be opened by dlopen(3). norelro- Do not indicate that portions of the object shold be mapped read-only
after initial relocation processing. The object will omit the
PT_GNU_RELROsegment. notext- Allow relocations against read-only segments. Sets the
DT_TEXTREL flag in theDYNAMICsection. now- 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. origin- Set the
DF_ORIGINflag to indicate that the object requires $ORIGIN processing. retpolineplt- Emit retpoline format PLT entries as a mitigation for CVE-2017-5715.
rodynamic- Make the
.dynamicsection read-only. TheDT_DEBUGtag will not be emitted. stack-size=size- Set the main thread's stack size to size. The
stack size is recorded as the size of the size.
PT_GNU_STACKprogram segment. text- Do not allow relocations against read-only segments. This is the default.
wxneeded- Create a
PT_OPENBSD_WXNEEDEDsegment.