xref: /llvm-project/lld/docs/ld.lld.1 (revision 52574b5f40606b8319952e45d0c407675d9ee0fa)
12946cd70SChandler Carruth.\" Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
22946cd70SChandler Carruth.\" See https://llvm.org/LICENSE.txt for license information.
32946cd70SChandler Carruth.\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
43a775a17SEd Maste.\"
53a775a17SEd Maste.\" This man page documents only lld's ELF linking support, obtained originally
63a775a17SEd Maste.\" from FreeBSD.
76084ee74SWANG Xuerui.Dd Jul 25, 2023
83a775a17SEd Maste.Dt LD.LLD 1
93a775a17SEd Maste.Os
103a775a17SEd Maste.Sh NAME
113a775a17SEd Maste.Nm ld.lld
123a775a17SEd Maste.Nd ELF linker from the LLVM project
133a775a17SEd Maste.Sh SYNOPSIS
143a775a17SEd Maste.Nm ld.lld
153a775a17SEd Maste.Op Ar options
163a775a17SEd Maste.Ar objfile ...
173a775a17SEd Maste.Sh DESCRIPTION
183a775a17SEd MasteA linker takes one or more object, archive, and library files, and combines
193a775a17SEd Mastethem into an output file (an executable, a shared library, or another object
203a775a17SEd Mastefile).
213a775a17SEd MasteIt relocates code and data from the input files and resolves symbol
223a775a17SEd Mastereferences between them.
233a775a17SEd Maste.Pp
243a775a17SEd Maste.Nm
253a775a17SEd Masteis a drop-in replacement for the GNU BFD and gold linkers.
263a775a17SEd MasteIt accepts most of the same command line arguments and linker scripts
273a775a17SEd Masteas GNU linkers.
283a775a17SEd Maste.Pp
291e591d80SRui Ueyama.Nm
306084ee74SWANG Xueruicurrently supports i386, x86-64, ARM, AArch64, LoongArch, PowerPC32,
316084ee74SWANG XueruiPowerPC64, MIPS32, MIPS64, RISC-V, AMDGPU, Hexagon and SPARC V9 targets.
321e591d80SRui Ueyama.Nm
331e591d80SRui Ueyamaacts as a Microsoft link.exe-compatible linker if invoked as
341e591d80SRui Ueyama.Nm lld-link
351e591d80SRui Ueyamaand as macOS's ld if invoked as
361e591d80SRui Ueyama.Nm ld.ld64.
371e591d80SRui UeyamaAll these targets are always supported however
381e591d80SRui Ueyama.Nm
391e591d80SRui Ueyamawas built, so you can always use
401e591d80SRui Ueyama.Nm
411e591d80SRui Ueyamaas a native linker as well as a cross linker.
421e591d80SRui Ueyama.Sh OPTIONS
435289bbe4SEd MasteMany options have both a single-letter and long form.
445289bbe4SEd MasteWhen using the long form options other than those beginning with the
455289bbe4SEd Masteletter
465289bbe4SEd Maste.Cm o
475289bbe4SEd Mastemay be specified using either one or two dashes preceding the option name.
485289bbe4SEd MasteLong options beginning with
495289bbe4SEd Maste.Cm o
505289bbe4SEd Masterequire two dashes to avoid confusion with the
515289bbe4SEd Maste.Fl o Ar path
525289bbe4SEd Masteoption.
535289bbe4SEd Maste.Pp
543a775a17SEd Maste.Bl -tag -width indent
553a775a17SEd Maste.It Fl -allow-multiple-definition
563a775a17SEd MasteDo not error if a symbol is defined multiple times.
573a775a17SEd MasteThe first definition will be used.
58ae029437SFangrui Song.It Fl -allow-shlib-undefined
59ae029437SFangrui SongAllow unresolved references in shared libraries.
60ae029437SFangrui SongThis option is enabled by default when linking a shared library.
6105779bfcSFangrui Song.It Fl -apply-dynamic-relocs
6205779bfcSFangrui SongApply link-time values for dynamic relocations.
633a775a17SEd Maste.It Fl -as-needed
643a775a17SEd MasteOnly set
653a775a17SEd Maste.Dv DT_NEEDED
663a775a17SEd Mastefor shared libraries if used.
67dfcd846bSEd Maste.It Fl -auxiliary Ns = Ns Ar value
683a775a17SEd MasteSet the
693a775a17SEd Maste.Dv DT_AUXILIARY
703a775a17SEd Mastefield to the specified name.
71bac187beSFangrui Song.It Fl -Bdynamic , Fl -dy
723a775a17SEd MasteLink against shared libraries.
73bac187beSFangrui Song.It Fl -Bstatic , Fl -static , Fl -dn
743a775a17SEd MasteDo not link against shared libraries.
754adf7a76SFangrui Song.It Fl Bno-symbolic
764adf7a76SFangrui SongDon't bind default visibility defined symbols locally for
774adf7a76SFangrui Song.Fl shared
784adf7a76SFangrui Song(default).
794adf7a76SFangrui Song.It Fl Bsymbolic
804adf7a76SFangrui SongBind default visibility defined symbols locally for
814adf7a76SFangrui Song.Fl shared.
824adf7a76SFangrui SongAlso set the
834adf7a76SFangrui Song.Dv DF_SYMBOLIC
844adf7a76SFangrui Songflag.
8597e39f96SShoaib Meenai.It Fl Bsymbolic-non-weak
8697e39f96SShoaib MeenaiBind default visibility defined STB_GLOBAL symbols locally for
8797e39f96SShoaib Meenai.Fl shared.
884adf7a76SFangrui Song.It Fl Bsymbolic-functions
894adf7a76SFangrui SongBind default visibility defined function symbols locally for
904adf7a76SFangrui Song.Fl shared.
91b06426daSFangrui Song.It Fl Bsymbolic-non-weak-functions
92b06426daSFangrui SongBind default visibility defined STB_GLOBAL function symbols locally for
93b06426daSFangrui Song.Fl shared.
94f146763eSSimi Pallipurath.It Fl --be8
95f146763eSSimi PallipurathWrite a Big Endian ELF File using BE8 format(AArch32 only)
96a83e226cSEd Maste.It Fl -build-id Ns = Ns Ar value
973a775a17SEd MasteGenerate a build ID note.
983a775a17SEd Maste.Ar value
993a775a17SEd Mastemay be one of
100421fdaa1SEd Maste.Cm fast ,
1013a775a17SEd Maste.Cm md5 ,
1023a775a17SEd Maste.Cm sha1 ,
1033a775a17SEd Maste.Cm tree ,
1043a775a17SEd Maste.Cm uuid ,
1053a775a17SEd Maste.Cm 0x Ns Ar hex-string ,
1063a775a17SEd Masteand
1073a775a17SEd Maste.Cm none .
1083a775a17SEd Maste.Cm tree
1093a775a17SEd Masteis an alias for
1103a775a17SEd Maste.Cm sha1 .
1113a775a17SEd MasteBuild-IDs of type
112421fdaa1SEd Maste.Cm fast ,
1133a775a17SEd Maste.Cm md5 ,
1143a775a17SEd Maste.Cm sha1 ,
1153a775a17SEd Masteand
1163a775a17SEd Maste.Cm tree
1173a775a17SEd Masteare calculated from the object contents.
118421fdaa1SEd Maste.Cm fast
119421fdaa1SEd Masteis not intended to be cryptographically secure.
1203a775a17SEd Maste.It Fl -build-id
121421fdaa1SEd MasteSynonym for
1221d96e4bcSTatsuyuki Ishi.Fl -build-id Ns = Ns Cm sha1 .
1238c556b7eSFangrui Song.It Fl -call-graph-profile-sort Ns = Ns Ar algorithm
1248c556b7eSFangrui Song.Ar algorithm
1258c556b7eSFangrui Songmay be:
1268c556b7eSFangrui Song.Pp
1278c556b7eSFangrui Song.Bl -tag -width 2n -compact
1288c556b7eSFangrui Song.It Cm none
1298c556b7eSFangrui SongIgnore call graph profile.
1308c556b7eSFangrui Song.It Cm hfsort
131b53c04a8SspupyrevUse hfsort.
132904b3f66Sspupyrev.It Cm cdsort
133b53c04a8SspupyrevUse cdsort (default).
1348c556b7eSFangrui Song.El
1358c556b7eSFangrui Song.Pp
136a83e226cSEd Maste.It Fl -color-diagnostics Ns = Ns Ar value
1373a775a17SEd MasteUse colors in diagnostics.
1383a775a17SEd Maste.Ar value
1393a775a17SEd Mastemay be one of
1403a775a17SEd Maste.Cm always ,
1413a775a17SEd Maste.Cm auto ,
1423a775a17SEd Masteand
1433a775a17SEd Maste.Cm never .
1443a775a17SEd Maste.Cm auto
1453a775a17SEd Masteenables color if and only if output is to a terminal.
1463a775a17SEd Maste.It Fl -color-diagnostics
1473a775a17SEd MasteAlias for
148a83e226cSEd Maste.Fl -color-diagnostics Ns = Ns Cm auto .
149a83e226cSEd Maste.It Fl -compress-debug-sections Ns = Ns Ar value
1503a775a17SEd MasteCompress DWARF debug sections.
151cfa97699SFangrui SongThe sections remain uncompressed if compressed content would be larger.
152449f2ca1SFangrui Song.Cm value
1533a775a17SEd Mastemay be
154449f2ca1SFangrui Song.Pp
155449f2ca1SFangrui Song.Bl -tag -width 2n -compact
156449f2ca1SFangrui Song.It Cm none
157449f2ca1SFangrui SongNo compression.
158449f2ca1SFangrui Song.It Cm zlib
1596faf8bdcSRui UeyamaThe default compression level is 1 (fastest) as the debug info usually
1606d44a1efSFangrui Songcompresses well at that level.
161449f2ca1SFangrui Song.It Cm zstd
1626d44a1efSFangrui SongUse the default compression level in zstd.
163449f2ca1SFangrui Song.El
164449f2ca1SFangrui Song.Pp
1656d44a1efSFangrui Song.It Fl -compress-sections Ns = Ns Ar section-glob={none,zlib,zstd}[:level]
166f1ca2a09SFangrui SongCompress output sections that match the glob and do not have the SHF_ALLOC flag.
167cfa97699SFangrui SongThe matched sections remain uncompressed if compressed content would be larger.
1686d44a1efSFangrui SongThe compression level is
1696d44a1efSFangrui Song.Cm level
1706d44a1efSFangrui Song(if specified) or a default speed-focused level.
171f1ca2a09SFangrui SongThis is like a generalized
172f1ca2a09SFangrui Song.Cm --compress-debug-sections.
173bac187beSFangrui Song.It Fl -cref
1741ce51a5fSFangrui SongOutput cross reference table. If
1751ce51a5fSFangrui Song.Fl Map
1761ce51a5fSFangrui Songis specified, print to the map file.
17716711b43Scmtice.It Fl -debug-names
17816711b43ScmticeGenerate a merged
17916711b43Scmtice.Li .debug_names
18016711b43Scmticesection.
181f02a27dfSFangrui Song.It Fl -default-script Ns = Ns Ar file , Fl dT Ar file
182f02a27dfSFangrui SongIn the absence of
183f02a27dfSFangrui Song.Fl -script ,
184f02a27dfSFangrui Songread this default linker script.
185a83e226cSEd Maste.It Fl -defsym Ns = Ns Ar symbol Ns = Ns Ar expression
1863a775a17SEd MasteDefine a symbol alias.
1873a775a17SEd Maste.Ar expression
1883a775a17SEd Mastemay be another symbol or a linker script expression.
1893a775a17SEd MasteFor example,
190a83e226cSEd Maste.Ql --defsym=foo=bar
1913a775a17SEd Masteor
192a83e226cSEd Maste.Ql --defsym=foo=bar+0x100 .
1933a775a17SEd Maste.It Fl -demangle
1943a775a17SEd MasteDemangle symbol names.
1953a775a17SEd Maste.It Fl -disable-new-dtags
1963a775a17SEd MasteDisable new dynamic tags.
197bac187beSFangrui Song.It Fl -discard-all , Fl x
1983a775a17SEd MasteDelete all local symbols.
199bac187beSFangrui Song.It Fl -discard-locals , Fl X
2003a775a17SEd MasteDelete temporary local symbols.
2013a775a17SEd Maste.It Fl -discard-none
2023a775a17SEd MasteKeep all symbols in the symbol table.
203dfcd846bSEd Maste.It Fl -dynamic-linker Ns = Ns Ar value
2043a775a17SEd MasteSpecify the dynamic linker to be used for a dynamically linked executable.
2053a775a17SEd MasteThis is recorded in an ELF segment of type
2063a775a17SEd Maste.Dv PT_INTERP .
207dde3a917SEd Maste.It Fl -dynamic-list Ns = Ns Ar file
20844361e5bSFangrui SongSimilar to
20944361e5bSFangrui Song.Cm --export-dynamic-symbol-list .
21044361e5bSFangrui SongWhen creating a shared object, implies
211751f18e7SFangrui Song.Cm -Bsymbolic
212751f18e7SFangrui Songbut does not set DF_SYMBOLIC
213eea34aaeSFangrui Song.It Fl -EB
214eea34aaeSFangrui SongSelect the big-endian format in the OUTPUT_FORMAT command.
215eea34aaeSFangrui Song.It Fl -EL
216eea34aaeSFangrui SongSelect the little-endian format in the OUTPUT_FORMAT command.
2173a775a17SEd Maste.It Fl -eh-frame-hdr
2183a775a17SEd MasteRequest creation of
2193a775a17SEd Maste.Li .eh_frame_hdr
2203a775a17SEd Mastesection and
2213a775a17SEd Maste.Dv PT_GNU_EH_FRAME
2223a775a17SEd Mastesegment header.
223bac187beSFangrui Song.It Fl -emit-relocs , Fl q
2243a775a17SEd MasteGenerate relocations in the output.
2253a775a17SEd Maste.It Fl -enable-new-dtags
2263a775a17SEd MasteEnable new dynamic tags.
22766466ff1SDaniel Thornburgh.It Fl -enable-non-contiguous-regions
22866466ff1SDaniel ThornburghSpill input sections to later matching output sections to avoid memory region overflow.
2293a775a17SEd Maste.It Fl -end-lib
2303a775a17SEd MasteEnd a grouping of objects that should be treated as if they were together
2313a775a17SEd Mastein an archive.
232dde3a917SEd Maste.It Fl -entry Ns = Ns Ar entry
2333a775a17SEd MasteName of entry point symbol.
234dde3a917SEd Maste.It Fl -error-limit Ns = Ns Ar value
2353a775a17SEd MasteMaximum number of errors to emit before stopping.
2363a775a17SEd MasteA value of zero indicates that there is no limit.
2373a775a17SEd Maste.It Fl -error-unresolved-symbols
2383a775a17SEd MasteReport unresolved symbols as errors.
239cfc32267Sserge-sans-paille.It Fl -error-handing-script Ns = Ns Ar script_path
240cfc32267Sserge-sans-pailleCall script
241cfc32267Sserge-sans-paille.Ar script_path
242cfc32267Sserge-sans-pailleupon some error, with
243cfc32267Sserge-sans-paille.Ar tag
244cfc32267Sserge-sans-pailleas first argument, and an extra parameter as second argument. The script is
245cfc32267Sserge-sans-pailleexpected to return 0 on success. Any other value is considered a generic error.
246cfc32267Sserge-sans-paille.Ar tag
247cfc32267Sserge-sans-paillemay be
248cfc32267Sserge-sans-paille.Cm missing-lib
249cfc32267Sserge-sans-paillefollowed by the name of the missing library.
2501e70ec10Sserge-sans-paille.Cm undefined-symbol
2511e70ec10Sserge-sans-paillefollowed by the name of the undefined symbol.
252378a028dSRui Ueyama.It Fl -execute-only
253174e0833SEd MasteMark executable sections unreadable.
254174e0833SEd MasteThis option is currently only supported on AArch64.
255dde3a917SEd Maste.It Fl -exclude-libs Ns = Ns Ar value
2563a775a17SEd MasteExclude static libraries from automatic export.
257f35ff042SFangrui Song.It Fl -export-dynamic , Fl E
258f35ff042SFangrui SongPut symbols in the dynamic symbol table.
259751f18e7SFangrui Song.It Fl -export-dynamic-symbol Ns = Ns Ar glob
260751f18e7SFangrui Song(executable) Put matched non-local defined symbols to the dynamic symbol table.
261751f18e7SFangrui Song(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
262751f18e7SFangrui Song.Cm -Bsymbolic
263751f18e7SFangrui Song,
264751f18e7SFangrui Song.Cm -Bsymbolic-functions
265751f18e7SFangrui Songor
266751f18e7SFangrui Song.Cm --dynamic-list
26744361e5bSFangrui Song.It Fl -export-dynamic-symbol-list Ns = Ns Ar file
26844361e5bSFangrui SongRead a list of dynamic symbol patterns from
26944361e5bSFangrui Song.Ar file .
27044361e5bSFangrui SongApply
27144361e5bSFangrui Song.Cm --export-dynamic-symbol
27244361e5bSFangrui Songon each pattern.
2733a775a17SEd Maste.It Fl -fatal-warnings
2743a775a17SEd MasteTreat warnings as errors.
275bac187beSFangrui Song.It Fl -filter Ns = Ns Ar value , Fl F Ar value
2763a775a17SEd MasteSet the
2773a775a17SEd Maste.Dv DT_FILTER
2783a775a17SEd Mastefield to the specified value.
279dde3a917SEd Maste.It Fl -fini Ns = Ns Ar symbol
2803a775a17SEd MasteSpecify a finalizer function.
2814d9020caSFangrui Song.It Fl -force-group-allocation
2824d9020caSFangrui SongOnly meaningful for -r. Section groups are discarded. If two section group members are placed to the same output section, combine their relocations as well.
283bac187beSFangrui Song.It Fl -format Ns = Ns Ar input-format , Fl b Ar input-format
2843a775a17SEd MasteSpecify the format of the inputs following this option.
2853a775a17SEd Maste.Ar input-format
2863a775a17SEd Mastemay be one of
2873a775a17SEd Maste.Cm binary ,
2883a775a17SEd Maste.Cm elf ,
2893a775a17SEd Masteand
2903a775a17SEd Maste.Cm default .
2913a775a17SEd Maste.Cm default
2923a775a17SEd Masteis a synonym for
2933a775a17SEd Maste.Cm elf .
2943a775a17SEd Maste.It Fl -gc-sections
2953a775a17SEd MasteEnable garbage collection of unused sections.
2963a775a17SEd Maste.It Fl -gdb-index
2973a775a17SEd MasteGenerate
2983a775a17SEd Maste.Li .gdb_index
2993a775a17SEd Mastesection.
300dde3a917SEd Maste.It Fl -hash-style Ns = Ns Ar value
3013a775a17SEd MasteSpecify hash style.
3023a775a17SEd Maste.Ar value
3033a775a17SEd Mastemay be
3043a775a17SEd Maste.Cm sysv ,
3053a775a17SEd Maste.Cm gnu ,
3063a775a17SEd Masteor
3073a775a17SEd Maste.Cm both .
3083a775a17SEd Maste.Cm both
3093a775a17SEd Masteis the default.
3103a775a17SEd Maste.It Fl -help
311a83e226cSEd MastePrint a help message.
312a83e226cSEd Maste.It Fl -icf Ns = Ns Cm all
3133a775a17SEd MasteEnable identical code folding.
314a327a4c3SPeter Collingbourne.It Fl -icf Ns = Ns Cm safe
315a327a4c3SPeter CollingbourneEnable safe identical code folding.
316a83e226cSEd Maste.It Fl -icf Ns = Ns Cm none
3173a775a17SEd MasteDisable identical code folding.
3187507208aSFangrui Song.It Fl -ignore-data-address-equality
3197507208aSFangrui SongIgnore address equality of data. C/C++ requires each data to have a unique
320174e0833SEd Masteaddress.
321174e0833SEd MasteThis option allows lld to do unsafe optimization that breaks the
3227507208aSFangrui Songrequirement: create copies of read-only data or merge two or more read-only data
3237507208aSFangrui Songthat happen to have the same value.
3247507208aSFangrui Song.It Fl -ignore-function-address-equality
325174e0833SEd MasteIgnore address equality of functions.
326174e0833SEd MasteThis option allows non-PIC calls to a function with non-default visibility in
327174e0833SEd Mastea shared object.
328174e0833SEd MasteThe function may have different addresses within the executable and within the
329174e0833SEd Masteshared object.
330a83e226cSEd Maste.It Fl -image-base Ns = Ns Ar value
3313a775a17SEd MasteSet the base address to
3323a775a17SEd Maste.Ar value .
333dde3a917SEd Maste.It Fl -init Ns = Ns Ar symbol
3343a775a17SEd MasteSpecify an initializer function.
335bac187beSFangrui Song.It Fl -keep-unique Ns = Ns Ar symbol
336bac187beSFangrui SongDo not fold
337bac187beSFangrui Song.Ar symbol
338bac187beSFangrui Songduring ICF.
339f35ff042SFangrui Song.It Fl l Ar libName, Fl -library Ns = Ns Ar libName
340f35ff042SFangrui SongRoot name of library to use.
341f35ff042SFangrui Song.It Fl L Ar dir , Fl -library-path Ns = Ns Ar dir
342f35ff042SFangrui SongAdd a directory to the library search path.
343a83e226cSEd Maste.It Fl -lto-aa-pipeline Ns = Ns Ar value
3443a775a17SEd MasteAA pipeline to run during LTO.
3453a775a17SEd MasteUsed in conjunction with
3463a775a17SEd Maste.Fl -lto-newpm-passes .
347a83e226cSEd Maste.It Fl -lto-newpm-passes Ns = Ns Ar value
3483a775a17SEd MastePasses to run during LTO.
349dfcd846bSEd Maste.It Fl -lto-O Ns Ar opt-level
3503a775a17SEd MasteOptimization level for LTO.
351a83e226cSEd Maste.It Fl -lto-partitions Ns = Ns Ar value
3523a775a17SEd MasteNumber of LTO codegen partitions.
353f35ff042SFangrui Song.It Fl m Ar value
354f35ff042SFangrui SongSet target emulation.
355bac187beSFangrui Song.It Fl -Map Ns = Ns Ar file , Fl M Ar file
3563a775a17SEd MastePrint a link map to
3573a775a17SEd Maste.Ar file .
3584e21c770SPeter Smith.It Fl -nmagic , Fl n
3594e21c770SPeter SmithDo not page align sections, link against static libraries.
360ae029437SFangrui Song.It Fl -no-allow-shlib-undefined
361ae029437SFangrui SongDo not allow unresolved references in shared libraries.
362ae029437SFangrui SongThis option is enabled by default when linking an executable.
3633a775a17SEd Maste.It Fl -no-as-needed
3643a775a17SEd MasteAlways set
3653a775a17SEd Maste.Dv DT_NEEDED
3663a775a17SEd Mastefor shared libraries.
3673a775a17SEd Maste.It Fl -no-color-diagnostics
3683a775a17SEd MasteDo not use colors in diagnostics.
3693a775a17SEd Maste.It Fl -no-demangle
3703a775a17SEd MasteDo not demangle symbol names.
3713a775a17SEd Maste.It Fl -no-dynamic-linker
3723a775a17SEd MasteInhibit output of an
3733a775a17SEd Maste.Li .interp
3743a775a17SEd Mastesection.
3758f91f381SSean Fertile.It Fl -no-fortran-common
3768f91f381SSean FertileDo not search archive members for definitions to override COMMON symbols.
3773a775a17SEd Maste.It Fl -no-gc-sections
3783a775a17SEd MasteDisable garbage collection of unused sections.
3793a775a17SEd Maste.It Fl -no-gnu-unique
3803a775a17SEd MasteDisable STB_GNU_UNIQUE symbol binding.
3817507208aSFangrui Song.It Fl -no-merge-exidx-entries
3827507208aSFangrui SongDisable merging .ARM.exidx entries.
383b372259aSFangrui Song.It Fl -no-nmagic
3844e21c770SPeter SmithPage align sections.
385b372259aSFangrui Song.It Fl -no-omagic
3864e21c770SPeter SmithDo not set the text data sections to be writable, page align sections.
38709b81a72SFangrui Song.It Fl -no-relax
388a05384dcSFangrui SongDisable target-specific relaxations. For x86-64 this disables R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization.
3893a775a17SEd Maste.It Fl -no-rosegment
3903a775a17SEd MasteDo not put read-only non-executable sections in their own segment.
391241dbd31SDan Albert.It Fl -undefined-version
392241dbd31SDan AlbertDo not report version scripts that refer to undefined symbols.
3933a775a17SEd Maste.It Fl -no-undefined
3943a775a17SEd MasteReport unresolved symbols even if the linker is creating a shared library.
395e115c005SFangrui Song.It Fl -no-warn-mismatch
396e115c005SFangrui SongDo not reject unknown section types.
3977507208aSFangrui Song.It Fl -no-warn-symbol-ordering
3987507208aSFangrui SongDo not warn about problems with the symbol ordering file or call graph profile.
39926fcee60SFangrui Song.It Fl -no-warnings , Fl w
40026fcee60SFangrui SongSuppress warnings and cancel
40126fcee60SFangrui Song.Cm --fatal-warnings.
4023a775a17SEd Maste.It Fl -no-whole-archive
4033a775a17SEd MasteRestores the default behavior of loading archive members.
4047507208aSFangrui Song.It Fl -no-pie , Fl -no-pic-executable
4053a775a17SEd MasteDo not create a position independent executable.
406f35ff042SFangrui Song.It Fl -noinhibit-exec
407f35ff042SFangrui SongRetain the executable output file whenever it is still usable.
4083a775a17SEd Maste.It Fl -nostdlib
4093a775a17SEd MasteOnly search directories specified on the command line.
410f35ff042SFangrui Song.It Fl o Ar path
411f35ff042SFangrui SongWrite the output executable, library, or object to
412f35ff042SFangrui Song.Ar path .
413f35ff042SFangrui SongIf not specified,
414f35ff042SFangrui Song.Dv a.out
415f35ff042SFangrui Songis used as a default.
416a83e226cSEd Maste.It Fl O Ns Ar value
4173a775a17SEd MasteOptimize output file size.
4183a775a17SEd Maste.Ar value
4193a775a17SEd Mastemay be:
420a83e226cSEd Maste.Pp
421a83e226cSEd Maste.Bl -tag -width 2n -compact
422a83e226cSEd Maste.It Cm 0
4233a775a17SEd MasteDisable string merging.
424a83e226cSEd Maste.It Cm 1
4253a775a17SEd MasteEnable string merging.
426a83e226cSEd Maste.It Cm 2
427cfa97699SFangrui SongEnable string tail merging.
4283a775a17SEd Maste.El
429a83e226cSEd Maste.Pp
430a83e226cSEd Maste.Fl O Ns Cm 1
4313a775a17SEd Masteis the default.
432f35ff042SFangrui Song.It Fl -oformat Ns = Ns Ar format
433f35ff042SFangrui SongSpecify the format for the output object file.
434f35ff042SFangrui SongThe only supported
435f35ff042SFangrui Song.Ar format
436f35ff042SFangrui Songis
437f35ff042SFangrui Song.Cm binary ,
438f35ff042SFangrui Songwhich produces output with no ELF header.
439f35ff042SFangrui Song.It Fl -omagic , Fl N
440174e0833SEd MasteSet the text and data sections to be readable and writable, do not page align
441174e0833SEd Mastesections, link against static libraries.
442f35ff042SFangrui Song.It Fl -opt-remarks-filename Ar file
443f35ff042SFangrui SongWrite optimization remarks in YAML format to
444f35ff042SFangrui Song.Ar file .
445dd42236cSFrancis Visoiu Mistrih.It Fl -opt-remarks-passes Ar pass-regex
446dd42236cSFrancis Visoiu MistrihFilter optimization remarks by only allowing the passes matching
447dd42236cSFrancis Visoiu Mistrih.Ar pass-regex .
448f35ff042SFangrui Song.It Fl -opt-remarks-with-hotness
449f35ff042SFangrui SongInclude hotness information in the optimization remarks file.
4507507208aSFangrui Song.It Fl -orphan-handling Ns = Ns Ar mode
451174e0833SEd MasteControl how orphan sections are handled.
452174e0833SEd MasteAn orphan section is one not specifically mentioned in a linker script.
4537507208aSFangrui Song.Ar mode
4547507208aSFangrui Songmay be:
4557507208aSFangrui Song.Pp
4567507208aSFangrui Song.Bl -tag -width 2n -compact
4577507208aSFangrui Song.It Cm place
4587507208aSFangrui SongPlace orphan sections in suitable output sections.
4597507208aSFangrui Song.It Cm warn
4607507208aSFangrui SongPlace orphan sections as for
4617507208aSFangrui Song.Cm place
4627507208aSFangrui Songand also report a warning.
4637507208aSFangrui Song.It Cm error
4647507208aSFangrui SongPlace orphan sections as for
4657507208aSFangrui Song.Cm place
4667507208aSFangrui Songand also report an error.
4677507208aSFangrui Song.El
4687507208aSFangrui Song.Pp
4697507208aSFangrui Song.Cm place
4707507208aSFangrui Songis the default.
4717507208aSFangrui Song.It Fl -pack-dyn-relocs Ns = Ns Ar format
4727507208aSFangrui SongPack dynamic relocations in the given format.
4737507208aSFangrui Song.Ar format
4747507208aSFangrui Songmay be:
4757507208aSFangrui Song.Pp
4767507208aSFangrui Song.Bl -tag -width 2n -compact
4777507208aSFangrui Song.It Cm none
478174e0833SEd MasteDo not pack.
479174e0833SEd MasteDynamic relocations are encoded in SHT_REL(A).
4807507208aSFangrui Song.It Cm android
4817507208aSFangrui SongPack dynamic relocations in SHT_ANDROID_REL(A).
4827507208aSFangrui Song.It Cm relr
483174e0833SEd MastePack relative relocations in SHT_RELR, and the rest of dynamic relocations in
484174e0833SEd MasteSHT_REL(A).
4857507208aSFangrui Song.It Cm android+relr
486174e0833SEd MastePack relative relocations in SHT_RELR, and the rest of dynamic relocations in
487174e0833SEd MasteSHT_ANDROID_REL(A).
4887507208aSFangrui Song.El
4897507208aSFangrui Song.Pp
4907507208aSFangrui Song.Cm none
491174e0833SEd Masteis the default.
492174e0833SEd MasteIf
4937507208aSFangrui Song.Fl -use-android-relr-tags
4947507208aSFangrui Songis specified, use SHT_ANDROID_RELR instead of SHT_RELR.
4957507208aSFangrui Song.Pp
49613d13468SPeter Smith.It Fl -pic-veneer
49713d13468SPeter SmithAlways generate position independent thunks.
4987507208aSFangrui Song.It Fl -pie , Fl -pic-executable
4993a775a17SEd MasteCreate a position independent executable.
5003b4dd68dSFangrui Song.It Fl -power10-stubs Ns = Ns Cm mode
5013b4dd68dSFangrui SongWhether to use Power10 instructions in call stubs for R_PPC64_REL24_NOTOC and TOC/NOTOC interworking.
5023b4dd68dSFangrui Song.Ar mode
5033b4dd68dSFangrui Songmay be:
5043b4dd68dSFangrui Song.Pp
5053b4dd68dSFangrui Song.Bl -tag -width 2n -compact
5063b4dd68dSFangrui Song.It Cm yes
5073b4dd68dSFangrui Song(default) Use.
5083b4dd68dSFangrui Song.It Cm auto
5093b4dd68dSFangrui SongCurrently the same as yes.
5103b4dd68dSFangrui Song.It Cm no
5113b4dd68dSFangrui SongDon't use.
5123b4dd68dSFangrui Song.El
5133b4dd68dSFangrui Song
5143a775a17SEd Maste.It Fl -print-gc-sections
5153a775a17SEd MasteList removed unused sections.
5163a84a093SFangrui Song.It Fl -print-icf-sections
5173a84a093SFangrui SongList identical folded sections.
5183a775a17SEd Maste.It Fl -print-map
5193a775a17SEd MastePrint a link map to the standard output.
520b912b887SFangrui Song.It Fl -print-archive-stats Ns = Ns Ar file
521b912b887SFangrui SongWrite archive usage statistics to the specified file.
522b912b887SFangrui SongPrint the numbers of members and fetched members for each archive.
523f75ea0b9SRui Ueyama.It Fl -push-state
524f75ea0b9SRui UeyamaSave the current state of
525f75ea0b9SRui Ueyama.Fl -as-needed ,
526f75ea0b9SRui Ueyama.Fl -static ,
527f75ea0b9SRui Ueyamaand
528194a4eb8SJames Henderson.Fl -whole-archive.
529f75ea0b9SRui Ueyama.It Fl -pop-state
530bfc2f4b1SFangrui SongRestore the states saved by
531f75ea0b9SRui Ueyama.Fl -push-state.
53264da33a5SPeter Collingbourne.It Fl -randomize-section-padding Ns = Ns Ar seed
53364da33a5SPeter CollingbourneRandomly insert padding between input sections and at the start of each segment using the given seed.
53464da33a5SPeter CollingbournePadding is inserted into output sections with names matching the following patterns:
53564da33a5SPeter Collingbourne.Cm .bss ,
53664da33a5SPeter Collingbourne.Cm .data ,
53764da33a5SPeter Collingbourne.Cm .data.rel.ro ,
53864da33a5SPeter Collingbourne.Cm .lbss ,
53964da33a5SPeter Collingbourne.Cm .ldata ,
54064da33a5SPeter Collingbourne.Cm .lrodata ,
54164da33a5SPeter Collingbourne.Cm .ltext ,
54264da33a5SPeter Collingbourne.Cm .rodata
54364da33a5SPeter Collingbourneand
54464da33a5SPeter Collingbourne.Cm .text* .
54585444794SCraig Topper.It Fl --relax-gp
54685444794SCraig TopperEnable global pointer relaxation for RISC-V.
547bac187beSFangrui Song.It Fl -relocatable , Fl r
5483a775a17SEd MasteCreate relocatable object file.
54939c20a63SFangrui Song.It Fl -remap-inputs Ns = Ns Ar from-glob=to-file
55039c20a63SFangrui SongInput files matching
55139c20a63SFangrui Song.Cm from-glob
55239c20a63SFangrui Songare mapped to
55339c20a63SFangrui Song.Cm to-file.
55439c20a63SFangrui SongUse
55539c20a63SFangrui Song.Cm /dev/null
55639c20a63SFangrui Songto ignore an input file.
55739c20a63SFangrui Song.It Fl -remap-inputs-file Ns = Ns Ar file
55839c20a63SFangrui SongRemap input files based on patterns in
55939c20a63SFangrui Song.Ar file .
56039c20a63SFangrui SongEach line in the remap file is of the format
56139c20a63SFangrui Song.Cm from-glob=to-file
56239c20a63SFangrui Songor a comment starting with
56339c20a63SFangrui Song.Cm # .
56472d1089aSRui Ueyama.It Fl -reproduce Ns = Ns Ar path
5657d6aa7ebSPeter SmithWrite a tar file to
56672d1089aSRui Ueyama.Ar path,
5677d6aa7ebSPeter Smithcontaining all the input files needed to reproduce the link, a text file called
5687d6aa7ebSPeter Smithresponse.txt containing the command line options and a text file called
569174e0833SEd Masteversion.txt containing the output of ld.lld --version.
570174e0833SEd MasteThe archive when
5717d6aa7ebSPeter Smithunpacked can be used to re-run the linker with the same options and input files.
572a83e226cSEd Maste.It Fl -retain-symbols-file Ns = Ns Ar file
5733a775a17SEd MasteRetain only the symbols listed in the file.
574bac187beSFangrui Song.It Fl -rpath Ns = Ns Ar value , Fl R Ar value
5753a775a17SEd MasteAdd a
5763a775a17SEd Maste.Dv DT_RUNPATH
5773a775a17SEd Masteto the output.
578a83e226cSEd Maste.It Fl -rsp-quoting Ns = Ns Ar value
5793a775a17SEd MasteQuoting style for response files.
5803a775a17SEd MasteThe supported values are
581a83e226cSEd Maste.Cm windows
5823a775a17SEd Masteand
583a83e226cSEd Maste.Cm posix .
584bac187beSFangrui Song.It Fl -script Ns = Ns Ar file , Fl T Ar file
5853a775a17SEd MasteRead linker script from
5863a775a17SEd Maste.Ar file .
5876ef01c3eSRui UeyamaIf multiple linker scripts are given, they are processed as if they
5886ef01c3eSRui Ueyamawere concatenated in the order they appeared on the command line.
589bac187beSFangrui Song.It Fl -section-start Ns = Ns Ar section Ns = Ns Ar address
5903a775a17SEd MasteSet address of section.
591bac187beSFangrui Song.It Fl -shared , Fl -Bsharable
5923a775a17SEd MasteBuild a shared object.
593d48d3391SRafael Ávila de Espíndola.It Fl -shuffle-sections Ns = Ns Ar seed
59416c30c3cSFangrui SongShuffle matched sections using the given seed before mapping them to the output sections.
595423cb321SFangrui SongIf -1, reverse the section order. If 0, use a random seed.
596bac187beSFangrui Song.It Fl -soname Ns = Ns Ar value , Fl h Ar value
5973a775a17SEd MasteSet
5983a775a17SEd Maste.Dv DT_SONAME
5993a775a17SEd Masteto
6003a775a17SEd Maste.Ar value .
601471f1180SRui Ueyama.It Fl -sort-common
602471f1180SRui UeyamaThis option is ignored for GNU compatibility.
603dde3a917SEd Maste.It Fl -sort-section Ns = Ns Ar value
6043a775a17SEd MasteSpecifies sections sorting rule when linkerscript is used.
6053a775a17SEd Maste.It Fl -start-lib
6063a775a17SEd MasteStart a grouping of objects that should be treated as if they were together
6073a775a17SEd Mastein an archive.
608bac187beSFangrui Song.It Fl -strip-all , Fl s
6093a775a17SEd MasteStrip all symbols.
6105dd9f44cSBen DunbobbinImplies
6115dd9f44cSBen Dunbobbin.Fl -strip-debug .
612bac187beSFangrui Song.It Fl -strip-debug , Fl S
6133a775a17SEd MasteStrip debugging information.
614dfcd846bSEd Maste.It Fl -symbol-ordering-file Ns = Ns Ar file
6153a775a17SEd MasteLay out sections in the order specified by
6163a775a17SEd Maste.Ar file .
617a83e226cSEd Maste.It Fl -sysroot Ns = Ns Ar value
6183a775a17SEd MasteSet the system root.
6193a775a17SEd Maste.It Fl -target1-abs
6203a775a17SEd MasteInterpret
6213a775a17SEd Maste.Dv R_ARM_TARGET1
6223a775a17SEd Masteas
6233a775a17SEd Maste.Dv R_ARM_ABS32 .
6243a775a17SEd Maste.It Fl -target1-rel
6253a775a17SEd MasteInterpret
6263a775a17SEd Maste.Dv R_ARM_TARGET1
6273a775a17SEd Masteas
6283a775a17SEd Maste.Dv R_ARM_REL32 .
629a83e226cSEd Maste.It Fl -target2 Ns = Ns Ar type
6303a775a17SEd MasteInterpret
6313a775a17SEd Maste.Dv R_ARM_TARGET2
6323a775a17SEd Masteas
6333a775a17SEd Maste.Ar type ,
6343a775a17SEd Mastewhere
6353a775a17SEd Maste.Ar type
6363a775a17SEd Masteis one of
637a83e226cSEd Maste.Cm rel ,
638a83e226cSEd Maste.Cm abs ,
6393a775a17SEd Masteor
640a83e226cSEd Maste.Cm got-rel .
641dde3a917SEd Maste.It Fl -Tbss Ns = Ns Ar value
6423a775a17SEd MasteSame as
6433a775a17SEd Maste.Fl -section-start
6443a775a17SEd Mastewith
6453a775a17SEd Maste.Li .bss
6463a775a17SEd Masteas the sectionname.
647dde3a917SEd Maste.It Fl -Tdata Ns = Ns Ar value
6483a775a17SEd MasteSame as
6493a775a17SEd Maste.Fl -section-start
6503a775a17SEd Mastewith
6513a775a17SEd Maste.Li .data
6523a775a17SEd Masteas the sectionname.
653f35ff042SFangrui Song.It Fl -Ttext Ns = Ns Ar value
654f35ff042SFangrui SongSame as
655f35ff042SFangrui Song.Fl -section-start
656f35ff042SFangrui Songwith
657f35ff042SFangrui Song.Li .text
658f35ff042SFangrui Songas the sectionname.
659a83e226cSEd Maste.It Fl -thinlto-cache-dir Ns = Ns Ar value
6603a775a17SEd MastePath to ThinLTO cached object file directory.
661dfcd846bSEd Maste.It Fl -thinlto-cache-policy Ns = Ns Ar value
6623a775a17SEd MastePruning policy for the ThinLTO cache.
663a83e226cSEd Maste.It Fl -thinlto-jobs Ns = Ns Ar value
6643a775a17SEd MasteNumber of ThinLTO jobs.
665eb4663d8SFangrui Song.It Fl -threads Ns = Ns Ar N
666eb4663d8SFangrui SongNumber of threads.
667eb4663d8SFangrui Song.Cm all
668eb4663d8SFangrui Song(default) means all of concurrent threads supported.
669eb4663d8SFangrui Song.Cm 1
670eb4663d8SFangrui Songdisables multi-threading.
67114e3bec8SPaul Kirth.It Fl -fat-lto-objects
67214e3bec8SPaul KirthUse the .llvm.lto section, which contains LLVM bitcode, in fat LTO object files to perform LTO.
67314e3bec8SPaul Kirth.It Fl -no-fat-lto-objects
67414e3bec8SPaul KirthIgnore the .llvm.lto section in relocatable object files (default).
67585bb9b71SRussell Gallop.It Fl -time-trace
67685bb9b71SRussell GallopRecord time trace.
67785bb9b71SRussell Gallop.It Fl -time-trace-file Ns = Ns Ar file
67885bb9b71SRussell GallopWrite time trace output to
67985bb9b71SRussell Gallop.Ar file .
68085bb9b71SRussell Gallop.It Fl -time-trace-granularity Ns = Ns Ar value
68185bb9b71SRussell GallopMinimum time granularity (in microseconds) traced by time profiler.
682f35ff042SFangrui Song.It Fl -trace
683f35ff042SFangrui SongPrint the names of the input files.
684bac187beSFangrui Song.It Fl -trace-symbol Ns = Ns Ar symbol , Fl y Ar symbol
6853a775a17SEd MasteTrace references to
6863a775a17SEd Maste.Ar symbol .
687bac187beSFangrui Song.It Fl -undefined Ns = Ns Ar symbol , Fl u Ar symbol
68843f4b037SRui UeyamaIf
6893a775a17SEd Maste.Ar symbol
69043f4b037SRui Ueyamais not defined after symbol resolution, and there's a static library
69143f4b037SRui Ueyamathat contains an object file defining the symbol, load the member
69243f4b037SRui Ueyamato include the object file in the output file.
69343f4b037SRui Ueyama.It Fl -undefined-glob Ns = Ns Ar pattern
69443f4b037SRui UeyamaSynonym for
69543f4b037SRui Ueyama.Fl -undefined ,
696174e0833SEd Masteexcept that it takes a glob pattern.
697174e0833SEd MasteIn a glob pattern,
69843f4b037SRui Ueyama.Cm *
69943f4b037SRui Ueyamamatches zero or more characters,
70043f4b037SRui Ueyama.Cm ?
70143f4b037SRui Ueyamamatches any single character, and
70243f4b037SRui Ueyama.Cm [...]
703174e0833SEd Mastematches the characters within brackets.
704174e0833SEd MasteAll symbols that match
70543f4b037SRui Ueyamaa given pattern are handled as if they were given as arguments of
70643f4b037SRui Ueyama.Fl -undefined .
7076e2804ceSDavid Bozier.It Fl -unique
7086e2804ceSDavid BozierCreates a separate output section for every orphan input section.
709a83e226cSEd Maste.It Fl -unresolved-symbols Ns = Ns Ar value
7103a775a17SEd MasteDetermine how to handle unresolved symbols.
7117507208aSFangrui Song.It Fl -use-android-relr-tags
7127507208aSFangrui SongUse SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*.
71306010fd1SFangrui Song.It Fl v , Fl V
714f35ff042SFangrui SongDisplay the version number and proceed with linking if object files are
715f35ff042SFangrui Songspecified.
71606010fd1SFangrui Song.It Fl -version
717f35ff042SFangrui SongDisplay the version number and exit.
7183a775a17SEd Maste.It Fl -verbose
7193a775a17SEd MasteVerbose mode.
720dde3a917SEd Maste.It Fl -version-script Ns = Ns Ar file
7213a775a17SEd MasteRead version script from
7223a775a17SEd Maste.Ar file .
72359c4962cSEd Maste.It Fl -warn-backrefs
72459c4962cSEd MasteWarn about reverse or cyclic dependencies to or between static archives.
72559c4962cSEd MasteThis can be used to ensure linker invocation remains compatible with
72659c4962cSEd Mastetraditional Unix-like linkers.
72723257880SFangrui Song.It Fl -warn-backrefs-exclude Ns = Ns Ar glob
72823257880SFangrui SongGlob describing an archive (or an object file within --start-lib)
72923257880SFangrui Songwhich should be ignored for
73023257880SFangrui Song.Fl -warn-backrefs
7313a775a17SEd Maste.It Fl -warn-common
7323a775a17SEd MasteWarn about duplicate common symbols.
73363830b27SAli Tamur.It Fl -warn-ifunc-textrel
73463830b27SAli TamurWarn about using ifunc symbols in conjunction with text relocations.
73563830b27SAli TamurOlder versions of glibc library (2.28 and earlier) has a bug that causes
73663830b27SAli Tamurthe segment that includes ifunc symbols to be marked as not executable when
737174e0833SEd Mastethey are relocated.
738174e0833SEd MasteAs a result, although the program compiles and links
73963830b27SAli Tamursuccessfully, it gives segmentation fault when the instruction pointer reaches
740174e0833SEd Mastean ifunc symbol.
741174e0833SEd MasteUse -warn-ifunc-textrel to let lld give a warning, if the
74263830b27SAli Tamurcode may include ifunc symbols, may do text relocations and be linked with
743174e0833SEd Mastean older glibc version.
744174e0833SEd MasteOtherwise, there is no need to use it, as the default value does not give a
745174e0833SEd Mastewarning.
746174e0833SEd MasteThis flag has been introduced in late 2018, has no counter part in ld and gold
747174e0833SEd Mastelinkers, and may be removed in the future.
7483a775a17SEd Maste.It Fl -warn-unresolved-symbols
7493a775a17SEd MasteReport unresolved symbols as warnings.
7503a775a17SEd Maste.It Fl -whole-archive
7513a775a17SEd MasteForce load of all members in a static library.
752a954bb18SFangrui Song.It Fl -why-extract Ns = Ns Ar file
753a954bb18SFangrui SongPrint to a file about why archive members are extracted.
754dde3a917SEd Maste.It Fl -wrap Ns = Ns Ar symbol
755d24b94f0SFangrui SongRedirect
756d24b94f0SFangrui Song.Ar symbol
757d24b94f0SFangrui Songreferences to
758d24b94f0SFangrui Song.Ar __wrap_symbol
759d24b94f0SFangrui Songand
760d24b94f0SFangrui Song.Ar __real_symbol
761d24b94f0SFangrui Songreferences to
762d24b94f0SFangrui Song.Ar symbol.
7633a775a17SEd Maste.It Fl z Ar option
7643a775a17SEd MasteLinker option extensions.
76502649506SFangrui Song.Bl -tag -width indent -compact
76602649506SFangrui Song.Pp
7674ce56b81SFangrui Song.It Cm dead-reloc-in-nonalloc Ns = Ns Ar section_glob=value
7684ce56b81SFangrui SongResolve a relocation in a matched non-SHF_ALLOC section referencing a discarded symbol to
7694ce56b81SFangrui Song.Ar value
7704ce56b81SFangrui SongAccepts globs, in the event of a section matching more than one option, the last
7714ce56b81SFangrui Songoption takes precedence. An order of least specific to most specific match is
7724ce56b81SFangrui Songrecommended.
7734ce56b81SFangrui Song.Pp
7743a775a17SEd Maste.It Cm execstack
7753a775a17SEd MasteMake the main stack executable.
7763a775a17SEd MasteStack permissions are recorded in the
7773a775a17SEd Maste.Dv PT_GNU_STACK
7783a775a17SEd Mastesegment.
77902649506SFangrui Song.Pp
7802b4e6052SDaniel Kiss.It Cm bti-report Ns = Ns Ar [none|warning|error]
7812b4e6052SDaniel KissSpecify how to report the missing GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
7822b4e6052SDaniel Kiss.Cm none
7832b4e6052SDaniel Kissis the default, linker will not report the missing property otherwise will be reported as a warning or an error.
7842b4e6052SDaniel Kiss.Pp
7852b4e6052SDaniel Kiss.It Cm cet-report Ns = Ns Ar [none|warning|error]
7862b4e6052SDaniel KissSpecify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT or GNU_PROPERTY_X86_FEATURE_1_SHSTK properties.
7872b4e6052SDaniel Kiss.Cm none
7882b4e6052SDaniel Kissis the default, linker will not report the missing property otherwise will be reported as a warning or an error.
7892b4e6052SDaniel Kiss.Pp
790cca9115bSDaniil Kovalev.It Cm pauth-report Ns = Ns Ar [none|warning|error]
791cca9115bSDaniil KovalevSpecify how to report the missing GNU_PROPERTY_AARCH64_FEATURE_PAUTH property.
792cca9115bSDaniil Kovalev.Cm none
793cca9115bSDaniil Kovalevis the default, linker will not report the missing property otherwise will be reported as a warning or an error.
794cca9115bSDaniil Kovalev.Pp
7955a3a9e99SFangrui Song.It Cm force-bti
7965a3a9e99SFangrui SongForce enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
7975a3a9e99SFangrui Song.Pp
7987cd429f2SFangrui Song.It Cm force-ibt
7997cd429f2SFangrui SongForce enable Intel Indirect Branch Tracking in PLT, warn if an input ELF file
8007cd429f2SFangrui Songdoes not have GNU_PROPERTY_X86_FEATURE_1_IBT property.
8017cd429f2SFangrui Song.Pp
802b5a6538bSGeorge Rimar.It Cm global
803b5a6538bSGeorge RimarSets the
804b5a6538bSGeorge Rimar.Dv DF_1_GLOBAL flag in the
805b5a6538bSGeorge Rimar.Dv DYNAMIC
806b5a6538bSGeorge Rimarsection.
807b5a6538bSGeorge RimarDifferent loaders can decide how to handle this flag on their own.
80802649506SFangrui Song.Pp
809e041d15fSFangrui Song.It Cm ifunc-noplt
810e041d15fSFangrui SongDo not emit PLT entries for ifunc symbols.
811e041d15fSFangrui SongInstead, emit text relocations referencing the resolver.
812e041d15fSFangrui SongThis is an experimental optimization and only suitable for standalone
813e041d15fSFangrui Songenvironments where text relocations do not have the usual drawbacks.
814e041d15fSFangrui SongThis option must be combined with the
815e041d15fSFangrui Song.Fl z Li notext
816e041d15fSFangrui Songoption.
81702649506SFangrui Song.Pp
81805779bfcSFangrui Song.It Cm initfirst
81905779bfcSFangrui SongSets the
82005779bfcSFangrui Song.Dv DF_1_INITFIRST
82105779bfcSFangrui Songflag to indicate the module should be initialized first.
82202649506SFangrui Song.Pp
823c0b474f6SEd Maste.It Cm interpose
824c0b474f6SEd MasteSet the
825c0b474f6SEd Maste.Dv DF_1_INTERPOSE
826c0b474f6SEd Masteflag to indicate to the runtime linker that the object is an interposer.
827c0b474f6SEd MasteDuring symbol resolution interposers are searched after the application
828c0b474f6SEd Mastebut before other dependencies.
82902649506SFangrui Song.Pp
83078762357SFangrui Song.It Cm lrodata-after-bss
83178762357SFangrui SongPlace .lrodata after .bss.
83278762357SFangrui Song.Pp
8333a775a17SEd Maste.It Cm muldefs
8343a775a17SEd MasteDo not error if a symbol is defined multiple times.
8353a775a17SEd MasteThe first definition will be used.
8363a775a17SEd MasteThis is a synonym for
8373a775a17SEd Maste.Fl -allow-multiple-definition.
83802649506SFangrui Song.Pp
8393a775a17SEd Maste.It Cm nocombreloc
8403a775a17SEd MasteDisable combining and sorting multiple relocation sections.
84102649506SFangrui Song.Pp
8423a775a17SEd Maste.It Cm nocopyreloc
8433a775a17SEd MasteDisable the creation of copy relocations.
84402649506SFangrui Song.Pp
845a1b3ddbfSGeorge Rimar.It Cm nodefaultlib
846a1b3ddbfSGeorge RimarSet the
847a1b3ddbfSGeorge Rimar.Dv DF_1_NODEFLIB
848a1b3ddbfSGeorge Rimarflag to indicate that default library search paths should be ignored.
84902649506SFangrui Song.Pp
8503a775a17SEd Maste.It Cm nodelete
8513a775a17SEd MasteSet the
8523a775a17SEd Maste.Dv DF_1_NODELETE
8533a775a17SEd Masteflag to indicate that the object cannot be unloaded from a process.
85402649506SFangrui Song.Pp
8553a775a17SEd Maste.It Cm nodlopen
8563a775a17SEd MasteSet the
8573a775a17SEd Maste.Dv DF_1_NOOPEN
8585f8fc76bSGeorge Rimarflag to indicate that the object may not be opened by
8593a775a17SEd Maste.Xr dlopen 3 .
86002649506SFangrui Song.Pp
8612a0fcae3SMichał Górny.It Cm nognustack
8622a0fcae3SMichał GórnyDo not emit the
8632a0fcae3SMichał Górny.Dv PT_GNU_STACK
8642a0fcae3SMichał Górnysegment.
8652a0fcae3SMichał Górny.Pp
8663a775a17SEd Maste.It Cm norelro
867efabe427SNico WeberDo not indicate that portions of the object should be mapped read-only
8683a775a17SEd Masteafter initial relocation processing.
8693a775a17SEd MasteThe object will omit the
8703a775a17SEd Maste.Dv PT_GNU_RELRO
8713a775a17SEd Mastesegment.
87202649506SFangrui Song.Pp
8735d972c58SFangrui Song.It Cm nosectionheader
8745d972c58SFangrui SongDon't generate the section header table.
8755d972c58SFangrui Song.Pp
8763a775a17SEd Maste.It Cm notext
8773a775a17SEd MasteAllow relocations against read-only segments.
8783a775a17SEd MasteSets the
8793a775a17SEd Maste.Dv DT_TEXTREL flag in the
8803a775a17SEd Maste.Dv DYNAMIC
8813a775a17SEd Mastesection.
88202649506SFangrui Song.Pp
8833a775a17SEd Maste.It Cm now
8843a775a17SEd MasteSet the
8853a775a17SEd Maste.Dv DF_BIND_NOW
8863a775a17SEd Masteflag to indicate that the run-time loader should perform all relocation
8873a775a17SEd Masteprocessing as part of object initialization.
8883a775a17SEd MasteBy default relocations may be performed on demand.
88902649506SFangrui Song.Pp
8903a775a17SEd Maste.It Cm origin
8913a775a17SEd MasteSet the
8923a775a17SEd Maste.Dv DF_ORIGIN
8933a775a17SEd Masteflag to indicate that the object requires
8943a775a17SEd Maste$ORIGIN
8953a775a17SEd Masteprocessing.
89602649506SFangrui Song.Pp
8975a3a9e99SFangrui Song.It Cm pac-plt
8985a3a9e99SFangrui SongAArch64 only, use pointer authentication in PLT.
8995a3a9e99SFangrui Song.Pp
9004a8de283SFangrui Song.It Cm pack-relative-relocs
9014a8de283SFangrui SongSimilar to
9024a8de283SFangrui Song.Cm -pack-dyn-relocs=relr
9034a8de283SFangrui Song, but synthesizes the GLIBC_ABI_DT_RELR version dependency if there is a GLIBC_2.* version dependency.
9044a8de283SFangrui Songglibc ld.so rejects loading a dynamically linked object without the GLIBC_ABI_DT_RELR version dependency.
9054a8de283SFangrui Song.Pp
906881c5eefSFangrui Song.It Cm rel
907881c5eefSFangrui SongUse REL format for dynamic relocations.
908881c5eefSFangrui Song.Pp
909881c5eefSFangrui Song.It Cm rela
910881c5eefSFangrui SongUse RELA format for dynamic relocations.
911881c5eefSFangrui Song.Pp
9123a775a17SEd Maste.It Cm retpolineplt
9133a775a17SEd MasteEmit retpoline format PLT entries as a mitigation for CVE-2017-5715.
91402649506SFangrui Song.Pp
9153a775a17SEd Maste.It Cm rodynamic
9163a775a17SEd MasteMake the
9173a775a17SEd Maste.Li .dynamic
9183a775a17SEd Mastesection read-only.
9193a775a17SEd MasteThe
9203a775a17SEd Maste.Dv DT_DEBUG
9213a775a17SEd Mastetag will not be emitted.
92202649506SFangrui Song.Pp
92302649506SFangrui Song.It Cm separate-loadable-segments
92402649506SFangrui Song.It Cm separate-code
92502649506SFangrui Song.It Cm noseparate-code
92602649506SFangrui SongSpecify whether two adjacent PT_LOAD segments are allowed to overlap in pages.
92702649506SFangrui Song.Cm noseparate-code
92802649506SFangrui Song(default) allows overlap.
92902649506SFangrui Song.Cm separate-code
93002649506SFangrui Songallows overlap between two executable segments, or two non-executable segments.
93102649506SFangrui Song.Cm separate-loadable-segments
93202649506SFangrui Songdisallows overlap.
93302649506SFangrui Song.Pp
9347cd429f2SFangrui Song.It Cm shstk
9357cd429f2SFangrui Songx86 only, use shadow stack.
9367cd429f2SFangrui Song.Pp
937a83e226cSEd Maste.It Cm stack-size Ns = Ns Ar size
9383a775a17SEd MasteSet the main thread's stack size to
9393a775a17SEd Maste.Ar size .
9403a775a17SEd MasteThe stack size is recorded as the size of the
9413a775a17SEd Maste.Ar size .
9423a775a17SEd Maste.Dv PT_GNU_STACK
9433a775a17SEd Masteprogram segment.
94402649506SFangrui Song.Pp
9454bbcd63eSFangrui Song.It Cm start-stop-gc
9467f0acc4eSFangrui SongDon't let __start_/__stop_ references retain the associated C identifier name sections (default).
9477f0acc4eSFangrui Song.Pp
9487f0acc4eSFangrui Song.It Cm nostart-stop-gc
9497f0acc4eSFangrui SongLet __start_/__stop_ references retain the associated C identifier name sections.
9507f0acc4eSFangrui Song.Pp
9513a775a17SEd Maste.It Cm text
9523a775a17SEd MasteDo not allow relocations against read-only segments.
9533a775a17SEd MasteThis is the default.
95402649506SFangrui Song.Pp
955*52574b5fSBrad Smith.It Cm nobtcfi
956*52574b5fSBrad SmithCreate a
957*52574b5fSBrad Smith.Dv PT_OPENBSD_NOBTCFI
958*52574b5fSBrad Smithsegment.
959*52574b5fSBrad Smith.Pp
9603a775a17SEd Maste.It Cm wxneeded
9613a775a17SEd MasteCreate a
9623a775a17SEd Maste.Dv PT_OPENBSD_WXNEEDED
9633a775a17SEd Mastesegment.
9643a775a17SEd Maste.El
9653a775a17SEd Maste.El
9663d570a5cSFangrui Song
9673d570a5cSFangrui Song.Sh ENVIRONMENT VARIABLES
9683d570a5cSFangrui Song.Bl -tag -width LC_CTYPE
9693d570a5cSFangrui Song.It Ev LLD_REPRODUCE
9703d570a5cSFangrui SongCreate a reproduce tarball with the specified filename. If
9713d570a5cSFangrui Song.Fl -reproduce
9723d570a5cSFangrui Songis specified,
9733d570a5cSFangrui Song.Fl -reproduce
9743d570a5cSFangrui Songtakes precedence.
9753d570a5cSFangrui Song.It Ev LLD_VERSION
9763d570a5cSFangrui Songld.lld creates a section named
9773d570a5cSFangrui Song.Cm .comment
9783d570a5cSFangrui Songcontaining the LLD version string. The version string can be overridden by this environment variable,
9793d570a5cSFangrui Songwhich is useful to eliminate differences in the binary caused by LLD version number differences.
9803d570a5cSFangrui Song.El
9813d570a5cSFangrui Song
9821136f3f0SEd Maste.Sh IMPLEMENTATION NOTES
9831136f3f0SEd Maste.Nm Ap s
9841136f3f0SEd Mastehanding of archive files (those with a
985a83e226cSEd Maste.Pa .a
9861136f3f0SEd Mastefile extension) is different from traditional linkers used on Unix-like
9871136f3f0SEd Mastesystems.
9881136f3f0SEd Maste.Pp
9891136f3f0SEd MasteTraditional linkers maintain a set of undefined symbols during linking.
9901136f3f0SEd MasteThe linker processes each file in the order in which it appears on the
9911136f3f0SEd Mastecommand line, until the set of undefined symbols becomes empty.
9921136f3f0SEd MasteAn object file is linked into the output object when it is encountered,
9931136f3f0SEd Mastewith its undefined symbols added to the set.
9941136f3f0SEd MasteUpon encountering an archive file a traditional linker searches the objects
9951136f3f0SEd Mastecontained therein, and processes those that satisfy symbols in the unresolved
9961136f3f0SEd Masteset.
9971136f3f0SEd Maste.Pp
9981136f3f0SEd MasteHandling mutually dependent archives may be awkward when using a traditional
9991136f3f0SEd Mastelinker.
10001136f3f0SEd MasteArchive files may have to be specified multiple times, or the special command
10011136f3f0SEd Masteline options
10021136f3f0SEd Maste.Fl -start-group
10031136f3f0SEd Masteand
10041136f3f0SEd Maste.Fl -end-group
10051136f3f0SEd Mastemay be used to have the linker loop over the files in the group until no new
10061136f3f0SEd Mastesymbols are added to the set.
10071136f3f0SEd Maste.Pp
10081136f3f0SEd Maste.Nm
10091136f3f0SEd Masterecords all symbols found in objects and archives as it iterates over
10101136f3f0SEd Mastecommand line arguments.
10111136f3f0SEd MasteWhen
10121136f3f0SEd Maste.Nm
10131136f3f0SEd Masteencounters an undefined symbol that can be resolved by an object file
10141136f3f0SEd Mastecontained in a previously processed archive file, it immediately extracts
10151136f3f0SEd Masteand links it into the output object.
10161136f3f0SEd Maste.Pp
10171136f3f0SEd MasteWith certain archive inputs
10181136f3f0SEd Maste.Nm
10191136f3f0SEd Mastemay produce different results compared to traditional linkers.
10201136f3f0SEd MasteIn practice, large bodies of third party software have been linked with
10211136f3f0SEd Maste.Nm
10221136f3f0SEd Mastewithout material issues.
102359c4962cSEd Maste.Pp
102459c4962cSEd MasteThe
102559c4962cSEd Maste.Fl -warn-backrefs
102659c4962cSEd Masteoption may be used to identify a linker invocation that may be incompatible
102759c4962cSEd Mastewith traditional Unix-like linker behavior.
1028