LD.LLD(1)

🌸 NAME 🌸

ld.lld β€” ELF linker from the LLVM project πŸ’–

πŸ¦‹ SYNOPSIS πŸ¦‹

ld.lld [options] objfile ...

πŸ’– DESCRIPTION πŸ’–

okay bestie, so a linker takes one or more object, archive, and library files, and smooshes them into one output file (which could be an executable, a shared library, or another object file). It relocates code and data from the input files and resolves symbol references between them. iconic behavior, honestly.

ld.lld is a drop-in replacement for the GNU BFD and gold linkers. It accepts most of the same command line arguments and linker scripts as GNU linkers. no cap.

ld.lld currently supports i386, x86-64, ARM, AArch64, LoongArch, PowerPC32, PowerPC64, MIPS32, MIPS64, RISC-V, AMDGPU, Hexagon, and SPARC V9 targets. ld.lld acts as a Microsoft link.exe-compatible linker if invoked as lld-link, and as macOS's ld if invoked as ld.ld64. All these targets are always supported however ld.lld was built, so you can always use ld.lld as a native linker as well as a cross linker. slay.

πŸ‘‘ OPTIONS πŸ‘‘

Many options have both a single-letter and long form. When using the long form options other than those beginning with the letter o, you can specify them using either one or two dashes before the option name. Long options beginning with o require two dashes to avoid confusion with the -o path option. periodt.

  • --allow-multiple-definition β€” bestie, if a symbol gets defined more than once, don't error out β€” the first definition is the one that gets used. periodt.
  • --allow-shlib-undefined β€” Allow unresolved references in shared libraries. This option is enabled by default when linking a shared library. so if that's your vibe, it's already on.
  • --apply-dynamic-relocs β€” Apply link-time values for dynamic relocations. slay.
  • --as-needed β€” Only set DT_NEEDED for shared libraries if they're actually used. iykyk.
  • --auxiliary=value β€” Set the DT_AUXILIARY field to the specified name.
  • --Bdynamic, --dy β€” Link against shared libraries. πŸ’…
  • --Bstatic, --static, --dn β€” Do not link against shared libraries.
  • -Bno-symbolic β€” Don't bind default visibility defined symbols locally for -shared (this is the default).
  • -Bsymbolic β€” Bind default visibility defined symbols locally for -shared. Also set the DF_SYMBOLIC flag.
  • -Bsymbolic-functions β€” Bind default visibility defined function symbols locally for -shared.
  • -Bsymbolic-non-weak-functions β€” Bind default visibility defined STB_GLOBAL function symbols locally for -shared.
  • ---be8 β€” Write a Big Endian ELF File using BE8 format(AArch32 only).
  • --build-id=value β€” Generate a build ID note. value may be one of fast, md5, sha1, tree, uuid, 0xhex-string, and none. tree is an alias for sha1. Build-IDs of type fast, md5, sha1, and tree are calculated from the object contents. And heads up: fast is not intended to be cryptographically secure. no cap.
  • --build-id β€” Synonym for --build-id=fast.
  • --color-diagnostics=value β€” Use colors in diagnostics. value may be one of always, auto, and never. auto enables color if and only if output is to a terminal.
  • --color-diagnostics β€” Alias for --color-diagnostics=auto.
  • --compress-debug-sections=value β€” Compress DWARF debug sections. value may be:
    • none β€” No compression. we're just vibing.
    • zlib β€” The default compression level is 1 (fastest) as the debug info usually compresses well at that level. If you want to compress it more, you can specify -O2 to set the compression level to 6.
    • zstd β€” The compression level is 5.
  • --cref β€” Output cross reference table. If -Map is specified, print to the map file.
  • --defsym=symbol=expression β€” Define a symbol alias. expression may be another symbol or a linker script expression. For example, --defsym=foo=bar or --defsym=foo=bar+0x100.
  • --demangle β€” Demangle symbol names so they're actually readable, bestie.
  • --disable-new-dtags β€” Disable new dynamic tags.
  • --discard-all, -x β€” Delete all local symbols.
  • --discard-locals, -X β€” Delete temporary local symbols.
  • --discard-none β€” Keep all symbols in the symbol table. no cap.
  • --dynamic-linker=value β€” Specify the dynamic linker to be used for a dynamically linked executable. This is recorded in an ELF segment of type PT_INTERP.
  • --dynamic-list=file β€” Similar to --export-dynamic-symbol-list. When creating a shared object, implies -Bsymbolic but does not set DF_SYMBOLIC.
  • --EB β€” Select the big-endian format in the OUTPUT_FORMAT command.
  • --EL β€” Select the little-endian format in the OUTPUT_FORMAT command.
  • --eh-frame-hdr β€” Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header.
  • --emit-relocs, -q β€” Generate relocations in the output.
  • --enable-new-dtags β€” Enable new dynamic tags.
  • --end-lib β€” End a grouping of objects that should be treated as if they were together in an archive.
  • --entry=entry β€” Name of entry point symbol.
  • --error-limit=value β€” Maximum number of errors to emit before stopping. A value of 0 indicates that there is no limit. go off.
  • --error-unresolved-symbols β€” Report unresolved symbols as errors.
  • --error-handing-script=script_path β€” Call script script_path upon some error, with tag as first argument, and an extra parameter as second argument. The script is expected to return 0 on success. Any other value is considered a generic error. tag may be missing-lib followed by the name of the missing library, or undefined-symbol followed by the name of the undefined symbol.
  • --execute-only β€” Mark executable sections unreadable. This option is currently only supported on AArch64.
  • --exclude-libs=value β€” Exclude static libraries from automatic export.
  • --export-dynamic, -E β€” Put symbols in the dynamic symbol table.
  • --export-dynamic-symbol=glob β€” For an executable: put matched non-local defined symbols to the dynamic symbol table. For a 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 -Bsymbolic, -Bsymbolic-functions or --dynamic-list.
  • --export-dynamic-symbol-list=file β€” Read a list of dynamic symbol patterns from file. Apply --export-dynamic-symbol on each pattern.
  • --fatal-warnings β€” Treat warnings as errors. no mercy.
  • --filter=value, -F value β€” Set the DT_FILTER field to the specified value.
  • --fini=symbol β€” Specify a finalizer function.
  • --format=input-format, -b input-format β€” Specify the format of the inputs following this option. input-format may be one of binary, elf, and default. default is a synonym for elf.
  • --gc-sections β€” Enable garbage collection of unused sections. bye, dead code.
  • --gdb-index β€” Generate .gdb_index section.
  • --hash-style=value β€” Specify hash style. value may be sysv, gnu, or both. both is the default.
  • --help β€” Print a help message.
  • --icf=all β€” Enable identical code folding.
  • --icf=safe β€” Enable safe identical code folding.
  • --icf=none β€” Disable identical code folding.
  • --ignore-data-address-equality β€” Ignore address equality of data. C/C++ requires each data to have a unique address. This option allows lld to do unsafe optimization that breaks the requirement: create copies of read-only data or merge two or more read-only data that happen to have the same value.
  • --ignore-function-address-equality β€” Ignore address equality of functions. This option allows non-PIC calls to a function with non-default visibility in a shared object. The function may have different addresses within the executable and within the shared object.
  • --image-base=value β€” Set the base address to value.
  • --init=symbol β€” Specify an initializer function.
  • --keep-unique=symbol β€” Do not fold symbol during ICF.
  • -l libName, --library=libName β€” Root name of library to use.
  • -L dir, --library-path=dir β€” Add a directory to the library search path.
  • --lto-aa-pipeline=value β€” AA pipeline to run during LTO. Used in conjunction with --lto-newpm-passes.
  • --lto-newpm-passes=value β€” Passes to run during LTO.
  • --lto-Oopt-level β€” Optimization level for LTO.
  • --lto-partitions=value β€” Number of LTO codegen partitions.
  • -m value β€” Set target emulation.
  • --Map=file, -M file β€” Print a link map to file.
  • --nmagic, -n β€” Do not page align sections, link against static libraries.
  • --no-allow-shlib-undefined β€” Do not allow unresolved references in shared libraries. This option is enabled by default when linking an executable.
  • --no-as-needed β€” Always set DT_NEEDED for shared libraries.
  • --no-color-diagnostics β€” Do not use colors in diagnostics.
  • --no-demangle β€” Do not demangle symbol names.
  • --no-dynamic-linker β€” Inhibit output of an .interp section.
  • --no-fortran-common β€” Do not search archive members for definitions to override COMMON symbols.
  • --no-gc-sections β€” Disable garbage collection of unused sections.
  • --no-gnu-unique β€” Disable STB_GNU_UNIQUE symbol binding.
  • --no-merge-exidx-entries β€” Disable merging .ARM.exidx entries.
  • --no-nmagic β€” Page align sections.
  • --no-omagic β€” Do not set the text data sections to be writable, page align sections.
  • --no-relax β€” Disable target-specific relaxations. For x86-64 this disables R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization.
  • --no-rosegment β€” Do not put read-only non-executable sections in their own segment.
  • --undefined-version β€” Do not report version scripts that refer to undefined symbols.
  • --no-undefined β€” Report unresolved symbols even if the linker is creating a shared library.
  • --no-warn-symbol-ordering β€” Do not warn about problems with the symbol ordering file or call graph profile.
  • --no-warnings, -w β€” Suppress warnings and cancel --fatal-warnings.
  • --no-whole-archive β€” Restores the default behavior of loading archive members.
  • --no-pie, --no-pic-executable β€” bestie, we are NOT making a position independent executable. that's it, that's the whole vibe πŸ’…
  • --noinhibit-exec β€” keep the executable output file whenever it's still usable. stubborn queen behavior, she stays ✨
  • --nostdlib β€” only search the directories you specified on the command line. nowhere else, no sneaky extras, no cap.
  • -o path β€” write the output executable, library, or object to path. if you don't say anything, a.out is the default (the classic default, the og, the main character of "i forgot to name my binary" πŸ™ˆ).
  • -Ovalue β€” optimize the output file size. value can be:
    • 0 β€” disable string merging.
    • 1 β€” enable string merging.
    • 2 β€” enable string tail merging. and if --compress-debug-sections is given, compress debug sections at compression level 6 instead of 1.

