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