xref: /freebsd/contrib/llvm-project/lld/docs/ld.lld.1 (revision 577b62c2bacc7dfa228591ca3da361e1bc398301)
1.\" Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2.\" See https://llvm.org/LICENSE.txt for license information.
3.\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4.\"
5.\" This man page documents only lld's ELF linking support, obtained originally
6.\" from FreeBSD.
7.Dd May 12, 2019
8.Dt LD.LLD 1
9.Os
10.Sh NAME
11.Nm ld.lld
12.Nd ELF linker from the LLVM project
13.Sh SYNOPSIS
14.Nm ld.lld
15.Op Ar options
16.Ar objfile ...
17.Sh DESCRIPTION
18A linker takes one or more object, archive, and library files, and combines
19them into an output file (an executable, a shared library, or another object
20file).
21It relocates code and data from the input files and resolves symbol
22references between them.
23.Pp
24.Nm
25is a drop-in replacement for the GNU BFD and gold linkers.
26It accepts most of the same command line arguments and linker scripts
27as GNU linkers.
28.Pp
29.Nm
30currently supports i386, x86-64, ARM, AArch64, PowerPC32, PowerPC64,
31MIPS32, MIPS64, RISC-V, AMDGPU, Hexagon and SPARC V9 targets.
32.Nm
33acts as a Microsoft link.exe-compatible linker if invoked as
34.Nm lld-link
35and as macOS's ld if invoked as
36.Nm ld.ld64.
37All these targets are always supported however
38.Nm
39was built, so you can always use
40.Nm
41as a native linker as well as a cross linker.
42.Sh OPTIONS
43Many options have both a single-letter and long form.
44When using the long form options other than those beginning with the
45letter
46.Cm o
47may be specified using either one or two dashes preceding the option name.
48Long options beginning with
49.Cm o
50require two dashes to avoid confusion with the
51.Fl o Ar path
52option.
53.Pp
54.Bl -tag -width indent
55.It Fl -allow-multiple-definition
56Do not error if a symbol is defined multiple times.
57The first definition will be used.
58.It Fl -allow-shlib-undefined
59Allow unresolved references in shared libraries.
60This option is enabled by default when linking a shared library.
61.It Fl -apply-dynamic-relocs
62Apply link-time values for dynamic relocations.
63.It Fl -as-needed
64Only set
65.Dv DT_NEEDED
66for shared libraries if used.
67.It Fl -auxiliary Ns = Ns Ar value
68Set the
69.Dv DT_AUXILIARY
70field to the specified name.
71.It Fl -Bdynamic , Fl -dy
72Link against shared libraries.
73.It Fl -Bstatic , Fl -static , Fl -dn
74Do not link against shared libraries.
75.It Fl Bno-symbolic
76Don't bind default visibility defined symbols locally for
77.Fl shared
78(default).
79.It Fl Bsymbolic
80Bind default visibility defined symbols locally for
81.Fl shared.
82Also set the
83.Dv DF_SYMBOLIC
84flag.
85.It Fl Bsymbolic-functions
86Bind default visibility defined function symbols locally for
87.Fl shared.
88.It Fl Bsymbolic-non-weak-functions
89Bind default visibility defined STB_GLOBAL function symbols locally for
90.Fl shared.
91.It Fl -build-id Ns = Ns Ar value
92Generate a build ID note.
93.Ar value
94may be one of
95.Cm fast ,
96.Cm md5 ,
97.Cm sha1 ,
98.Cm tree ,
99.Cm uuid ,
100.Cm 0x Ns Ar hex-string ,
101and
102.Cm none .
103.Cm tree
104is an alias for
105.Cm sha1 .
106Build-IDs of type
107.Cm fast ,
108.Cm md5 ,
109.Cm sha1 ,
110and
111.Cm tree
112are calculated from the object contents.
113.Cm fast
114is not intended to be cryptographically secure.
115.It Fl -build-id
116Synonym for
117.Fl -build-id Ns = Ns Cm fast .
118.It Fl -color-diagnostics Ns = Ns Ar value
119Use colors in diagnostics.
120.Ar value
121may be one of
122.Cm always ,
123.Cm auto ,
124and
125.Cm never .
126.Cm auto
127enables color if and only if output is to a terminal.
128.It Fl -color-diagnostics
129Alias for
130.Fl -color-diagnostics Ns = Ns Cm auto .
131.It Fl -compress-debug-sections Ns = Ns Ar value
132Compress DWARF debug sections.
133.Ar value
134may be
135.Cm none
136or
137.Cm zlib .
138The default compression level is 1 (fastest) as the debug info usually
139compresses well at that level, but if you want to compress it more,
140you can specify
141.Fl O2
142to set the compression level to 6.
143.It Fl -cref
144Output cross reference table. If
145.Fl Map
146is specified, print to the map file.
147.It Fl -defsym Ns = Ns Ar symbol Ns = Ns Ar expression
148Define a symbol alias.
149.Ar expression
150may be another symbol or a linker script expression.
151For example,
152.Ql --defsym=foo=bar
153or
154.Ql --defsym=foo=bar+0x100 .
155.It Fl -demangle
156Demangle symbol names.
157.It Fl -disable-new-dtags
158Disable new dynamic tags.
159.It Fl -discard-all , Fl x
160Delete all local symbols.
161.It Fl -discard-locals , Fl X
162Delete temporary local symbols.
163.It Fl -discard-none
164Keep all symbols in the symbol table.
165.It Fl -dynamic-linker Ns = Ns Ar value
166Specify the dynamic linker to be used for a dynamically linked executable.
167This is recorded in an ELF segment of type
168.Dv PT_INTERP .
169.It Fl -dynamic-list Ns = Ns Ar file
170Similar to
171.Cm --export-dynamic-symbol-list .
172When creating a shared object, implies
173.Cm -Bsymbolic
174but does not set DF_SYMBOLIC
175.It Fl -EB
176Select the big-endian format in the OUTPUT_FORMAT command.
177.It Fl -EL
178Select the little-endian format in the OUTPUT_FORMAT command.
179.It Fl -eh-frame-hdr
180Request creation of
181.Li .eh_frame_hdr
182section and
183.Dv PT_GNU_EH_FRAME
184segment header.
185.It Fl -emit-relocs , Fl q
186Generate relocations in the output.
187.It Fl -enable-new-dtags
188Enable new dynamic tags.
189.It Fl -end-lib
190End a grouping of objects that should be treated as if they were together
191in an archive.
192.It Fl -entry Ns = Ns Ar entry
193Name of entry point symbol.
194.It Fl -error-limit Ns = Ns Ar value
195Maximum number of errors to emit before stopping.
196A value of zero indicates that there is no limit.
197.It Fl -error-unresolved-symbols
198Report unresolved symbols as errors.
199.It Fl -error-handing-script Ns = Ns Ar script_path
200Call script
201.Ar script_path
202upon some error, with
203.Ar tag
204as first argument, and an extra parameter as second argument. The script is
205expected to return 0 on success. Any other value is considered a generic error.
206.Ar tag
207may be
208.Cm missing-lib
209followed by the name of the missing library.
210.Cm undefined-symbol
211followed by the name of the undefined symbol.
212.It Fl -execute-only
213Mark executable sections unreadable.
214This option is currently only supported on AArch64.
215.It Fl -exclude-libs Ns = Ns Ar value
216Exclude static libraries from automatic export.
217.It Fl -export-dynamic , Fl E
218Put symbols in the dynamic symbol table.
219.It Fl -export-dynamic-symbol Ns = Ns Ar glob
220(executable) Put matched non-local defined symbols to the dynamic symbol table.
221(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
222.Cm -Bsymbolic
223,
224.Cm -Bsymbolic-functions
225or
226.Cm --dynamic-list
227.It Fl -export-dynamic-symbol-list Ns = Ns Ar file
228Read a list of dynamic symbol patterns from
229.Ar file .
230Apply
231.Cm --export-dynamic-symbol
232on each pattern.
233.It Fl -fatal-warnings
234Treat warnings as errors.
235.It Fl -filter Ns = Ns Ar value , Fl F Ar value
236Set the
237.Dv DT_FILTER
238field to the specified value.
239.It Fl -fini Ns = Ns Ar symbol
240Specify a finalizer function.
241.It Fl -format Ns = Ns Ar input-format , Fl b Ar input-format
242Specify the format of the inputs following this option.
243.Ar input-format
244may be one of
245.Cm binary ,
246.Cm elf ,
247and
248.Cm default .
249.Cm default
250is a synonym for
251.Cm elf .
252.It Fl -gc-sections
253Enable garbage collection of unused sections.
254.It Fl -gdb-index
255Generate
256.Li .gdb_index
257section.
258.It Fl -hash-style Ns = Ns Ar value
259Specify hash style.
260.Ar value
261may be
262.Cm sysv ,
263.Cm gnu ,
264or
265.Cm both .
266.Cm both
267is the default.
268.It Fl -help
269Print a help message.
270.It Fl -icf Ns = Ns Cm all
271Enable identical code folding.
272.It Fl -icf Ns = Ns Cm safe
273Enable safe identical code folding.
274.It Fl -icf Ns = Ns Cm none
275Disable identical code folding.
276.It Fl -ignore-data-address-equality
277Ignore address equality of data. C/C++ requires each data to have a unique
278address.
279This option allows lld to do unsafe optimization that breaks the
280requirement: create copies of read-only data or merge two or more read-only data
281that happen to have the same value.
282.It Fl -ignore-function-address-equality
283Ignore address equality of functions.
284This option allows non-PIC calls to a function with non-default visibility in
285a shared object.
286The function may have different addresses within the executable and within the
287shared object.
288.It Fl -image-base Ns = Ns Ar value
289Set the base address to
290.Ar value .
291.It Fl -init Ns = Ns Ar symbol
292Specify an initializer function.
293.It Fl -keep-unique Ns = Ns Ar symbol
294Do not fold
295.Ar symbol
296during ICF.
297.It Fl l Ar libName, Fl -library Ns = Ns Ar libName
298Root name of library to use.
299.It Fl L Ar dir , Fl -library-path Ns = Ns Ar dir
300Add a directory to the library search path.
301.It Fl -lto-aa-pipeline Ns = Ns Ar value
302AA pipeline to run during LTO.
303Used in conjunction with
304.Fl -lto-newpm-passes .
305.It Fl -lto-newpm-passes Ns = Ns Ar value
306Passes to run during LTO.
307.It Fl -lto-O Ns Ar opt-level
308Optimization level for LTO.
309.It Fl -lto-partitions Ns = Ns Ar value
310Number of LTO codegen partitions.
311.It Fl m Ar value
312Set target emulation.
313.It Fl -Map Ns = Ns Ar file , Fl M Ar file
314Print a link map to
315.Ar file .
316.It Fl -nmagic , Fl n
317Do not page align sections, link against static libraries.
318.It Fl -no-allow-shlib-undefined
319Do not allow unresolved references in shared libraries.
320This option is enabled by default when linking an executable.
321.It Fl -no-as-needed
322Always set
323.Dv DT_NEEDED
324for shared libraries.
325.It Fl -no-color-diagnostics
326Do not use colors in diagnostics.
327.It Fl -no-demangle
328Do not demangle symbol names.
329.It Fl -no-dynamic-linker
330Inhibit output of an
331.Li .interp
332section.
333.It Fl -no-fortran-common
334Do not search archive members for definitions to override COMMON symbols.
335.It Fl -no-gc-sections
336Disable garbage collection of unused sections.
337.It Fl -no-gnu-unique
338Disable STB_GNU_UNIQUE symbol binding.
339.It Fl -no-merge-exidx-entries
340Disable merging .ARM.exidx entries.
341.It Fl -no-nmagic
342Page align sections.
343.It Fl -no-omagic
344Do not set the text data sections to be writable, page align sections.
345.It Fl -no-relax
346Disable target-specific relaxations. For x86-64 this disables R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization.
347.It Fl -no-rosegment
348Do not put read-only non-executable sections in their own segment.
349.It Fl -no-undefined-version
350Report version scripts that refer undefined symbols.
351.It Fl -no-undefined
352Report unresolved symbols even if the linker is creating a shared library.
353.It Fl -no-warn-symbol-ordering
354Do not warn about problems with the symbol ordering file or call graph profile.
355.It Fl -no-whole-archive
356Restores the default behavior of loading archive members.
357.It Fl -no-pie , Fl -no-pic-executable
358Do not create a position independent executable.
359.It Fl -noinhibit-exec
360Retain the executable output file whenever it is still usable.
361.It Fl -nostdlib
362Only search directories specified on the command line.
363.It Fl o Ar path
364Write the output executable, library, or object to
365.Ar path .
366If not specified,
367.Dv a.out
368is used as a default.
369.It Fl O Ns Ar value
370Optimize output file size.
371.Ar value
372may be:
373.Pp
374.Bl -tag -width 2n -compact
375.It Cm 0
376Disable string merging.
377.It Cm 1
378Enable string merging.
379.It Cm 2
380Enable string tail merging. If
381.Fl -compress-debug-sections
382is given, compress debug sections at compression level 6 instead of 1.
383.El
384.Pp
385.Fl O Ns Cm 1
386is the default.
387.It Fl -oformat Ns = Ns Ar format
388Specify the format for the output object file.
389The only supported
390.Ar format
391is
392.Cm binary ,
393which produces output with no ELF header.
394.It Fl -omagic , Fl N
395Set the text and data sections to be readable and writable, do not page align
396sections, link against static libraries.
397.It Fl -opt-remarks-filename Ar file
398Write optimization remarks in YAML format to
399.Ar file .
400.It Fl -opt-remarks-passes Ar pass-regex
401Filter optimization remarks by only allowing the passes matching
402.Ar pass-regex .
403.It Fl -opt-remarks-with-hotness
404Include hotness information in the optimization remarks file.
405.It Fl -orphan-handling Ns = Ns Ar mode
406Control how orphan sections are handled.
407An orphan section is one not specifically mentioned in a linker script.
408.Ar mode
409may be:
410.Pp
411.Bl -tag -width 2n -compact
412.It Cm place
413Place orphan sections in suitable output sections.
414.It Cm warn
415Place orphan sections as for
416.Cm place
417and also report a warning.
418.It Cm error
419Place orphan sections as for
420.Cm place
421and also report an error.
422.El
423.Pp
424.Cm place
425is the default.
426.It Fl -pack-dyn-relocs Ns = Ns Ar format
427Pack dynamic relocations in the given format.
428.Ar format
429may be:
430.Pp
431.Bl -tag -width 2n -compact
432.It Cm none
433Do not pack.
434Dynamic relocations are encoded in SHT_REL(A).
435.It Cm android
436Pack dynamic relocations in SHT_ANDROID_REL(A).
437.It Cm relr
438Pack relative relocations in SHT_RELR, and the rest of dynamic relocations in
439SHT_REL(A).
440.It Cm android+relr
441Pack relative relocations in SHT_RELR, and the rest of dynamic relocations in
442SHT_ANDROID_REL(A).
443.El
444.Pp
445.Cm none
446is the default.
447If
448.Fl -use-android-relr-tags
449is specified, use SHT_ANDROID_RELR instead of SHT_RELR.
450.Pp
451.It Fl -pic-veneer
452Always generate position independent thunks.
453.It Fl -pie , Fl -pic-executable
454Create a position independent executable.
455.It Fl -power10-stubs Ns = Ns Cm mode
456Whether to use Power10 instructions in call stubs for R_PPC64_REL24_NOTOC and TOC/NOTOC interworking.
457.Ar mode
458may be:
459.Pp
460.Bl -tag -width 2n -compact
461.It Cm yes
462(default) Use.
463.It Cm auto
464Currently the same as yes.
465.It Cm no
466Don't use.
467.El
468
469.It Fl -print-gc-sections
470List removed unused sections.
471.It Fl -print-icf-sections
472List identical folded sections.
473.It Fl -print-map
474Print a link map to the standard output.
475.It Fl -print-archive-stats Ns = Ns Ar file
476Write archive usage statistics to the specified file.
477Print the numbers of members and fetched members for each archive.
478.It Fl -push-state
479Save the current state of
480.Fl -as-needed ,
481.Fl -static ,
482and
483.Fl -whole-archive.
484.It Fl -pop-state
485Restore the states saved by
486.Fl -push-state.
487.It Fl -relocatable , Fl r
488Create relocatable object file.
489.It Fl -reproduce Ns = Ns Ar path
490Write a tar file to
491.Ar path,
492containing all the input files needed to reproduce the link, a text file called
493response.txt containing the command line options and a text file called
494version.txt containing the output of ld.lld --version.
495The archive when
496unpacked can be used to re-run the linker with the same options and input files.
497.It Fl -retain-symbols-file Ns = Ns Ar file
498Retain only the symbols listed in the file.
499.It Fl -rpath Ns = Ns Ar value , Fl R Ar value
500Add a
501.Dv DT_RUNPATH
502to the output.
503.It Fl -rsp-quoting Ns = Ns Ar value
504Quoting style for response files.
505The supported values are
506.Cm windows
507and
508.Cm posix .
509.It Fl -script Ns = Ns Ar file , Fl T Ar file
510Read linker script from
511.Ar file .
512If multiple linker scripts are given, they are processed as if they
513were concatenated in the order they appeared on the command line.
514.It Fl -section-start Ns = Ns Ar section Ns = Ns Ar address
515Set address of section.
516.It Fl -shared , Fl -Bsharable
517Build a shared object.
518.It Fl -shuffle-sections Ns = Ns Ar seed
519Shuffle matched sections using the given seed before mapping them to the output sections.
520If -1, reverse the section order. If 0, use a random seed.
521.It Fl -soname Ns = Ns Ar value , Fl h Ar value
522Set
523.Dv DT_SONAME
524to
525.Ar value .
526.It Fl -sort-common
527This option is ignored for GNU compatibility.
528.It Fl -sort-section Ns = Ns Ar value
529Specifies sections sorting rule when linkerscript is used.
530.It Fl -start-lib
531Start a grouping of objects that should be treated as if they were together
532in an archive.
533.It Fl -strip-all , Fl s
534Strip all symbols.
535Implies
536.Fl -strip-debug .
537.It Fl -strip-debug , Fl S
538Strip debugging information.
539.It Fl -symbol-ordering-file Ns = Ns Ar file
540Lay out sections in the order specified by
541.Ar file .
542.It Fl -sysroot Ns = Ns Ar value
543Set the system root.
544.It Fl -target1-abs
545Interpret
546.Dv R_ARM_TARGET1
547as
548.Dv R_ARM_ABS32 .
549.It Fl -target1-rel
550Interpret
551.Dv R_ARM_TARGET1
552as
553.Dv R_ARM_REL32 .
554.It Fl -target2 Ns = Ns Ar type
555Interpret
556.Dv R_ARM_TARGET2
557as
558.Ar type ,
559where
560.Ar type
561is one of
562.Cm rel ,
563.Cm abs ,
564or
565.Cm got-rel .
566.It Fl -Tbss Ns = Ns Ar value
567Same as
568.Fl -section-start
569with
570.Li .bss
571as the sectionname.
572.It Fl -Tdata Ns = Ns Ar value
573Same as
574.Fl -section-start
575with
576.Li .data
577as the sectionname.
578.It Fl -Ttext Ns = Ns Ar value
579Same as
580.Fl -section-start
581with
582.Li .text
583as the sectionname.
584.It Fl -thinlto-cache-dir Ns = Ns Ar value
585Path to ThinLTO cached object file directory.
586.It Fl -thinlto-cache-policy Ns = Ns Ar value
587Pruning policy for the ThinLTO cache.
588.It Fl -thinlto-jobs Ns = Ns Ar value
589Number of ThinLTO jobs.
590.It Fl -threads Ns = Ns Ar N
591Number of threads.
592.Cm all
593(default) means all of concurrent threads supported.
594.Cm 1
595disables multi-threading.
596.It Fl -time-trace
597Record time trace.
598.It Fl -time-trace-file Ns = Ns Ar file
599Write time trace output to
600.Ar file .
601.It Fl -time-trace-granularity Ns = Ns Ar value
602Minimum time granularity (in microseconds) traced by time profiler.
603.It Fl -trace
604Print the names of the input files.
605.It Fl -trace-symbol Ns = Ns Ar symbol , Fl y Ar symbol
606Trace references to
607.Ar symbol .
608.It Fl -undefined Ns = Ns Ar symbol , Fl u Ar symbol
609If
610.Ar symbol
611is not defined after symbol resolution, and there's a static library
612that contains an object file defining the symbol, load the member
613to include the object file in the output file.
614.It Fl -undefined-glob Ns = Ns Ar pattern
615Synonym for
616.Fl -undefined ,
617except that it takes a glob pattern.
618In a glob pattern,
619.Cm *
620matches zero or more characters,
621.Cm ?
622matches any single character, and
623.Cm [...]
624matches the characters within brackets.
625All symbols that match
626a given pattern are handled as if they were given as arguments of
627.Fl -undefined .
628.It Fl -unique
629Creates a separate output section for every orphan input section.
630.It Fl -unresolved-symbols Ns = Ns Ar value
631Determine how to handle unresolved symbols.
632.It Fl -use-android-relr-tags
633Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*.
634.It Fl v
635Display the version number and proceed with linking if object files are
636specified.
637.It Fl V , Fl -version
638Display the version number and exit.
639.It Fl -verbose
640Verbose mode.
641.It Fl -version-script Ns = Ns Ar file
642Read version script from
643.Ar file .
644.It Fl -warn-backrefs
645Warn about reverse or cyclic dependencies to or between static archives.
646This can be used to ensure linker invocation remains compatible with
647traditional Unix-like linkers.
648.It Fl -warn-backrefs-exclude Ns = Ns Ar glob
649Glob describing an archive (or an object file within --start-lib)
650which should be ignored for
651.Fl -warn-backrefs
652.It Fl -warn-common
653Warn about duplicate common symbols.
654.It Fl -warn-ifunc-textrel
655Warn about using ifunc symbols in conjunction with text relocations.
656Older versions of glibc library (2.28 and earlier) has a bug that causes
657the segment that includes ifunc symbols to be marked as not executable when
658they are relocated.
659As a result, although the program compiles and links
660successfully, it gives segmentation fault when the instruction pointer reaches
661an ifunc symbol.
662Use -warn-ifunc-textrel to let lld give a warning, if the
663code may include ifunc symbols, may do text relocations and be linked with
664an older glibc version.
665Otherwise, there is no need to use it, as the default value does not give a
666warning.
667This flag has been introduced in late 2018, has no counter part in ld and gold
668linkers, and may be removed in the future.
669.It Fl -warn-unresolved-symbols
670Report unresolved symbols as warnings.
671.It Fl -whole-archive
672Force load of all members in a static library.
673.It Fl -why-extract Ns = Ns Ar file
674Print to a file about why archive members are extracted.
675.It Fl -wrap Ns = Ns Ar symbol
676Redirect
677.Ar symbol
678references to
679.Ar __wrap_symbol
680and
681.Ar __real_symbol
682references to
683.Ar symbol.
684.It Fl z Ar option
685Linker option extensions.
686.Bl -tag -width indent -compact
687.Pp
688.It Cm dead-reloc-in-nonalloc Ns = Ns Ar section_glob=value
689Resolve a relocation in a matched non-SHF_ALLOC section referencing a discarded symbol to
690.Ar value
691Accepts globs, in the event of a section matching more than one option, the last
692option takes precedence. An order of least specific to most specific match is
693recommended.
694.Pp
695.It Cm execstack
696Make the main stack executable.
697Stack permissions are recorded in the
698.Dv PT_GNU_STACK
699segment.
700.Pp
701.It Cm bti-report Ns = Ns Ar [none|warning|error]
702Specify how to report the missing GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
703.Cm none
704is the default, linker will not report the missing property otherwise will be reported as a warning or an error.
705.Pp
706.It Cm cet-report Ns = Ns Ar [none|warning|error]
707Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT or GNU_PROPERTY_X86_FEATURE_1_SHSTK properties.
708.Cm none
709is the default, linker will not report the missing property otherwise will be reported as a warning or an error.
710.Pp
711.It Cm force-bti
712Force enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
713.Pp
714.It Cm force-ibt
715Force enable Intel Indirect Branch Tracking in PLT, warn if an input ELF file
716does not have GNU_PROPERTY_X86_FEATURE_1_IBT property.
717.Pp
718.It Cm global
719Sets the
720.Dv DF_1_GLOBAL flag in the
721.Dv DYNAMIC
722section.
723Different loaders can decide how to handle this flag on their own.
724.Pp
725.It Cm ifunc-noplt
726Do not emit PLT entries for ifunc symbols.
727Instead, emit text relocations referencing the resolver.
728This is an experimental optimization and only suitable for standalone
729environments where text relocations do not have the usual drawbacks.
730This option must be combined with the
731.Fl z Li notext
732option.
733.Pp
734.It Cm initfirst
735Sets the
736.Dv DF_1_INITFIRST
737flag to indicate the module should be initialized first.
738.Pp
739.It Cm interpose
740Set the
741.Dv DF_1_INTERPOSE
742flag to indicate to the runtime linker that the object is an interposer.
743During symbol resolution interposers are searched after the application
744but before other dependencies.
745.Pp
746.It Cm muldefs
747Do not error if a symbol is defined multiple times.
748The first definition will be used.
749This is a synonym for
750.Fl -allow-multiple-definition.
751.Pp
752.It Cm nocombreloc
753Disable combining and sorting multiple relocation sections.
754.Pp
755.It Cm nocopyreloc
756Disable the creation of copy relocations.
757.Pp
758.It Cm nodefaultlib
759Set the
760.Dv DF_1_NODEFLIB
761flag to indicate that default library search paths should be ignored.
762.Pp
763.It Cm nodelete
764Set the
765.Dv DF_1_NODELETE
766flag to indicate that the object cannot be unloaded from a process.
767.Pp
768.It Cm nodlopen
769Set the
770.Dv DF_1_NOOPEN
771flag to indicate that the object may not be opened by
772.Xr dlopen 3 .
773.Pp
774.It Cm nognustack
775Do not emit the
776.Dv PT_GNU_STACK
777segment.
778.Pp
779.It Cm norelro
780Do not indicate that portions of the object should be mapped read-only
781after initial relocation processing.
782The object will omit the
783.Dv PT_GNU_RELRO
784segment.
785.Pp
786.It Cm notext
787Allow relocations against read-only segments.
788Sets the
789.Dv DT_TEXTREL flag in the
790.Dv DYNAMIC
791section.
792.Pp
793.It Cm now
794Set the
795.Dv DF_BIND_NOW
796flag to indicate that the run-time loader should perform all relocation
797processing as part of object initialization.
798By default relocations may be performed on demand.
799.Pp
800.It Cm origin
801Set the
802.Dv DF_ORIGIN
803flag to indicate that the object requires
804$ORIGIN
805processing.
806.Pp
807.It Cm pac-plt
808AArch64 only, use pointer authentication in PLT.
809.Pp
810.It Cm pack-relative-relocs
811Similar to
812.Cm -pack-dyn-relocs=relr
813, but synthesizes the GLIBC_ABI_DT_RELR version dependency if there is a GLIBC_2.* version dependency.
814glibc ld.so rejects loading a dynamically linked object without the GLIBC_ABI_DT_RELR version dependency.
815.Pp
816.It Cm rel
817Use REL format for dynamic relocations.
818.Pp
819.It Cm rela
820Use RELA format for dynamic relocations.
821.Pp
822.It Cm retpolineplt
823Emit retpoline format PLT entries as a mitigation for CVE-2017-5715.
824.Pp
825.It Cm rodynamic
826Make the
827.Li .dynamic
828section read-only.
829The
830.Dv DT_DEBUG
831tag will not be emitted.
832.Pp
833.It Cm separate-loadable-segments
834.It Cm separate-code
835.It Cm noseparate-code
836Specify whether two adjacent PT_LOAD segments are allowed to overlap in pages.
837.Cm noseparate-code
838(default) allows overlap.
839.Cm separate-code
840allows overlap between two executable segments, or two non-executable segments.
841.Cm separate-loadable-segments
842disallows overlap.
843.Pp
844.It Cm shstk
845x86 only, use shadow stack.
846.Pp
847.It Cm stack-size Ns = Ns Ar size
848Set the main thread's stack size to
849.Ar size .
850The stack size is recorded as the size of the
851.Ar size .
852.Dv PT_GNU_STACK
853program segment.
854.Pp
855.It Cm start-stop-gc
856Don't let __start_/__stop_ references retain the associated C identifier name sections (default).
857.Pp
858.It Cm nostart-stop-gc
859Let __start_/__stop_ references retain the associated C identifier name sections.
860.Pp
861.It Cm text
862Do not allow relocations against read-only segments.
863This is the default.
864.Pp
865.It Cm wxneeded
866Create a
867.Dv PT_OPENBSD_WXNEEDED
868segment.
869.El
870.El
871.Sh IMPLEMENTATION NOTES
872.Nm Ap s
873handing of archive files (those with a
874.Pa .a
875file extension) is different from traditional linkers used on Unix-like
876systems.
877.Pp
878Traditional linkers maintain a set of undefined symbols during linking.
879The linker processes each file in the order in which it appears on the
880command line, until the set of undefined symbols becomes empty.
881An object file is linked into the output object when it is encountered,
882with its undefined symbols added to the set.
883Upon encountering an archive file a traditional linker searches the objects
884contained therein, and processes those that satisfy symbols in the unresolved
885set.
886.Pp
887Handling mutually dependent archives may be awkward when using a traditional
888linker.
889Archive files may have to be specified multiple times, or the special command
890line options
891.Fl -start-group
892and
893.Fl -end-group
894may be used to have the linker loop over the files in the group until no new
895symbols are added to the set.
896.Pp
897.Nm
898records all symbols found in objects and archives as it iterates over
899command line arguments.
900When
901.Nm
902encounters an undefined symbol that can be resolved by an object file
903contained in a previously processed archive file, it immediately extracts
904and links it into the output object.
905.Pp
906With certain archive inputs
907.Nm
908may produce different results compared to traditional linkers.
909In practice, large bodies of third party software have been linked with
910.Nm
911without material issues.
912.Pp
913The
914.Fl -warn-backrefs
915option may be used to identify a linker invocation that may be incompatible
916with traditional Unix-like linker behavior.
917