2019-01-19 16:50:56 +08:00
|
|
|
.\" Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
.\" See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
.\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-02-08 04:38:18 +08:00
|
|
|
.\"
|
|
|
|
.\" This man page documents only lld's ELF linking support, obtained originally
|
|
|
|
.\" from FreeBSD.
|
2019-05-14 23:25:21 +08:00
|
|
|
.Dd May 12, 2019
|
2018-02-08 04:38:18 +08:00
|
|
|
.Dt LD.LLD 1
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm ld.lld
|
|
|
|
.Nd ELF linker from the LLVM project
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm ld.lld
|
|
|
|
.Op Ar options
|
|
|
|
.Ar objfile ...
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
A linker takes one or more object, archive, and library files, and combines
|
|
|
|
them into an output file (an executable, a shared library, or another object
|
|
|
|
file).
|
|
|
|
It relocates code and data from the input files and resolves symbol
|
|
|
|
references between them.
|
|
|
|
.Pp
|
|
|
|
.Nm
|
|
|
|
is a drop-in replacement for the GNU BFD and gold linkers.
|
|
|
|
It accepts most of the same command line arguments and linker scripts
|
|
|
|
as GNU linkers.
|
|
|
|
.Pp
|
2018-10-02 00:41:58 +08:00
|
|
|
.Nm
|
|
|
|
currently supports i386, x86-64, ARM, AArch64, PowerPC32, PowerPC64,
|
|
|
|
MIPS32, MIPS64, RISC-V, AMDGPU, Hexagon and SPARC V9 targets.
|
|
|
|
.Nm
|
|
|
|
acts as a Microsoft link.exe-compatible linker if invoked as
|
|
|
|
.Nm lld-link
|
|
|
|
and as macOS's ld if invoked as
|
|
|
|
.Nm ld.ld64.
|
|
|
|
All these targets are always supported however
|
|
|
|
.Nm
|
|
|
|
was built, so you can always use
|
|
|
|
.Nm
|
|
|
|
as a native linker as well as a cross linker.
|
|
|
|
.Sh OPTIONS
|
2019-09-04 01:58:30 +08:00
|
|
|
Many options have both a single-letter and long form.
|
|
|
|
When using the long form options other than those beginning with the
|
|
|
|
letter
|
|
|
|
.Cm o
|
|
|
|
may be specified using either one or two dashes preceding the option name.
|
|
|
|
Long options beginning with
|
|
|
|
.Cm o
|
|
|
|
require two dashes to avoid confusion with the
|
|
|
|
.Fl o Ar path
|
|
|
|
option.
|
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Fl -allow-multiple-definition
|
|
|
|
Do not error if a symbol is defined multiple times.
|
|
|
|
The first definition will be used.
|
2019-02-02 08:34:28 +08:00
|
|
|
.It Fl -allow-shlib-undefined
|
|
|
|
Allow unresolved references in shared libraries.
|
|
|
|
This option is enabled by default when linking a shared library.
|
2018-07-31 01:36:38 +08:00
|
|
|
.It Fl -apply-dynamic-relocs
|
|
|
|
Apply link-time values for dynamic relocations.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -as-needed
|
|
|
|
Only set
|
|
|
|
.Dv DT_NEEDED
|
|
|
|
for shared libraries if used.
|
2018-03-02 10:57:12 +08:00
|
|
|
.It Fl -auxiliary Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Set the
|
|
|
|
.Dv DT_AUXILIARY
|
|
|
|
field to the specified name.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -Bdynamic , Fl -dy
|
2018-02-08 04:38:18 +08:00
|
|
|
Link against shared libraries.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -Bstatic , Fl -static , Fl -dn
|
2018-02-08 04:38:18 +08:00
|
|
|
Do not link against shared libraries.
|
|
|
|
.It Fl -Bsymbolic
|
|
|
|
Bind defined symbols locally.
|
2018-07-31 01:36:38 +08:00
|
|
|
.It Fl -Bsymbolic-functions
|
|
|
|
Bind defined function symbols locally.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -build-id Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Generate a build ID note.
|
|
|
|
.Ar value
|
|
|
|
may be one of
|
2018-02-08 05:22:20 +08:00
|
|
|
.Cm fast ,
|
2018-02-08 04:38:18 +08:00
|
|
|
.Cm md5 ,
|
|
|
|
.Cm sha1 ,
|
|
|
|
.Cm tree ,
|
|
|
|
.Cm uuid ,
|
|
|
|
.Cm 0x Ns Ar hex-string ,
|
|
|
|
and
|
|
|
|
.Cm none .
|
|
|
|
.Cm tree
|
|
|
|
is an alias for
|
|
|
|
.Cm sha1 .
|
|
|
|
Build-IDs of type
|
2018-02-08 05:22:20 +08:00
|
|
|
.Cm fast ,
|
2018-02-08 04:38:18 +08:00
|
|
|
.Cm md5 ,
|
|
|
|
.Cm sha1 ,
|
|
|
|
and
|
|
|
|
.Cm tree
|
|
|
|
are calculated from the object contents.
|
2018-02-08 05:22:20 +08:00
|
|
|
.Cm fast
|
|
|
|
is not intended to be cryptographically secure.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -build-id
|
2018-02-08 05:22:20 +08:00
|
|
|
Synonym for
|
2018-03-02 00:02:19 +08:00
|
|
|
.Fl -build-id Ns = Ns Cm fast .
|
|
|
|
.It Fl -color-diagnostics Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Use colors in diagnostics.
|
|
|
|
.Ar value
|
|
|
|
may be one of
|
|
|
|
.Cm always ,
|
|
|
|
.Cm auto ,
|
|
|
|
and
|
|
|
|
.Cm never .
|
|
|
|
.Cm auto
|
|
|
|
enables color if and only if output is to a terminal.
|
|
|
|
.It Fl -color-diagnostics
|
|
|
|
Alias for
|
2018-03-02 00:02:19 +08:00
|
|
|
.Fl -color-diagnostics Ns = Ns Cm auto .
|
|
|
|
.It Fl -compress-debug-sections Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Compress DWARF debug sections.
|
|
|
|
.Ar value
|
|
|
|
may be
|
|
|
|
.Cm none
|
|
|
|
or
|
|
|
|
.Cm zlib .
|
2019-12-12 11:09:45 +08:00
|
|
|
The default compression level is 1 (fastest) as the debug info usually
|
|
|
|
compresses well at that level, but if you want to compress it more,
|
|
|
|
you can specify
|
|
|
|
.Fl O2
|
|
|
|
to set the compression level to 6.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -cref
|
|
|
|
Output cross reference table.
|
|
|
|
.It Fl -define-common , Fl d
|
2018-02-08 04:38:18 +08:00
|
|
|
Assign space to common symbols.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -defsym Ns = Ns Ar symbol Ns = Ns Ar expression
|
2018-02-08 04:38:18 +08:00
|
|
|
Define a symbol alias.
|
|
|
|
.Ar expression
|
|
|
|
may be another symbol or a linker script expression.
|
|
|
|
For example,
|
2018-03-02 00:02:19 +08:00
|
|
|
.Ql --defsym=foo=bar
|
2018-02-08 04:38:18 +08:00
|
|
|
or
|
2018-03-02 00:02:19 +08:00
|
|
|
.Ql --defsym=foo=bar+0x100 .
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -demangle
|
|
|
|
Demangle symbol names.
|
|
|
|
.It Fl -disable-new-dtags
|
|
|
|
Disable new dynamic tags.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -discard-all , Fl x
|
2018-02-08 04:38:18 +08:00
|
|
|
Delete all local symbols.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -discard-locals , Fl X
|
2018-02-08 04:38:18 +08:00
|
|
|
Delete temporary local symbols.
|
|
|
|
.It Fl -discard-none
|
|
|
|
Keep all symbols in the symbol table.
|
2018-03-02 10:57:12 +08:00
|
|
|
.It Fl -dynamic-linker Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Specify the dynamic linker to be used for a dynamically linked executable.
|
|
|
|
This is recorded in an ELF segment of type
|
|
|
|
.Dv PT_INTERP .
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -dynamic-list Ns = Ns Ar file
|
2018-02-08 04:38:18 +08:00
|
|
|
Read a list of dynamic symbols from
|
|
|
|
.Ar file .
|
|
|
|
.It Fl -eh-frame-hdr
|
|
|
|
Request creation of
|
|
|
|
.Li .eh_frame_hdr
|
|
|
|
section and
|
|
|
|
.Dv PT_GNU_EH_FRAME
|
|
|
|
segment header.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -emit-relocs , Fl q
|
2018-02-08 04:38:18 +08:00
|
|
|
Generate relocations in the output.
|
|
|
|
.It Fl -enable-new-dtags
|
|
|
|
Enable new dynamic tags.
|
|
|
|
.It Fl -end-lib
|
|
|
|
End a grouping of objects that should be treated as if they were together
|
|
|
|
in an archive.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -entry Ns = Ns Ar entry
|
2018-02-08 04:38:18 +08:00
|
|
|
Name of entry point symbol.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -error-limit Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Maximum number of errors to emit before stopping.
|
|
|
|
A value of zero indicates that there is no limit.
|
|
|
|
.It Fl -error-unresolved-symbols
|
|
|
|
Report unresolved symbols as errors.
|
2018-09-26 05:39:08 +08:00
|
|
|
.It Fl -execute-only
|
2019-09-04 01:58:24 +08:00
|
|
|
Mark executable sections unreadable.
|
|
|
|
This option is currently only supported on AArch64.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -exclude-libs Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Exclude static libraries from automatic export.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl -export-dynamic , Fl E
|
|
|
|
Put symbols in the dynamic symbol table.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -export-dynamic-symbol Ns = Ns Ar symbol
|
2018-02-08 04:38:18 +08:00
|
|
|
Include
|
|
|
|
.Ar symbol
|
|
|
|
in the dynamic symbol table.
|
|
|
|
.It Fl -fatal-warnings
|
|
|
|
Treat warnings as errors.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -filter Ns = Ns Ar value , Fl F Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Set the
|
|
|
|
.Dv DT_FILTER
|
|
|
|
field to the specified value.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -fini Ns = Ns Ar symbol
|
2018-02-08 04:38:18 +08:00
|
|
|
Specify a finalizer function.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -format Ns = Ns Ar input-format , Fl b Ar input-format
|
2018-02-08 04:38:18 +08:00
|
|
|
Specify the format of the inputs following this option.
|
|
|
|
.Ar input-format
|
|
|
|
may be one of
|
|
|
|
.Cm binary ,
|
|
|
|
.Cm elf ,
|
|
|
|
and
|
|
|
|
.Cm default .
|
|
|
|
.Cm default
|
|
|
|
is a synonym for
|
|
|
|
.Cm elf .
|
|
|
|
.It Fl -gc-sections
|
|
|
|
Enable garbage collection of unused sections.
|
|
|
|
.It Fl -gdb-index
|
|
|
|
Generate
|
|
|
|
.Li .gdb_index
|
|
|
|
section.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -hash-style Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Specify hash style.
|
|
|
|
.Ar value
|
|
|
|
may be
|
|
|
|
.Cm sysv ,
|
|
|
|
.Cm gnu ,
|
|
|
|
or
|
|
|
|
.Cm both .
|
|
|
|
.Cm both
|
|
|
|
is the default.
|
|
|
|
.It Fl -help
|
2018-03-02 00:02:19 +08:00
|
|
|
Print a help message.
|
|
|
|
.It Fl -icf Ns = Ns Cm all
|
2018-02-08 04:38:18 +08:00
|
|
|
Enable identical code folding.
|
2018-07-19 06:49:31 +08:00
|
|
|
.It Fl -icf Ns = Ns Cm safe
|
|
|
|
Enable safe identical code folding.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -icf Ns = Ns Cm none
|
2018-02-08 04:38:18 +08:00
|
|
|
Disable identical code folding.
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Fl -ignore-data-address-equality
|
|
|
|
Ignore address equality of data. C/C++ requires each data to have a unique
|
2019-09-04 01:58:24 +08:00
|
|
|
address.
|
|
|
|
This option allows lld to do unsafe optimization that breaks the
|
2019-03-01 12:49:42 +08:00
|
|
|
requirement: create copies of read-only data or merge two or more read-only data
|
|
|
|
that happen to have the same value.
|
|
|
|
.It Fl -ignore-function-address-equality
|
2019-09-04 01:58:24 +08:00
|
|
|
Ignore address equality of functions.
|
|
|
|
This option allows non-PIC calls to a function with non-default visibility in
|
|
|
|
a shared object.
|
|
|
|
The function may have different addresses within the executable and within the
|
|
|
|
shared object.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -image-base Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Set the base address to
|
|
|
|
.Ar value .
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -init Ns = Ns Ar symbol
|
2018-02-08 04:38:18 +08:00
|
|
|
Specify an initializer function.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -keep-unique Ns = Ns Ar symbol
|
|
|
|
Do not fold
|
|
|
|
.Ar symbol
|
|
|
|
during ICF.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl l Ar libName, Fl -library Ns = Ns Ar libName
|
|
|
|
Root name of library to use.
|
|
|
|
.It Fl L Ar dir , Fl -library-path Ns = Ns Ar dir
|
|
|
|
Add a directory to the library search path.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -lto-aa-pipeline Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
AA pipeline to run during LTO.
|
|
|
|
Used in conjunction with
|
|
|
|
.Fl -lto-newpm-passes .
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -lto-newpm-passes Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Passes to run during LTO.
|
2018-03-02 10:57:12 +08:00
|
|
|
.It Fl -lto-O Ns Ar opt-level
|
2018-02-08 04:38:18 +08:00
|
|
|
Optimization level for LTO.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -lto-partitions Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Number of LTO codegen partitions.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl m Ar value
|
|
|
|
Set target emulation.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -Map Ns = Ns Ar file , Fl M Ar file
|
2018-02-08 04:38:18 +08:00
|
|
|
Print a link map to
|
|
|
|
.Ar file .
|
2019-05-14 00:01:26 +08:00
|
|
|
.It Fl -nmagic , Fl n
|
|
|
|
Do not page align sections, link against static libraries.
|
2019-02-02 08:34:28 +08:00
|
|
|
.It Fl -no-allow-shlib-undefined
|
|
|
|
Do not allow unresolved references in shared libraries.
|
|
|
|
This option is enabled by default when linking an executable.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -no-as-needed
|
|
|
|
Always set
|
|
|
|
.Dv DT_NEEDED
|
|
|
|
for shared libraries.
|
|
|
|
.It Fl -no-color-diagnostics
|
|
|
|
Do not use colors in diagnostics.
|
|
|
|
.It Fl -no-define-common
|
|
|
|
Do not assign space to common symbols.
|
|
|
|
.It Fl -no-demangle
|
|
|
|
Do not demangle symbol names.
|
|
|
|
.It Fl -no-dynamic-linker
|
|
|
|
Inhibit output of an
|
|
|
|
.Li .interp
|
|
|
|
section.
|
|
|
|
.It Fl -no-gc-sections
|
|
|
|
Disable garbage collection of unused sections.
|
|
|
|
.It Fl -no-gnu-unique
|
|
|
|
Disable STB_GNU_UNIQUE symbol binding.
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Fl -no-merge-exidx-entries
|
|
|
|
Disable merging .ARM.exidx entries.
|
2019-05-22 10:15:25 +08:00
|
|
|
.It Fl -no-nmagic
|
2019-05-14 00:01:26 +08:00
|
|
|
Page align sections.
|
2019-05-22 10:15:25 +08:00
|
|
|
.It Fl -no-omagic
|
2019-05-14 00:01:26 +08:00
|
|
|
Do not set the text data sections to be writable, page align sections.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -no-rosegment
|
|
|
|
Do not put read-only non-executable sections in their own segment.
|
|
|
|
.It Fl -no-undefined-version
|
|
|
|
Report version scripts that refer undefined symbols.
|
|
|
|
.It Fl -no-undefined
|
|
|
|
Report unresolved symbols even if the linker is creating a shared library.
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Fl -no-warn-symbol-ordering
|
|
|
|
Do not warn about problems with the symbol ordering file or call graph profile.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -no-whole-archive
|
|
|
|
Restores the default behavior of loading archive members.
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Fl -no-pie , Fl -no-pic-executable
|
2018-02-08 04:38:18 +08:00
|
|
|
Do not create a position independent executable.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl -noinhibit-exec
|
|
|
|
Retain the executable output file whenever it is still usable.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -nostdlib
|
|
|
|
Only search directories specified on the command line.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl o Ar path
|
|
|
|
Write the output executable, library, or object to
|
|
|
|
.Ar path .
|
|
|
|
If not specified,
|
|
|
|
.Dv a.out
|
|
|
|
is used as a default.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl O Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Optimize output file size.
|
|
|
|
.Ar value
|
|
|
|
may be:
|
2018-03-02 00:02:19 +08:00
|
|
|
.Pp
|
|
|
|
.Bl -tag -width 2n -compact
|
|
|
|
.It Cm 0
|
2018-02-08 04:38:18 +08:00
|
|
|
Disable string merging.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Cm 1
|
2018-02-08 04:38:18 +08:00
|
|
|
Enable string merging.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Cm 2
|
2019-12-12 11:09:45 +08:00
|
|
|
Enable string tail merging. If
|
|
|
|
.Fl -compress-debug-sections
|
|
|
|
is given, compress debug sections at compression level 6 instead of 1.
|
2018-02-08 04:38:18 +08:00
|
|
|
.El
|
2018-03-02 00:02:19 +08:00
|
|
|
.Pp
|
|
|
|
.Fl O Ns Cm 1
|
2018-02-08 04:38:18 +08:00
|
|
|
is the default.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl -oformat Ns = Ns Ar format
|
|
|
|
Specify the format for the output object file.
|
|
|
|
The only supported
|
|
|
|
.Ar format
|
|
|
|
is
|
|
|
|
.Cm binary ,
|
|
|
|
which produces output with no ELF header.
|
|
|
|
.It Fl -omagic , Fl N
|
2019-09-04 01:58:24 +08:00
|
|
|
Set the text and data sections to be readable and writable, do not page align
|
|
|
|
sections, link against static libraries.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl -opt-remarks-filename Ar file
|
|
|
|
Write optimization remarks in YAML format to
|
|
|
|
.Ar file .
|
2019-03-13 05:22:27 +08:00
|
|
|
.It Fl -opt-remarks-passes Ar pass-regex
|
|
|
|
Filter optimization remarks by only allowing the passes matching
|
|
|
|
.Ar pass-regex .
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl -opt-remarks-with-hotness
|
|
|
|
Include hotness information in the optimization remarks file.
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Fl -orphan-handling Ns = Ns Ar mode
|
2019-09-04 01:58:24 +08:00
|
|
|
Control how orphan sections are handled.
|
|
|
|
An orphan section is one not specifically mentioned in a linker script.
|
2019-03-01 12:49:42 +08:00
|
|
|
.Ar mode
|
|
|
|
may be:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width 2n -compact
|
|
|
|
.It Cm place
|
|
|
|
Place orphan sections in suitable output sections.
|
|
|
|
.It Cm warn
|
|
|
|
Place orphan sections as for
|
|
|
|
.Cm place
|
|
|
|
and also report a warning.
|
|
|
|
.It Cm error
|
|
|
|
Place orphan sections as for
|
|
|
|
.Cm place
|
|
|
|
and also report an error.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.Cm place
|
|
|
|
is the default.
|
|
|
|
.It Fl -pack-dyn-relocs Ns = Ns Ar format
|
|
|
|
Pack dynamic relocations in the given format.
|
|
|
|
.Ar format
|
|
|
|
may be:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width 2n -compact
|
|
|
|
.It Cm none
|
2019-09-04 01:58:24 +08:00
|
|
|
Do not pack.
|
|
|
|
Dynamic relocations are encoded in SHT_REL(A).
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Cm android
|
|
|
|
Pack dynamic relocations in SHT_ANDROID_REL(A).
|
|
|
|
.It Cm relr
|
2019-09-04 01:58:24 +08:00
|
|
|
Pack relative relocations in SHT_RELR, and the rest of dynamic relocations in
|
|
|
|
SHT_REL(A).
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Cm android+relr
|
2019-09-04 01:58:24 +08:00
|
|
|
Pack relative relocations in SHT_RELR, and the rest of dynamic relocations in
|
|
|
|
SHT_ANDROID_REL(A).
|
2019-03-01 12:49:42 +08:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.Cm none
|
2019-09-04 01:58:24 +08:00
|
|
|
is the default.
|
|
|
|
If
|
2019-03-01 12:49:42 +08:00
|
|
|
.Fl -use-android-relr-tags
|
|
|
|
is specified, use SHT_ANDROID_RELR instead of SHT_RELR.
|
|
|
|
.Pp
|
2019-01-16 20:09:13 +08:00
|
|
|
.It Fl -pic-veneer
|
|
|
|
Always generate position independent thunks.
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Fl -pie , Fl -pic-executable
|
2018-02-08 04:38:18 +08:00
|
|
|
Create a position independent executable.
|
|
|
|
.It Fl -print-gc-sections
|
|
|
|
List removed unused sections.
|
2018-08-21 15:35:23 +08:00
|
|
|
.It Fl -print-icf-sections
|
|
|
|
List identical folded sections.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -print-map
|
|
|
|
Print a link map to the standard output.
|
2020-04-28 10:30:09 +08:00
|
|
|
.It Fl -print-archive-stats Ns = Ns Ar file
|
|
|
|
Write archive usage statistics to the specified file.
|
|
|
|
Print the numbers of members and fetched members for each archive.
|
2018-05-31 21:00:25 +08:00
|
|
|
.It Fl -push-state
|
|
|
|
Save the current state of
|
|
|
|
.Fl -as-needed ,
|
|
|
|
.Fl -static ,
|
|
|
|
and
|
2018-10-01 17:57:20 +08:00
|
|
|
.Fl -whole-archive.
|
2018-05-31 21:00:25 +08:00
|
|
|
.It Fl -pop-state
|
|
|
|
Undo the effect of
|
|
|
|
.Fl -push-state.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -relocatable , Fl r
|
2018-02-08 04:38:18 +08:00
|
|
|
Create relocatable object file.
|
2019-08-23 16:52:55 +08:00
|
|
|
.It Fl -reproduce Ns = Ns Ar path
|
2019-08-23 22:41:25 +08:00
|
|
|
Write a tar file to
|
2019-08-23 16:52:55 +08:00
|
|
|
.Ar path,
|
2019-08-23 22:41:25 +08:00
|
|
|
containing all the input files needed to reproduce the link, a text file called
|
|
|
|
response.txt containing the command line options and a text file called
|
2019-09-04 01:58:24 +08:00
|
|
|
version.txt containing the output of ld.lld --version.
|
|
|
|
The archive when
|
2019-08-23 22:41:25 +08:00
|
|
|
unpacked can be used to re-run the linker with the same options and input files.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -retain-symbols-file Ns = Ns Ar file
|
2018-02-08 04:38:18 +08:00
|
|
|
Retain only the symbols listed in the file.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -rpath Ns = Ns Ar value , Fl R Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Add a
|
|
|
|
.Dv DT_RUNPATH
|
|
|
|
to the output.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -rsp-quoting Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Quoting style for response files.
|
|
|
|
The supported values are
|
2018-03-02 00:02:19 +08:00
|
|
|
.Cm windows
|
2018-02-08 04:38:18 +08:00
|
|
|
and
|
2018-03-02 00:02:19 +08:00
|
|
|
.Cm posix .
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -script Ns = Ns Ar file , Fl T Ar file
|
2018-02-08 04:38:18 +08:00
|
|
|
Read linker script from
|
|
|
|
.Ar file .
|
2019-08-23 15:50:09 +08:00
|
|
|
If multiple linker scripts are given, they are processed as if they
|
|
|
|
were concatenated in the order they appeared on the command line.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -section-start Ns = Ns Ar section Ns = Ns Ar address
|
2018-02-08 04:38:18 +08:00
|
|
|
Set address of section.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -shared , Fl -Bsharable
|
2018-02-08 04:38:18 +08:00
|
|
|
Build a shared object.
|
2020-02-20 05:19:58 +08:00
|
|
|
.It Fl -shuffle-sections Ns = Ns Ar seed
|
|
|
|
Shuffle input sections using the given seed. If 0, use a random seed.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -soname Ns = Ns Ar value , Fl h Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Set
|
|
|
|
.Dv DT_SONAME
|
|
|
|
to
|
|
|
|
.Ar value .
|
2019-06-03 13:11:44 +08:00
|
|
|
.It Fl -sort-common
|
|
|
|
This option is ignored for GNU compatibility.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -sort-section Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Specifies sections sorting rule when linkerscript is used.
|
|
|
|
.It Fl -start-lib
|
|
|
|
Start a grouping of objects that should be treated as if they were together
|
|
|
|
in an archive.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -strip-all , Fl s
|
2018-02-08 04:38:18 +08:00
|
|
|
Strip all symbols.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -strip-debug , Fl S
|
2018-02-08 04:38:18 +08:00
|
|
|
Strip debugging information.
|
2018-03-02 10:57:12 +08:00
|
|
|
.It Fl -symbol-ordering-file Ns = Ns Ar file
|
2018-02-08 04:38:18 +08:00
|
|
|
Lay out sections in the order specified by
|
|
|
|
.Ar file .
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -sysroot Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Set the system root.
|
|
|
|
.It Fl -target1-abs
|
|
|
|
Interpret
|
|
|
|
.Dv R_ARM_TARGET1
|
|
|
|
as
|
|
|
|
.Dv R_ARM_ABS32 .
|
|
|
|
.It Fl -target1-rel
|
|
|
|
Interpret
|
|
|
|
.Dv R_ARM_TARGET1
|
|
|
|
as
|
|
|
|
.Dv R_ARM_REL32 .
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -target2 Ns = Ns Ar type
|
2018-02-08 04:38:18 +08:00
|
|
|
Interpret
|
|
|
|
.Dv R_ARM_TARGET2
|
|
|
|
as
|
|
|
|
.Ar type ,
|
|
|
|
where
|
|
|
|
.Ar type
|
|
|
|
is one of
|
2018-03-02 00:02:19 +08:00
|
|
|
.Cm rel ,
|
|
|
|
.Cm abs ,
|
2018-02-08 04:38:18 +08:00
|
|
|
or
|
2018-03-02 00:02:19 +08:00
|
|
|
.Cm got-rel .
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -Tbss Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Same as
|
|
|
|
.Fl -section-start
|
|
|
|
with
|
|
|
|
.Li .bss
|
|
|
|
as the sectionname.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -Tdata Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Same as
|
|
|
|
.Fl -section-start
|
|
|
|
with
|
|
|
|
.Li .data
|
|
|
|
as the sectionname.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl -Ttext Ns = Ns Ar value
|
|
|
|
Same as
|
|
|
|
.Fl -section-start
|
|
|
|
with
|
|
|
|
.Li .text
|
|
|
|
as the sectionname.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -thinlto-cache-dir Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Path to ThinLTO cached object file directory.
|
2018-03-02 10:57:12 +08:00
|
|
|
.It Fl -thinlto-cache-policy Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Pruning policy for the ThinLTO cache.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -thinlto-jobs Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Number of ThinLTO jobs.
|
[lld][COFF][ELF][WebAssembly] Replace --[no-]threads /threads[:no] with --threads={1,2,...} /threads:{1,2,...}
--no-threads is a name copied from gold.
gold has --no-thread, --thread-count and several other --thread-count-*.
There are needs to customize the number of threads (running several lld
processes concurrently or customizing the number of LTO threads).
Having a single --threads=N is a straightforward replacement of gold's
--no-threads + --thread-count.
--no-threads is used rarely. So just delete --no-threads instead of
keeping it for compatibility for a while.
If --threads= is specified (ELF,wasm; COFF /threads: is similar),
--thinlto-jobs= defaults to --threads=,
otherwise all available hardware threads are used.
There is currently no way to override a --threads={1,2,...}. It is still
a debate whether we should use --threads=all.
Reviewed By: rnk, aganea
Differential Revision: https://reviews.llvm.org/D76885
2020-03-18 03:40:19 +08:00
|
|
|
.It Fl -threads Ns = Ns Ar N
|
|
|
|
Number of threads.
|
|
|
|
.Cm all
|
|
|
|
(default) means all of concurrent threads supported.
|
|
|
|
.Cm 1
|
|
|
|
disables multi-threading.
|
2020-05-12 18:54:18 +08:00
|
|
|
.It Fl -time-trace
|
|
|
|
Record time trace.
|
|
|
|
.It Fl -time-trace-file Ns = Ns Ar file
|
|
|
|
Write time trace output to
|
|
|
|
.Ar file .
|
|
|
|
.It Fl -time-trace-granularity Ns = Ns Ar value
|
|
|
|
Minimum time granularity (in microseconds) traced by time profiler.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl -trace
|
|
|
|
Print the names of the input files.
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -trace-symbol Ns = Ns Ar symbol , Fl y Ar symbol
|
2018-02-08 04:38:18 +08:00
|
|
|
Trace references to
|
|
|
|
.Ar symbol .
|
2018-07-31 06:31:00 +08:00
|
|
|
.It Fl -undefined Ns = Ns Ar symbol , Fl u Ar symbol
|
2019-06-14 22:00:59 +08:00
|
|
|
If
|
2018-02-08 04:38:18 +08:00
|
|
|
.Ar symbol
|
2019-06-14 22:00:59 +08:00
|
|
|
is not defined after symbol resolution, and there's a static library
|
|
|
|
that contains an object file defining the symbol, load the member
|
|
|
|
to include the object file in the output file.
|
|
|
|
.It Fl -undefined-glob Ns = Ns Ar pattern
|
|
|
|
Synonym for
|
|
|
|
.Fl -undefined ,
|
2019-09-04 01:58:24 +08:00
|
|
|
except that it takes a glob pattern.
|
|
|
|
In a glob pattern,
|
2019-06-14 22:00:59 +08:00
|
|
|
.Cm *
|
|
|
|
matches zero or more characters,
|
|
|
|
.Cm ?
|
|
|
|
matches any single character, and
|
|
|
|
.Cm [...]
|
2019-09-04 01:58:24 +08:00
|
|
|
matches the characters within brackets.
|
|
|
|
All symbols that match
|
2019-06-14 22:00:59 +08:00
|
|
|
a given pattern are handled as if they were given as arguments of
|
|
|
|
.Fl -undefined .
|
[LLD] Add support for --unique option
Summary:
Places orphan sections into a unique output section. This prevents the merging of orphan sections of the same name.
Matches behaviour of GNU ld --unique. --unique=pattern is not implemented.
Motivated user case shown in the test has 2 local symbols as they would appear if C++ source has been compiled with -ffunction-sections. The merging of these sections in the case of a partial link (-r) may limit the effectiveness of -gc-sections of a subsequent link.
Reviewers: espindola, jhenderson, bd1976llvm, edd, andrewng, JonChesterfield, MaskRay, grimar, ruiu, psmith
Reviewed By: MaskRay, grimar
Subscribers: emaste, arichardson, MaskRay, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D75536
2020-03-09 23:43:20 +08:00
|
|
|
.It Fl -unique
|
|
|
|
Creates a separate output section for every orphan input section.
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Fl -unresolved-symbols Ns = Ns Ar value
|
2018-02-08 04:38:18 +08:00
|
|
|
Determine how to handle unresolved symbols.
|
2019-03-01 12:49:42 +08:00
|
|
|
.It Fl -use-android-relr-tags
|
|
|
|
Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*.
|
2018-07-31 07:07:44 +08:00
|
|
|
.It Fl v
|
|
|
|
Display the version number and proceed with linking if object files are
|
|
|
|
specified.
|
|
|
|
.It Fl V , Fl -version
|
|
|
|
Display the version number and exit.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -verbose
|
|
|
|
Verbose mode.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -version-script Ns = Ns Ar file
|
2018-02-08 04:38:18 +08:00
|
|
|
Read version script from
|
|
|
|
.Ar file .
|
2018-04-29 10:18:48 +08:00
|
|
|
.It Fl -warn-backrefs
|
|
|
|
Warn about reverse or cyclic dependencies to or between static archives.
|
|
|
|
This can be used to ensure linker invocation remains compatible with
|
|
|
|
traditional Unix-like linkers.
|
[ELF] Add --warn-backrefs-exclude=<glob>
D77522 changed --warn-backrefs to not warn for linking sandwich
problems (-ldef1 -lref -ldef2). This removed lots of false positives.
However, glibc still has some problems. libc.a defines some symbols
which are normally in libm.a and libpthread.a, e.g. __isnanl/raise.
For a linking order `-lm -lpthread -lc`, I have seen:
```
// different resolutions: GNU ld/gold select libc.a(s_isnan.o) as the definition
backward reference detected: __isnanl in libc.a(printf_fp.o) refers to libm.a(m_isnanl.o)
// different resolutions: GNU ld/gold select libc.a(raise.o) as the definition
backward reference detected: raise in libc.a(abort.o) refers to libpthread.a(pt-raise.o)
```
To facilitate deployment of --warn-backrefs, add --warn-backrefs-exclude= so that
certain known issues (which may be impractical to fix) can be whitelisted.
Deliberate choices:
* Not a comma-separated list (`--warn-backrefs-exclude=liba.a,libb.a`).
-Wl, splits the argument at commas, so we cannot use commas.
--export-dynamic-symbol is similar.
* Not in the style of `--warn-backrefs='*' --warn-backrefs=-liba.a`.
We just need exclusion, not inclusion. For easier build system
integration, we should avoid order dependency. With the current
scheme, we enable --warn-backrefs, and indivial libraries can add
--warn-backrefs-exclude=<glob> to their LDFLAGS.
Reviewed By: psmith
Differential Revision: https://reviews.llvm.org/D77512
2020-04-05 12:31:36 +08:00
|
|
|
.It Fl -warn-backrefs-exclude Ns = Ns Ar glob
|
|
|
|
Glob describing an archive (or an object file within --start-lib)
|
|
|
|
which should be ignored for
|
|
|
|
.Fl -warn-backrefs
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -warn-common
|
|
|
|
Warn about duplicate common symbols.
|
Introduce a flag to warn when ifunc symbols are used with text relocations.
Summary:
This patch adds a new flag, --warn-ifunc-textrel, to work around a glibc bug. When a code with ifunc symbols is used to produce an object file with text relocations, lld always succeeds. However, if that object file is linked using an old version of glibc, the resultant binary just crashes with segmentation fault when it is run (The bug is going to be corrected as of glibc 2.19).
Since there is no way to tell beforehand what library the object file will be linked against in the future, there does not seem to be a fool-proof way for lld to give an error only in cases where the binary will crash. So, with this change (dated 2018-09-25), lld starts to give a warning, contingent on a new command line flag that does not have a gnu counter part. The default value for --warn-ifunc-textrel is false, so lld behaviour will not change unless the user explicitly asks lld to give a warning. Users that link with a glibc library with version 2.19 or newer, or does not use ifunc symbols, or does not generate object files with text relocations do not need to take any action. Other users may consider to start passing warn-ifunc-textrel to lld to get early warnings.
Reviewers: ruiu, espindola
Reviewed By: ruiu
Subscribers: grimar, MaskRay, markj, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D52430
llvm-svn: 343628
2018-10-03 04:30:22 +08:00
|
|
|
.It Fl -warn-ifunc-textrel
|
|
|
|
Warn about using ifunc symbols in conjunction with text relocations.
|
|
|
|
Older versions of glibc library (2.28 and earlier) has a bug that causes
|
|
|
|
the segment that includes ifunc symbols to be marked as not executable when
|
2019-09-04 01:58:24 +08:00
|
|
|
they are relocated.
|
|
|
|
As a result, although the program compiles and links
|
Introduce a flag to warn when ifunc symbols are used with text relocations.
Summary:
This patch adds a new flag, --warn-ifunc-textrel, to work around a glibc bug. When a code with ifunc symbols is used to produce an object file with text relocations, lld always succeeds. However, if that object file is linked using an old version of glibc, the resultant binary just crashes with segmentation fault when it is run (The bug is going to be corrected as of glibc 2.19).
Since there is no way to tell beforehand what library the object file will be linked against in the future, there does not seem to be a fool-proof way for lld to give an error only in cases where the binary will crash. So, with this change (dated 2018-09-25), lld starts to give a warning, contingent on a new command line flag that does not have a gnu counter part. The default value for --warn-ifunc-textrel is false, so lld behaviour will not change unless the user explicitly asks lld to give a warning. Users that link with a glibc library with version 2.19 or newer, or does not use ifunc symbols, or does not generate object files with text relocations do not need to take any action. Other users may consider to start passing warn-ifunc-textrel to lld to get early warnings.
Reviewers: ruiu, espindola
Reviewed By: ruiu
Subscribers: grimar, MaskRay, markj, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D52430
llvm-svn: 343628
2018-10-03 04:30:22 +08:00
|
|
|
successfully, it gives segmentation fault when the instruction pointer reaches
|
2019-09-04 01:58:24 +08:00
|
|
|
an ifunc symbol.
|
|
|
|
Use -warn-ifunc-textrel to let lld give a warning, if the
|
Introduce a flag to warn when ifunc symbols are used with text relocations.
Summary:
This patch adds a new flag, --warn-ifunc-textrel, to work around a glibc bug. When a code with ifunc symbols is used to produce an object file with text relocations, lld always succeeds. However, if that object file is linked using an old version of glibc, the resultant binary just crashes with segmentation fault when it is run (The bug is going to be corrected as of glibc 2.19).
Since there is no way to tell beforehand what library the object file will be linked against in the future, there does not seem to be a fool-proof way for lld to give an error only in cases where the binary will crash. So, with this change (dated 2018-09-25), lld starts to give a warning, contingent on a new command line flag that does not have a gnu counter part. The default value for --warn-ifunc-textrel is false, so lld behaviour will not change unless the user explicitly asks lld to give a warning. Users that link with a glibc library with version 2.19 or newer, or does not use ifunc symbols, or does not generate object files with text relocations do not need to take any action. Other users may consider to start passing warn-ifunc-textrel to lld to get early warnings.
Reviewers: ruiu, espindola
Reviewed By: ruiu
Subscribers: grimar, MaskRay, markj, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D52430
llvm-svn: 343628
2018-10-03 04:30:22 +08:00
|
|
|
code may include ifunc symbols, may do text relocations and be linked with
|
2019-09-04 01:58:24 +08:00
|
|
|
an older glibc version.
|
|
|
|
Otherwise, there is no need to use it, as the default value does not give a
|
|
|
|
warning.
|
|
|
|
This flag has been introduced in late 2018, has no counter part in ld and gold
|
|
|
|
linkers, and may be removed in the future.
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Fl -warn-unresolved-symbols
|
|
|
|
Report unresolved symbols as warnings.
|
|
|
|
.It Fl -whole-archive
|
|
|
|
Force load of all members in a static library.
|
2018-03-02 02:40:11 +08:00
|
|
|
.It Fl -wrap Ns = Ns Ar symbol
|
2018-02-08 04:38:18 +08:00
|
|
|
Use wrapper functions for symbol.
|
|
|
|
.It Fl z Ar option
|
|
|
|
Linker option extensions.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Bl -tag -width indent -compact
|
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm execstack
|
|
|
|
Make the main stack executable.
|
|
|
|
Stack permissions are recorded in the
|
|
|
|
.Dv PT_GNU_STACK
|
|
|
|
segment.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2019-12-11 14:07:17 +08:00
|
|
|
.It Cm force-bti
|
|
|
|
Force enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
|
|
|
|
.Pp
|
2019-12-11 10:05:36 +08:00
|
|
|
.It Cm force-ibt
|
|
|
|
Force enable Intel Indirect Branch Tracking in PLT, warn if an input ELF file
|
|
|
|
does not have GNU_PROPERTY_X86_FEATURE_1_IBT property.
|
|
|
|
.Pp
|
2018-09-25 17:32:31 +08:00
|
|
|
.It Cm global
|
|
|
|
Sets the
|
|
|
|
.Dv DF_1_GLOBAL flag in the
|
|
|
|
.Dv DYNAMIC
|
|
|
|
section.
|
|
|
|
Different loaders can decide how to handle this flag on their own.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2019-05-14 23:25:21 +08:00
|
|
|
.It Cm ifunc-noplt
|
|
|
|
Do not emit PLT entries for ifunc symbols.
|
|
|
|
Instead, emit text relocations referencing the resolver.
|
|
|
|
This is an experimental optimization and only suitable for standalone
|
|
|
|
environments where text relocations do not have the usual drawbacks.
|
|
|
|
This option must be combined with the
|
|
|
|
.Fl z Li notext
|
|
|
|
option.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-07-31 01:36:38 +08:00
|
|
|
.It Cm initfirst
|
|
|
|
Sets the
|
|
|
|
.Dv DF_1_INITFIRST
|
|
|
|
flag to indicate the module should be initialized first.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-09-14 22:25:37 +08:00
|
|
|
.It Cm interpose
|
|
|
|
Set the
|
|
|
|
.Dv DF_1_INTERPOSE
|
|
|
|
flag to indicate to the runtime linker that the object is an interposer.
|
|
|
|
During symbol resolution interposers are searched after the application
|
|
|
|
but before other dependencies.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm muldefs
|
|
|
|
Do not error if a symbol is defined multiple times.
|
|
|
|
The first definition will be used.
|
|
|
|
This is a synonym for
|
|
|
|
.Fl -allow-multiple-definition.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm nocombreloc
|
|
|
|
Disable combining and sorting multiple relocation sections.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm nocopyreloc
|
|
|
|
Disable the creation of copy relocations.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-11-27 17:48:17 +08:00
|
|
|
.It Cm nodefaultlib
|
|
|
|
Set the
|
|
|
|
.Dv DF_1_NODEFLIB
|
|
|
|
flag to indicate that default library search paths should be ignored.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm nodelete
|
|
|
|
Set the
|
|
|
|
.Dv DF_1_NODELETE
|
|
|
|
flag to indicate that the object cannot be unloaded from a process.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm nodlopen
|
|
|
|
Set the
|
|
|
|
.Dv DF_1_NOOPEN
|
2018-11-23 15:59:28 +08:00
|
|
|
flag to indicate that the object may not be opened by
|
2018-02-08 04:38:18 +08:00
|
|
|
.Xr dlopen 3 .
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2019-10-22 01:27:51 +08:00
|
|
|
.It Cm nognustack
|
|
|
|
Do not emit the
|
|
|
|
.Dv PT_GNU_STACK
|
|
|
|
segment.
|
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm norelro
|
2020-01-10 12:09:48 +08:00
|
|
|
Do not indicate that portions of the object should be mapped read-only
|
2018-02-08 04:38:18 +08:00
|
|
|
after initial relocation processing.
|
|
|
|
The object will omit the
|
|
|
|
.Dv PT_GNU_RELRO
|
|
|
|
segment.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm notext
|
|
|
|
Allow relocations against read-only segments.
|
|
|
|
Sets the
|
|
|
|
.Dv DT_TEXTREL flag in the
|
|
|
|
.Dv DYNAMIC
|
|
|
|
section.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm now
|
|
|
|
Set the
|
|
|
|
.Dv DF_BIND_NOW
|
|
|
|
flag to indicate that the run-time loader should perform all relocation
|
|
|
|
processing as part of object initialization.
|
|
|
|
By default relocations may be performed on demand.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm origin
|
|
|
|
Set the
|
|
|
|
.Dv DF_ORIGIN
|
|
|
|
flag to indicate that the object requires
|
|
|
|
$ORIGIN
|
|
|
|
processing.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2019-12-11 14:07:17 +08:00
|
|
|
.It Cm pac-plt
|
|
|
|
AArch64 only, use pointer authentication in PLT.
|
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm retpolineplt
|
|
|
|
Emit retpoline format PLT entries as a mitigation for CVE-2017-5715.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm rodynamic
|
|
|
|
Make the
|
|
|
|
.Li .dynamic
|
|
|
|
section read-only.
|
|
|
|
The
|
|
|
|
.Dv DT_DEBUG
|
|
|
|
tag will not be emitted.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
|
|
|
.It Cm separate-loadable-segments
|
|
|
|
.It Cm separate-code
|
|
|
|
.It Cm noseparate-code
|
|
|
|
Specify whether two adjacent PT_LOAD segments are allowed to overlap in pages.
|
|
|
|
.Cm noseparate-code
|
|
|
|
(default) allows overlap.
|
|
|
|
.Cm separate-code
|
|
|
|
allows overlap between two executable segments, or two non-executable segments.
|
|
|
|
.Cm separate-loadable-segments
|
|
|
|
disallows overlap.
|
|
|
|
.Pp
|
2019-12-11 10:05:36 +08:00
|
|
|
.It Cm shstk
|
|
|
|
x86 only, use shadow stack.
|
|
|
|
.Pp
|
2018-03-02 00:02:19 +08:00
|
|
|
.It Cm stack-size Ns = Ns Ar size
|
2018-02-08 04:38:18 +08:00
|
|
|
Set the main thread's stack size to
|
|
|
|
.Ar size .
|
|
|
|
The stack size is recorded as the size of the
|
|
|
|
.Ar size .
|
|
|
|
.Dv PT_GNU_STACK
|
|
|
|
program segment.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm text
|
|
|
|
Do not allow relocations against read-only segments.
|
|
|
|
This is the default.
|
2019-09-25 11:39:31 +08:00
|
|
|
.Pp
|
2018-02-08 04:38:18 +08:00
|
|
|
.It Cm wxneeded
|
|
|
|
Create a
|
|
|
|
.Dv PT_OPENBSD_WXNEEDED
|
|
|
|
segment.
|
|
|
|
.El
|
|
|
|
.El
|
2018-02-09 23:36:13 +08:00
|
|
|
.Sh IMPLEMENTATION NOTES
|
|
|
|
.Nm Ap s
|
|
|
|
handing of archive files (those with a
|
2018-03-02 00:02:19 +08:00
|
|
|
.Pa .a
|
2018-02-09 23:36:13 +08:00
|
|
|
file extension) is different from traditional linkers used on Unix-like
|
|
|
|
systems.
|
|
|
|
.Pp
|
|
|
|
Traditional linkers maintain a set of undefined symbols during linking.
|
|
|
|
The linker processes each file in the order in which it appears on the
|
|
|
|
command line, until the set of undefined symbols becomes empty.
|
|
|
|
An object file is linked into the output object when it is encountered,
|
|
|
|
with its undefined symbols added to the set.
|
|
|
|
Upon encountering an archive file a traditional linker searches the objects
|
|
|
|
contained therein, and processes those that satisfy symbols in the unresolved
|
|
|
|
set.
|
|
|
|
.Pp
|
|
|
|
Handling mutually dependent archives may be awkward when using a traditional
|
|
|
|
linker.
|
|
|
|
Archive files may have to be specified multiple times, or the special command
|
|
|
|
line options
|
|
|
|
.Fl -start-group
|
|
|
|
and
|
|
|
|
.Fl -end-group
|
|
|
|
may be used to have the linker loop over the files in the group until no new
|
|
|
|
symbols are added to the set.
|
|
|
|
.Pp
|
|
|
|
.Nm
|
|
|
|
records all symbols found in objects and archives as it iterates over
|
|
|
|
command line arguments.
|
|
|
|
When
|
|
|
|
.Nm
|
|
|
|
encounters an undefined symbol that can be resolved by an object file
|
|
|
|
contained in a previously processed archive file, it immediately extracts
|
|
|
|
and links it into the output object.
|
|
|
|
.Pp
|
|
|
|
With certain archive inputs
|
|
|
|
.Nm
|
|
|
|
may produce different results compared to traditional linkers.
|
|
|
|
In practice, large bodies of third party software have been linked with
|
|
|
|
.Nm
|
|
|
|
without material issues.
|
2018-04-29 10:18:48 +08:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fl -warn-backrefs
|
|
|
|
option may be used to identify a linker invocation that may be incompatible
|
|
|
|
with traditional Unix-like linker behavior.
|