Index: ELF/Options.td =================================================================== --- ELF/Options.td +++ ELF/Options.td @@ -58,8 +58,8 @@ "Do not allow multiple definitions (default)">; defm apply_dynamic_relocs: B<"apply-dynamic-relocs", - "Apply dynamic relocations to place", - "Do not apply dynamic relocations to place">; + "Apply link-time values for dynamic relocations", + "Do not apply link-time values for dynamic relocations (default)">; defm as_needed: B<"as-needed", "Only set DT_NEEDED for shared libraries if used", Index: docs/ld.lld.1 =================================================================== --- docs/ld.lld.1 +++ docs/ld.lld.1 @@ -26,27 +26,41 @@ as GNU linkers. .Pp These options are available: -.Bl -tag -width indent +.Bl -tag -width indent -compact +.Pp .It Fl -allow-multiple-definition Do not error if a symbol is defined multiple times. The first definition will be used. +.Pp +.It Fl -apply-dynamic-relocs +Apply link-time values for dynamic relocations. +.Pp .It Fl -as-needed Only set .Dv DT_NEEDED for shared libraries if used. -.It Fl -auxiliary Ns = Ns Ar value +.Pp +.It Fl -auxiliary Ar value Set the .Dv DT_AUXILIARY field to the specified name. +.Pp .It Fl -Bdynamic +.It Fl -dy Link against shared libraries. +.Pp .It Fl -Bstatic +.It Fl -static +.It Fl -dn Do not link against shared libraries. +.Pp .It Fl -Bsymbolic-functions Bind defined function symbols locally. +.Pp .It Fl -Bsymbolic Bind defined symbols locally. -.It Fl -build-id Ns = Ns Ar value +.Pp +.It Fl -build-id= Ns Ar value Generate a build ID note. .Ar value may be one of @@ -70,10 +84,12 @@ are calculated from the object contents. .Cm fast is not intended to be cryptographically secure. +.Pp .It Fl -build-id Synonym for -.Fl -build-id Ns = Ns Cm fast . -.It Fl -color-diagnostics Ns = Ns Ar value +.Fl -build-id= Ns Cm fast . +.Pp +.It Fl -color-diagnostics= Ns Ar value Use colors in diagnostics. .Ar value may be one of @@ -83,80 +99,112 @@ .Cm never . .Cm auto enables color if and only if output is to a terminal. +.Pp .It Fl -color-diagnostics Alias for -.Fl -color-diagnostics Ns = Ns Cm auto . -.It Fl -compress-debug-sections Ns = Ns Ar value +.Fl -color-diagnostics= Ns Cm auto . +.Pp +.It Fl -compress-debug-sections Ar value Compress DWARF debug sections. .Ar value may be .Cm none or .Cm zlib . +.Pp +.It Fl -cref +Output cross reference table. +.Pp .It Fl -define-common +.It Fl d Assign space to common symbols. -.It Fl -defsym Ns = Ns Ar symbol Ns = Ns Ar expression +.Pp +.It Fl -defsym Ar symbol= Ns Ar expression Define a symbol alias. .Ar expression may be another symbol or a linker script expression. For example, -.Ql --defsym=foo=bar +.Fl -defsym Cm foo= Ns Cm bar or -.Ql --defsym=foo=bar+0x100 . +.Fl -defsym Cm foo= Ns Cm bar+0x100 . +.Pp .It Fl -demangle Demangle symbol names. +.Pp .It Fl -disable-new-dtags Disable new dynamic tags. +.Pp .It Fl -discard-all +.It Fl x Delete all local symbols. +.Pp .It Fl -discard-locals +.It Fl X Delete temporary local symbols. +.Pp .It Fl -discard-none Keep all symbols in the symbol table. -.It Fl -dynamic-linker Ns = Ns Ar value +.Pp +.It Fl -dynamic-linker Ar value Specify the dynamic linker to be used for a dynamically linked executable. This is recorded in an ELF segment of type .Dv PT_INTERP . -.It Fl -dynamic-list Ns = Ns Ar file +.Pp +.It Fl -dynamic-list Ar file Read a list of dynamic symbols from .Ar file . +.Pp .It Fl -eh-frame-hdr Request creation of .Li .eh_frame_hdr section and .Dv PT_GNU_EH_FRAME segment header. +.Pp .It Fl -emit-relocs +.It Fl q Generate relocations in the output. -.It Fl -enable-new-dtags -Enable new dynamic tags. +.Pp .It Fl -end-lib End a grouping of objects that should be treated as if they were together in an archive. -.It Fl -entry Ns = Ns Ar entry +.Pp +.It Fl -entry Ar entry Name of entry point symbol. -.It Fl -error-limit Ns = Ns Ar value +.Pp +.It Fl -error-limit Ar value Maximum number of errors to emit before stopping. A value of zero indicates that there is no limit. +.Pp .It Fl -error-unresolved-symbols Report unresolved symbols as errors. -.It Fl -exclude-libs Ns = Ns Ar value +.Pp +.It Fl -exclude-libs Ar value Exclude static libraries from automatic export. -.It Fl -export-dynamic-symbol Ns = Ns Ar symbol +.Pp +.It Fl -export-dynamic-symbol Ar symbol Include .Ar symbol in the dynamic symbol table. +.Pp .It Fl -export-dynamic +.It Fl E Put symbols in the dynamic symbol table. +.Pp .It Fl -fatal-warnings Treat warnings as errors. -.It Fl -filter Ns = Ns Ar value +.Pp +.It Fl -filter Ar value +.It Fl F Ar value Set the .Dv DT_FILTER field to the specified value. -.It Fl -fini Ns = Ns Ar symbol +.Pp +.It Fl -fini Ar symbol Specify a finalizer function. -.It Fl -format Ns = Ns Ar input-format +.Pp +.It Fl -format Ar input-format +.It Fl b Ar input-format Specify the format of the inputs following this option. .Ar input-format may be one of @@ -167,13 +215,16 @@ .Cm default is a synonym for .Cm elf . +.Pp .It Fl -gc-sections Enable garbage collection of unused sections. +.Pp .It Fl -gdb-index Generate .Li .gdb_index section. -.It Fl -hash-style Ns = Ns Ar value +.Pp +.It Fl -hash-style Ar value Specify hash style. .Ar value may be @@ -183,86 +234,121 @@ .Cm both . .Cm both is the default. +.Pp .It Fl -help Print a help message. -.It Fl -icf Ns = Ns Cm all +.Pp +.It Fl -icf=all Enable identical code folding. -.It Fl -icf Ns = Ns Cm safe +.Pp +.It Fl -icf=safe Enable safe identical code folding. -.It Fl -icf Ns = Ns Cm none +.Pp +.It Fl -icf=none Disable identical code folding. -.It Fl -image-base Ns = Ns Ar value +.Pp +.It Fl -image-base Ar value Set the base address to .Ar value . -.It Fl -init Ns = Ns Ar symbol +.Pp +.It Fl -init Ar symbol Specify an initializer function. +.Pp +.It Fl -keep-unique Ar symbol +Do not fold this symbol during ICF. +.Pp +.It Fl L Ar dir +.It Fl -library-path dir +Add a directory to the library search path. +.Pp +.It Fl l Ar libName +.It Fl -library Ar libName +Root name of library to use. +.Pp .It Fl -lto-aa-pipeline Ns = Ns Ar value AA pipeline to run during LTO. Used in conjunction with .Fl -lto-newpm-passes . -.It Fl -lto-newpm-passes Ns = Ns Ar value +.Pp +.It Fl -lto-newpm-passes= Ns Ar value Passes to run during LTO. +.Pp .It Fl -lto-O Ns Ar opt-level Optimization level for LTO. -.It Fl -lto-partitions Ns = Ns Ar value +.Pp +.It Fl -lto-partitions= Ns Ar value Number of LTO codegen partitions. -.It Fl L Ar dir -Add a directory to the library search path. -.It Fl l Ar libName -Root name of library to use. -.It Fl -Map Ns = Ns Ar file +.Pp +.It Fl -Map Ar file +.It Fl M Ar file Print a link map to .Ar file . +.Pp .It Fl m Ar value Set target emulation. +.Pp .It Fl -no-as-needed Always set .Dv DT_NEEDED for shared libraries. +.Pp .It Fl -no-color-diagnostics Do not use colors in diagnostics. +.Pp .It Fl -no-define-common Do not assign space to common symbols. +.Pp .It Fl -no-demangle Do not demangle symbol names. +.Pp .It Fl -no-dynamic-linker Inhibit output of an .Li .interp section. -.It Fl -no-gc-sections -Disable garbage collection of unused sections. +.Pp .It Fl -no-gnu-unique Disable STB_GNU_UNIQUE symbol binding. +.Pp .It Fl -no-rosegment Do not put read-only non-executable sections in their own segment. +.Pp .It Fl -no-threads Do not run the linker multi-threaded. +.Pp .It Fl -no-undefined-version Report version scripts that refer undefined symbols. +.Pp .It Fl -no-undefined Report unresolved symbols even if the linker is creating a shared library. +.Pp .It Fl -no-whole-archive Restores the default behavior of loading archive members. +.Pp .It Fl -noinhibit-exec Retain the executable output file whenever it is still usable. -.It Fl -no-pie -Do not create a position independent executable. +.Pp .It Fl -nostdlib Only search directories specified on the command line. -.It Fl -oformat Ns = Ns Ar format +.Pp +.It Fl -oformat 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. +.Pp .It Fl -omagic +.It Fl N Set the text and data sections to be readable and writable. +.Pp .It Fl -opt-remarks-filename Ar file Write optimization remarks in YAML format to .Ar file . +.Pp .It Fl -opt-remarks-with-hotness Include hotness information in the optimization remarks file. +.Pp .It Fl O Ns Ar value Optimize output file size. .Ar value @@ -279,80 +365,111 @@ .Pp .Fl O Ns Cm 1 is the default. +.Pp .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. +.Pp .It Fl -pie Create a position independent executable. +.Pp .It Fl -print-gc-sections List removed unused sections. +.Pp .It Fl -print-map Print a link map to the standard output. +.Pp .It Fl -push-state Save the current state of .Fl -as-needed , .Fl -static , and .Fl -while-archive. +.Pp .It Fl -pop-state Undo the effect of .Fl -push-state. +.Pp .It Fl -relocatable +.It Fl r Create relocatable object file. -.It Fl -reproduce Ns = Ns Ar value +.Pp +.It Fl -reproduce Ar value Dump linker invocation and input files for debugging. -.It Fl -retain-symbols-file Ns = Ns Ar file +.Pp +.It Fl -retain-symbols-file Ar file Retain only the symbols listed in the file. -.It Fl -rpath Ns = Ns Ar value +.Pp +.It Fl -rpath Ar value +.It Fl R Ar value Add a .Dv DT_RUNPATH to the output. -.It Fl -rsp-quoting Ns = Ns Ar value +.Pp +.It Fl -rsp-quoting Ar value Quoting style for response files. The supported values are .Cm windows and .Cm posix . -.It Fl -script Ns = Ns Ar file +.Pp +.It Fl -script Ar file +.It Fl T Ar file Read linker script from .Ar file . -.It Fl -section-start Ns = Ar section Ns = Ns Ar address +.Pp +.It Fl -section-start Ar section Ar address Set address of section. +.Pp .It Fl -shared +.It Fl -Bsharable Build a shared object. -.It Fl -soname Ns = Ns Ar value +.Pp +.It Fl -soname Ar value +.It Fl h Ar value Set .Dv DT_SONAME to .Ar value . -.It Fl -sort-section Ns = Ns Ar value +.Pp +.It Fl -sort-section Ar value Specifies sections sorting rule when linkerscript is used. +.Pp .It Fl -start-lib Start a grouping of objects that should be treated as if they were together in an archive. +.Pp .It Fl -strip-all +.It Fl s Strip all symbols. +.Pp .It Fl -strip-debug +.It Fl S Strip debugging information. -.It Fl -symbol-ordering-file Ns = Ns Ar file +.Pp +.It Fl -symbol-ordering-file Ar file Lay out sections in the order specified by .Ar file . -.It Fl -sysroot Ns = Ns Ar value +.Pp +.It Fl -sysroot Ar value Set the system root. +.Pp .It Fl -target1-abs Interpret .Dv R_ARM_TARGET1 as .Dv R_ARM_ABS32 . +.Pp .It Fl -target1-rel Interpret .Dv R_ARM_TARGET1 as .Dv R_ARM_REL32 . -.It Fl -target2 Ns = Ns Ar type +.Pp +.It Fl -target2 Ar type Interpret .Dv R_ARM_TARGET2 as @@ -364,118 +481,159 @@ .Cm abs , or .Cm got-rel . -.It Fl -Tbss Ns = Ns Ar value +.Pp +.It Fl -Tbss Ar value Same as .Fl -section-start with .Li .bss as the sectionname. -.It Fl -Tdata Ns = Ns Ar value +.Pp +.It Fl -Tdata Ar value Same as .Fl -section-start with .Li .data as the sectionname. -.It Fl -thinlto-cache-dir Ns = Ns Ar value +.Pp +.It Fl -thinlto-cache-dir= Ns Ar value Path to ThinLTO cached object file directory. -.It Fl -thinlto-cache-policy Ns = Ns Ar value +.Pp +.It Fl -thinlto-cache-policy Ar value Pruning policy for the ThinLTO cache. -.It Fl -thinlto-jobs Ns = Ns Ar value +.Pp +.It Fl -thinlto-jobs= Ns Ar value Number of ThinLTO jobs. +.Pp .It Fl -threads Run the linker multi-threaded. This option is enabled by default. -.It Fl -trace-symbol Ns = Ns Ar symbol +.Pp +.It Fl -trace-symbol Ar symbol +.It Fl y Ar symbol Trace references to .Ar symbol . +.Pp .It Fl -trace Print the names of the input files. -.It Fl -Ttext Ns = Ns Ar value +.Pp +.It Fl -Ttext Ar value Same as .Fl -section-start with .Li .text as the sectionname. -.It Fl -undefined Ns = Ns Ar symbol +.Pp +.It Fl -undefined Ar symbol +.It Fl u Ar symbol Force .Ar symbol to be an undefined symbol during linking. -.It Fl -unresolved-symbols Ns = Ns Ar value +.Pp +.It Fl -unresolved-symbols Ar value Determine how to handle unresolved symbols. -.It Fl -verbose -Verbose mode. -.It Fl -version-script Ns = Ns Ar file -Read version script from -.Ar file . -.It Fl V , Fl -version -Display the version number and exit. +.Pp .It Fl v Display the version number and proceed with linking if object files are specified. +.Pp +.It Fl -verbose +Verbose mode. +.Pp +.It Fl -version +.It Fl V +Display the version number and exit. +.Pp +.It Fl -version-script Ar file +Read version script from +.Ar file . +.Pp .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. +.Pp .It Fl -warn-common Warn about duplicate common symbols. +.Pp .It Fl -warn-unresolved-symbols Report unresolved symbols as warnings. +.Pp .It Fl -whole-archive Force load of all members in a static library. -.It Fl -wrap Ns = Ns Ar symbol +.Pp +.It Fl -wrap Ar symbol Use wrapper functions for symbol. +.Pp .It Fl z Ar option Linker option extensions. .Bl -tag -width indent +.Pp .It Cm execstack Make the main stack executable. Stack permissions are recorded in the .Dv PT_GNU_STACK segment. +.Pp +.It Cm initfirst +Sets the +.Dv DF_1_INITFIRST +flag to indicate the module should be initialized first. +.Pp .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. +.Pp .It Cm nocombreloc Disable combining and sorting multiple relocation sections. +.Pp .It Cm nocopyreloc Disable the creation of copy relocations. +.Pp .It Cm nodelete Set the .Dv DF_1_NODELETE flag to indicate that the object cannot be unloaded from a process. +.Pp .It Cm nodlopen Set the .Dv DF_1_NOOPEN flag to indcate that the object may not be opened by .Xr dlopen 3 . +.Pp .It Cm norelro Do not indicate that portions of the object shold be mapped read-only after initial relocation processing. The object will omit the .Dv PT_GNU_RELRO segment. +.Pp .It Cm notext Allow relocations against read-only segments. Sets the .Dv DT_TEXTREL flag in the .Dv DYNAMIC section. +.Pp .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. +.Pp .It Cm origin Set the .Dv DF_ORIGIN flag to indicate that the object requires $ORIGIN processing. +.Pp .It Cm retpolineplt Emit retpoline format PLT entries as a mitigation for CVE-2017-5715. +.Pp .It Cm rodynamic Make the .Li .dynamic @@ -483,16 +641,19 @@ The .Dv DT_DEBUG tag will not be emitted. -.It Cm stack-size Ns = Ns Ar size +.Pp +.It Cm stack-size= Ns Ar size 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. +.Pp .It Cm text Do not allow relocations against read-only segments. This is the default. +.Pp .It Cm wxneeded Create a .Dv PT_OPENBSD_WXNEEDED