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