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