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