2 .\" Copyright (c) 2018 Kirill Ponomarev
3 .\" Copyright (c) 2018 The FreeBSD Foundation
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .Dd September 14, 2018
33 .Nd ELF linker from the LLVM project
39 A linker takes one or more object, archive, and library files, and combines
40 them into an output file (an executable, a shared library, or another object
42 It relocates code and data from the input files and resolves symbol
43 references between them.
46 is a drop-in replacement for the GNU BFD and gold linkers.
47 It accepts most of the same command line arguments and linker scripts
50 Many options have both a single-letter and long form.
51 When using the long form options other than those beginning with the
54 may be specified using either one or two dashes preceeding the option name.
55 Long options beginning with
57 require two dashes to avoid confusion with the
61 These options are available:
62 .Bl -tag -width indent
63 .It Fl -allow-multiple-definition
64 Do not error if a symbol is defined multiple times.
65 The first definition will be used.
69 for shared libraries if used.
70 .It Fl -auxiliary Ar value
73 field to the specified name.
75 Link against shared libraries.
77 Do not link against shared libraries.
78 .It Fl -Bsymbolic-functions
79 Bind defined function symbols locally.
81 Bind defined symbols locally.
82 .It Fl -build-id= Ns Ar value
83 Generate a build ID note.
90 .Cm 0x Ns Ar hex-string ,
101 are calculated from the object contents.
103 Generate a build ID note.
104 .It Fl -color-diagnostics= Ns Ar value
105 Use colors in diagnostics.
113 enables color if and only if output is to a terminal.
114 .It Fl -color-diagnostics
116 .Fl -color-diagnostics= Ns Cm auto .
117 .It Fl -compress-debug-sections= Ns Ar value
118 Compress DWARF debug sections.
124 .It Fl -define-common
125 Assign space to common symbols.
126 .It Fl -defsym= Ns Ar symbol= Ns Ar expression
127 Define a symbol alias.
129 may be another symbol or a linker script expression.
131 .Fl -defsym= Ns Cm foo= Ns Cm bar
133 .Fl -defsym= Ns Cm foo= Ns Cm bar+0x100 .
135 Demangle symbol names.
136 .It Fl -disable-new-dtags
137 Disable new dynamic tags.
139 Delete all local symbols.
140 .It Fl -discard-locals
141 Delete temporary local symbols.
143 Keep all symbols in the symbol table.
144 .It Fl -dynamic-linker Ar value
145 Specify the dynamic linker to be used for a dynamically linked executable.
146 This is recorded in an ELF segment of type
148 .It Fl -dynamic-list Ar file
149 Read a list of dynamic symbols from
158 Generate relocations in the output.
159 .It Fl -enable-new-dtags
160 Enable new dynamic tags.
162 End a grouping of objects that should be treated as if they were together
164 .It Fl -entry Ar entry
165 Name of entry point symbol.
166 .It Fl -error-limit Ar value
167 Maximum number of errors to emit before stopping.
168 A value of zero indicates that there is no limit.
169 .It Fl -error-unresolved-symbols
170 Report unresolved symbols as errors.
171 .It Fl -exclude-libs Ar value
172 Exclude static libraries from automatic export.
173 .It Fl -export-dynamic-symbol Ar symbol
176 in the dynamic symbol table.
177 .It Fl -export-dynamic
178 Put symbols in the dynamic symbol table.
179 .It Fl -fatal-warnings
180 Treat warnings as errors.
181 .It Fl -filter= Ns Ar value
184 field to the specified value.
185 .It Fl -fini Ar symbol
186 Specify a finalizer function.
187 .It Fl -format= Ns Ar input-format
188 Specify the format of the inputs following this option.
199 Enable garbage collection of unused sections.
204 .It Fl -hash-style Ar value
215 Print a usage message.
217 Enable identical code folding.
219 Disable identical code folding.
220 .It Fl -image-base= Ns Ar value
221 Set the base address to
223 .It Fl -init Ar symbol
224 Specify an initializer function.
225 .It Fl -lto-aa-pipeline= Ns Ar value
226 AA pipeline to run during LTO.
227 Used in conjunction with
228 .Fl -lto-newpm-passes .
229 .It Fl -lto-newpm-passes= Ns Ar value
230 Passes to run during LTO.
231 .It Fl -lto-O Ar opt-level
232 Optimization level for LTO.
233 .It Fl -lto-partitions= Ns Ar value
234 Number of LTO codegen partitions.
236 Add a directory to the library search path.
238 Root name of library to use.
243 Set target emulation.
247 for shared libraries.
248 .It Fl -no-color-diagnostics
249 Do not use colors in diagnostics.
250 .It Fl -no-define-common
251 Do not assign space to common symbols.
253 Do not demangle symbol names.
254 .It Fl -no-dynamic-linker
258 .It Fl -no-gc-sections
259 Disable garbage collection of unused sections.
260 .It Fl -no-gnu-unique
261 Disable STB_GNU_UNIQUE symbol binding.
263 Do not put read-only non-executable sections in their own segment.
265 Do not run the linker multi-threaded.
266 .It Fl -no-undefined-version
267 Report version scripts that refer undefined symbols.
269 Report unresolved symbols even if the linker is creating a shared library.
270 .It Fl -no-whole-archive
271 Restores the default behavior of loading archive members.
272 .It Fl -noinhibit-exec
273 Retain the executable output file whenever it is still usable.
275 Do not create a position independent executable.
277 Only search directories specified on the command line.
278 .It Fl -oformat Ar format
279 Specify the format for the output object file.
284 which produces output with no ELF header.
286 Set the text and data sections to be readable and writable.
287 .It Fl -opt-remarks-filename Ar file
288 Write optimization remarks in YAML format to
290 .It Fl -opt-remarks-with-hotness
291 Include hotness information in the optimization remarks file.
293 Optimize output file size.
296 .Bl -tag -width indent
298 Disable string merging.
300 Enable string merging.
302 Enable string tail merging.
307 Write the output executable, library, or object to
311 is used as a default.
313 Create a position independent executable.
314 .It Fl -print-gc-sections
315 List removed unused sections.
317 Print a link map to the standard output.
319 Create relocatable object file.
320 .It Fl -reproduce Ar value
321 Dump linker invocation and input files for debugging.
322 .It Fl -retain-symbols-file= Ns Ar file
323 Retain only the symbols listed in the file.
324 .It Fl -rpath Ar value
328 .It Fl -rsp-quoting= Ns Ar value
329 Quoting style for response files.
330 The supported values are
334 .It Fl -script Ar file
335 Read linker script from
337 .It Fl -section-start Ar address
338 Set address of section.
340 Build a shared object.
341 .It Fl -soname= Ns Ar value
346 .It Fl -sort-section Ar value
347 Specifies sections sorting rule when linkerscript is used.
349 Start a grouping of objects that should be treated as if they were together
354 Strip debugging information.
355 .It Fl -symbol-ordering-file Ar file
356 Lay out sections in the order specified by
358 .It Fl -sysroot= Ns Ar value
382 .It Fl -Tbss Ar value
388 .It Fl -Tdata Ar value
394 .It Fl -thinlto-cache-dir= Ns Ar value
395 Path to ThinLTO cached object file directory.
396 .It Fl -thinlto-cache-policy Ar value
397 Pruning policy for the ThinLTO cache.
398 .It Fl -thinlto-jobs= Ns Ar value
399 Number of ThinLTO jobs.
401 Run the linker multi-threaded.
402 This option is enabled by default.
403 .It Fl -trace-symbol Ar symbol
407 Print the names of the input files.
408 .It Fl -Ttext Ar value
414 .It Fl -undefined Ar symbol
417 to be an undefined symbol during linking.
418 .It Fl -unresolved-symbols= Ns Ar value
419 Determine how to handle unresolved symbols.
422 .It Fl -version-script Ar file
423 Read version script from
425 .It Fl V , Fl -version
426 Display the version number and exit.
428 Display the version number and proceed with linking if object files are
431 Warn about duplicate common symbols.
432 .It Fl -warn-unresolved-symbols
433 Report unresolved symbols as warnings.
434 .It Fl -whole-archive
435 Force load of all members in a static library.
436 .It Fl -wrap Ar symbol
437 Use wrapper functions for symbol.
439 Linker option extensions.
440 .Bl -tag -width indent
442 Make the main stack executable.
443 Stack permissions are recorded in the
447 Do not emit PLT entries for GNU ifuncs.
448 Instead, preserve relocations for ifunc call sites so that they may
449 be applied by a run-time loader.
450 Note that this feature requires special loader support and will
451 generally result in application crashes when used outside of freestanding
456 flag to indicate that the object is an interposer.
457 Runtime linkers perform symbol resolution by first searching the application,
458 followed by interposers, and then any other dependencies.
460 Do not error if a symbol is defined multiple times.
461 The first definition will be used.
462 This is a synonym for
463 .Fl -allow-multiple-definition.
465 Disable combining and sorting multiple relocation sections.
467 Disable the creation of copy relocations.
471 flag to indicate that the object cannot be unloaded from a process.
475 flag to indcate that the object may not be opened by
478 Do not indicate that portions of the object shold be mapped read-only
479 after initial relocation processing.
480 The object will omit the
484 Allow relocations against read-only segments.
486 .Dv DT_TEXTREL flag in the
492 flag to indicate that the run-time loader should perform all relocation
493 processing as part of object initialization.
494 By default relocations may be performed on demand.
498 flag to indicate that the object requires
502 Emit retpoline format PLT entries as a mitigation for CVE-2017-5715.
509 tag will not be emitted.
510 .It Cm stack-size= Ns Ar size
511 Set the main thread's stack size to
513 The stack size is recorded as the size of the
518 Do not allow relocations against read-only segments.
522 .Dv PT_OPENBSD_WXNEEDED