-O1 is the default. so if you do nothing, you get level 1 energy πŸŽ€

  • --oformat=format β€” specify the format for the output object file. the only supported format is binary, which produces output with no ELF header. that's it, that's the list, don't @ me πŸ¦‹
  • --omagic, -N β€” set the text and data sections to be readable AND writable, do not page align sections, and link against static libraries. chaotic but make it functional πŸ’€
  • --opt-remarks-filename file β€” write optimization remarks in YAML format to file. receipts, but for your optimizer ✨
  • --opt-remarks-passes pass-regex β€” filter optimization remarks by only allowing the passes matching pass-regex. picky, and honestly? valid.
  • --opt-remarks-with-hotness β€” include hotness information in the optimization remarks file. now we know which parts are serving cunt and which are not πŸ”₯
  • --orphan-handling=mode β€” control how orphan sections are handled. an orphan section is one that's not specifically mentioned in a linker script (yes, they're literally orphans, be nice to them 😭). mode may be:
    • place β€” place orphan sections in suitable output sections.
    • warn β€” place orphan sections as for place and also report a warning.
    • error β€” place orphan sections as for place and also report an error.

place is the default. the gentle option, the soft-launch option, the "we don't do confrontation" option 🫢

  • --pack-dyn-relocs=format β€” pack dynamic relocations in the given format. format may be:
    • none β€” do not pack. dynamic relocations are encoded in SHT_REL(A).
    • android β€” pack dynamic relocations in SHT_ANDROID_REL(A).
    • relr β€” pack relative relocations in SHT_RELR, and the rest of dynamic relocations in SHT_REL(A).
    • android+relr β€” pack relative relocations in SHT_RELR, and the rest of dynamic relocations in SHT_ANDROID_REL(A).

