xref: /freebsd/contrib/llvm-project/lld/docs/ld.lld.1 (revision 5e801ac66d24704442eba426ed13c3effb8a34e7)
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.
145.It Fl -define-common , Fl d
146Assign space to common symbols.
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-define-common
328Do not assign space to common symbols.
329.It Fl -no-demangle
330Do not demangle symbol names.
331.It Fl -no-dynamic-linker
332Inhibit output of an
333.Li .interp
334section.
335.It Fl -no-fortran-common
336Do not search archive members for definitions to override COMMON symbols.
337.It Fl -no-gc-sections
338Disable garbage collection of unused sections.
339.It Fl -no-gnu-unique
340Disable STB_GNU_UNIQUE symbol binding.
341.It Fl -no-merge-exidx-entries
342Disable merging .ARM.exidx entries.
343.It Fl -no-nmagic
344Page align sections.
345.It Fl -no-omagic
346Do not set the text data sections to be writable, page align sections.
347.It Fl -no-relax
348Disable target-specific relaxations. For x86-64 this disables R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization.
349.It Fl -no-rosegment
350Do not put read-only non-executable sections in their own segment.
351.It Fl -no-undefined-version
352Report version scripts that refer undefined symbols.
353.It Fl -no-undefined
354Report unresolved symbols even if the linker is creating a shared library.
355.It Fl -no-warn-symbol-ordering
356Do not warn about problems with the symbol ordering file or call graph profile.
357.It Fl -no-whole-archive
358Restores the default behavior of loading archive members.
359.It Fl -no-pie , Fl -no-pic-executable
360Do not create a position independent executable.
361.It Fl -noinhibit-exec
362Retain the executable output file whenever it is still usable.
363.It Fl -nostdlib
364Only search directories specified on the command line.
365.It Fl o Ar path
366Write the output executable, library, or object to
367.Ar path .
368If not specified,
369.Dv a.out
370is used as a default.
371.It Fl O Ns Ar value
372Optimize output file size.
373.Ar value
374may be:
375.Pp
376.Bl -tag -width 2n -compact
377.It Cm 0
378Disable string merging.
379.It Cm 1
380Enable string merging.
381.It Cm 2
382Enable string tail merging. If
383.Fl -compress-debug-sections
384is given, compress debug sections at compression level 6 instead of 1.
385.El
386.Pp
387.Fl O Ns Cm 1
388is the default.
389.It Fl -oformat Ns = Ns Ar format
390Specify the format for the output object file.
391The only supported
392.Ar format
393is
394.Cm binary ,
395which produces output with no ELF header.
396.It Fl -omagic , Fl N
397Set the text and data sections to be readable and writable, do not page align
398sections, link against static libraries.
399.It Fl -opt-remarks-filename Ar file
400Write optimization remarks in YAML format to
401.Ar file .
402.It Fl -opt-remarks-passes Ar pass-regex
403Filter optimization remarks by only allowing the passes matching
404.Ar pass-regex .
405.It Fl -opt-remarks-with-hotness
406Include hotness information in the optimization remarks file.
407.It Fl -orphan-handling Ns = Ns Ar mode
408Control how orphan sections are handled.
409An orphan section is one not specifically mentioned in a linker script.
410.Ar mode
411may be:
412.Pp
413.Bl -tag -width 2n -compact
414.It Cm place
415Place orphan sections in suitable output sections.
416.It Cm warn
417Place orphan sections as for
418.Cm place
419and also report a warning.
420.It Cm error
421Place orphan sections as for
422.Cm place
423and also report an error.
424.El
425.Pp
426.Cm place
427is the default.
428.It Fl -pack-dyn-relocs Ns = Ns Ar format
429Pack dynamic relocations in the given format.
430.Ar format
431may be:
432.Pp
433.Bl -tag -width 2n -compact
434.It Cm none
435Do not pack.
436Dynamic relocations are encoded in SHT_REL(A).
437.It Cm android
438Pack dynamic relocations in SHT_ANDROID_REL(A).
439.It Cm relr
440Pack relative relocations in SHT_RELR, and the rest of dynamic relocations in
441SHT_REL(A).
442.It Cm android+relr
443Pack relative relocations in SHT_RELR, and the rest of dynamic relocations in
444SHT_ANDROID_REL(A).
445.El
446.Pp
447.Cm none
448is the default.
449If
450.Fl -use-android-relr-tags
451is specified, use SHT_ANDROID_RELR instead of SHT_RELR.
452.Pp
453.It Fl -pic-veneer
454Always generate position independent thunks.
455.It Fl -pie , Fl -pic-executable
456Create a position independent executable.
457.It Fl -print-gc-sections
458List removed unused sections.
459.It Fl -print-icf-sections
460List identical folded sections.
461.It Fl -print-map
462Print a link map to the standard output.
463.It Fl -print-archive-stats Ns = Ns Ar file
464Write archive usage statistics to the specified file.
465Print the numbers of members and fetched members for each archive.
466.It Fl -push-state
467Save the current state of
468.Fl -as-needed ,
469.Fl -static ,
470and
471.Fl -whole-archive.
472.It Fl -pop-state
473Undo the effect of
474.Fl -push-state.
475.It Fl -relocatable , Fl r
476Create relocatable object file.
477.It Fl -reproduce Ns = Ns Ar path
478Write a tar file to
479.Ar path,
480containing all the input files needed to reproduce the link, a text file called
481response.txt containing the command line options and a text file called
482version.txt containing the output of ld.lld --version.
483The archive when
484unpacked can be used to re-run the linker with the same options and input files.
485.It Fl -retain-symbols-file Ns = Ns Ar file
486Retain only the symbols listed in the file.
487.It Fl -rpath Ns = Ns Ar value , Fl R Ar value
488Add a
489.Dv DT_RUNPATH
490to the output.
491.It Fl -rsp-quoting Ns = Ns Ar value
492Quoting style for response files.
493The supported values are
494.Cm windows
495and
496.Cm posix .
497.It Fl -script Ns = Ns Ar file , Fl T Ar file
498Read linker script from
499.Ar file .
500If multiple linker scripts are given, they are processed as if they
501were concatenated in the order they appeared on the command line.
502.It Fl -section-start Ns = Ns Ar section Ns = Ns Ar address
503Set address of section.
504.It Fl -shared , Fl -Bsharable
505Build a shared object.
506.It Fl -shuffle-sections Ns = Ns Ar seed
507Shuffle matched sections using the given seed before mapping them to the output sections.
508If -1, reverse the section order. If 0, use a random seed.
509.It Fl -soname Ns = Ns Ar value , Fl h Ar value
510Set
511.Dv DT_SONAME
512to
513.Ar value .
514.It Fl -sort-common
515This option is ignored for GNU compatibility.
516.It Fl -sort-section Ns = Ns Ar value
517Specifies sections sorting rule when linkerscript is used.
518.It Fl -start-lib
519Start a grouping of objects that should be treated as if they were together
520in an archive.
521.It Fl -strip-all , Fl s
522Strip all symbols.
523Implies
524.Fl -strip-debug .
525.It Fl -strip-debug , Fl S
526Strip debugging information.
527.It Fl -symbol-ordering-file Ns = Ns Ar file
528Lay out sections in the order specified by
529.Ar file .
530.It Fl -sysroot Ns = Ns Ar value
531Set the system root.
532.It Fl -target1-abs
533Interpret
534.Dv R_ARM_TARGET1
535as
536.Dv R_ARM_ABS32 .
537.It Fl -target1-rel
538Interpret
539.Dv R_ARM_TARGET1
540as
541.Dv R_ARM_REL32 .
542.It Fl -target2 Ns = Ns Ar type
543Interpret
544.Dv R_ARM_TARGET2
545as
546.Ar type ,
547where
548.Ar type
549is one of
550.Cm rel ,
551.Cm abs ,
552or
553.Cm got-rel .
554.It Fl -Tbss Ns = Ns Ar value
555Same as
556.Fl -section-start
557with
558.Li .bss
559as the sectionname.
560.It Fl -Tdata Ns = Ns Ar value
561Same as
562.Fl -section-start
563with
564.Li .data
565as the sectionname.
566.It Fl -Ttext Ns = Ns Ar value
567Same as
568.Fl -section-start
569with
570.Li .text
571as the sectionname.
572.It Fl -thinlto-cache-dir Ns = Ns Ar value
573Path to ThinLTO cached object file directory.
574.It Fl -thinlto-cache-policy Ns = Ns Ar value
575Pruning policy for the ThinLTO cache.
576.It Fl -thinlto-jobs Ns = Ns Ar value
577Number of ThinLTO jobs.
578.It Fl -threads Ns = Ns Ar N
579Number of threads.
580.Cm all
581(default) means all of concurrent threads supported.
582.Cm 1
583disables multi-threading.
584.It Fl -time-trace
585Record time trace.
586.It Fl -time-trace-file Ns = Ns Ar file
587Write time trace output to
588.Ar file .
589.It Fl -time-trace-granularity Ns = Ns Ar value
590Minimum time granularity (in microseconds) traced by time profiler.
591.It Fl -trace
592Print the names of the input files.
593.It Fl -trace-symbol Ns = Ns Ar symbol , Fl y Ar symbol
594Trace references to
595.Ar symbol .
596.It Fl -undefined Ns = Ns Ar symbol , Fl u Ar symbol
597If
598.Ar symbol
599is not defined after symbol resolution, and there's a static library
600that contains an object file defining the symbol, load the member
601to include the object file in the output file.
602.It Fl -undefined-glob Ns = Ns Ar pattern
603Synonym for
604.Fl -undefined ,
605except that it takes a glob pattern.
606In a glob pattern,
607.Cm *
608matches zero or more characters,
609.Cm ?
610matches any single character, and
611.Cm [...]
612matches the characters within brackets.
613All symbols that match
614a given pattern are handled as if they were given as arguments of
615.Fl -undefined .
616.It Fl -unique
617Creates a separate output section for every orphan input section.
618.It Fl -unresolved-symbols Ns = Ns Ar value
619Determine how to handle unresolved symbols.
620.It Fl -use-android-relr-tags
621Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*.
622.It Fl v
623Display the version number and proceed with linking if object files are
624specified.
625.It Fl V , Fl -version
626Display the version number and exit.
627.It Fl -verbose
628Verbose mode.
629.It Fl -version-script Ns = Ns Ar file
630Read version script from
631.Ar file .
632.It Fl -warn-backrefs
633Warn about reverse or cyclic dependencies to or between static archives.
634This can be used to ensure linker invocation remains compatible with
635traditional Unix-like linkers.
636.It Fl -warn-backrefs-exclude Ns = Ns Ar glob
637Glob describing an archive (or an object file within --start-lib)
638which should be ignored for
639.Fl -warn-backrefs
640.It Fl -warn-common
641Warn about duplicate common symbols.
642.It Fl -warn-ifunc-textrel
643Warn about using ifunc symbols in conjunction with text relocations.
644Older versions of glibc library (2.28 and earlier) has a bug that causes
645the segment that includes ifunc symbols to be marked as not executable when
646they are relocated.
647As a result, although the program compiles and links
648successfully, it gives segmentation fault when the instruction pointer reaches
649an ifunc symbol.
650Use -warn-ifunc-textrel to let lld give a warning, if the
651code may include ifunc symbols, may do text relocations and be linked with
652an older glibc version.
653Otherwise, there is no need to use it, as the default value does not give a
654warning.
655This flag has been introduced in late 2018, has no counter part in ld and gold
656linkers, and may be removed in the future.
657.It Fl -warn-unresolved-symbols
658Report unresolved symbols as warnings.
659.It Fl -whole-archive
660Force load of all members in a static library.
661.It Fl -why-extract Ns = Ns Ar file
662Print to a file about why archive members are extracted.
663.It Fl -wrap Ns = Ns Ar symbol
664Redirect
665.Ar symbol
666references to
667.Ar __wrap_symbol
668and
669.Ar __real_symbol
670references to
671.Ar symbol.
672.It Fl z Ar option
673Linker option extensions.
674.Bl -tag -width indent -compact
675.Pp
676.It Cm dead-reloc-in-nonalloc Ns = Ns Ar section_glob=value
677Resolve a relocation in a matched non-SHF_ALLOC section referencing a discarded symbol to
678.Ar value
679Accepts globs, in the event of a section matching more than one option, the last
680option takes precedence. An order of least specific to most specific match is
681recommended.
682.Pp
683.It Cm execstack
684Make the main stack executable.
685Stack permissions are recorded in the
686.Dv PT_GNU_STACK
687segment.
688.Pp
689.It Cm force-bti
690Force enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
691.Pp
692.It Cm force-ibt
693Force enable Intel Indirect Branch Tracking in PLT, warn if an input ELF file
694does not have GNU_PROPERTY_X86_FEATURE_1_IBT property.
695.Pp
696.It Cm global
697Sets the
698.Dv DF_1_GLOBAL flag in the
699.Dv DYNAMIC
700section.
701Different loaders can decide how to handle this flag on their own.
702.Pp
703.It Cm ifunc-noplt
704Do not emit PLT entries for ifunc symbols.
705Instead, emit text relocations referencing the resolver.
706This is an experimental optimization and only suitable for standalone
707environments where text relocations do not have the usual drawbacks.
708This option must be combined with the
709.Fl z Li notext
710option.
711.Pp
712.It Cm initfirst
713Sets the
714.Dv DF_1_INITFIRST
715flag to indicate the module should be initialized first.
716.Pp
717.It Cm interpose
718Set the
719.Dv DF_1_INTERPOSE
720flag to indicate to the runtime linker that the object is an interposer.
721During symbol resolution interposers are searched after the application
722but before other dependencies.
723.Pp
724.It Cm muldefs
725Do not error if a symbol is defined multiple times.
726The first definition will be used.
727This is a synonym for
728.Fl -allow-multiple-definition.
729.Pp
730.It Cm nocombreloc
731Disable combining and sorting multiple relocation sections.
732.Pp
733.It Cm nocopyreloc
734Disable the creation of copy relocations.
735.Pp
736.It Cm nodefaultlib
737Set the
738.Dv DF_1_NODEFLIB
739flag to indicate that default library search paths should be ignored.
740.Pp
741.It Cm nodelete
742Set the
743.Dv DF_1_NODELETE
744flag to indicate that the object cannot be unloaded from a process.
745.Pp
746.It Cm nodlopen
747Set the
748.Dv DF_1_NOOPEN
749flag to indicate that the object may not be opened by
750.Xr dlopen 3 .
751.Pp
752.It Cm nognustack
753Do not emit the
754.Dv PT_GNU_STACK
755segment.
756.Pp
757.It Cm norelro
758Do not indicate that portions of the object should be mapped read-only
759after initial relocation processing.
760The object will omit the
761.Dv PT_GNU_RELRO
762segment.
763.Pp
764.It Cm notext
765Allow relocations against read-only segments.
766Sets the
767.Dv DT_TEXTREL flag in the
768.Dv DYNAMIC
769section.
770.Pp
771.It Cm now
772Set the
773.Dv DF_BIND_NOW
774flag to indicate that the run-time loader should perform all relocation
775processing as part of object initialization.
776By default relocations may be performed on demand.
777.Pp
778.It Cm origin
779Set the
780.Dv DF_ORIGIN
781flag to indicate that the object requires
782$ORIGIN
783processing.
784.Pp
785.It Cm pac-plt
786AArch64 only, use pointer authentication in PLT.
787.Pp
788.It Cm rel
789Use REL format for dynamic relocations.
790.Pp
791.It Cm rela
792Use RELA format for dynamic relocations.
793.Pp
794.It Cm retpolineplt
795Emit retpoline format PLT entries as a mitigation for CVE-2017-5715.
796.Pp
797.It Cm rodynamic
798Make the
799.Li .dynamic
800section read-only.
801The
802.Dv DT_DEBUG
803tag will not be emitted.
804.Pp
805.It Cm separate-loadable-segments
806.It Cm separate-code
807.It Cm noseparate-code
808Specify whether two adjacent PT_LOAD segments are allowed to overlap in pages.
809.Cm noseparate-code
810(default) allows overlap.
811.Cm separate-code
812allows overlap between two executable segments, or two non-executable segments.
813.Cm separate-loadable-segments
814disallows overlap.
815.Pp
816.It Cm shstk
817x86 only, use shadow stack.
818.Pp
819.It Cm stack-size Ns = Ns Ar size
820Set the main thread's stack size to
821.Ar size .
822The stack size is recorded as the size of the
823.Ar size .
824.Dv PT_GNU_STACK
825program segment.
826.Pp
827.It Cm start-stop-gc
828Don't let __start_/__stop_ references retain the associated C identifier name sections (default).
829.Pp
830.It Cm nostart-stop-gc
831Let __start_/__stop_ references retain the associated C identifier name sections.
832.Pp
833.It Cm text
834Do not allow relocations against read-only segments.
835This is the default.
836.Pp
837.It Cm wxneeded
838Create a
839.Dv PT_OPENBSD_WXNEEDED
840segment.
841.El
842.El
843.Sh IMPLEMENTATION NOTES
844.Nm Ap s
845handing of archive files (those with a
846.Pa .a
847file extension) is different from traditional linkers used on Unix-like
848systems.
849.Pp
850Traditional linkers maintain a set of undefined symbols during linking.
851The linker processes each file in the order in which it appears on the
852command line, until the set of undefined symbols becomes empty.
853An object file is linked into the output object when it is encountered,
854with its undefined symbols added to the set.
855Upon encountering an archive file a traditional linker searches the objects
856contained therein, and processes those that satisfy symbols in the unresolved
857set.
858.Pp
859Handling mutually dependent archives may be awkward when using a traditional
860linker.
861Archive files may have to be specified multiple times, or the special command
862line options
863.Fl -start-group
864and
865.Fl -end-group
866may be used to have the linker loop over the files in the group until no new
867symbols are added to the set.
868.Pp
869.Nm
870records all symbols found in objects and archives as it iterates over
871command line arguments.
872When
873.Nm
874encounters an undefined symbol that can be resolved by an object file
875contained in a previously processed archive file, it immediately extracts
876and links it into the output object.
877.Pp
878With certain archive inputs
879.Nm
880may produce different results compared to traditional linkers.
881In practice, large bodies of third party software have been linked with
882.Nm
883without material issues.
884.Pp
885The
886.Fl -warn-backrefs
887option may be used to identify a linker invocation that may be incompatible
888with traditional Unix-like linker behavior.
889