LD.LLD(1)

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.

The following options are available:

--allow-multiple-definition
    Allow multiple definitions.

--as-needed
    Only set DT_NEEDED for shared libraries if used.

--auxiliary value
    Set the DT_AUXILIARY field 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.

--build-id
    Generate a build ID note.

--color-diagnostics=value
    Use colors in diagnostics.

--color-diagnostics
    Use colors in diagnostics.

--compress-debug-sections=value
    Compress DWARF debug sections.

--define-common
    Assign space to common symbols.

--defsym=value
    Define a symbol alias.

--demangle
    Demangle symbol names.

--disable-new-dtags
    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-linker value
    Specify the dynamic linker to be used for a dynamically linked executable. This is recorded in an ELF segment of type PT_INTERP.

--dynamic-list value
    Read a list of dynamic symbols.

--eh-frame-hdr
    Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header.

--emit-relocs
    Generate relocations in the output.

--enable-new-dtags
    Enable new dynamic tags.

--end-lib
    End a grouping of objects that should be treated as if they were together in an archive.

--entry entry
    Name of entry point symbol.

--error-limit value
    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-libs value
    Exclude static libraries from automatic export.

--export-dynamic-symbol value
    Put a 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_FILTER field to the specified value.

--fini symbol
    Specify a finalizer function.

--format=input-format
    Change the input format of the inputs following this option.

--full-shutdown
    Perform a full shutdown instead of calling _exit().

--gc-sections
    Enable garbage collection of unused sections.

--gdb-index
    Generate .gdb_index section.

--hash-style value
    Specify hash style (sysv, gnu or both).

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

--init symbol
    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-O opt-level
    Optimization level for LTO.

--lto-partitions=value
    Number of LTO codegen partitions.

-L dir
    Add a directory to the library search path.

-l libName
    Root name of library to use.

--Map value
    Print a link map to the specified file.

-m value
    Set target emulation.

--no-as-needed
    Always set DT_NEEDED for 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 .interp section.

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

--nopie
    Do not create a position independent executable.

--nostdlib
    Only search directories specified on the command line.

--oformat format
    Specify the binary format for the output object file.

--omagic
    Set the text and data sections to be readable and writable.

--opt-remarks-filename value
    YAML output file for optimization remarks.

--opt-remarks-with-hotness
    Include hotness information in the optimization remarks file.

-O value
    Optimize output file size.

-o path
    Write the output executable, library or object to path. If not specified, a.out is 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.

--reproduce value
    Dump linker invocation and input files for debugging.

--retain-symbols-file=file
    Retain only the symbols listed in the file.

--rpath value
    Add a DT_RUNPATH to the output.

--rsp-quoting=value
    Quoting style for response files. The supported values are windows and posix.

--script value
    Read linker script from the path value.

--section-start address
    Set address of section.

--shared
    Build a shared object.

--soname=value
    Set DT_SONAME to value.

--sort-section value
    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-file value
    Lay out sections in the order specified by the symbol file.

--sysroot=value
    Set the system root.

--target1-abs
    Interpret R_ARM_TARGET1 as R_ARM_ABS32.

--target1-rel
    Interpret R_ARM_TARGET1 as R_ARM_REL32.

--target2=type
    Interpret R_ARM_TARGET2 as type, where type is one of rel, abs, or got-rel.

--Tbss value
    Same as --section-start with .bss as the sectionname.

--Tdata value
    Same as --section-start with .data as the sectionname.

--thinlto-cache-dir=value
    Path to ThinLTO cached object file directory.

--thinlto-cache-policy value
    Pruning policy for the ThinLTO cache.

--thinlto-jobs=value
    Number of ThinLTO jobs.

--threads
    Run the linker multi-threaded.

--trace-symbol value
    Trace references to symbols.

--trace
    Print the names of the input files.

--Ttext value
    Same as --section-start with .text as the sectionname.

--undefined value
    Force undefined symbol during linking.

--unresolved-symbols=value
    Determine how to handle unresolved symbols.

--verbose
    Verbose mode.

--version-script value
    Read a version script.

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

--wrap symbol
    Use wrapper functions for symbol.

-z option
    Linker option extensions.

    notext
        Allow relocations against read-only segments. Sets the DT_TEXTREL flag in the DYNAMIC section.

    text
        Do not allow relocations against read-only segments. This is the default.

IMPLEMENTATION NOTES
The targets supported by ld.lld are: elf32-i386 elf32-iamcu elf32-littlearm elf32-ntradbigmips elf32-ntradlittlemips elf32-powerpc elf32-tradbigmips elf32-tradlittlemips elf32-x86-64 elf64-amdgpu elf64-littleaarch64 elf64-powerpc elf64-tradbigmips elf64-tradlittlemips elf64-x86-64