none is the default. and if --use-android-relr-tags is specified, use SHT_ANDROID_RELR instead of SHT_RELR. iykyk 🌸

  • --pic-veneer β€” always generate position independent thunks. always. no exceptions, periodt πŸ’…
  • --pie, --pic-executable β€” create a position independent executable. the flip side of that --no-pie moment up there ⭐
  • --power10-stubs=mode β€” whether to use Power10 instructions in call stubs for R_PPC64_REL24_NOTOC and TOC/NOTOC interworking. mode may be:
    • yes β€” (default) Use.
    • auto β€” currently the same as yes.
    • no β€” Don't use.

the classic yes/auto/no trio, and auto is literally just yes wearing a little disguise πŸ™ˆ

  • --print-gc-sections β€” list removed unused sections. gossip time: here's everything we threw out πŸ—‘οΈβœ¨
  • --print-icf-sections β€” list identical folded sections. "you two are the same person actually" πŸ’€
  • --print-map β€” print a link map to the standard output. the full map, the whole layout, the entire diagram, slay πŸ—ΊοΈ
  • --print-archive-stats=file β€” write archive usage statistics to the specified file. it prints the numbers of members and fetched members for each archive. stats bestie, we love stats πŸ“Š
  • --push-state β€” save the current state of --as-needed, --static, and --whole-archive. it's a save point, like a game πŸŽ€
  • --pop-state β€” restore the states saved by --push-state. and we're back πŸ¦‹
  • ---relax-gp β€” enable global pointer relaxation for RISC-V. yes, it really does have three dashes up there, that's not a typo on my part, that's just how it is 😭
  • --relocatable, -r β€” create relocatable object file. not an executable, not a library, an object file. she's a work in progress and that's fine πŸ’œ
  • --remap-inputs=from-glob=to-file β€” input files matching from-glob are mapped to to-file. use /dev/null to ignore an input file. the "you're going to the void now" move 🌈
  • --remap-inputs-file=file β€” remap input files based on patterns in file. each line in the remap file is of the format from-glob=to-file or a comment starting with #. so you can leave little notes for yourself, cute πŸ“
  • --reproduce=path β€” write a tar file to path, containing all the input files needed to reproduce the link, a text file called response.txt containing the command line options and a text file called version.txt containing the output of ld.lld --version. the archive, when unpacked, can be used to re-run the linker with the same options and input files. it's a time capsule fr fr πŸ•°οΈβœ¨
  • --retain-symbols-file=file β€” retain only the symbols listed in the file. everyone else, pack it up πŸ‘‘
  • --rpath=value, -R value β€” add a DT_RUNPATH to the output.
  • --rsp-quoting=value β€” quoting style for response files. the supported values are windows and posix. pick your dialect πŸ’…
  • --script=file, -T file β€” read linker script from file. if multiple linker scripts are given, they are processed as if they were concatenated in the order they appeared on the command line. so order matters, bestie, don't shuffle them 🌸
  • --section-start=section=address β€” set address of section. put it exactly where you want it, main character placement energy ⭐
  • --shared, --Bsharable β€” build a shared object. (yes, it's spelled --Bsharable in here, i don't make the rules πŸ™ˆ)
  • --shuffle-sections=seed β€” shuffle matched sections using the given seed before mapping them to the output sections. if -1, reverse the section order. if 0, use a random seed. it's a playlist on shuffle and honestly sometimes that's the vibe πŸ”€
  • --soname=value, -h value β€” set DT_SONAME to value. give your library a name, a legacy, a brand πŸ’–
  • --sort-common β€” this option is ignored for GNU compatibility. she's here, she's present, she does absolutely nothing. iconic behavior actually πŸ’€
  • --sort-section=value β€” specifies sections sorting rule when linkerscript is used.
  • --start-lib β€” start a grouping of objects that should be treated as if they were together in an archive. assemble the squad 🫢
  • --strip-all, -s β€” strip all symbols. implies --strip-debug. no symbols, no baggage, we're traveling light ✨
  • --strip-debug, -S β€” strip debugging information. the debug info? gone. not with us anymore πŸ¦‹
  • --symbol-ordering-file=file β€” lay out sections in the order specified by file. you're the director, the sections are your cast 🎬
  • --sysroot=value β€” set the system root.
  • --target1-abs β€” interpret R_ARM_TARGET1 as R_ARM_ABS32.
  • --target1-rel β€” interpret R_ARM_TARGET1 as R_ARM_REL32.
  • --target2=type β€” interpret R_ARM_TARGET2 as type, where type is one of rel, abs, or got-rel.
  • --Tbss=value β€” same as --section-start with .bss as the sectionname.
  • --Tdata=value β€” same as --section-start with .data as the sectionname.
  • --Ttext=value β€” same as --section-start with .text as the sectionname.
  • --thinlto-cache-dir=value β€” path to ThinLTO cached object file directory. where the cached goodies live πŸ“
  • --thinlto-cache-policy=value β€” pruning policy for the ThinLTO cache. when to declutter, when to let it go 🧹
  • --thinlto-jobs=value β€” number of ThinLTO jobs. how many little workers we're spawning πŸ’…
  • --threads=N β€” number of threads. all (default) means all of concurrent threads supported. 1 disables multi-threading. so all is the default, 1 is the introvert mode 🐒
  • --time-trace β€” record time trace. let's see where the time actually went ⏱️
  • --time-trace-file=file β€” write time trace output to file.
  • --time-trace-granularity=value β€” minimum time granularity (in microseconds) traced by time profiler. tiny little slices of time, measured in microseconds, we're being precise bestie πŸ”
  • --trace β€” print the names of the input files. roll call! everyone say present πŸ“£
  • --trace-symbol=symbol, -y symbol β€” trace references to symbol. follow that symbol around, see where it goes πŸ•΅οΈ
  • --undefined=symbol, -u symbol β€” if symbol is not defined after symbol resolution, and there's a static library that contains an object file defining the symbol, load the member to include the object file in the output file. like a summoning spell for a missing symbol ✨
  • --undefined-glob=pattern β€” synonym for --undefined, except that it takes a glob pattern. in a glob pattern, * matches zero or more characters, ? matches any single character, and [...] matches the characters within brackets. all symbols that match a given pattern are handled as if they were given as arguments of --undefined. bulk summoning, we love efficiency 🌈
  • --unique β€” creates a separate output section for every orphan input section. every orphan gets their own room, no roommates, no sharing πŸ’…
  • --unresolved-symbols=value β€” determine how to handle unresolved symbols. (yes that's the whole description, take it up with the manual 😭)
  • --use-android-relr-tags β€” use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*.
  • -v, -V β€” display the version number and proceed with linking if object files are specified. so she tells you her version AND keeps working. multitasking queen πŸ‘‘
  • --version β€” display the version number and exit. this one tells you and then immediately leaves. no further questions, goodbye πŸ’€
  • --verbose β€” verbose mode. she will not be quiet. she will tell you everything. and honestly? sometimes you need that πŸ—£οΈ
  • --version-script=file β€” read version script from file.
  • --warn-backrefs β€” warn about reverse or cyclic dependencies to or between static archives. this can be used to ensure linker invocation remains compatible with traditional Unix-like linkers. it's the "hey, are we still doing this the classic way" check πŸŽ€
  • --warn-backrefs-exclude=glob β€” glob describing an archive (or an object file within --start-lib) which should be ignored for --warn-backrefs. the exception list, the "not you though" list πŸ™ˆ
  • --warn-common β€” warn about duplicate common symbols. two commons walk into a bar and the linker has opinions πŸ’€
  • --warn-ifunc-textrel β€” warn about using ifunc symbols in conjunction with text relocations. older versions of glibc library (2.28 and earlier) has a bug that causes the segment that includes ifunc symbols to be marked as not executable when they are relocated. as a result, although the program compiles and links successfully, it gives segmentation fault when the instruction pointer reaches an ifunc symbol. use -warn-ifunc-textrel to let lld give a warning, if the code may include ifunc symbols, may do text relocations and be linked with an older glibc version. otherwise, there is no need to use it, as the default value does not give a warning. this flag has been introduced in late 2018, has no counter part in ld and gold linkers, and may be removed in the future.
bestie this one is a whole paragraph and it's important: it's a bug in older glibc (2.28 and earlier), it compiles and links fine and then segfaults when the instruction pointer hits an ifunc symbol, and this flag is the warning. note that the flag has no counter part in ld and gold linkers, and it may be removed in the future. so don't get too attached 😭
  • --warn-unresolved-symbols β€” report unresolved symbols as warnings. not errors. warnings. we're being chill about it today 🫢
  • --whole-archive β€” force load of all members in a static library. everyone comes to the party, no rsvp required πŸŽ‰
  • --why-extract=file β€” print to a file about why archive members are extracted. finally, an explanation. the "why are you here" document πŸ“„βœ¨
  • --wrap=symbol β€” redirect symbol references to __wrap_symbol and __real_symbol references to symbol. it's a little switcheroo, a name swap, a costume change 🎭
  • -z option β€” linker option extensions. the -z family, the extended universe 🌌
    • dead-reloc-in-nonalloc=section_glob=value β€” resolve a relocation in a matched non-SHF_ALLOC section referencing a discarded symbol to value. accepts globs; in the event of a section matching more than one option, the last option takes precedence. an order of least specific to most specific match is recommended. so: globs in, last one wins, and go from vague to specific, bestie 🌸
    • execstack β€” make the main stack executable. stack permissions are recorded in the PT_GNU_STACK segment.

  • bti-report=[none|warning|error] β€” tells the linker how to snitch on a missing GNU_PROPERTY_AARCH64_FEATURE_1_BTI property. none is the default, so the linker just stays quiet about the missing property; otherwise it gets reported as a warning or an error.
  • cet-report=[none|warning|error] β€” same energy, but for missing GNU_PROPERTY_X86_FEATURE_1_IBT or GNU_PROPERTY_X86_FEATURE_1_SHSTK properties. none is default, no reporting; otherwise warning or error.
  • force-bti β€” force-enable AArch64 BTI instruction in PLT, and warn if an input ELF file doesn’t have the GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
  • force-ibt β€” force-enable Intel Indirect Branch Tracking in PLT, and warn if an input ELF file doesn’t have the GNU_PROPERTY_X86_FEATURE_1_IBT property.
  • global β€” sets the DF_1_GLOBAL flag in the DYNAMIC section. Different loaders can decide how to handle this flag on their own, so it’s giving β€œyou do you” energy.
  • ifunc-noplt β€” do not emit PLT entries for ifunc symbols. Instead, emit text relocations referencing the resolver. This is an experimental optimization and only suitable for standalone environments where text relocations do not have the usual drawbacks. This option must be combined with the -z notext option.
  • initfirst β€” sets the DF_1_INITFIRST flag to indicate the module should be initialized first. main character behavior, honestly.
  • interpose β€” set the DF_1_INTERPOSE flag to tell the runtime linker that the object is an interposer. During symbol resolution, interposers are searched after the application but before other dependencies.
  • muldefs β€” do not error if a symbol is defined multiple times. The first definition will be used. This is a synonym for --allow-multiple-definition.
  • nocombreloc β€” disable combining and sorting multiple relocation sections.
  • nocopyreloc β€” disable the creation of copy relocations.
  • nodefaultlib β€” set the DF_1_NODEFLIB flag to indicate that default library search paths should be ignored.
  • nodelete β€” set the DF_1_NODELETE flag to indicate that the object cannot be unloaded from a process.
  • nodlopen β€” set the DF_1_NOOPEN flag to indicate that the object may not be opened by dlopen(3).
  • nognustack β€” do not emit the PT_GNU_STACK segment.
  • norelro β€” do not indicate that portions of the object should be mapped read-only after initial relocation processing. The object will omit the PT_GNU_RELRO segment.
  • notext β€” allow relocations against read-only segments. Sets the DT_TEXTREL flag in the DYNAMIC section.
  • now β€” set the DF_BIND_NOW flag to indicate that the run-time loader should perform all relocation processing as part of object initialization. By default, relocations may be performed on demand.
  • origin β€” set the DF_ORIGIN flag to indicate that the object requires $ORIGIN processing.
  • pac-plt β€” AArch64 only, use pointer authentication in PLT.
  • pack-relative-relocs β€” similar to -pack-dyn-relocs=relr, but synthesizes the GLIBC_ABI_DT_RELR version dependency if there is a GLIBC_2.* version dependency. glibc ld.so rejects loading a dynamically linked object without the GLIBC_ABI_DT_RELR version dependency.
  • rel β€” use REL format for dynamic relocations.
  • rela β€” use RELA format for dynamic relocations.
  • retpolineplt β€” emit retpoline format PLT entries as a mitigation for CVE-2017-5715.
  • rodynamic β€” make the .dynamic section read-only. The DT_DEBUG tag will not be emitted.
  • separate-loadable-segments β€” one of the three knobs for whether two adjacent PT_LOAD segments are allowed to overlap in pages. separate-loadable-segments disallows overlap.
  • separate-code β€” allows overlap between two executable segments, or two non-executable segments.
  • noseparate-code β€” this is the default, and it allows overlap.
  • shstk β€” x86 only, use shadow stack.
  • stack-size=size β€” set the main thread’s stack size to size. The stack size is recorded as the size of the PT_GNU_STACK program segment.
  • start-stop-gc β€” don’t let __start_/__stop_ references retain the associated C identifier name sections (default).
  • nostart-stop-gc β€” let __start_/__stop_ references retain the associated C identifier name sections.
  • text β€” do not allow relocations against read-only segments. This is the default.
  • wxneeded β€” create a PT_OPENBSD_WXNEEDED segment.

🌈 ENVIRONMENT VARIABLES 🌈

  • LLD_REPRODUCE β€” create a reproduce tarball with the specified filename. If --reproduce is specified, --reproduce takes precedence.
  • LLD_VERSION β€” ld.lld creates a section named .comment containing the LLD version string. The version string can be overridden by this environment variable, which is useful to eliminate differences in the binary caused by LLD version number differences.

πŸ’– IMPLEMENTATION NOTES πŸ’–

ok so ld.lld’s handling of archive files β€” the ones with a .a file extension β€” is different from traditional linkers used on Unix-like systems. Not bad different, just different bestie.

Traditional linkers maintain a set of undefined symbols during linking. The linker processes each file in the order in which it appears on the command line, until the set of undefined symbols becomes empty. An object file is linked into the output object when it is encountered, with its undefined symbols added to the set. Upon encountering an archive file, a traditional linker searches the objects contained therein, and processes those that satisfy symbols in the unresolved set.

Handling mutually dependent archives may be awkward when using a traditional linker. Archive files may have to be specified multiple times, or the special command line options --start-group and --end-group may be used to have the linker loop over the files in the group until no new symbols are added to the set.

ld.lld records all symbols found in objects and archives as it iterates over command line arguments. When ld.lld encounters an undefined symbol that can be resolved by an object file contained in a previously processed archive file, it immediately extracts and links it into the output object.

With certain archive inputs, ld.lld may produce different results compared to traditional linkers. In practice, large bodies of third party software have been linked with ld.lld without material issues.

The --warn-backrefs option may be used to identify a linker invocation that may be incompatible with traditional Unix-like linker behavior.


Debian, Jul 25, 2023, LD.LLD(1) β€” that’s the source, the date, and the page name, and honestly? iconic. πŸ’…βœ¨

πŸ“¦ where this page comes from