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 only supported on x86-64 (default), AArch64 (default), 216MIPS64, RISC-V (default), and SPARC64. 217.It Fl -exclude-libs Ns = Ns Ar value 218Exclude static libraries from automatic export. 219.It Fl -export-dynamic , Fl E 220Put symbols in the dynamic symbol table. 221.It Fl -export-dynamic-symbol Ns = Ns Ar glob 222(executable) Put matched non-local defined symbols to the dynamic symbol table. 223(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 224.Cm -Bsymbolic 225, 226.Cm -Bsymbolic-functions 227or 228.Cm --dynamic-list 229.It Fl -fatal-warnings 230Treat warnings as errors. 231.It Fl -filter Ns = Ns Ar value , Fl F Ar value 232Set the 233.Dv DT_FILTER 234field to the specified value. 235.It Fl -fini Ns = Ns Ar symbol 236Specify a finalizer function. 237.It Fl -format Ns = Ns Ar input-format , Fl b Ar input-format 238Specify the format of the inputs following this option. 239.Ar input-format 240may be one of 241.Cm binary , 242.Cm elf , 243and 244.Cm default . 245.Cm default 246is a synonym for 247.Cm elf . 248.It Fl -gc-sections 249Enable garbage collection of unused sections. 250.It Fl -gdb-index 251Generate 252.Li .gdb_index 253section. 254.It Fl -hash-style Ns = Ns Ar value 255Specify hash style. 256.Ar value 257may be 258.Cm sysv , 259.Cm gnu , 260or 261.Cm both . 262.Cm both 263is the default. 264.It Fl -help 265Print a help message. 266.It Fl -icf Ns = Ns Cm all 267Enable identical code folding. 268.It Fl -icf Ns = Ns Cm safe 269Enable safe identical code folding. 270.It Fl -icf Ns = Ns Cm none 271Disable identical code folding. 272.It Fl -ignore-data-address-equality 273Ignore address equality of data. C/C++ requires each data to have a unique 274address. 275This option allows lld to do unsafe optimization that breaks the 276requirement: create copies of read-only data or merge two or more read-only data 277that happen to have the same value. 278.It Fl -ignore-function-address-equality 279Ignore address equality of functions. 280This option allows non-PIC calls to a function with non-default visibility in 281a shared object. 282The function may have different addresses within the executable and within the 283shared object. 284.It Fl -image-base Ns = Ns Ar value 285Set the base address to 286.Ar value . 287.It Fl -init Ns = Ns Ar symbol 288Specify an initializer function. 289.It Fl -keep-unique Ns = Ns Ar symbol 290Do not fold 291.Ar symbol 292during ICF. 293.It Fl l Ar libName, Fl -library Ns = Ns Ar libName 294Root name of library to use. 295.It Fl L Ar dir , Fl -library-path Ns = Ns Ar dir 296Add a directory to the library search path. 297.It Fl -lto-aa-pipeline Ns = Ns Ar value 298AA pipeline to run during LTO. 299Used in conjunction with 300.Fl -lto-newpm-passes . 301.It Fl -lto-newpm-passes Ns = Ns Ar value 302Passes to run during LTO. 303.It Fl -lto-O Ns Ar opt-level 304Optimization level for LTO. 305.It Fl -lto-partitions Ns = Ns Ar value 306Number of LTO codegen partitions. 307.It Fl m Ar value 308Set target emulation. 309.It Fl -Map Ns = Ns Ar file , Fl M Ar file 310Print a link map to 311.Ar file . 312.It Fl -nmagic , Fl n 313Do not page align sections, link against static libraries. 314.It Fl -no-allow-shlib-undefined 315Do not allow unresolved references in shared libraries. 316This option is enabled by default when linking an executable. 317.It Fl -no-as-needed 318Always set 319.Dv DT_NEEDED 320for shared libraries. 321.It Fl -no-color-diagnostics 322Do not use colors in diagnostics. 323.It Fl -no-define-common 324Do not assign space to common symbols. 325.It Fl -no-demangle 326Do not demangle symbol names. 327.It Fl -no-dynamic-linker 328Inhibit output of an 329.Li .interp 330section. 331.It Fl -no-fortran-common 332Do not search archive members for definitions to override COMMON symbols. 333.It Fl -no-gc-sections 334Disable garbage collection of unused sections. 335.It Fl -no-gnu-unique 336Disable STB_GNU_UNIQUE symbol binding. 337.It Fl -no-merge-exidx-entries 338Disable merging .ARM.exidx entries. 339.It Fl -no-nmagic 340Page align sections. 341.It Fl -no-omagic 342Do not set the text data sections to be writable, page align sections. 343.It Fl -no-relax 344Disable target-specific relaxations. This is currently a no-op. 345.It Fl -no-rosegment 346Do not put read-only non-executable sections in their own segment. 347.It Fl -no-undefined-version 348Report version scripts that refer undefined symbols. 349.It Fl -no-undefined 350Report unresolved symbols even if the linker is creating a shared library. 351.It Fl -no-warn-symbol-ordering 352Do not warn about problems with the symbol ordering file or call graph profile. 353.It Fl -no-whole-archive 354Restores the default behavior of loading archive members. 355.It Fl -no-pie , Fl -no-pic-executable 356Do not create a position independent executable. 357.It Fl -noinhibit-exec 358Retain the executable output file whenever it is still usable. 359.It Fl -nostdlib 360Only search directories specified on the command line. 361.It Fl o Ar path 362Write the output executable, library, or object to 363.Ar path . 364If not specified, 365.Dv a.out 366is used as a default. 367.It Fl O Ns Ar value 368Optimize output file size. 369.Ar value 370may be: 371.Pp 372.Bl -tag -width 2n -compact 373.It Cm 0 374Disable string merging. 375.It Cm 1 376Enable string merging. 377.It Cm 2 378Enable string tail merging. If 379.Fl -compress-debug-sections 380is given, compress debug sections at compression level 6 instead of 1. 381.El 382.Pp 383.Fl O Ns Cm 1 384is the default. 385.It Fl -oformat Ns = Ns Ar format 386Specify the format for the output object file. 387The only supported 388.Ar format 389is 390.Cm binary , 391which produces output with no ELF header. 392.It Fl -omagic , Fl N 393Set the text and data sections to be readable and writable, do not page align 394sections, link against static libraries. 395.It Fl -opt-remarks-filename Ar file 396Write optimization remarks in YAML format to 397.Ar file . 398.It Fl -opt-remarks-passes Ar pass-regex 399Filter optimization remarks by only allowing the passes matching 400.Ar pass-regex . 401.It Fl -opt-remarks-with-hotness 402Include hotness information in the optimization remarks file. 403.It Fl -orphan-handling Ns = Ns Ar mode 404Control how orphan sections are handled. 405An orphan section is one not specifically mentioned in a linker script. 406.Ar mode 407may be: 408.Pp 409.Bl -tag -width 2n -compact 410.It Cm place 411Place orphan sections in suitable output sections. 412.It Cm warn 413Place orphan sections as for 414.Cm place 415and also report a warning. 416.It Cm error 417Place orphan sections as for 418.Cm place 419and also report an error. 420.El 421.Pp 422.Cm place 423is the default. 424.It Fl -pack-dyn-relocs Ns = Ns Ar format 425Pack dynamic relocations in the given format. 426.Ar format 427may be: 428.Pp 429.Bl -tag -width 2n -compact 430.It Cm none 431Do not pack. 432Dynamic relocations are encoded in SHT_REL(A). 433.It Cm android 434Pack dynamic relocations in SHT_ANDROID_REL(A). 435.It Cm relr 436Pack relative relocations in SHT_RELR, and the rest of dynamic relocations in 437SHT_REL(A). 438.It Cm android+relr 439Pack relative relocations in SHT_RELR, and the rest of dynamic relocations in 440SHT_ANDROID_REL(A). 441.El 442.Pp 443.Cm none 444is the default. 445If 446.Fl -use-android-relr-tags 447is specified, use SHT_ANDROID_RELR instead of SHT_RELR. 448.Pp 449.It Fl -pic-veneer 450Always generate position independent thunks. 451.It Fl -pie , Fl -pic-executable 452Create a position independent executable. 453.It Fl -print-gc-sections 454List removed unused sections. 455.It Fl -print-icf-sections 456List identical folded sections. 457.It Fl -print-map 458Print a link map to the standard output. 459.It Fl -print-archive-stats Ns = Ns Ar file 460Write archive usage statistics to the specified file. 461Print the numbers of members and fetched members for each archive. 462.It Fl -push-state 463Save the current state of 464.Fl -as-needed , 465.Fl -static , 466and 467.Fl -whole-archive. 468.It Fl -pop-state 469Undo the effect of 470.Fl -push-state. 471.It Fl -relocatable , Fl r 472Create relocatable object file. 473.It Fl -reproduce Ns = Ns Ar path 474Write a tar file to 475.Ar path, 476containing all the input files needed to reproduce the link, a text file called 477response.txt containing the command line options and a text file called 478version.txt containing the output of ld.lld --version. 479The archive when 480unpacked can be used to re-run the linker with the same options and input files. 481.It Fl -retain-symbols-file Ns = Ns Ar file 482Retain only the symbols listed in the file. 483.It Fl -rpath Ns = Ns Ar value , Fl R Ar value 484Add a 485.Dv DT_RUNPATH 486to the output. 487.It Fl -rsp-quoting Ns = Ns Ar value 488Quoting style for response files. 489The supported values are 490.Cm windows 491and 492.Cm posix . 493.It Fl -script Ns = Ns Ar file , Fl T Ar file 494Read linker script from 495.Ar file . 496If multiple linker scripts are given, they are processed as if they 497were concatenated in the order they appeared on the command line. 498.It Fl -section-start Ns = Ns Ar section Ns = Ns Ar address 499Set address of section. 500.It Fl -shared , Fl -Bsharable 501Build a shared object. 502.It Fl -shuffle-sections Ns = Ns Ar seed 503Shuffle matched sections using the given seed before mapping them to the output sections. 504If -1, reverse the section order. If 0, use a random seed. 505.It Fl -soname Ns = Ns Ar value , Fl h Ar value 506Set 507.Dv DT_SONAME 508to 509.Ar value . 510.It Fl -sort-common 511This option is ignored for GNU compatibility. 512.It Fl -sort-section Ns = Ns Ar value 513Specifies sections sorting rule when linkerscript is used. 514.It Fl -start-lib 515Start a grouping of objects that should be treated as if they were together 516in an archive. 517.It Fl -strip-all , Fl s 518Strip all symbols. 519Implies 520.Fl -strip-debug . 521.It Fl -strip-debug , Fl S 522Strip debugging information. 523.It Fl -symbol-ordering-file Ns = Ns Ar file 524Lay out sections in the order specified by 525.Ar file . 526.It Fl -sysroot Ns = Ns Ar value 527Set the system root. 528.It Fl -target1-abs 529Interpret 530.Dv R_ARM_TARGET1 531as 532.Dv R_ARM_ABS32 . 533.It Fl -target1-rel 534Interpret 535.Dv R_ARM_TARGET1 536as 537.Dv R_ARM_REL32 . 538.It Fl -target2 Ns = Ns Ar type 539Interpret 540.Dv R_ARM_TARGET2 541as 542.Ar type , 543where 544.Ar type 545is one of 546.Cm rel , 547.Cm abs , 548or 549.Cm got-rel . 550.It Fl -Tbss Ns = Ns Ar value 551Same as 552.Fl -section-start 553with 554.Li .bss 555as the sectionname. 556.It Fl -Tdata Ns = Ns Ar value 557Same as 558.Fl -section-start 559with 560.Li .data 561as the sectionname. 562.It Fl -Ttext Ns = Ns Ar value 563Same as 564.Fl -section-start 565with 566.Li .text 567as the sectionname. 568.It Fl -thinlto-cache-dir Ns = Ns Ar value 569Path to ThinLTO cached object file directory. 570.It Fl -thinlto-cache-policy Ns = Ns Ar value 571Pruning policy for the ThinLTO cache. 572.It Fl -thinlto-jobs Ns = Ns Ar value 573Number of ThinLTO jobs. 574.It Fl -threads Ns = Ns Ar N 575Number of threads. 576.Cm all 577(default) means all of concurrent threads supported. 578.Cm 1 579disables multi-threading. 580.It Fl -time-trace 581Record time trace. 582.It Fl -time-trace-file Ns = Ns Ar file 583Write time trace output to 584.Ar file . 585.It Fl -time-trace-granularity Ns = Ns Ar value 586Minimum time granularity (in microseconds) traced by time profiler. 587.It Fl -trace 588Print the names of the input files. 589.It Fl -trace-symbol Ns = Ns Ar symbol , Fl y Ar symbol 590Trace references to 591.Ar symbol . 592.It Fl -undefined Ns = Ns Ar symbol , Fl u Ar symbol 593If 594.Ar symbol 595is not defined after symbol resolution, and there's a static library 596that contains an object file defining the symbol, load the member 597to include the object file in the output file. 598.It Fl -undefined-glob Ns = Ns Ar pattern 599Synonym for 600.Fl -undefined , 601except that it takes a glob pattern. 602In a glob pattern, 603.Cm * 604matches zero or more characters, 605.Cm ? 606matches any single character, and 607.Cm [...] 608matches the characters within brackets. 609All symbols that match 610a given pattern are handled as if they were given as arguments of 611.Fl -undefined . 612.It Fl -unique 613Creates a separate output section for every orphan input section. 614.It Fl -unresolved-symbols Ns = Ns Ar value 615Determine how to handle unresolved symbols. 616.It Fl -use-android-relr-tags 617Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*. 618.It Fl v 619Display the version number and proceed with linking if object files are 620specified. 621.It Fl V , Fl -version 622Display the version number and exit. 623.It Fl -verbose 624Verbose mode. 625.It Fl -version-script Ns = Ns Ar file 626Read version script from 627.Ar file . 628.It Fl -warn-backrefs 629Warn about reverse or cyclic dependencies to or between static archives. 630This can be used to ensure linker invocation remains compatible with 631traditional Unix-like linkers. 632.It Fl -warn-backrefs-exclude Ns = Ns Ar glob 633Glob describing an archive (or an object file within --start-lib) 634which should be ignored for 635.Fl -warn-backrefs 636.It Fl -warn-common 637Warn about duplicate common symbols. 638.It Fl -warn-ifunc-textrel 639Warn about using ifunc symbols in conjunction with text relocations. 640Older versions of glibc library (2.28 and earlier) has a bug that causes 641the segment that includes ifunc symbols to be marked as not executable when 642they are relocated. 643As a result, although the program compiles and links 644successfully, it gives segmentation fault when the instruction pointer reaches 645an ifunc symbol. 646Use -warn-ifunc-textrel to let lld give a warning, if the 647code may include ifunc symbols, may do text relocations and be linked with 648an older glibc version. 649Otherwise, there is no need to use it, as the default value does not give a 650warning. 651This flag has been introduced in late 2018, has no counter part in ld and gold 652linkers, and may be removed in the future. 653.It Fl -warn-unresolved-symbols 654Report unresolved symbols as warnings. 655.It Fl -whole-archive 656Force load of all members in a static library. 657.It Fl -wrap Ns = Ns Ar symbol 658Redirect 659.Ar symbol 660references to 661.Ar __wrap_symbol 662and 663.Ar __real_symbol 664references to 665.Ar symbol. 666.It Fl z Ar option 667Linker option extensions. 668.Bl -tag -width indent -compact 669.Pp 670.It Cm dead-reloc-in-nonalloc Ns = Ns Ar section_glob=value 671Resolve a relocation in a matched non-SHF_ALLOC section referencing a discarded symbol to 672.Ar value 673Accepts globs, in the event of a section matching more than one option, the last 674option takes precedence. An order of least specific to most specific match is 675recommended. 676.Pp 677.It Cm execstack 678Make the main stack executable. 679Stack permissions are recorded in the 680.Dv PT_GNU_STACK 681segment. 682.Pp 683.It Cm force-bti 684Force enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property. 685.Pp 686.It Cm force-ibt 687Force enable Intel Indirect Branch Tracking in PLT, warn if an input ELF file 688does not have GNU_PROPERTY_X86_FEATURE_1_IBT property. 689.Pp 690.It Cm global 691Sets the 692.Dv DF_1_GLOBAL flag in the 693.Dv DYNAMIC 694section. 695Different loaders can decide how to handle this flag on their own. 696.Pp 697.It Cm ifunc-noplt 698Do not emit PLT entries for ifunc symbols. 699Instead, emit text relocations referencing the resolver. 700This is an experimental optimization and only suitable for standalone 701environments where text relocations do not have the usual drawbacks. 702This option must be combined with the 703.Fl z Li notext 704option. 705.Pp 706.It Cm initfirst 707Sets the 708.Dv DF_1_INITFIRST 709flag to indicate the module should be initialized first. 710.Pp 711.It Cm interpose 712Set the 713.Dv DF_1_INTERPOSE 714flag to indicate to the runtime linker that the object is an interposer. 715During symbol resolution interposers are searched after the application 716but before other dependencies. 717.Pp 718.It Cm muldefs 719Do not error if a symbol is defined multiple times. 720The first definition will be used. 721This is a synonym for 722.Fl -allow-multiple-definition. 723.Pp 724.It Cm nocombreloc 725Disable combining and sorting multiple relocation sections. 726.Pp 727.It Cm nocopyreloc 728Disable the creation of copy relocations. 729.Pp 730.It Cm nodefaultlib 731Set the 732.Dv DF_1_NODEFLIB 733flag to indicate that default library search paths should be ignored. 734.Pp 735.It Cm nodelete 736Set the 737.Dv DF_1_NODELETE 738flag to indicate that the object cannot be unloaded from a process. 739.Pp 740.It Cm nodlopen 741Set the 742.Dv DF_1_NOOPEN 743flag to indicate that the object may not be opened by 744.Xr dlopen 3 . 745.Pp 746.It Cm nognustack 747Do not emit the 748.Dv PT_GNU_STACK 749segment. 750.Pp 751.It Cm norelro 752Do not indicate that portions of the object should be mapped read-only 753after initial relocation processing. 754The object will omit the 755.Dv PT_GNU_RELRO 756segment. 757.Pp 758.It Cm notext 759Allow relocations against read-only segments. 760Sets the 761.Dv DT_TEXTREL flag in the 762.Dv DYNAMIC 763section. 764.Pp 765.It Cm now 766Set the 767.Dv DF_BIND_NOW 768flag to indicate that the run-time loader should perform all relocation 769processing as part of object initialization. 770By default relocations may be performed on demand. 771.Pp 772.It Cm origin 773Set the 774.Dv DF_ORIGIN 775flag to indicate that the object requires 776$ORIGIN 777processing. 778.Pp 779.It Cm pac-plt 780AArch64 only, use pointer authentication in PLT. 781.Pp 782.It Cm rel 783Use REL format for dynamic relocations. 784.Pp 785.It Cm rela 786Use RELA format for dynamic relocations. 787.Pp 788.It Cm retpolineplt 789Emit retpoline format PLT entries as a mitigation for CVE-2017-5715. 790.Pp 791.It Cm rodynamic 792Make the 793.Li .dynamic 794section read-only. 795The 796.Dv DT_DEBUG 797tag will not be emitted. 798.Pp 799.It Cm separate-loadable-segments 800.It Cm separate-code 801.It Cm noseparate-code 802Specify whether two adjacent PT_LOAD segments are allowed to overlap in pages. 803.Cm noseparate-code 804(default) allows overlap. 805.Cm separate-code 806allows overlap between two executable segments, or two non-executable segments. 807.Cm separate-loadable-segments 808disallows overlap. 809.Pp 810.It Cm shstk 811x86 only, use shadow stack. 812.Pp 813.It Cm stack-size Ns = Ns Ar size 814Set the main thread's stack size to 815.Ar size . 816The stack size is recorded as the size of the 817.Ar size . 818.Dv PT_GNU_STACK 819program segment. 820.Pp 821.It Cm start-stop-gc 822Don't let __start_/__stop_ references retain the associated C identifier name sections (default). 823.Pp 824.It Cm nostart-stop-gc 825Let __start_/__stop_ references retain the associated C identifier name sections. 826.Pp 827.It Cm text 828Do not allow relocations against read-only segments. 829This is the default. 830.Pp 831.It Cm wxneeded 832Create a 833.Dv PT_OPENBSD_WXNEEDED 834segment. 835.El 836.El 837.Sh IMPLEMENTATION NOTES 838.Nm Ap s 839handing of archive files (those with a 840.Pa .a 841file extension) is different from traditional linkers used on Unix-like 842systems. 843.Pp 844Traditional linkers maintain a set of undefined symbols during linking. 845The linker processes each file in the order in which it appears on the 846command line, until the set of undefined symbols becomes empty. 847An object file is linked into the output object when it is encountered, 848with its undefined symbols added to the set. 849Upon encountering an archive file a traditional linker searches the objects 850contained therein, and processes those that satisfy symbols in the unresolved 851set. 852.Pp 853Handling mutually dependent archives may be awkward when using a traditional 854linker. 855Archive files may have to be specified multiple times, or the special command 856line options 857.Fl -start-group 858and 859.Fl -end-group 860may be used to have the linker loop over the files in the group until no new 861symbols are added to the set. 862.Pp 863.Nm 864records all symbols found in objects and archives as it iterates over 865command line arguments. 866When 867.Nm 868encounters an undefined symbol that can be resolved by an object file 869contained in a previously processed archive file, it immediately extracts 870and links it into the output object. 871.Pp 872With certain archive inputs 873.Nm 874may produce different results compared to traditional linkers. 875In practice, large bodies of third party software have been linked with 876.Nm 877without material issues. 878.Pp 879The 880.Fl -warn-backrefs 881option may be used to identify a linker invocation that may be incompatible 882with traditional Unix-like linker behavior. 883