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