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 -randomize-section-padding Ns = Ns Ar seed 533Randomly insert padding between input sections and at the start of each segment using the given seed. 534Padding is inserted into output sections with names matching the following patterns: 535.Cm .bss , 536.Cm .data , 537.Cm .data.rel.ro , 538.Cm .lbss , 539.Cm .ldata , 540.Cm .lrodata , 541.Cm .ltext , 542.Cm .rodata 543and 544.Cm .text* . 545.It Fl --relax-gp 546Enable global pointer relaxation for RISC-V. 547.It Fl -relocatable , Fl r 548Create relocatable object file. 549.It Fl -remap-inputs Ns = Ns Ar from-glob=to-file 550Input files matching 551.Cm from-glob 552are mapped to 553.Cm to-file. 554Use 555.Cm /dev/null 556to ignore an input file. 557.It Fl -remap-inputs-file Ns = Ns Ar file 558Remap input files based on patterns in 559.Ar file . 560Each line in the remap file is of the format 561.Cm from-glob=to-file 562or a comment starting with 563.Cm # . 564.It Fl -reproduce Ns = Ns Ar path 565Write a tar file to 566.Ar path, 567containing all the input files needed to reproduce the link, a text file called 568response.txt containing the command line options and a text file called 569version.txt containing the output of ld.lld --version. 570The archive when 571unpacked can be used to re-run the linker with the same options and input files. 572.It Fl -retain-symbols-file Ns = Ns Ar file 573Retain only the symbols listed in the file. 574.It Fl -rpath Ns = Ns Ar value , Fl R Ar value 575Add a 576.Dv DT_RUNPATH 577to the output. 578.It Fl -rsp-quoting Ns = Ns Ar value 579Quoting style for response files. 580The supported values are 581.Cm windows 582and 583.Cm posix . 584.It Fl -script Ns = Ns Ar file , Fl T Ar file 585Read linker script from 586.Ar file . 587If multiple linker scripts are given, they are processed as if they 588were concatenated in the order they appeared on the command line. 589.It Fl -section-start Ns = Ns Ar section Ns = Ns Ar address 590Set address of section. 591.It Fl -shared , Fl -Bsharable 592Build a shared object. 593.It Fl -shuffle-sections Ns = Ns Ar seed 594Shuffle matched sections using the given seed before mapping them to the output sections. 595If -1, reverse the section order. If 0, use a random seed. 596.It Fl -soname Ns = Ns Ar value , Fl h Ar value 597Set 598.Dv DT_SONAME 599to 600.Ar value . 601.It Fl -sort-common 602This option is ignored for GNU compatibility. 603.It Fl -sort-section Ns = Ns Ar value 604Specifies sections sorting rule when linkerscript is used. 605.It Fl -start-lib 606Start a grouping of objects that should be treated as if they were together 607in an archive. 608.It Fl -strip-all , Fl s 609Strip all symbols. 610Implies 611.Fl -strip-debug . 612.It Fl -strip-debug , Fl S 613Strip debugging information. 614.It Fl -symbol-ordering-file Ns = Ns Ar file 615Lay out sections in the order specified by 616.Ar file . 617.It Fl -sysroot Ns = Ns Ar value 618Set the system root. 619.It Fl -target1-abs 620Interpret 621.Dv R_ARM_TARGET1 622as 623.Dv R_ARM_ABS32 . 624.It Fl -target1-rel 625Interpret 626.Dv R_ARM_TARGET1 627as 628.Dv R_ARM_REL32 . 629.It Fl -target2 Ns = Ns Ar type 630Interpret 631.Dv R_ARM_TARGET2 632as 633.Ar type , 634where 635.Ar type 636is one of 637.Cm rel , 638.Cm abs , 639or 640.Cm got-rel . 641.It Fl -Tbss Ns = Ns Ar value 642Same as 643.Fl -section-start 644with 645.Li .bss 646as the sectionname. 647.It Fl -Tdata Ns = Ns Ar value 648Same as 649.Fl -section-start 650with 651.Li .data 652as the sectionname. 653.It Fl -Ttext Ns = Ns Ar value 654Same as 655.Fl -section-start 656with 657.Li .text 658as the sectionname. 659.It Fl -thinlto-cache-dir Ns = Ns Ar value 660Path to ThinLTO cached object file directory. 661.It Fl -thinlto-cache-policy Ns = Ns Ar value 662Pruning policy for the ThinLTO cache. 663.It Fl -thinlto-jobs Ns = Ns Ar value 664Number of ThinLTO jobs. 665.It Fl -threads Ns = Ns Ar N 666Number of threads. 667.Cm all 668(default) means all of concurrent threads supported. 669.Cm 1 670disables multi-threading. 671.It Fl -fat-lto-objects 672Use the .llvm.lto section, which contains LLVM bitcode, in fat LTO object files to perform LTO. 673.It Fl -no-fat-lto-objects 674Ignore the .llvm.lto section in relocatable object files (default). 675.It Fl -time-trace 676Record time trace. 677.It Fl -time-trace-file Ns = Ns Ar file 678Write time trace output to 679.Ar file . 680.It Fl -time-trace-granularity Ns = Ns Ar value 681Minimum time granularity (in microseconds) traced by time profiler. 682.It Fl -trace 683Print the names of the input files. 684.It Fl -trace-symbol Ns = Ns Ar symbol , Fl y Ar symbol 685Trace references to 686.Ar symbol . 687.It Fl -undefined Ns = Ns Ar symbol , Fl u Ar symbol 688If 689.Ar symbol 690is not defined after symbol resolution, and there's a static library 691that contains an object file defining the symbol, load the member 692to include the object file in the output file. 693.It Fl -undefined-glob Ns = Ns Ar pattern 694Synonym for 695.Fl -undefined , 696except that it takes a glob pattern. 697In a glob pattern, 698.Cm * 699matches zero or more characters, 700.Cm ? 701matches any single character, and 702.Cm [...] 703matches the characters within brackets. 704All symbols that match 705a given pattern are handled as if they were given as arguments of 706.Fl -undefined . 707.It Fl -unique 708Creates a separate output section for every orphan input section. 709.It Fl -unresolved-symbols Ns = Ns Ar value 710Determine how to handle unresolved symbols. 711.It Fl -use-android-relr-tags 712Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*. 713.It Fl v , Fl V 714Display the version number and proceed with linking if object files are 715specified. 716.It Fl -version 717Display the version number and exit. 718.It Fl -verbose 719Verbose mode. 720.It Fl -version-script Ns = Ns Ar file 721Read version script from 722.Ar file . 723.It Fl -warn-backrefs 724Warn about reverse or cyclic dependencies to or between static archives. 725This can be used to ensure linker invocation remains compatible with 726traditional Unix-like linkers. 727.It Fl -warn-backrefs-exclude Ns = Ns Ar glob 728Glob describing an archive (or an object file within --start-lib) 729which should be ignored for 730.Fl -warn-backrefs 731.It Fl -warn-common 732Warn about duplicate common symbols. 733.It Fl -warn-ifunc-textrel 734Warn about using ifunc symbols in conjunction with text relocations. 735Older versions of glibc library (2.28 and earlier) has a bug that causes 736the segment that includes ifunc symbols to be marked as not executable when 737they are relocated. 738As a result, although the program compiles and links 739successfully, it gives segmentation fault when the instruction pointer reaches 740an ifunc symbol. 741Use -warn-ifunc-textrel to let lld give a warning, if the 742code may include ifunc symbols, may do text relocations and be linked with 743an older glibc version. 744Otherwise, there is no need to use it, as the default value does not give a 745warning. 746This flag has been introduced in late 2018, has no counter part in ld and gold 747linkers, and may be removed in the future. 748.It Fl -warn-unresolved-symbols 749Report unresolved symbols as warnings. 750.It Fl -whole-archive 751Force load of all members in a static library. 752.It Fl -why-extract Ns = Ns Ar file 753Print to a file about why archive members are extracted. 754.It Fl -wrap Ns = Ns Ar symbol 755Redirect 756.Ar symbol 757references to 758.Ar __wrap_symbol 759and 760.Ar __real_symbol 761references to 762.Ar symbol. 763.It Fl z Ar option 764Linker option extensions. 765.Bl -tag -width indent -compact 766.Pp 767.It Cm dead-reloc-in-nonalloc Ns = Ns Ar section_glob=value 768Resolve a relocation in a matched non-SHF_ALLOC section referencing a discarded symbol to 769.Ar value 770Accepts globs, in the event of a section matching more than one option, the last 771option takes precedence. An order of least specific to most specific match is 772recommended. 773.Pp 774.It Cm execstack 775Make the main stack executable. 776Stack permissions are recorded in the 777.Dv PT_GNU_STACK 778segment. 779.Pp 780.It Cm bti-report Ns = Ns Ar [none|warning|error] 781Specify how to report the missing GNU_PROPERTY_AARCH64_FEATURE_1_BTI property. 782.Cm none 783is the default, linker will not report the missing property otherwise will be reported as a warning or an error. 784.Pp 785.It Cm cet-report Ns = Ns Ar [none|warning|error] 786Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT or GNU_PROPERTY_X86_FEATURE_1_SHSTK properties. 787.Cm none 788is the default, linker will not report the missing property otherwise will be reported as a warning or an error. 789.Pp 790.It Cm pauth-report Ns = Ns Ar [none|warning|error] 791Specify how to report the missing GNU_PROPERTY_AARCH64_FEATURE_PAUTH property. 792.Cm none 793is the default, linker will not report the missing property otherwise will be reported as a warning or an error. 794.Pp 795.It Cm force-bti 796Force enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property. 797.Pp 798.It Cm force-ibt 799Force enable Intel Indirect Branch Tracking in PLT, warn if an input ELF file 800does not have GNU_PROPERTY_X86_FEATURE_1_IBT property. 801.Pp 802.It Cm global 803Sets the 804.Dv DF_1_GLOBAL flag in the 805.Dv DYNAMIC 806section. 807Different loaders can decide how to handle this flag on their own. 808.Pp 809.It Cm ifunc-noplt 810Do not emit PLT entries for ifunc symbols. 811Instead, emit text relocations referencing the resolver. 812This is an experimental optimization and only suitable for standalone 813environments where text relocations do not have the usual drawbacks. 814This option must be combined with the 815.Fl z Li notext 816option. 817.Pp 818.It Cm initfirst 819Sets the 820.Dv DF_1_INITFIRST 821flag to indicate the module should be initialized first. 822.Pp 823.It Cm interpose 824Set the 825.Dv DF_1_INTERPOSE 826flag to indicate to the runtime linker that the object is an interposer. 827During symbol resolution interposers are searched after the application 828but before other dependencies. 829.Pp 830.It Cm lrodata-after-bss 831Place .lrodata after .bss. 832.Pp 833.It Cm muldefs 834Do not error if a symbol is defined multiple times. 835The first definition will be used. 836This is a synonym for 837.Fl -allow-multiple-definition. 838.Pp 839.It Cm nocombreloc 840Disable combining and sorting multiple relocation sections. 841.Pp 842.It Cm nocopyreloc 843Disable the creation of copy relocations. 844.Pp 845.It Cm nodefaultlib 846Set the 847.Dv DF_1_NODEFLIB 848flag to indicate that default library search paths should be ignored. 849.Pp 850.It Cm nodelete 851Set the 852.Dv DF_1_NODELETE 853flag to indicate that the object cannot be unloaded from a process. 854.Pp 855.It Cm nodlopen 856Set the 857.Dv DF_1_NOOPEN 858flag to indicate that the object may not be opened by 859.Xr dlopen 3 . 860.Pp 861.It Cm nognustack 862Do not emit the 863.Dv PT_GNU_STACK 864segment. 865.Pp 866.It Cm norelro 867Do not indicate that portions of the object should be mapped read-only 868after initial relocation processing. 869The object will omit the 870.Dv PT_GNU_RELRO 871segment. 872.Pp 873.It Cm nosectionheader 874Don't generate the section header table. 875.Pp 876.It Cm notext 877Allow relocations against read-only segments. 878Sets the 879.Dv DT_TEXTREL flag in the 880.Dv DYNAMIC 881section. 882.Pp 883.It Cm now 884Set the 885.Dv DF_BIND_NOW 886flag to indicate that the run-time loader should perform all relocation 887processing as part of object initialization. 888By default relocations may be performed on demand. 889.Pp 890.It Cm origin 891Set the 892.Dv DF_ORIGIN 893flag to indicate that the object requires 894$ORIGIN 895processing. 896.Pp 897.It Cm pac-plt 898AArch64 only, use pointer authentication in PLT. 899.Pp 900.It Cm pack-relative-relocs 901Similar to 902.Cm -pack-dyn-relocs=relr 903, but synthesizes the GLIBC_ABI_DT_RELR version dependency if there is a GLIBC_2.* version dependency. 904glibc ld.so rejects loading a dynamically linked object without the GLIBC_ABI_DT_RELR version dependency. 905.Pp 906.It Cm rel 907Use REL format for dynamic relocations. 908.Pp 909.It Cm rela 910Use RELA format for dynamic relocations. 911.Pp 912.It Cm retpolineplt 913Emit retpoline format PLT entries as a mitigation for CVE-2017-5715. 914.Pp 915.It Cm rodynamic 916Make the 917.Li .dynamic 918section read-only. 919The 920.Dv DT_DEBUG 921tag will not be emitted. 922.Pp 923.It Cm separate-loadable-segments 924.It Cm separate-code 925.It Cm noseparate-code 926Specify whether two adjacent PT_LOAD segments are allowed to overlap in pages. 927.Cm noseparate-code 928(default) allows overlap. 929.Cm separate-code 930allows overlap between two executable segments, or two non-executable segments. 931.Cm separate-loadable-segments 932disallows overlap. 933.Pp 934.It Cm shstk 935x86 only, use shadow stack. 936.Pp 937.It Cm stack-size Ns = Ns Ar size 938Set the main thread's stack size to 939.Ar size . 940The stack size is recorded as the size of the 941.Ar size . 942.Dv PT_GNU_STACK 943program segment. 944.Pp 945.It Cm start-stop-gc 946Don't let __start_/__stop_ references retain the associated C identifier name sections (default). 947.Pp 948.It Cm nostart-stop-gc 949Let __start_/__stop_ references retain the associated C identifier name sections. 950.Pp 951.It Cm text 952Do not allow relocations against read-only segments. 953This is the default. 954.Pp 955.It Cm nobtcfi 956Create a 957.Dv PT_OPENBSD_NOBTCFI 958segment. 959.Pp 960.It Cm wxneeded 961Create a 962.Dv PT_OPENBSD_WXNEEDED 963segment. 964.El 965.El 966 967.Sh ENVIRONMENT VARIABLES 968.Bl -tag -width LC_CTYPE 969.It Ev LLD_REPRODUCE 970Create a reproduce tarball with the specified filename. If 971.Fl -reproduce 972is specified, 973.Fl -reproduce 974takes precedence. 975.It Ev LLD_VERSION 976ld.lld creates a section named 977.Cm .comment 978containing the LLD version string. The version string can be overridden by this environment variable, 979which is useful to eliminate differences in the binary caused by LLD version number differences. 980.El 981 982.Sh IMPLEMENTATION NOTES 983.Nm Ap s 984handing of archive files (those with a 985.Pa .a 986file extension) is different from traditional linkers used on Unix-like 987systems. 988.Pp 989Traditional linkers maintain a set of undefined symbols during linking. 990The linker processes each file in the order in which it appears on the 991command line, until the set of undefined symbols becomes empty. 992An object file is linked into the output object when it is encountered, 993with its undefined symbols added to the set. 994Upon encountering an archive file a traditional linker searches the objects 995contained therein, and processes those that satisfy symbols in the unresolved 996set. 997.Pp 998Handling mutually dependent archives may be awkward when using a traditional 999linker. 1000Archive files may have to be specified multiple times, or the special command 1001line options 1002.Fl -start-group 1003and 1004.Fl -end-group 1005may be used to have the linker loop over the files in the group until no new 1006symbols are added to the set. 1007.Pp 1008.Nm 1009records all symbols found in objects and archives as it iterates over 1010command line arguments. 1011When 1012.Nm 1013encounters an undefined symbol that can be resolved by an object file 1014contained in a previously processed archive file, it immediately extracts 1015and links it into the output object. 1016.Pp 1017With certain archive inputs 1018.Nm 1019may produce different results compared to traditional linkers. 1020In practice, large bodies of third party software have been linked with 1021.Nm 1022without material issues. 1023.Pp 1024The 1025.Fl -warn-backrefs 1026option may be used to identify a linker invocation that may be incompatible 1027with traditional Unix-like linker behavior. 1028