xref: /freebsd-src/contrib/llvm-project/lld/docs/ld.lld.1 (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric.\" Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
20b57cec5SDimitry Andric.\" See https://llvm.org/LICENSE.txt for license information.
30b57cec5SDimitry Andric.\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
40b57cec5SDimitry Andric.\"
50b57cec5SDimitry Andric.\" This man page documents only lld's ELF linking support, obtained originally
60b57cec5SDimitry Andric.\" from FreeBSD.
706c3fb27SDimitry Andric.Dd Jul 25, 2023
80b57cec5SDimitry Andric.Dt LD.LLD 1
90b57cec5SDimitry Andric.Os
100b57cec5SDimitry Andric.Sh NAME
110b57cec5SDimitry Andric.Nm ld.lld
120b57cec5SDimitry Andric.Nd ELF linker from the LLVM project
130b57cec5SDimitry Andric.Sh SYNOPSIS
140b57cec5SDimitry Andric.Nm ld.lld
150b57cec5SDimitry Andric.Op Ar options
160b57cec5SDimitry Andric.Ar objfile ...
170b57cec5SDimitry Andric.Sh DESCRIPTION
180b57cec5SDimitry AndricA linker takes one or more object, archive, and library files, and combines
190b57cec5SDimitry Andricthem into an output file (an executable, a shared library, or another object
200b57cec5SDimitry Andricfile).
210b57cec5SDimitry AndricIt relocates code and data from the input files and resolves symbol
220b57cec5SDimitry Andricreferences between them.
230b57cec5SDimitry Andric.Pp
240b57cec5SDimitry Andric.Nm
250b57cec5SDimitry Andricis a drop-in replacement for the GNU BFD and gold linkers.
260b57cec5SDimitry AndricIt accepts most of the same command line arguments and linker scripts
270b57cec5SDimitry Andricas GNU linkers.
280b57cec5SDimitry Andric.Pp
290b57cec5SDimitry Andric.Nm
3006c3fb27SDimitry Andriccurrently supports i386, x86-64, ARM, AArch64, LoongArch, PowerPC32,
3106c3fb27SDimitry AndricPowerPC64, MIPS32, MIPS64, RISC-V, AMDGPU, Hexagon and SPARC V9 targets.
320b57cec5SDimitry Andric.Nm
330b57cec5SDimitry Andricacts as a Microsoft link.exe-compatible linker if invoked as
340b57cec5SDimitry Andric.Nm lld-link
350b57cec5SDimitry Andricand as macOS's ld if invoked as
360b57cec5SDimitry Andric.Nm ld.ld64.
370b57cec5SDimitry AndricAll these targets are always supported however
380b57cec5SDimitry Andric.Nm
390b57cec5SDimitry Andricwas built, so you can always use
400b57cec5SDimitry Andric.Nm
410b57cec5SDimitry Andricas a native linker as well as a cross linker.
420b57cec5SDimitry Andric.Sh OPTIONS
430b57cec5SDimitry AndricMany options have both a single-letter and long form.
440b57cec5SDimitry AndricWhen using the long form options other than those beginning with the
450b57cec5SDimitry Andricletter
460b57cec5SDimitry Andric.Cm o
470b57cec5SDimitry Andricmay be specified using either one or two dashes preceding the option name.
480b57cec5SDimitry AndricLong options beginning with
490b57cec5SDimitry Andric.Cm o
500b57cec5SDimitry Andricrequire two dashes to avoid confusion with the
510b57cec5SDimitry Andric.Fl o Ar path
520b57cec5SDimitry Andricoption.
530b57cec5SDimitry Andric.Pp
540b57cec5SDimitry Andric.Bl -tag -width indent
550b57cec5SDimitry Andric.It Fl -allow-multiple-definition
560b57cec5SDimitry AndricDo not error if a symbol is defined multiple times.
570b57cec5SDimitry AndricThe first definition will be used.
580b57cec5SDimitry Andric.It Fl -allow-shlib-undefined
590b57cec5SDimitry AndricAllow unresolved references in shared libraries.
600b57cec5SDimitry AndricThis option is enabled by default when linking a shared library.
610b57cec5SDimitry Andric.It Fl -apply-dynamic-relocs
620b57cec5SDimitry AndricApply link-time values for dynamic relocations.
630b57cec5SDimitry Andric.It Fl -as-needed
640b57cec5SDimitry AndricOnly set
650b57cec5SDimitry Andric.Dv DT_NEEDED
660b57cec5SDimitry Andricfor shared libraries if used.
670b57cec5SDimitry Andric.It Fl -auxiliary Ns = Ns Ar value
680b57cec5SDimitry AndricSet the
690b57cec5SDimitry Andric.Dv DT_AUXILIARY
700b57cec5SDimitry Andricfield to the specified name.
710b57cec5SDimitry Andric.It Fl -Bdynamic , Fl -dy
720b57cec5SDimitry AndricLink against shared libraries.
730b57cec5SDimitry Andric.It Fl -Bstatic , Fl -static , Fl -dn
740b57cec5SDimitry AndricDo not link against shared libraries.
75fe6060f1SDimitry Andric.It Fl Bno-symbolic
76fe6060f1SDimitry AndricDon't bind default visibility defined symbols locally for
77fe6060f1SDimitry Andric.Fl shared
78fe6060f1SDimitry Andric(default).
79fe6060f1SDimitry Andric.It Fl Bsymbolic
80fe6060f1SDimitry AndricBind default visibility defined symbols locally for
81fe6060f1SDimitry Andric.Fl shared.
82fe6060f1SDimitry AndricAlso set the
83fe6060f1SDimitry Andric.Dv DF_SYMBOLIC
84fe6060f1SDimitry Andricflag.
855f757f3fSDimitry Andric.It Fl Bsymbolic-non-weak
865f757f3fSDimitry AndricBind default visibility defined STB_GLOBAL symbols locally for
875f757f3fSDimitry Andric.Fl shared.
88fe6060f1SDimitry Andric.It Fl Bsymbolic-functions
89fe6060f1SDimitry AndricBind default visibility defined function symbols locally for
90fe6060f1SDimitry Andric.Fl shared.
916e75b2fbSDimitry Andric.It Fl Bsymbolic-non-weak-functions
926e75b2fbSDimitry AndricBind default visibility defined STB_GLOBAL function symbols locally for
936e75b2fbSDimitry Andric.Fl shared.
9406c3fb27SDimitry Andric.It Fl --be8
9506c3fb27SDimitry AndricWrite a Big Endian ELF File using BE8 format(AArch32 only)
960b57cec5SDimitry Andric.It Fl -build-id Ns = Ns Ar value
970b57cec5SDimitry AndricGenerate a build ID note.
980b57cec5SDimitry Andric.Ar value
990b57cec5SDimitry Andricmay be one of
1000b57cec5SDimitry Andric.Cm fast ,
1010b57cec5SDimitry Andric.Cm md5 ,
1020b57cec5SDimitry Andric.Cm sha1 ,
1030b57cec5SDimitry Andric.Cm tree ,
1040b57cec5SDimitry Andric.Cm uuid ,
1050b57cec5SDimitry Andric.Cm 0x Ns Ar hex-string ,
1060b57cec5SDimitry Andricand
1070b57cec5SDimitry Andric.Cm none .
1080b57cec5SDimitry Andric.Cm tree
1090b57cec5SDimitry Andricis an alias for
1100b57cec5SDimitry Andric.Cm sha1 .
1110b57cec5SDimitry AndricBuild-IDs of type
1120b57cec5SDimitry Andric.Cm fast ,
1130b57cec5SDimitry Andric.Cm md5 ,
1140b57cec5SDimitry Andric.Cm sha1 ,
1150b57cec5SDimitry Andricand
1160b57cec5SDimitry Andric.Cm tree
1170b57cec5SDimitry Andricare calculated from the object contents.
1180b57cec5SDimitry Andric.Cm fast
1190b57cec5SDimitry Andricis not intended to be cryptographically secure.
1200b57cec5SDimitry Andric.It Fl -build-id
1210b57cec5SDimitry AndricSynonym for
122*0fca6ea1SDimitry Andric.Fl -build-id Ns = Ns Cm sha1 .
1235f757f3fSDimitry Andric.It Fl -call-graph-profile-sort Ns = Ns Ar algorithm
1245f757f3fSDimitry Andric.Ar algorithm
1255f757f3fSDimitry Andricmay be:
1265f757f3fSDimitry Andric.Pp
1275f757f3fSDimitry Andric.Bl -tag -width 2n -compact
1285f757f3fSDimitry Andric.It Cm none
1295f757f3fSDimitry AndricIgnore call graph profile.
1305f757f3fSDimitry Andric.It Cm hfsort
1315f757f3fSDimitry AndricUse hfsort.
1325f757f3fSDimitry Andric.It Cm cdsort
1335f757f3fSDimitry AndricUse cdsort (default).
1345f757f3fSDimitry Andric.El
1355f757f3fSDimitry Andric.Pp
1360b57cec5SDimitry Andric.It Fl -color-diagnostics Ns = Ns Ar value
1370b57cec5SDimitry AndricUse colors in diagnostics.
1380b57cec5SDimitry Andric.Ar value
1390b57cec5SDimitry Andricmay be one of
1400b57cec5SDimitry Andric.Cm always ,
1410b57cec5SDimitry Andric.Cm auto ,
1420b57cec5SDimitry Andricand
1430b57cec5SDimitry Andric.Cm never .
1440b57cec5SDimitry Andric.Cm auto
1450b57cec5SDimitry Andricenables color if and only if output is to a terminal.
1460b57cec5SDimitry Andric.It Fl -color-diagnostics
1470b57cec5SDimitry AndricAlias for
1480b57cec5SDimitry Andric.Fl -color-diagnostics Ns = Ns Cm auto .
1490b57cec5SDimitry Andric.It Fl -compress-debug-sections Ns = Ns Ar value
1500b57cec5SDimitry AndricCompress DWARF debug sections.
151*0fca6ea1SDimitry AndricThe sections remain uncompressed if compressed content would be larger.
152bdd1243dSDimitry Andric.Cm value
1530b57cec5SDimitry Andricmay be
154bdd1243dSDimitry Andric.Pp
155bdd1243dSDimitry Andric.Bl -tag -width 2n -compact
156bdd1243dSDimitry Andric.It Cm none
157bdd1243dSDimitry AndricNo compression.
158bdd1243dSDimitry Andric.It Cm zlib
159480093f4SDimitry AndricThe default compression level is 1 (fastest) as the debug info usually
160*0fca6ea1SDimitry Andriccompresses well at that level.
161bdd1243dSDimitry Andric.It Cm zstd
162*0fca6ea1SDimitry AndricUse the default compression level in zstd.
163bdd1243dSDimitry Andric.El
164bdd1243dSDimitry Andric.Pp
165*0fca6ea1SDimitry Andric.It Fl -compress-sections Ns = Ns Ar section-glob={none,zlib,zstd}[:level]
166*0fca6ea1SDimitry AndricCompress output sections that match the glob and do not have the SHF_ALLOC flag.
167*0fca6ea1SDimitry AndricThe matched sections remain uncompressed if compressed content would be larger.
168*0fca6ea1SDimitry AndricThe compression level is
169*0fca6ea1SDimitry Andric.Cm level
170*0fca6ea1SDimitry Andric(if specified) or a default speed-focused level.
171*0fca6ea1SDimitry AndricThis is like a generalized
172*0fca6ea1SDimitry Andric.Cm --compress-debug-sections.
1730b57cec5SDimitry Andric.It Fl -cref
1744824e7fdSDimitry AndricOutput cross reference table. If
1754824e7fdSDimitry Andric.Fl Map
1764824e7fdSDimitry Andricis specified, print to the map file.
177*0fca6ea1SDimitry Andric.It Fl -debug-names
178*0fca6ea1SDimitry AndricGenerate a merged
179*0fca6ea1SDimitry Andric.Li .debug_names
180*0fca6ea1SDimitry Andricsection.
181*0fca6ea1SDimitry Andric.It Fl -default-script Ns = Ns Ar file , Fl dT Ar file
182*0fca6ea1SDimitry AndricIn the absence of
183*0fca6ea1SDimitry Andric.Fl -script ,
184*0fca6ea1SDimitry Andricread this default linker script.
1850b57cec5SDimitry Andric.It Fl -defsym Ns = Ns Ar symbol Ns = Ns Ar expression
1860b57cec5SDimitry AndricDefine a symbol alias.
1870b57cec5SDimitry Andric.Ar expression
1880b57cec5SDimitry Andricmay be another symbol or a linker script expression.
1890b57cec5SDimitry AndricFor example,
1900b57cec5SDimitry Andric.Ql --defsym=foo=bar
1910b57cec5SDimitry Andricor
1920b57cec5SDimitry Andric.Ql --defsym=foo=bar+0x100 .
1930b57cec5SDimitry Andric.It Fl -demangle
1940b57cec5SDimitry AndricDemangle symbol names.
1950b57cec5SDimitry Andric.It Fl -disable-new-dtags
1960b57cec5SDimitry AndricDisable new dynamic tags.
1970b57cec5SDimitry Andric.It Fl -discard-all , Fl x
1980b57cec5SDimitry AndricDelete all local symbols.
1990b57cec5SDimitry Andric.It Fl -discard-locals , Fl X
2000b57cec5SDimitry AndricDelete temporary local symbols.
2010b57cec5SDimitry Andric.It Fl -discard-none
2020b57cec5SDimitry AndricKeep all symbols in the symbol table.
2030b57cec5SDimitry Andric.It Fl -dynamic-linker Ns = Ns Ar value
2040b57cec5SDimitry AndricSpecify the dynamic linker to be used for a dynamically linked executable.
2050b57cec5SDimitry AndricThis is recorded in an ELF segment of type
2060b57cec5SDimitry Andric.Dv PT_INTERP .
2070b57cec5SDimitry Andric.It Fl -dynamic-list Ns = Ns Ar file
208349cc55cSDimitry AndricSimilar to
209349cc55cSDimitry Andric.Cm --export-dynamic-symbol-list .
210349cc55cSDimitry AndricWhen creating a shared object, implies
2115ffd83dbSDimitry Andric.Cm -Bsymbolic
2125ffd83dbSDimitry Andricbut does not set DF_SYMBOLIC
213fe6060f1SDimitry Andric.It Fl -EB
214fe6060f1SDimitry AndricSelect the big-endian format in the OUTPUT_FORMAT command.
215fe6060f1SDimitry Andric.It Fl -EL
216fe6060f1SDimitry AndricSelect the little-endian format in the OUTPUT_FORMAT command.
2170b57cec5SDimitry Andric.It Fl -eh-frame-hdr
2180b57cec5SDimitry AndricRequest creation of
2190b57cec5SDimitry Andric.Li .eh_frame_hdr
2200b57cec5SDimitry Andricsection and
2210b57cec5SDimitry Andric.Dv PT_GNU_EH_FRAME
2220b57cec5SDimitry Andricsegment header.
2230b57cec5SDimitry Andric.It Fl -emit-relocs , Fl q
2240b57cec5SDimitry AndricGenerate relocations in the output.
2250b57cec5SDimitry Andric.It Fl -enable-new-dtags
2260b57cec5SDimitry AndricEnable new dynamic tags.
227*0fca6ea1SDimitry Andric.It Fl -enable-non-contiguous-regions
228*0fca6ea1SDimitry AndricSpill input sections to later matching output sections to avoid memory region overflow.
2290b57cec5SDimitry Andric.It Fl -end-lib
2300b57cec5SDimitry AndricEnd a grouping of objects that should be treated as if they were together
2310b57cec5SDimitry Andricin an archive.
2320b57cec5SDimitry Andric.It Fl -entry Ns = Ns Ar entry
2330b57cec5SDimitry AndricName of entry point symbol.
2340b57cec5SDimitry Andric.It Fl -error-limit Ns = Ns Ar value
2350b57cec5SDimitry AndricMaximum number of errors to emit before stopping.
2360b57cec5SDimitry AndricA value of zero indicates that there is no limit.
2370b57cec5SDimitry Andric.It Fl -error-unresolved-symbols
2380b57cec5SDimitry AndricReport unresolved symbols as errors.
239e8d8bef9SDimitry Andric.It Fl -error-handing-script Ns = Ns Ar script_path
240e8d8bef9SDimitry AndricCall script
241e8d8bef9SDimitry Andric.Ar script_path
242e8d8bef9SDimitry Andricupon some error, with
243e8d8bef9SDimitry Andric.Ar tag
244e8d8bef9SDimitry Andricas first argument, and an extra parameter as second argument. The script is
245e8d8bef9SDimitry Andricexpected to return 0 on success. Any other value is considered a generic error.
246e8d8bef9SDimitry Andric.Ar tag
247e8d8bef9SDimitry Andricmay be
248e8d8bef9SDimitry Andric.Cm missing-lib
249e8d8bef9SDimitry Andricfollowed by the name of the missing library.
250e8d8bef9SDimitry Andric.Cm undefined-symbol
251e8d8bef9SDimitry Andricfollowed by the name of the undefined symbol.
2520b57cec5SDimitry Andric.It Fl -execute-only
25385868e8aSDimitry AndricMark executable sections unreadable.
25485868e8aSDimitry AndricThis option is currently only supported on AArch64.
2550b57cec5SDimitry Andric.It Fl -exclude-libs Ns = Ns Ar value
2560b57cec5SDimitry AndricExclude static libraries from automatic export.
2570b57cec5SDimitry Andric.It Fl -export-dynamic , Fl E
2580b57cec5SDimitry AndricPut symbols in the dynamic symbol table.
2595ffd83dbSDimitry Andric.It Fl -export-dynamic-symbol Ns = Ns Ar glob
2605ffd83dbSDimitry Andric(executable) Put matched non-local defined symbols to the dynamic symbol table.
2615ffd83dbSDimitry Andric(shared object) References to matched non-local STV_DEFAULT symbols shouldn't be bound to definitions within the shared object even if they would otherwise be due to
2625ffd83dbSDimitry Andric.Cm -Bsymbolic
2635ffd83dbSDimitry Andric,
2645ffd83dbSDimitry Andric.Cm -Bsymbolic-functions
2655ffd83dbSDimitry Andricor
2665ffd83dbSDimitry Andric.Cm --dynamic-list
267349cc55cSDimitry Andric.It Fl -export-dynamic-symbol-list Ns = Ns Ar file
268349cc55cSDimitry AndricRead a list of dynamic symbol patterns from
269349cc55cSDimitry Andric.Ar file .
270349cc55cSDimitry AndricApply
271349cc55cSDimitry Andric.Cm --export-dynamic-symbol
272349cc55cSDimitry Andricon each pattern.
2730b57cec5SDimitry Andric.It Fl -fatal-warnings
2740b57cec5SDimitry AndricTreat warnings as errors.
2750b57cec5SDimitry Andric.It Fl -filter Ns = Ns Ar value , Fl F Ar value
2760b57cec5SDimitry AndricSet the
2770b57cec5SDimitry Andric.Dv DT_FILTER
2780b57cec5SDimitry Andricfield to the specified value.
2790b57cec5SDimitry Andric.It Fl -fini Ns = Ns Ar symbol
2800b57cec5SDimitry AndricSpecify a finalizer function.
281*0fca6ea1SDimitry Andric.It Fl -force-group-allocation
282*0fca6ea1SDimitry AndricOnly meaningful for -r. Section groups are discarded. If two section group members are placed to the same output section, combine their relocations as well.
2830b57cec5SDimitry Andric.It Fl -format Ns = Ns Ar input-format , Fl b Ar input-format
2840b57cec5SDimitry AndricSpecify the format of the inputs following this option.
2850b57cec5SDimitry Andric.Ar input-format
2860b57cec5SDimitry Andricmay be one of
2870b57cec5SDimitry Andric.Cm binary ,
2880b57cec5SDimitry Andric.Cm elf ,
2890b57cec5SDimitry Andricand
2900b57cec5SDimitry Andric.Cm default .
2910b57cec5SDimitry Andric.Cm default
2920b57cec5SDimitry Andricis a synonym for
2930b57cec5SDimitry Andric.Cm elf .
2940b57cec5SDimitry Andric.It Fl -gc-sections
2950b57cec5SDimitry AndricEnable garbage collection of unused sections.
2960b57cec5SDimitry Andric.It Fl -gdb-index
2970b57cec5SDimitry AndricGenerate
2980b57cec5SDimitry Andric.Li .gdb_index
2990b57cec5SDimitry Andricsection.
3000b57cec5SDimitry Andric.It Fl -hash-style Ns = Ns Ar value
3010b57cec5SDimitry AndricSpecify hash style.
3020b57cec5SDimitry Andric.Ar value
3030b57cec5SDimitry Andricmay be
3040b57cec5SDimitry Andric.Cm sysv ,
3050b57cec5SDimitry Andric.Cm gnu ,
3060b57cec5SDimitry Andricor
3070b57cec5SDimitry Andric.Cm both .
3080b57cec5SDimitry Andric.Cm both
3090b57cec5SDimitry Andricis the default.
3100b57cec5SDimitry Andric.It Fl -help
3110b57cec5SDimitry AndricPrint a help message.
3120b57cec5SDimitry Andric.It Fl -icf Ns = Ns Cm all
3130b57cec5SDimitry AndricEnable identical code folding.
3140b57cec5SDimitry Andric.It Fl -icf Ns = Ns Cm safe
3150b57cec5SDimitry AndricEnable safe identical code folding.
3160b57cec5SDimitry Andric.It Fl -icf Ns = Ns Cm none
3170b57cec5SDimitry AndricDisable identical code folding.
3180b57cec5SDimitry Andric.It Fl -ignore-data-address-equality
3190b57cec5SDimitry AndricIgnore address equality of data. C/C++ requires each data to have a unique
32085868e8aSDimitry Andricaddress.
32185868e8aSDimitry AndricThis option allows lld to do unsafe optimization that breaks the
3220b57cec5SDimitry Andricrequirement: create copies of read-only data or merge two or more read-only data
3230b57cec5SDimitry Andricthat happen to have the same value.
3240b57cec5SDimitry Andric.It Fl -ignore-function-address-equality
32585868e8aSDimitry AndricIgnore address equality of functions.
32685868e8aSDimitry AndricThis option allows non-PIC calls to a function with non-default visibility in
32785868e8aSDimitry Andrica shared object.
32885868e8aSDimitry AndricThe function may have different addresses within the executable and within the
32985868e8aSDimitry Andricshared object.
3300b57cec5SDimitry Andric.It Fl -image-base Ns = Ns Ar value
3310b57cec5SDimitry AndricSet the base address to
3320b57cec5SDimitry Andric.Ar value .
3330b57cec5SDimitry Andric.It Fl -init Ns = Ns Ar symbol
3340b57cec5SDimitry AndricSpecify an initializer function.
3350b57cec5SDimitry Andric.It Fl -keep-unique Ns = Ns Ar symbol
3360b57cec5SDimitry AndricDo not fold
3370b57cec5SDimitry Andric.Ar symbol
3380b57cec5SDimitry Andricduring ICF.
3390b57cec5SDimitry Andric.It Fl l Ar libName, Fl -library Ns = Ns Ar libName
3400b57cec5SDimitry AndricRoot name of library to use.
3410b57cec5SDimitry Andric.It Fl L Ar dir , Fl -library-path Ns = Ns Ar dir
3420b57cec5SDimitry AndricAdd a directory to the library search path.
3430b57cec5SDimitry Andric.It Fl -lto-aa-pipeline Ns = Ns Ar value
3440b57cec5SDimitry AndricAA pipeline to run during LTO.
3450b57cec5SDimitry AndricUsed in conjunction with
3460b57cec5SDimitry Andric.Fl -lto-newpm-passes .
3470b57cec5SDimitry Andric.It Fl -lto-newpm-passes Ns = Ns Ar value
3480b57cec5SDimitry AndricPasses to run during LTO.
3490b57cec5SDimitry Andric.It Fl -lto-O Ns Ar opt-level
3500b57cec5SDimitry AndricOptimization level for LTO.
3510b57cec5SDimitry Andric.It Fl -lto-partitions Ns = Ns Ar value
3520b57cec5SDimitry AndricNumber of LTO codegen partitions.
3530b57cec5SDimitry Andric.It Fl m Ar value
3540b57cec5SDimitry AndricSet target emulation.
3550b57cec5SDimitry Andric.It Fl -Map Ns = Ns Ar file , Fl M Ar file
3560b57cec5SDimitry AndricPrint a link map to
3570b57cec5SDimitry Andric.Ar file .
3580b57cec5SDimitry Andric.It Fl -nmagic , Fl n
3590b57cec5SDimitry AndricDo not page align sections, link against static libraries.
3600b57cec5SDimitry Andric.It Fl -no-allow-shlib-undefined
3610b57cec5SDimitry AndricDo not allow unresolved references in shared libraries.
3620b57cec5SDimitry AndricThis option is enabled by default when linking an executable.
3630b57cec5SDimitry Andric.It Fl -no-as-needed
3640b57cec5SDimitry AndricAlways set
3650b57cec5SDimitry Andric.Dv DT_NEEDED
3660b57cec5SDimitry Andricfor shared libraries.
3670b57cec5SDimitry Andric.It Fl -no-color-diagnostics
3680b57cec5SDimitry AndricDo not use colors in diagnostics.
3690b57cec5SDimitry Andric.It Fl -no-demangle
3700b57cec5SDimitry AndricDo not demangle symbol names.
3710b57cec5SDimitry Andric.It Fl -no-dynamic-linker
3720b57cec5SDimitry AndricInhibit output of an
3730b57cec5SDimitry Andric.Li .interp
3740b57cec5SDimitry Andricsection.
375e8d8bef9SDimitry Andric.It Fl -no-fortran-common
376e8d8bef9SDimitry AndricDo not search archive members for definitions to override COMMON symbols.
3770b57cec5SDimitry Andric.It Fl -no-gc-sections
3780b57cec5SDimitry AndricDisable garbage collection of unused sections.
3790b57cec5SDimitry Andric.It Fl -no-gnu-unique
3800b57cec5SDimitry AndricDisable STB_GNU_UNIQUE symbol binding.
3810b57cec5SDimitry Andric.It Fl -no-merge-exidx-entries
3820b57cec5SDimitry AndricDisable merging .ARM.exidx entries.
3830b57cec5SDimitry Andric.It Fl -no-nmagic
3840b57cec5SDimitry AndricPage align sections.
3850b57cec5SDimitry Andric.It Fl -no-omagic
3860b57cec5SDimitry AndricDo not set the text data sections to be writable, page align sections.
3875ffd83dbSDimitry Andric.It Fl -no-relax
388349cc55cSDimitry AndricDisable target-specific relaxations. For x86-64 this disables R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization.
3890b57cec5SDimitry Andric.It Fl -no-rosegment
3900b57cec5SDimitry AndricDo not put read-only non-executable sections in their own segment.
391bdd1243dSDimitry Andric.It Fl -undefined-version
392bdd1243dSDimitry AndricDo not report version scripts that refer to undefined symbols.
3930b57cec5SDimitry Andric.It Fl -no-undefined
3940b57cec5SDimitry AndricReport unresolved symbols even if the linker is creating a shared library.
395*0fca6ea1SDimitry Andric.It Fl -no-warn-mismatch
396*0fca6ea1SDimitry AndricDo not reject unknown section types.
3970b57cec5SDimitry Andric.It Fl -no-warn-symbol-ordering
3980b57cec5SDimitry AndricDo not warn about problems with the symbol ordering file or call graph profile.
399bdd1243dSDimitry Andric.It Fl -no-warnings , Fl w
400bdd1243dSDimitry AndricSuppress warnings and cancel
401bdd1243dSDimitry Andric.Cm --fatal-warnings.
4020b57cec5SDimitry Andric.It Fl -no-whole-archive
4030b57cec5SDimitry AndricRestores the default behavior of loading archive members.
4040b57cec5SDimitry Andric.It Fl -no-pie , Fl -no-pic-executable
4050b57cec5SDimitry AndricDo not create a position independent executable.
4060b57cec5SDimitry Andric.It Fl -noinhibit-exec
4070b57cec5SDimitry AndricRetain the executable output file whenever it is still usable.
4080b57cec5SDimitry Andric.It Fl -nostdlib
4090b57cec5SDimitry AndricOnly search directories specified on the command line.
4100b57cec5SDimitry Andric.It Fl o Ar path
4110b57cec5SDimitry AndricWrite the output executable, library, or object to
4120b57cec5SDimitry Andric.Ar path .
4130b57cec5SDimitry AndricIf not specified,
4140b57cec5SDimitry Andric.Dv a.out
4150b57cec5SDimitry Andricis used as a default.
4160b57cec5SDimitry Andric.It Fl O Ns Ar value
4170b57cec5SDimitry AndricOptimize output file size.
4180b57cec5SDimitry Andric.Ar value
4190b57cec5SDimitry Andricmay be:
4200b57cec5SDimitry Andric.Pp
4210b57cec5SDimitry Andric.Bl -tag -width 2n -compact
4220b57cec5SDimitry Andric.It Cm 0
4230b57cec5SDimitry AndricDisable string merging.
4240b57cec5SDimitry Andric.It Cm 1
4250b57cec5SDimitry AndricEnable string merging.
4260b57cec5SDimitry Andric.It Cm 2
427*0fca6ea1SDimitry AndricEnable string tail merging.
4280b57cec5SDimitry Andric.El
4290b57cec5SDimitry Andric.Pp
4300b57cec5SDimitry Andric.Fl O Ns Cm 1
4310b57cec5SDimitry Andricis the default.
4320b57cec5SDimitry Andric.It Fl -oformat Ns = Ns Ar format
4330b57cec5SDimitry AndricSpecify the format for the output object file.
4340b57cec5SDimitry AndricThe only supported
4350b57cec5SDimitry Andric.Ar format
4360b57cec5SDimitry Andricis
4370b57cec5SDimitry Andric.Cm binary ,
4380b57cec5SDimitry Andricwhich produces output with no ELF header.
4390b57cec5SDimitry Andric.It Fl -omagic , Fl N
44085868e8aSDimitry AndricSet the text and data sections to be readable and writable, do not page align
44185868e8aSDimitry Andricsections, link against static libraries.
4420b57cec5SDimitry Andric.It Fl -opt-remarks-filename Ar file
4430b57cec5SDimitry AndricWrite optimization remarks in YAML format to
4440b57cec5SDimitry Andric.Ar file .
4450b57cec5SDimitry Andric.It Fl -opt-remarks-passes Ar pass-regex
4460b57cec5SDimitry AndricFilter optimization remarks by only allowing the passes matching
4470b57cec5SDimitry Andric.Ar pass-regex .
4480b57cec5SDimitry Andric.It Fl -opt-remarks-with-hotness
4490b57cec5SDimitry AndricInclude hotness information in the optimization remarks file.
4500b57cec5SDimitry Andric.It Fl -orphan-handling Ns = Ns Ar mode
45185868e8aSDimitry AndricControl how orphan sections are handled.
45285868e8aSDimitry AndricAn orphan section is one not specifically mentioned in a linker script.
4530b57cec5SDimitry Andric.Ar mode
4540b57cec5SDimitry Andricmay be:
4550b57cec5SDimitry Andric.Pp
4560b57cec5SDimitry Andric.Bl -tag -width 2n -compact
4570b57cec5SDimitry Andric.It Cm place
4580b57cec5SDimitry AndricPlace orphan sections in suitable output sections.
4590b57cec5SDimitry Andric.It Cm warn
4600b57cec5SDimitry AndricPlace orphan sections as for
4610b57cec5SDimitry Andric.Cm place
4620b57cec5SDimitry Andricand also report a warning.
4630b57cec5SDimitry Andric.It Cm error
4640b57cec5SDimitry AndricPlace orphan sections as for
4650b57cec5SDimitry Andric.Cm place
4660b57cec5SDimitry Andricand also report an error.
4670b57cec5SDimitry Andric.El
4680b57cec5SDimitry Andric.Pp
4690b57cec5SDimitry Andric.Cm place
4700b57cec5SDimitry Andricis the default.
4710b57cec5SDimitry Andric.It Fl -pack-dyn-relocs Ns = Ns Ar format
4720b57cec5SDimitry AndricPack dynamic relocations in the given format.
4730b57cec5SDimitry Andric.Ar format
4740b57cec5SDimitry Andricmay be:
4750b57cec5SDimitry Andric.Pp
4760b57cec5SDimitry Andric.Bl -tag -width 2n -compact
4770b57cec5SDimitry Andric.It Cm none
47885868e8aSDimitry AndricDo not pack.
47985868e8aSDimitry AndricDynamic relocations are encoded in SHT_REL(A).
4800b57cec5SDimitry Andric.It Cm android
4810b57cec5SDimitry AndricPack dynamic relocations in SHT_ANDROID_REL(A).
4820b57cec5SDimitry Andric.It Cm relr
48385868e8aSDimitry AndricPack relative relocations in SHT_RELR, and the rest of dynamic relocations in
48485868e8aSDimitry AndricSHT_REL(A).
4850b57cec5SDimitry Andric.It Cm android+relr
48685868e8aSDimitry AndricPack relative relocations in SHT_RELR, and the rest of dynamic relocations in
48785868e8aSDimitry AndricSHT_ANDROID_REL(A).
4880b57cec5SDimitry Andric.El
4890b57cec5SDimitry Andric.Pp
4900b57cec5SDimitry Andric.Cm none
49185868e8aSDimitry Andricis the default.
49285868e8aSDimitry AndricIf
4930b57cec5SDimitry Andric.Fl -use-android-relr-tags
4940b57cec5SDimitry Andricis specified, use SHT_ANDROID_RELR instead of SHT_RELR.
4950b57cec5SDimitry Andric.Pp
4960b57cec5SDimitry Andric.It Fl -pic-veneer
4970b57cec5SDimitry AndricAlways generate position independent thunks.
4980b57cec5SDimitry Andric.It Fl -pie , Fl -pic-executable
4990b57cec5SDimitry AndricCreate a position independent executable.
5004824e7fdSDimitry Andric.It Fl -power10-stubs Ns = Ns Cm mode
5014824e7fdSDimitry AndricWhether to use Power10 instructions in call stubs for R_PPC64_REL24_NOTOC and TOC/NOTOC interworking.
5024824e7fdSDimitry Andric.Ar mode
5034824e7fdSDimitry Andricmay be:
5044824e7fdSDimitry Andric.Pp
5054824e7fdSDimitry Andric.Bl -tag -width 2n -compact
5064824e7fdSDimitry Andric.It Cm yes
5074824e7fdSDimitry Andric(default) Use.
5084824e7fdSDimitry Andric.It Cm auto
5094824e7fdSDimitry AndricCurrently the same as yes.
5104824e7fdSDimitry Andric.It Cm no
5114824e7fdSDimitry AndricDon't use.
5124824e7fdSDimitry Andric.El
5134824e7fdSDimitry Andric
5140b57cec5SDimitry Andric.It Fl -print-gc-sections
5150b57cec5SDimitry AndricList removed unused sections.
5160b57cec5SDimitry Andric.It Fl -print-icf-sections
5170b57cec5SDimitry AndricList identical folded sections.
5180b57cec5SDimitry Andric.It Fl -print-map
5190b57cec5SDimitry AndricPrint a link map to the standard output.
5205ffd83dbSDimitry Andric.It Fl -print-archive-stats Ns = Ns Ar file
5215ffd83dbSDimitry AndricWrite archive usage statistics to the specified file.
5225ffd83dbSDimitry AndricPrint the numbers of members and fetched members for each archive.
5230b57cec5SDimitry Andric.It Fl -push-state
5240b57cec5SDimitry AndricSave the current state of
5250b57cec5SDimitry Andric.Fl -as-needed ,
5260b57cec5SDimitry Andric.Fl -static ,
5270b57cec5SDimitry Andricand
5280b57cec5SDimitry Andric.Fl -whole-archive.
5290b57cec5SDimitry Andric.It Fl -pop-state
53004eeddc0SDimitry AndricRestore the states saved by
5310b57cec5SDimitry Andric.Fl -push-state.
53206c3fb27SDimitry Andric.It Fl --relax-gp
53306c3fb27SDimitry AndricEnable global pointer relaxation for RISC-V.
5340b57cec5SDimitry Andric.It Fl -relocatable , Fl r
5350b57cec5SDimitry AndricCreate relocatable object file.
53606c3fb27SDimitry Andric.It Fl -remap-inputs Ns = Ns Ar from-glob=to-file
53706c3fb27SDimitry AndricInput files matching
53806c3fb27SDimitry Andric.Cm from-glob
53906c3fb27SDimitry Andricare mapped to
54006c3fb27SDimitry Andric.Cm to-file.
54106c3fb27SDimitry AndricUse
54206c3fb27SDimitry Andric.Cm /dev/null
54306c3fb27SDimitry Andricto ignore an input file.
54406c3fb27SDimitry Andric.It Fl -remap-inputs-file Ns = Ns Ar file
54506c3fb27SDimitry AndricRemap input files based on patterns in
54606c3fb27SDimitry Andric.Ar file .
54706c3fb27SDimitry AndricEach line in the remap file is of the format
54806c3fb27SDimitry Andric.Cm from-glob=to-file
54906c3fb27SDimitry Andricor a comment starting with
55006c3fb27SDimitry Andric.Cm # .
55185868e8aSDimitry Andric.It Fl -reproduce Ns = Ns Ar path
55285868e8aSDimitry AndricWrite a tar file to
55385868e8aSDimitry Andric.Ar path,
55485868e8aSDimitry Andriccontaining all the input files needed to reproduce the link, a text file called
55585868e8aSDimitry Andricresponse.txt containing the command line options and a text file called
55685868e8aSDimitry Andricversion.txt containing the output of ld.lld --version.
55785868e8aSDimitry AndricThe archive when
55885868e8aSDimitry Andricunpacked can be used to re-run the linker with the same options and input files.
5590b57cec5SDimitry Andric.It Fl -retain-symbols-file Ns = Ns Ar file
5600b57cec5SDimitry AndricRetain only the symbols listed in the file.
5610b57cec5SDimitry Andric.It Fl -rpath Ns = Ns Ar value , Fl R Ar value
5620b57cec5SDimitry AndricAdd a
5630b57cec5SDimitry Andric.Dv DT_RUNPATH
5640b57cec5SDimitry Andricto the output.
5650b57cec5SDimitry Andric.It Fl -rsp-quoting Ns = Ns Ar value
5660b57cec5SDimitry AndricQuoting style for response files.
5670b57cec5SDimitry AndricThe supported values are
5680b57cec5SDimitry Andric.Cm windows
5690b57cec5SDimitry Andricand
5700b57cec5SDimitry Andric.Cm posix .
5710b57cec5SDimitry Andric.It Fl -script Ns = Ns Ar file , Fl T Ar file
5720b57cec5SDimitry AndricRead linker script from
5730b57cec5SDimitry Andric.Ar file .
57485868e8aSDimitry AndricIf multiple linker scripts are given, they are processed as if they
57585868e8aSDimitry Andricwere concatenated in the order they appeared on the command line.
5760b57cec5SDimitry Andric.It Fl -section-start Ns = Ns Ar section Ns = Ns Ar address
5770b57cec5SDimitry AndricSet address of section.
5780b57cec5SDimitry Andric.It Fl -shared , Fl -Bsharable
5790b57cec5SDimitry AndricBuild a shared object.
5805ffd83dbSDimitry Andric.It Fl -shuffle-sections Ns = Ns Ar seed
581fe6060f1SDimitry AndricShuffle matched sections using the given seed before mapping them to the output sections.
582fe6060f1SDimitry AndricIf -1, reverse the section order. If 0, use a random seed.
5830b57cec5SDimitry Andric.It Fl -soname Ns = Ns Ar value , Fl h Ar value
5840b57cec5SDimitry AndricSet
5850b57cec5SDimitry Andric.Dv DT_SONAME
5860b57cec5SDimitry Andricto
5870b57cec5SDimitry Andric.Ar value .
5880b57cec5SDimitry Andric.It Fl -sort-common
5890b57cec5SDimitry AndricThis option is ignored for GNU compatibility.
5900b57cec5SDimitry Andric.It Fl -sort-section Ns = Ns Ar value
5910b57cec5SDimitry AndricSpecifies sections sorting rule when linkerscript is used.
5920b57cec5SDimitry Andric.It Fl -start-lib
5930b57cec5SDimitry AndricStart a grouping of objects that should be treated as if they were together
5940b57cec5SDimitry Andricin an archive.
5950b57cec5SDimitry Andric.It Fl -strip-all , Fl s
5960b57cec5SDimitry AndricStrip all symbols.
597fe6060f1SDimitry AndricImplies
598fe6060f1SDimitry Andric.Fl -strip-debug .
5990b57cec5SDimitry Andric.It Fl -strip-debug , Fl S
6000b57cec5SDimitry AndricStrip debugging information.
6010b57cec5SDimitry Andric.It Fl -symbol-ordering-file Ns = Ns Ar file
6020b57cec5SDimitry AndricLay out sections in the order specified by
6030b57cec5SDimitry Andric.Ar file .
6040b57cec5SDimitry Andric.It Fl -sysroot Ns = Ns Ar value
6050b57cec5SDimitry AndricSet the system root.
6060b57cec5SDimitry Andric.It Fl -target1-abs
6070b57cec5SDimitry AndricInterpret
6080b57cec5SDimitry Andric.Dv R_ARM_TARGET1
6090b57cec5SDimitry Andricas
6100b57cec5SDimitry Andric.Dv R_ARM_ABS32 .
6110b57cec5SDimitry Andric.It Fl -target1-rel
6120b57cec5SDimitry AndricInterpret
6130b57cec5SDimitry Andric.Dv R_ARM_TARGET1
6140b57cec5SDimitry Andricas
6150b57cec5SDimitry Andric.Dv R_ARM_REL32 .
6160b57cec5SDimitry Andric.It Fl -target2 Ns = Ns Ar type
6170b57cec5SDimitry AndricInterpret
6180b57cec5SDimitry Andric.Dv R_ARM_TARGET2
6190b57cec5SDimitry Andricas
6200b57cec5SDimitry Andric.Ar type ,
6210b57cec5SDimitry Andricwhere
6220b57cec5SDimitry Andric.Ar type
6230b57cec5SDimitry Andricis one of
6240b57cec5SDimitry Andric.Cm rel ,
6250b57cec5SDimitry Andric.Cm abs ,
6260b57cec5SDimitry Andricor
6270b57cec5SDimitry Andric.Cm got-rel .
6280b57cec5SDimitry Andric.It Fl -Tbss Ns = Ns Ar value
6290b57cec5SDimitry AndricSame as
6300b57cec5SDimitry Andric.Fl -section-start
6310b57cec5SDimitry Andricwith
6320b57cec5SDimitry Andric.Li .bss
6330b57cec5SDimitry Andricas the sectionname.
6340b57cec5SDimitry Andric.It Fl -Tdata Ns = Ns Ar value
6350b57cec5SDimitry AndricSame as
6360b57cec5SDimitry Andric.Fl -section-start
6370b57cec5SDimitry Andricwith
6380b57cec5SDimitry Andric.Li .data
6390b57cec5SDimitry Andricas the sectionname.
6400b57cec5SDimitry Andric.It Fl -Ttext Ns = Ns Ar value
6410b57cec5SDimitry AndricSame as
6420b57cec5SDimitry Andric.Fl -section-start
6430b57cec5SDimitry Andricwith
6440b57cec5SDimitry Andric.Li .text
6450b57cec5SDimitry Andricas the sectionname.
6460b57cec5SDimitry Andric.It Fl -thinlto-cache-dir Ns = Ns Ar value
6470b57cec5SDimitry AndricPath to ThinLTO cached object file directory.
6480b57cec5SDimitry Andric.It Fl -thinlto-cache-policy Ns = Ns Ar value
6490b57cec5SDimitry AndricPruning policy for the ThinLTO cache.
6500b57cec5SDimitry Andric.It Fl -thinlto-jobs Ns = Ns Ar value
6510b57cec5SDimitry AndricNumber of ThinLTO jobs.
6525ffd83dbSDimitry Andric.It Fl -threads Ns = Ns Ar N
6535ffd83dbSDimitry AndricNumber of threads.
6545ffd83dbSDimitry Andric.Cm all
6555ffd83dbSDimitry Andric(default) means all of concurrent threads supported.
6565ffd83dbSDimitry Andric.Cm 1
6575ffd83dbSDimitry Andricdisables multi-threading.
6585f757f3fSDimitry Andric.It Fl -fat-lto-objects
6595f757f3fSDimitry AndricUse the .llvm.lto section, which contains LLVM bitcode, in fat LTO object files to perform LTO.
6605f757f3fSDimitry Andric.It Fl -no-fat-lto-objects
6615f757f3fSDimitry AndricIgnore the .llvm.lto section in relocatable object files (default).
6625ffd83dbSDimitry Andric.It Fl -time-trace
6635ffd83dbSDimitry AndricRecord time trace.
6645ffd83dbSDimitry Andric.It Fl -time-trace-file Ns = Ns Ar file
6655ffd83dbSDimitry AndricWrite time trace output to
6665ffd83dbSDimitry Andric.Ar file .
6675ffd83dbSDimitry Andric.It Fl -time-trace-granularity Ns = Ns Ar value
6685ffd83dbSDimitry AndricMinimum time granularity (in microseconds) traced by time profiler.
6690b57cec5SDimitry Andric.It Fl -trace
6700b57cec5SDimitry AndricPrint the names of the input files.
6710b57cec5SDimitry Andric.It Fl -trace-symbol Ns = Ns Ar symbol , Fl y Ar symbol
6720b57cec5SDimitry AndricTrace references to
6730b57cec5SDimitry Andric.Ar symbol .
6740b57cec5SDimitry Andric.It Fl -undefined Ns = Ns Ar symbol , Fl u Ar symbol
6750b57cec5SDimitry AndricIf
6760b57cec5SDimitry Andric.Ar symbol
6770b57cec5SDimitry Andricis not defined after symbol resolution, and there's a static library
6780b57cec5SDimitry Andricthat contains an object file defining the symbol, load the member
6790b57cec5SDimitry Andricto include the object file in the output file.
6800b57cec5SDimitry Andric.It Fl -undefined-glob Ns = Ns Ar pattern
6810b57cec5SDimitry AndricSynonym for
6820b57cec5SDimitry Andric.Fl -undefined ,
68385868e8aSDimitry Andricexcept that it takes a glob pattern.
68485868e8aSDimitry AndricIn a glob pattern,
6850b57cec5SDimitry Andric.Cm *
6860b57cec5SDimitry Andricmatches zero or more characters,
6870b57cec5SDimitry Andric.Cm ?
6880b57cec5SDimitry Andricmatches any single character, and
6890b57cec5SDimitry Andric.Cm [...]
69085868e8aSDimitry Andricmatches the characters within brackets.
69185868e8aSDimitry AndricAll symbols that match
6920b57cec5SDimitry Andrica given pattern are handled as if they were given as arguments of
6930b57cec5SDimitry Andric.Fl -undefined .
6945ffd83dbSDimitry Andric.It Fl -unique
6955ffd83dbSDimitry AndricCreates a separate output section for every orphan input section.
6960b57cec5SDimitry Andric.It Fl -unresolved-symbols Ns = Ns Ar value
6970b57cec5SDimitry AndricDetermine how to handle unresolved symbols.
6980b57cec5SDimitry Andric.It Fl -use-android-relr-tags
6990b57cec5SDimitry AndricUse SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*.
700bdd1243dSDimitry Andric.It Fl v , Fl V
7010b57cec5SDimitry AndricDisplay the version number and proceed with linking if object files are
7020b57cec5SDimitry Andricspecified.
703bdd1243dSDimitry Andric.It Fl -version
7040b57cec5SDimitry AndricDisplay the version number and exit.
7050b57cec5SDimitry Andric.It Fl -verbose
7060b57cec5SDimitry AndricVerbose mode.
7070b57cec5SDimitry Andric.It Fl -version-script Ns = Ns Ar file
7080b57cec5SDimitry AndricRead version script from
7090b57cec5SDimitry Andric.Ar file .
7100b57cec5SDimitry Andric.It Fl -warn-backrefs
7110b57cec5SDimitry AndricWarn about reverse or cyclic dependencies to or between static archives.
7120b57cec5SDimitry AndricThis can be used to ensure linker invocation remains compatible with
7130b57cec5SDimitry Andrictraditional Unix-like linkers.
7145ffd83dbSDimitry Andric.It Fl -warn-backrefs-exclude Ns = Ns Ar glob
7155ffd83dbSDimitry AndricGlob describing an archive (or an object file within --start-lib)
7165ffd83dbSDimitry Andricwhich should be ignored for
7175ffd83dbSDimitry Andric.Fl -warn-backrefs
7180b57cec5SDimitry Andric.It Fl -warn-common
7190b57cec5SDimitry AndricWarn about duplicate common symbols.
7200b57cec5SDimitry Andric.It Fl -warn-ifunc-textrel
7210b57cec5SDimitry AndricWarn about using ifunc symbols in conjunction with text relocations.
7220b57cec5SDimitry AndricOlder versions of glibc library (2.28 and earlier) has a bug that causes
7230b57cec5SDimitry Andricthe segment that includes ifunc symbols to be marked as not executable when
72485868e8aSDimitry Andricthey are relocated.
72585868e8aSDimitry AndricAs a result, although the program compiles and links
7260b57cec5SDimitry Andricsuccessfully, it gives segmentation fault when the instruction pointer reaches
72785868e8aSDimitry Andrican ifunc symbol.
72885868e8aSDimitry AndricUse -warn-ifunc-textrel to let lld give a warning, if the
7290b57cec5SDimitry Andriccode may include ifunc symbols, may do text relocations and be linked with
73085868e8aSDimitry Andrican older glibc version.
73185868e8aSDimitry AndricOtherwise, there is no need to use it, as the default value does not give a
73285868e8aSDimitry Andricwarning.
73385868e8aSDimitry AndricThis flag has been introduced in late 2018, has no counter part in ld and gold
73485868e8aSDimitry Andriclinkers, and may be removed in the future.
7350b57cec5SDimitry Andric.It Fl -warn-unresolved-symbols
7360b57cec5SDimitry AndricReport unresolved symbols as warnings.
7370b57cec5SDimitry Andric.It Fl -whole-archive
7380b57cec5SDimitry AndricForce load of all members in a static library.
739349cc55cSDimitry Andric.It Fl -why-extract Ns = Ns Ar file
740349cc55cSDimitry AndricPrint to a file about why archive members are extracted.
7410b57cec5SDimitry Andric.It Fl -wrap Ns = Ns Ar symbol
742e8d8bef9SDimitry AndricRedirect
743e8d8bef9SDimitry Andric.Ar symbol
744e8d8bef9SDimitry Andricreferences to
745e8d8bef9SDimitry Andric.Ar __wrap_symbol
746e8d8bef9SDimitry Andricand
747e8d8bef9SDimitry Andric.Ar __real_symbol
748e8d8bef9SDimitry Andricreferences to
749e8d8bef9SDimitry Andric.Ar symbol.
7500b57cec5SDimitry Andric.It Fl z Ar option
7510b57cec5SDimitry AndricLinker option extensions.
75285868e8aSDimitry Andric.Bl -tag -width indent -compact
75385868e8aSDimitry Andric.Pp
7545ffd83dbSDimitry Andric.It Cm dead-reloc-in-nonalloc Ns = Ns Ar section_glob=value
7555ffd83dbSDimitry AndricResolve a relocation in a matched non-SHF_ALLOC section referencing a discarded symbol to
7565ffd83dbSDimitry Andric.Ar value
7575ffd83dbSDimitry AndricAccepts globs, in the event of a section matching more than one option, the last
7585ffd83dbSDimitry Andricoption takes precedence. An order of least specific to most specific match is
7595ffd83dbSDimitry Andricrecommended.
7605ffd83dbSDimitry Andric.Pp
7610b57cec5SDimitry Andric.It Cm execstack
7620b57cec5SDimitry AndricMake the main stack executable.
7630b57cec5SDimitry AndricStack permissions are recorded in the
7640b57cec5SDimitry Andric.Dv PT_GNU_STACK
7650b57cec5SDimitry Andricsegment.
76685868e8aSDimitry Andric.Pp
7670eae32dcSDimitry Andric.It Cm bti-report Ns = Ns Ar [none|warning|error]
7680eae32dcSDimitry AndricSpecify how to report the missing GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
7690eae32dcSDimitry Andric.Cm none
7700eae32dcSDimitry Andricis the default, linker will not report the missing property otherwise will be reported as a warning or an error.
7710eae32dcSDimitry Andric.Pp
7720eae32dcSDimitry Andric.It Cm cet-report Ns = Ns Ar [none|warning|error]
7730eae32dcSDimitry AndricSpecify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT or GNU_PROPERTY_X86_FEATURE_1_SHSTK properties.
7740eae32dcSDimitry Andric.Cm none
7750eae32dcSDimitry Andricis the default, linker will not report the missing property otherwise will be reported as a warning or an error.
7760eae32dcSDimitry Andric.Pp
777*0fca6ea1SDimitry Andric.It Cm pauth-report Ns = Ns Ar [none|warning|error]
778*0fca6ea1SDimitry AndricSpecify how to report the missing GNU_PROPERTY_AARCH64_FEATURE_PAUTH property.
779*0fca6ea1SDimitry Andric.Cm none
780*0fca6ea1SDimitry Andricis the default, linker will not report the missing property otherwise will be reported as a warning or an error.
781*0fca6ea1SDimitry Andric.Pp
782480093f4SDimitry Andric.It Cm force-bti
783480093f4SDimitry AndricForce enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
784480093f4SDimitry Andric.Pp
785480093f4SDimitry Andric.It Cm force-ibt
786480093f4SDimitry AndricForce enable Intel Indirect Branch Tracking in PLT, warn if an input ELF file
787480093f4SDimitry Andricdoes not have GNU_PROPERTY_X86_FEATURE_1_IBT property.
788480093f4SDimitry Andric.Pp
7890b57cec5SDimitry Andric.It Cm global
7900b57cec5SDimitry AndricSets the
7910b57cec5SDimitry Andric.Dv DF_1_GLOBAL flag in the
7920b57cec5SDimitry Andric.Dv DYNAMIC
7930b57cec5SDimitry Andricsection.
7940b57cec5SDimitry AndricDifferent loaders can decide how to handle this flag on their own.
79585868e8aSDimitry Andric.Pp
7960b57cec5SDimitry Andric.It Cm ifunc-noplt
7970b57cec5SDimitry AndricDo not emit PLT entries for ifunc symbols.
7980b57cec5SDimitry AndricInstead, emit text relocations referencing the resolver.
7990b57cec5SDimitry AndricThis is an experimental optimization and only suitable for standalone
8000b57cec5SDimitry Andricenvironments where text relocations do not have the usual drawbacks.
8010b57cec5SDimitry AndricThis option must be combined with the
8020b57cec5SDimitry Andric.Fl z Li notext
8030b57cec5SDimitry Andricoption.
80485868e8aSDimitry Andric.Pp
8050b57cec5SDimitry Andric.It Cm initfirst
8060b57cec5SDimitry AndricSets the
8070b57cec5SDimitry Andric.Dv DF_1_INITFIRST
8080b57cec5SDimitry Andricflag to indicate the module should be initialized first.
80985868e8aSDimitry Andric.Pp
8100b57cec5SDimitry Andric.It Cm interpose
8110b57cec5SDimitry AndricSet the
8120b57cec5SDimitry Andric.Dv DF_1_INTERPOSE
8130b57cec5SDimitry Andricflag to indicate to the runtime linker that the object is an interposer.
8140b57cec5SDimitry AndricDuring symbol resolution interposers are searched after the application
8150b57cec5SDimitry Andricbut before other dependencies.
81685868e8aSDimitry Andric.Pp
817*0fca6ea1SDimitry Andric.It Cm lrodata-after-bss
818*0fca6ea1SDimitry AndricPlace .lrodata after .bss.
819*0fca6ea1SDimitry Andric.Pp
8200b57cec5SDimitry Andric.It Cm muldefs
8210b57cec5SDimitry AndricDo not error if a symbol is defined multiple times.
8220b57cec5SDimitry AndricThe first definition will be used.
8230b57cec5SDimitry AndricThis is a synonym for
8240b57cec5SDimitry Andric.Fl -allow-multiple-definition.
82585868e8aSDimitry Andric.Pp
8260b57cec5SDimitry Andric.It Cm nocombreloc
8270b57cec5SDimitry AndricDisable combining and sorting multiple relocation sections.
82885868e8aSDimitry Andric.Pp
8290b57cec5SDimitry Andric.It Cm nocopyreloc
8300b57cec5SDimitry AndricDisable the creation of copy relocations.
83185868e8aSDimitry Andric.Pp
8320b57cec5SDimitry Andric.It Cm nodefaultlib
8330b57cec5SDimitry AndricSet the
8340b57cec5SDimitry Andric.Dv DF_1_NODEFLIB
8350b57cec5SDimitry Andricflag to indicate that default library search paths should be ignored.
83685868e8aSDimitry Andric.Pp
8370b57cec5SDimitry Andric.It Cm nodelete
8380b57cec5SDimitry AndricSet the
8390b57cec5SDimitry Andric.Dv DF_1_NODELETE
8400b57cec5SDimitry Andricflag to indicate that the object cannot be unloaded from a process.
84185868e8aSDimitry Andric.Pp
8420b57cec5SDimitry Andric.It Cm nodlopen
8430b57cec5SDimitry AndricSet the
8440b57cec5SDimitry Andric.Dv DF_1_NOOPEN
8450b57cec5SDimitry Andricflag to indicate that the object may not be opened by
8460b57cec5SDimitry Andric.Xr dlopen 3 .
84785868e8aSDimitry Andric.Pp
848480093f4SDimitry Andric.It Cm nognustack
849480093f4SDimitry AndricDo not emit the
850480093f4SDimitry Andric.Dv PT_GNU_STACK
851480093f4SDimitry Andricsegment.
852480093f4SDimitry Andric.Pp
8530b57cec5SDimitry Andric.It Cm norelro
854480093f4SDimitry AndricDo not indicate that portions of the object should be mapped read-only
8550b57cec5SDimitry Andricafter initial relocation processing.
8560b57cec5SDimitry AndricThe object will omit the
8570b57cec5SDimitry Andric.Dv PT_GNU_RELRO
8580b57cec5SDimitry Andricsegment.
85985868e8aSDimitry Andric.Pp
8600b57cec5SDimitry Andric.It Cm notext
8610b57cec5SDimitry AndricAllow relocations against read-only segments.
8620b57cec5SDimitry AndricSets the
8630b57cec5SDimitry Andric.Dv DT_TEXTREL flag in the
8640b57cec5SDimitry Andric.Dv DYNAMIC
8650b57cec5SDimitry Andricsection.
86685868e8aSDimitry Andric.Pp
8670b57cec5SDimitry Andric.It Cm now
8680b57cec5SDimitry AndricSet the
8690b57cec5SDimitry Andric.Dv DF_BIND_NOW
8700b57cec5SDimitry Andricflag to indicate that the run-time loader should perform all relocation
8710b57cec5SDimitry Andricprocessing as part of object initialization.
8720b57cec5SDimitry AndricBy default relocations may be performed on demand.
87385868e8aSDimitry Andric.Pp
8740b57cec5SDimitry Andric.It Cm origin
8750b57cec5SDimitry AndricSet the
8760b57cec5SDimitry Andric.Dv DF_ORIGIN
8770b57cec5SDimitry Andricflag to indicate that the object requires
8780b57cec5SDimitry Andric$ORIGIN
8790b57cec5SDimitry Andricprocessing.
88085868e8aSDimitry Andric.Pp
881480093f4SDimitry Andric.It Cm pac-plt
882480093f4SDimitry AndricAArch64 only, use pointer authentication in PLT.
883480093f4SDimitry Andric.Pp
88481ad6265SDimitry Andric.It Cm pack-relative-relocs
88581ad6265SDimitry AndricSimilar to
88681ad6265SDimitry Andric.Cm -pack-dyn-relocs=relr
88781ad6265SDimitry Andric, but synthesizes the GLIBC_ABI_DT_RELR version dependency if there is a GLIBC_2.* version dependency.
88881ad6265SDimitry Andricglibc ld.so rejects loading a dynamically linked object without the GLIBC_ABI_DT_RELR version dependency.
88981ad6265SDimitry Andric.Pp
8905ffd83dbSDimitry Andric.It Cm rel
8915ffd83dbSDimitry AndricUse REL format for dynamic relocations.
8925ffd83dbSDimitry Andric.Pp
8935ffd83dbSDimitry Andric.It Cm rela
8945ffd83dbSDimitry AndricUse RELA format for dynamic relocations.
8955ffd83dbSDimitry Andric.Pp
8960b57cec5SDimitry Andric.It Cm retpolineplt
8970b57cec5SDimitry AndricEmit retpoline format PLT entries as a mitigation for CVE-2017-5715.
89885868e8aSDimitry Andric.Pp
8990b57cec5SDimitry Andric.It Cm rodynamic
9000b57cec5SDimitry AndricMake the
9010b57cec5SDimitry Andric.Li .dynamic
9020b57cec5SDimitry Andricsection read-only.
9030b57cec5SDimitry AndricThe
9040b57cec5SDimitry Andric.Dv DT_DEBUG
9050b57cec5SDimitry Andrictag will not be emitted.
90685868e8aSDimitry Andric.Pp
90785868e8aSDimitry Andric.It Cm separate-loadable-segments
90885868e8aSDimitry Andric.It Cm separate-code
90985868e8aSDimitry Andric.It Cm noseparate-code
91085868e8aSDimitry AndricSpecify whether two adjacent PT_LOAD segments are allowed to overlap in pages.
91185868e8aSDimitry Andric.Cm noseparate-code
91285868e8aSDimitry Andric(default) allows overlap.
91385868e8aSDimitry Andric.Cm separate-code
91485868e8aSDimitry Andricallows overlap between two executable segments, or two non-executable segments.
91585868e8aSDimitry Andric.Cm separate-loadable-segments
91685868e8aSDimitry Andricdisallows overlap.
91785868e8aSDimitry Andric.Pp
918480093f4SDimitry Andric.It Cm shstk
919480093f4SDimitry Andricx86 only, use shadow stack.
920480093f4SDimitry Andric.Pp
9210b57cec5SDimitry Andric.It Cm stack-size Ns = Ns Ar size
9220b57cec5SDimitry AndricSet the main thread's stack size to
9230b57cec5SDimitry Andric.Ar size .
9240b57cec5SDimitry AndricThe stack size is recorded as the size of the
9250b57cec5SDimitry Andric.Ar size .
9260b57cec5SDimitry Andric.Dv PT_GNU_STACK
9270b57cec5SDimitry Andricprogram segment.
92885868e8aSDimitry Andric.Pp
929fe6060f1SDimitry Andric.It Cm start-stop-gc
930fe6060f1SDimitry AndricDon't let __start_/__stop_ references retain the associated C identifier name sections (default).
931fe6060f1SDimitry Andric.Pp
932fe6060f1SDimitry Andric.It Cm nostart-stop-gc
933fe6060f1SDimitry AndricLet __start_/__stop_ references retain the associated C identifier name sections.
934fe6060f1SDimitry Andric.Pp
9350b57cec5SDimitry Andric.It Cm text
9360b57cec5SDimitry AndricDo not allow relocations against read-only segments.
9370b57cec5SDimitry AndricThis is the default.
93885868e8aSDimitry Andric.Pp
9390b57cec5SDimitry Andric.It Cm wxneeded
9400b57cec5SDimitry AndricCreate a
9410b57cec5SDimitry Andric.Dv PT_OPENBSD_WXNEEDED
9420b57cec5SDimitry Andricsegment.
9430b57cec5SDimitry Andric.El
9440b57cec5SDimitry Andric.El
94506c3fb27SDimitry Andric
94606c3fb27SDimitry Andric.Sh ENVIRONMENT VARIABLES
94706c3fb27SDimitry Andric.Bl -tag -width LC_CTYPE
94806c3fb27SDimitry Andric.It Ev LLD_REPRODUCE
94906c3fb27SDimitry AndricCreate a reproduce tarball with the specified filename. If
95006c3fb27SDimitry Andric.Fl -reproduce
95106c3fb27SDimitry Andricis specified,
95206c3fb27SDimitry Andric.Fl -reproduce
95306c3fb27SDimitry Andrictakes precedence.
95406c3fb27SDimitry Andric.It Ev LLD_VERSION
95506c3fb27SDimitry Andricld.lld creates a section named
95606c3fb27SDimitry Andric.Cm .comment
95706c3fb27SDimitry Andriccontaining the LLD version string. The version string can be overridden by this environment variable,
95806c3fb27SDimitry Andricwhich is useful to eliminate differences in the binary caused by LLD version number differences.
95906c3fb27SDimitry Andric.El
96006c3fb27SDimitry Andric
9610b57cec5SDimitry Andric.Sh IMPLEMENTATION NOTES
9620b57cec5SDimitry Andric.Nm Ap s
9630b57cec5SDimitry Andrichanding of archive files (those with a
9640b57cec5SDimitry Andric.Pa .a
9650b57cec5SDimitry Andricfile extension) is different from traditional linkers used on Unix-like
9660b57cec5SDimitry Andricsystems.
9670b57cec5SDimitry Andric.Pp
9680b57cec5SDimitry AndricTraditional linkers maintain a set of undefined symbols during linking.
9690b57cec5SDimitry AndricThe linker processes each file in the order in which it appears on the
9700b57cec5SDimitry Andriccommand line, until the set of undefined symbols becomes empty.
9710b57cec5SDimitry AndricAn object file is linked into the output object when it is encountered,
9720b57cec5SDimitry Andricwith its undefined symbols added to the set.
9730b57cec5SDimitry AndricUpon encountering an archive file a traditional linker searches the objects
9740b57cec5SDimitry Andriccontained therein, and processes those that satisfy symbols in the unresolved
9750b57cec5SDimitry Andricset.
9760b57cec5SDimitry Andric.Pp
9770b57cec5SDimitry AndricHandling mutually dependent archives may be awkward when using a traditional
9780b57cec5SDimitry Andriclinker.
9790b57cec5SDimitry AndricArchive files may have to be specified multiple times, or the special command
9800b57cec5SDimitry Andricline options
9810b57cec5SDimitry Andric.Fl -start-group
9820b57cec5SDimitry Andricand
9830b57cec5SDimitry Andric.Fl -end-group
9840b57cec5SDimitry Andricmay be used to have the linker loop over the files in the group until no new
9850b57cec5SDimitry Andricsymbols are added to the set.
9860b57cec5SDimitry Andric.Pp
9870b57cec5SDimitry Andric.Nm
9880b57cec5SDimitry Andricrecords all symbols found in objects and archives as it iterates over
9890b57cec5SDimitry Andriccommand line arguments.
9900b57cec5SDimitry AndricWhen
9910b57cec5SDimitry Andric.Nm
9920b57cec5SDimitry Andricencounters an undefined symbol that can be resolved by an object file
9930b57cec5SDimitry Andriccontained in a previously processed archive file, it immediately extracts
9940b57cec5SDimitry Andricand links it into the output object.
9950b57cec5SDimitry Andric.Pp
9960b57cec5SDimitry AndricWith certain archive inputs
9970b57cec5SDimitry Andric.Nm
9980b57cec5SDimitry Andricmay produce different results compared to traditional linkers.
9990b57cec5SDimitry AndricIn practice, large bodies of third party software have been linked with
10000b57cec5SDimitry Andric.Nm
10010b57cec5SDimitry Andricwithout material issues.
10020b57cec5SDimitry Andric.Pp
10030b57cec5SDimitry AndricThe
10040b57cec5SDimitry Andric.Fl -warn-backrefs
10050b57cec5SDimitry Andricoption may be used to identify a linker invocation that may be incompatible
10060b57cec5SDimitry Andricwith traditional Unix-like linker behavior.
1007