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