LD.LLD(1)
π ld.lld(1) β bestie edition π
okay so you opened the General Commands Manual and landed on ld.lld(1), which is the whole entire vibe of this page. buckle up, we're doing a linker tour π
β¨ NAME β¨
ld.lld β the ELF linker from the LLVM project. that's it. that's the name. iconic. π
π¦ SYNOPSIS π¦
ld.lld [options] objfile ...
π DESCRIPTION π
so like, what even is a linker? bestie. a linker takes one or more object, archive, and library files and smooshes them together into one output file β which could be an executable, a shared library, or honestly another object file. it relocates code and data from the input files and resolves symbol references between them. that's the whole job. matchmaking, basically. π«Ά
ld.lld is a drop-in replacement for the GNU BFD and gold linkers, no cap. it accepts most of the same command line arguments and linker scripts as GNU linkers do, so you can just swap it in and act natural. β¨
target support, and this is lowkey a lot: ld.lld currently supports i386, x86-64, ARM, AArch64, LoongArch, PowerPC32, PowerPC64, MIPS32, MIPS64, RISC-V, AMDGPU, Hexagon and SPARC V9 targets. also, 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. and the best part β 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. main character energy fr fr π
πΈ OPTIONS πΈ
many options have both a single-letter and a long form. when you're using the long form options β other than those beginning with the letter o β you may specify them using either one or two dashes preceding the option name. but long options beginning with o require two dashes, to avoid confusion with the -o path option. don't fight it, that's just the rules. π
--allow-multiple-definitionβ do not error if a symbol is defined multiple times. the first definition will be used. (yes, first one wins, we don't argue about it)--allow-shlib-undefinedβ allow unresolved references in shared libraries. this one is enabled by default when linking a shared library. π«Ά--apply-dynamic-relocsβ apply link-time values for dynamic relocations.--as-neededβ only setDT_NEEDEDfor shared libraries if they're actually used. minimal effort, minimal footprint β¨--auxiliary=valueβ set theDT_AUXILIARYfield 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 sets theDF_SYMBOLICflag. π-Bsymbolic-non-weakβ bind default visibility definedSTB_GLOBALsymbols locally for-shared.-Bsymbolic-functionsβ bind default visibility defined function symbols locally for-shared.-Bsymbolic-non-weak-functionsβ bind default visibility definedSTB_GLOBALfunction symbols locally for-shared.---be8β Write a Big Endian ELF File using BE8 format(AArch32 only) π (yes that's three dashes, i'm not gaslighting you)--build-id=valueβ generate a build ID note.valuemay be one offast,md5,sha1,tree,uuid,0xhex-string, andnone.treeis an alias forsha1. build-IDs of typefast,md5,sha1, andtreeare calculated from the object contents.fastis not intended to be cryptographically secure β it's giving "good enough" energy, not "protect my diary" energy. π₯--build-idβ synonym for--build-id=sha1.--call-graph-profile-sort=algorithmβ andalgorithmmay be:noneβ ignore call graph profile.hfsortβ use hfsort.cdsortβ use cdsort (default). π
--color-diagnostics=valueβ use colors in diagnostics.valuemay be one ofalways,auto, andnever.autoenables 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. the sections remain uncompressed if compressed content would be larger.valuemay be:noneβ no compression.zlibβ the default compression level is 1 (fastest) as the debug info usually compresses well at that level.zstdβ use the default compression level in zstd.
--compress-sections=section-glob={none,zlib,zstd}[:level]β compress output sections that match the glob and do not have theSHF_ALLOCflag. the matched sections remain uncompressed if compressed content would be larger. the compression level islevel(if specified) or a default speed-focused level. this is like a generalized--compress-debug-sections. π--crefβ output cross reference table. if-Mapis specified, print to the map file.--debug-namesβ generate a merged.debug_namessection.--default-script=file,-dT fileβ in the absence of--script, read this default linker script.--defsym=symbol=expressionβ define a symbol alias.expressionmay be another symbol or a linker script expression. for example,--defsym=foo=baror--defsym=foo=bar+0x100. cute, right?--demangleβ demangle symbol names. give those names their government name back π--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. hoarder behaviour, valid.--dynamic-linker=valueβ specify the dynamic linker to be used for a dynamically linked executable. this is recorded in an ELF segment of typePT_INTERP.--dynamic-list=fileβ similar to--export-dynamic-symbol-list. when creating a shared object, implies-Bsymbolicbut does not setDF_SYMBOLIC.--EBβ Select the big-endian format in theOUTPUT_FORMATcommand.--ELβ Select the little-endian format in theOUTPUT_FORMATcommand.--eh-frame-hdrβ request creation of.eh_frame_hdrsection andPT_GNU_EH_FRAMEsegment header.--emit-relocs,-qβ generate relocations in the output.--enable-new-dtagsβ enable new dynamic tags.--enable-non-contiguous-regionsβ spill input sections to later matching output sections to avoid memory region overflow.--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 zero indicates that there is no limit. (zero = infinite chaos, got it π)--error-unresolved-symbolsβ report unresolved symbols as errors.--error-handing-script=script_pathβ call scriptscript_pathupon some error, withtagas first argument, and an extra parameter as second argument. the script is expected to return0on success. any other value is considered a generic error.tagmay bemissing-libfollowed by the name of the missing library.undefined-symbolfollowed by the name of the undefined symbol. π like a little emergency hotline for your link--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β (executable) put matched non-local defined symbols to the dynamic symbol table. (shared object) references to matched non-localSTV_DEFAULTsymbols shouldn't be bound to definitions within the shared object even if they would otherwise be due to-Bsymbolic,-Bsymbolic-functionsor--dynamic-list. iykyk.--export-dynamic-symbol-list=fileβ read a list of dynamic symbol patterns fromfile. apply--export-dynamic-symbolon each pattern.--fatal-warningsβ treat warnings as errors. no chill mode. π--filter=value,-F valueβ set theDT_FILTERfield to the specified value.--fini=symbolβ specify a finalizer function.--force-group-allocationβ only meaningful for-r. section groups are discarded. if two section group members are placed to the same output section, combine their relocations as well.--format=input-format,-b input-formatβ specify the format of the inputs following this option.input-formatmay be one ofbinary,elf, anddefault.defaultis a synonym forelf.--gc-sectionsβ enable garbage collection of unused sections. spring cleaning for your binary π§--gdb-indexβ generate.gdb_indexsection.--hash-style=valueβ specify hash style.valuemay besysv,gnu, orboth.bothis the default.--helpβ print a help message. always there for you π«Ά--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. β οΈ unsafe, bestie, it says so right there--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. β οΈ same energy, be careful--image-base=valueβ set the base address tovalue.--init=symbolβ specify an initializer function.--keep-unique=symbolβ do not foldsymbolduring 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 tofile.--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 setDT_NEEDEDfor 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.interpsection.--no-fortran-commonβ okay so normally the linker goes digging through archive members looking for definitions that could override COMMON symbols, and this says nope, don't do that. π--no-gc-sectionsβ turns off the garbage collection of unused sections. Like, nothing gets swept away anymore. ποΈ--no-gnu-uniqueβ disablesSTB_GNU_UNIQUEsymbol binding. byeee π--no-merge-exidx-entriesβ stops the linker from merging.ARM.exidxentries. no grouping today bestie π--no-nmagicβ page align sections. that's it, that's the whole vibe π--no-omagicβ do not set the text data sections to be writable, and page align sections. π--no-relaxβ disables target-specific relaxations. and for x86-64 specifically, this kills theR_X86_64_GOTPCRELXandR_X86_64_REX_GOTPCRELXGOT optimization. no chill, no relax π€--no-rosegmentβ do not put read-only non-executable sections in their own segment. they gotta share, sorry π«Ά--undefined-versionβ do not report version scripts that refer to undefined symbols. like, let it slide β¨--no-undefinedβ report unresolved symbols even if the linker is creating a shared library. it's giving strict parent energy π--no-warn-mismatchβ do not reject unknown section types. live and let live ig πΈ--no-warn-symbol-orderingβ do not warn about problems with the symbol ordering file or the call graph profile. silence is golden π€«--no-warnings,-wβ suppress warnings AND cancel--fatal-warnings. two-for-one slay π--no-whole-archiveβ restores the default behavior of loading archive members. back to factory settings bestie π--no-pie,--no-pic-executableβ do not create a position independent executable. β¨--noinhibit-execβ retain the executable output file whenever it is still usable. keep it, it's still cute π--nostdlibβ only search directories specified on the command line. no default paths, we're going custom π¦-o pathβ write the output executable, library, or object topath. if you don't specify it,a.outis used as a default. main character output file fr fr π-Ovalueβ optimize output file size.valuemay be:0β disable string merging.1β enable string merging.2β enable string tail merging.
-O1 is the default. the way that 1 just quietly runs the whole show π
--oformat=formatβ specify the format for the output object file. the only supported format isbinary, which produces output with no ELF header. just so you know β it's the only one, no other options, periodt π--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 work π₯--opt-remarks-filename fileβ write optimization remarks in YAML format tofile. π--opt-remarks-passes pass-regexβ filter optimization remarks by only allowing the passes matchingpass-regex. only the chosen ones get through π--opt-remarks-with-hotnessβ include hotness information in the optimization remarks file. π₯ literally hotness, no cap--orphan-handling=modeβ control how orphan sections are handled. an orphan section is one not specifically mentioned in a linker script.modemay be:placeβ place orphan sections in suitable output sections.warnβ place orphan sections as forplaceand also report a warning.errorβ place orphan sections as forplaceand also report an error.
place is the default. taking care of the little orphan sections π₯Ίπ
--pack-dyn-relocs=formatβ pack dynamic relocations in the givenformat.formatmay be:noneβ do not pack. dynamic relocations are encoded inSHT_REL(A).androidβ pack dynamic relocations inSHT_ANDROID_REL(A).relrβ pack relative relocations inSHT_RELR, and the rest of dynamic relocations inSHT_REL(A).android+relrβ pack relative relocations inSHT_RELR, and the rest of dynamic relocations inSHT_ANDROID_REL(A).
none is the default. and heads up β if --use-android-relr-tags is specified, use SHT_ANDROID_RELR instead of SHT_RELR. π¦β¨
--pic-veneerβ always generate position independent thunks. π§--pie,--pic-executableβ create a position independent executable. the PIE of it all π₯§π--power10-stubs=modeβ whether to use Power10 instructions in call stubs forR_PPC64_REL24_NOTOCand TOC/NOTOC interworking.modemay be:yesβ (default) use.autoβ currently the same asyes.noβ don't use.
β‘ power10 energy, literally
--print-gc-sectionsβ list removed unused sections. snitch on the garbage ποΈπ--print-icf-sectionsβ list identical folded sections. twinning fr π―--print-mapβ print a link map to the standard output. πΊοΈ--print-archive-stats=fileβ write archive usage statistics to the specifiedfile. it prints the numbers of members and fetched members for each archive. receipts, bestie π§Ύ--push-stateβ save the current state of--as-needed,--static, and--whole-archive. bookmark it π--pop-stateβ restore the states saved by--push-state. un-bookmark it, we're back π«Ά---relax-gpβ enable global pointer relaxation for RISC-V. (yes, that's three dashes, that's literally how it's written, don't come for me) π--relocatable,-rβ create relocatable object file. π--remap-inputs=from-glob=to-fileβ input files matchingfrom-globare mapped toto-file. use/dev/nullto ignore an input file. bye felicia π--remap-inputs-file=fileβ remap input files based on patterns infile. each line in the remap file is of the formatfrom-glob=to-fileor a comment starting with#. π--reproduce=pathβ write a tar file topath, containing all the input files needed to reproduce the link, a text file calledresponse.txtcontaining the command line options and a text file calledversion.txtcontaining the output ofld.lld --version. the archive when unpacked can be used to re-run the linker with the same options and input files. time capsule core πβ¨--retain-symbols-file=fileβ retain only the symbols listed in thefile. keep the chosen ones, drop the rest π--rpath=value,-R valueβ add aDT_RUNPATHto the output. π£οΈ--rsp-quoting=valueβ quoting style for response files. the supported values arewindowsandposix. πͺπ§--script=file,-T fileβ read linker script fromfile. if multiple linker scripts are given, they are processed as if they were concatenated in the order they appeared on the command line. π--section-start=section=addressβ set address of section. π--shared,--Bsharableβ build a shared object. (yes,--Bsharable, that's the spelling, keep it moving) π«Ά--shuffle-sections=seedβ shuffle matched sections using the givenseedbefore mapping them to the output sections. if-1, reverse the section order. if0, use a random seed. π² no cap, it actually shuffles--soname=value,-h valueβ setDT_SONAMEtovalue. π·οΈ--sort-commonβ this option is ignored for GNU compatibility. it's just there for the vibes π--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. π―βοΈ--strip-all,-sβ strip all symbols. implies--strip-debug. βοΈ--strip-debug,-Sβ strip debugging information. πβοΈ--symbol-ordering-file=fileβ lay out sections in the order specified byfile. π--sysroot=valueβ set the system root. π³--target1-absβ interpretR_ARM_TARGET1asR_ARM_ABS32. π―--target1-relβ interpretR_ARM_TARGET1asR_ARM_REL32. π―--target2=typeβ interpretR_ARM_TARGET2astype, wheretypeis one ofrel,abs, orgot-rel. π―--Tbss=valueβ same as--section-startwith.bssas the sectionname. π--Tdata=valueβ same as--section-startwith.dataas the sectionname. π--Ttext=valueβ same as--section-startwith.textas the sectionname. π--thinlto-cache-dir=valueβ path to ThinLTO cached object file directory. π--thinlto-cache-policy=valueβ pruning policy for the ThinLTO cache. πΏβοΈ--thinlto-jobs=valueβ number of ThinLTO jobs. πΌ--threads=Nβ number of threads.all(default) means all of concurrent threads supported.1disables multi-threading. π§΅π§΅π§΅--fat-lto-objectsβ use the.llvm.ltosection, which contains LLVM bitcode, in fat LTO object files to perform LTO. π--no-fat-lto-objectsβ ignore the.llvm.ltosection in relocatable object files (default). π«π--time-traceβ record time trace. β±οΈ--time-trace-file=fileβ write time trace output tofile. β±οΈπ--time-trace-granularity=valueβ minimum time granularity (in microseconds) traced by time profiler. β±οΈπ--traceβ print the names of the input files. π£οΈ--trace-symbol=symbol,-y symbolβ trace references tosymbol. π--undefined=symbol,-u symbolβ ifsymbolis 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. the rescue mission π¦Έ--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. π--uniqueβ creates a separate output section for every orphan input section. everyone gets their own room πͺ--unresolved-symbols=valueβ determine how to handle unresolved symbols. β--use-android-relr-tagsβ useSHT_ANDROID_RELR/DT_ANDROID_RELR*tags instead ofSHT_RELR/DT_RELR*. π€-v,-Vβ display the version number and proceed with linking if object files are specified. π·οΈ--versionβ display the version number and exit. πͺ--verboseβ verbose mode. it's giving yapper π£οΈπ¬--version-script=fileβ read version script fromfile. π--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. β οΈ--warn-backrefs-exclude=globβ glob describing an archive (or an object file within--start-lib) which should be ignored for--warn-backrefs. π--warn-commonβ warn about duplicate common symbols. β οΈπ―--warn-ifunc-textrelβ okay so this one warns about using ifunc symbols in conjunction with text relocations. Older versions of the glibc library (2.28and 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 a segmentation fault when the instruction pointer reaches an ifunc symbol. Use-warn-ifunc-textrelto 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 inldandgoldlinkers, and may be removed in the future.--warn-unresolved-symbolsβ Report unresolved symbols as warnings. periodt.--whole-archiveβ Force load of all members in a static library. the whole squad, no skips.--why-extract=fileβ Print to a file about why archive members are extracted. receipts, bestie.--wrap=symbolβ Redirectsymbolreferences to__wrap_symbol, and__real_symbolreferences tosymbol. the way this swaps your references is lowkey iconic.-z optionβ Linker option extensions. the little sub-menu of chaos:dead-reloc-in-nonalloc=section_glob=valueβ Resolve a relocation in a matched non-SHF_ALLOCsection referencing a discarded symbol tovalue. 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. vibe check: globs.execstackβ Make the main stack executable. Stack permissions are recorded in thePT_GNU_STACKsegment.bti-report=[none|warning|error]β Specify how to report the missingGNU_PROPERTY_AARCH64_FEATURE_1_BTIproperty.noneis the default, linker will not report the missing property otherwise will be reported as a warning or an error. ngl, default is chill.cet-report=[none|warning|error]β Specify how to report the missingGNU_PROPERTY_X86_FEATURE_1_IBTorGNU_PROPERTY_X86_FEATURE_1_SHSTKproperties.noneis the default, linker will not report the missing property otherwise will be reported as a warning or an error.pauth-report=[none|warning|error]β Specify how to report the missingGNU_PROPERTY_AARCH64_FEATURE_PAUTHproperty.noneis the default, linker will not report the missing property otherwise will be reported as a warning or an error.force-btiβ Force enable AArch64 BTI instruction in PLT, warn if Input ELF file does not haveGNU_PROPERTY_AARCH64_FEATURE_1_BTIproperty. no cap.force-ibtβ Force enable Intel Indirect Branch Tracking in PLT, warn if an input ELF file does not haveGNU_PROPERTY_X86_FEATURE_1_IBTproperty.globalβ Sets theDF_1_GLOBALflag in the DYNAMIC section. Different loaders can decide how to handle this flag on their own.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 notextoption. experimental, so don't @ me.initfirstβ Sets theDF_1_INITFIRSTflag to indicate the module should be initialized first.interposeβ Set theDF_1_INTERPOSEflag to indicate to the runtime linker that the object is an interposer. During symbol resolution interposers are searched after the application but before other dependencies.lrodata-after-bssβ Place.lrodataafter.bss.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. first one wins, periodt.nocombrelocβ Disable combining and sorting multiple relocation sections.nocopyrelocβ Disable the creation of copy relocations.nodefaultlibβ Set theDF_1_NODEFLIBflag to indicate that default library search paths should be ignored.nodeleteβ Set theDF_1_NODELETEflag to indicate that the object cannot be unloaded from a process.nodlopenβ Set theDF_1_NOOPENflag to indicate that the object may not be opened bydlopen(3).nognustackβ Do not emit thePT_GNU_STACKsegment. bye segment.norelroβ Do not indicate that portions of the object should be mapped read-only after initial relocation processing. The object will omit thePT_GNU_RELROsegment.notextβ Allow relocations against read-only segments. Sets theDT_TEXTRELflag in the DYNAMIC section.nowβ Set theDF_BIND_NOWflag 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. on demand is the default vibe.originβ Set theDF_ORIGINflag to indicate that the object requires$ORIGINprocessing. iykyk.pac-pltβ AArch64 only, use pointer authentication in PLT. AArch64 only, bestie.pack-relative-relocsβ Similar to-pack-dyn-relocs=relr, but synthesizes theGLIBC_ABI_DT_RELRversion dependency if there is aGLIBC_2.*version dependency.glibc ld.sorejects loading a dynamically linked object without theGLIBC_ABI_DT_RELRversion dependency. glibc said no entry without the 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 forCVE-2017-5715. CVE-2017-5715 said not today.rodynamicβ Make the.dynamicsection read-only. TheDT_DEBUGtag will not be emitted.separate-loadable-segments,separate-code,noseparate-codeβ Specify whether two adjacentPT_LOADsegments are allowed to overlap in pages.noseparate-code(default) allows overlap.separate-codeallows overlap between two executable segments, or two non-executable segments.separate-loadable-segmentsdisallows overlap. pages are fighting.shstkβ x86 only, use shadow stack. x86 only, shadow stack slay.stack-size=sizeβ Set the main thread's stack size tosize. The stack size is recorded as the size of thesize.PT_GNU_STACKprogram segment. yes, that's the wording, bestie.start-stop-gcβ Don't let__start_/__stop_references retain the associated C identifier name sections (default). default behavior, no notes.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. this is the default, periodt.wxneededβ Create aPT_OPENBSD_WXNEEDEDsegment.
β¨ ENVIRONMENT VARIABLES β¨
LLD_REPRODUCEβ Create a reproduce tarball with the specified filename. If--reproduceis specified,--reproducetakes precedence. tarball time, bestie.LLD_VERSIONβld.lldcreates a section named.commentcontaining 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. version string but make it customizable.
π IMPLEMENTATION NOTES π
okay so this is the tea.
ld.lld's handing of archive files (those with a .a file extension) is different from traditional linkers used on Unix-like systems. (yes, the source says handing β we're keeping it, it's iconic. π
)
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.
This page is from Debian, dated Jul 25, 2023, and it's LD.LLD(1) β go link something iconic. πβ¨
π¦ where this page comes from
- debian bookworm: lld-19 1:19.1.7-3~deb12u1 Β· APACHE-2-LLVM-EXCEPTIONS
- debian trixie: lld-19 1:19.1.7-3+b1 Β· APACHE-2-LLVM-EXCEPTIONS
- epel 10: lld19 19.1.7-15.el10_1 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- epel 9: lld19 19.1.7-15.el9 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 43: lld19 19.1.7-13.fc43 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 43: lld19 19.1.7-16.fc43 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: lld19 19.1.7-18.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- ubuntu noble: lld-19 1:19.1.1-1ubuntu1~24.04.2 Β· APACHE-2-LLVM-EXCEPTIONS
- ubuntu questing: lld-19 1:19.1.7-6ubuntu3
- ubuntu resolute: lld-19 1:19.1.7-20ubuntu4 Β· APACHE-2-LLVM-EXCEPTIONS
- ubuntu stonking: lld-19 1:19.1.7-20ubuntu8 Β· APACHE-2-LLVM-EXCEPTIONS
- π the page's license: Apache-2.0 WITH LLVM-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms