GOLD(1)
πΈ NAME πΈ
okay bestie, gather round, because today we're talking about gold β the GNU ELF linker π. That's it, that's the whole name. It links your ELF files, it's GNU's take on the job, and it's lowkey the main character of your build pipeline. No cap.
π¦ SYNOPSIS π¦
the vibe check of how you actually invoke her:
ld.gold [options] file...
so it's just ld.gold, then a bunch of options, then a bunch of files. That's the whole shape of it, periodt β¨.
π OPTIONS π
okay this is the big one, the iconique list, so let's go one by one, no skipping, we keep EVERY detail fr fr π«Ά
--helpβ shows you the usage info. your "wait what do I type" button π-v,--versionβ spills the version info. iconique behavior honestly.-Vβ version and target info. she's giving extra π--add-neededβ not supported, bestie. don't come for her.--no-add-neededβ does not copyDT_NEEDEDtags from shared libraries (this is the default).--allow-multiple-definitionβ lets symbols be defined multiple times. chaos, but consensual.--no-allow-multiple-definitionβ does not allow multiple definitions (the default).--allow-shlib-undefinedβ allows unresolved references in shared libraries. live a little β¨--no-allow-shlib-undefinedβ does not allow unresolved references in shared libraries (the default).--apply-dynamic-relocsβ applies link-time values for dynamic relocations (the default).--no-apply-dynamic-relocsβ (aarch64 only) does not apply link-time values for dynamic relocations.--as-neededβ usesDT_NEEDEDonly for the shared libraries that are actually used. minimalism, we love her.--no-as-neededβ usesDT_NEEDEDfor all shared libraries (the default).-assert [ignored]β literally ignored. she said nothing, she did nothing, she's just there π«₯-b [elf,binary],--format [elf,binary]β sets the input format.--be8β outputs a BE8 format image.--build-id [=STYLE]β generates a build ID note.--build-id-chunk-size-for-treehash SIZEβ the chunk size for--build-id=tree.--build-id-min-file-size-for-treehash SIZEβ minimum output file size for--build-id=treeto work differently than--build-id=sha1.-Bdynamicβ-lsearches for shared libraries (the default).-Bstaticβ-ldoes not search for shared libraries.-dyβ alias for-Bdynamic(the default).-dnβ alias for-Bstatic.-Bgroupβ use group name lookup rules for shared library.-Bshareableβ generate a shared library (alias for-G/-shared).-Bno-symbolicβ don't bind default visibility defined symbols locally for-shared(the default).-Bsymbolic-functionsβ bind default visibility defined function symbols locally for-shared.-Bsymbolicβ bind default visibility defined symbols locally for-shared.--check-sectionsβ checks segment addresses for overlaps (the default).--no-check-sectionsβ does not check segment addresses for overlaps.--compress-debug-sections [none,zlib,zlib-gnu,zlib-gabi,zstd]β compresses.debug_*sections in the output file. tiny file, big energy π¦--copy-dt-needed-entriesβ not supported.--no-copy-dt-needed-entriesβ do not copyDT_NEEDEDtags from shared libraries (the default).--crefβ outputs a cross reference table.--no-crefβ does not output a cross reference table (the default).--ctors-in-init-arrayβ useDT_INIT_ARRAYfor all constructors (the default).--no-ctors-in-init-arrayβ handles constructors as directed by the compiler.-d,--define-commonβ defines common symbols.--no-define-commonβ does not define common symbols in relocatable output (the default).-dcβ alias for-d.-dpβ alias for-d.--debug [all,files,script,task][,...]β turns on debugging. the "why is this happening" switch π--defsym SYMBOL=EXPRESSIONβ defines a symbol.--demangle [=STYLE]β demangles C++ symbols in log messages so your eyes stop hurting.--no-demangleβ does not demangle C++ symbols in log messages.--dependency-file FILEβ writes a dependency file listing all files read.--detect-odr-violationsβ looks for violations of the C++ One Definition Rule.--no-detect-odr-violationsβ does not look for violations of the C++ One Definition Rule (the default).--dynamic-list-dataβ adds data symbols to dynamic symbols.--dynamic-list-cpp-newβ adds C++operator new/deleteto dynamic symbols.--dynamic-list-cpp-typeinfoβ adds C++ typeinfo to dynamic symbols.--dynamic-list FILEβ reads a list of dynamic symbols.--emit-stub-symsβ (PowerPC only) labels linker stubs with a symbol (the default).--no-emit-stub-symsβ (PowerPC only) does not label linker stubs with a symbol.-e ADDRESS,--entry ADDRESSβ sets the program start address.--eh-frame-hdrβ creates the exception frame header.--no-eh-frame-hdrβ does not create the exception frame header (the default).--enable-new-dtagsβ enables use ofDT_RUNPATH(the default).--disable-new-dtagsβ disables use ofDT_RUNPATH.--enable-linker-versionβ puts the linker version string into the.commentsection.--disable-linker-versionβ puts the linker version string into the.note.gnu.gold-versionsection (the default).--no-enum-size-warningβ (ARM only) does not warn about objects with incompatible enum sizes.--exclude-libs lib,lib ...β excludes libraries from automatic export.-E,--export-dynamicβ exports all dynamic symbols. everyone's invited π--no-export-dynamicβ does not export all dynamic symbols (the default).--export-dynamic-symbol SYMBOLβ exports SYMBOL to the dynamic symbol table.-EBβ link big-endian objects.-ELβ link little-endian objects.-f SHLIB,--auxiliary SHLIBβ auxiliary filter for the shared object symbol table.-F SHLIB,--filter SHLIBβ filter for the shared object symbol table.--fatal-warningsβ treats warnings as errors. no warnings allowed, we're strict now π€--no-fatal-warningsβ does not treat warnings as errors (the default).-fini SYMBOLβ call SYMBOL at unload-time.--fix-arm1176β (ARM only) fixes binaries for the ARM1176 erratum (the default).--no-fix-arm1176β (ARM only) does not fix binaries for the ARM1176 erratum.--fix-cortex-a8β (ARM only) fixes binaries for the Cortex-A8 erratum.--no-fix-cortex-a8β (ARM only) does not fix binaries for the Cortex-A8 erratum (the default).--fix-cortex-a53-843419β (AArch64 only) fixes Cortex-A53 erratum 843419.--no-fix-cortex-a53-843419β (AArch64 only) does not fix Cortex-A53 erratum 843419 (the default).--fix-cortex-a53-835769β (AArch64 only) fixes Cortex-A53 erratum 835769.--no-fix-cortex-a53-835769β (AArch64 only) does not fix Cortex-A53 erratum 835769 (the default).--fix-v4bxβ (ARM only) rewritesBX rnasMOV pc, rnfor ARMv4.--fix-v4bx-interworkingβ (ARM only) rewritesBX rnbranch to ARMv4 interworking veneer.-fuse-ld [gold,bfd]β ignored, kept around for GCC linker option compatibility. she's just here to be polite π-gβ ignored.--gc-sectionsβ removes unused sections. spring cleaning, but for your binary β¨--no-gc-sectionsβ doesn't remove unused sections (the default).--gdb-indexβ generates a.gdb_indexsection.--no-gdb-indexβ does not generate a.gdb_indexsection (the default).--gnu-uniqueβ enablesSTB_GNU_UNIQUEsymbol binding (the default).--no-gnu-uniqueβ disablesSTB_GNU_UNIQUEsymbol binding.-G,-sharedβ generate a shared library.-h FILENAME,-soname FILENAMEβ sets the shared library name.--hash-bucket-empty-fraction FRACTIONβ minimum fraction of empty buckets in the dynamic hash.--hash-style [sysv,gnu,both]β the dynamic hash style.-iβ alias for-r.--icf [none,all,safe]β Identical Code Folding.'--icf=safe'folds ctors, dtors and functions whose pointers are definitely not taken. very "if you're the same, you're the same" of her π--icf-iterations COUNTβ number of iterations of ICF (default 3).--incrementalβ does an incremental link if possible; otherwise, does a full link and prepares output for incremental linking.--no-incrementalβ does a full link (the default).--incremental-fullβ does a full link and prepares output for incremental linking.--incremental-updateβ does an incremental link; exits if it's not possible.--incremental-base FILEβ sets the base file for incremental linking (default is the output file).--incremental-changedβ assumes files changed.--incremental-unchangedβ assumes files didn't change.--incremental-unknownβ uses timestamps to check files (the default).--incremental-startup-unchangedβ assumes startup files unchanged (files preceding this option).--incremental-patch PERCENTβ amount of extra space to allocate for patches (default 10).-init SYMBOLβ call SYMBOL at load-time.-I PROGRAM,--dynamic-linker PROGRAMβ sets the dynamic linker path.--just-symbols FILEβ reads only symbol values from FILE. no lore, just numbers.--keep-files-mappedβ keeps files mapped across passes (default on 64bit architectures).--no-keep-files-mappedβ releases mapped files after each pass (default on 32bit architectures).--keep-unique SYMBOLβ do not fold this symbol during ICF. she's unique and she stays unique, periodt π-l LIBNAME,--library LIBNAMEβ search for library LIBNAME.--ld-generated-unwind-infoβ generates unwind information for PLT (the default).--no-ld-generated-unwind-infoβ does not generate unwind information for PLT.-L DIR,--library-path DIRβ adds a directory to the search path.--long-pltβ (ARM only) generates long PLT entries.--no-long-pltβ (ARM only) does not generate long PLT entries (the default).-m EMULATIONβ sets the GNU linker emulation; obsolete. she's retired bestie, respect the legacy.--map-whole-filesβ maps whole files to memory (default on 64bit architectures).--no-map-whole-filesβ maps relevant file parts to memory (default on 32bit architectures).--merge-exidx-entriesβ (ARM only) merges exidx entries in debuginfo (the default).--no-merge-exidx-entriesβ (ARM only) does not merge exidx entries in debuginfo.--mmap-output-fileβ maps the output file for writing (the default).--no-mmap-output-fileβ does not map the output file for writing.-M,--print-mapβ writes the map file on standard output.-Map MAPFILENAMEβ writes the map file.-n,--nmagicβ does not page align data.-N,--omagicβ does not page align data, and does not make text readonly.--no-omagicβ page aligns data, makes text readonly (the default).--no-keep-memoryβ uses less memory and more disk I/O (included only for compatibility with GNU ld).--no-undefinedβ reports undefined symbols (even with--shared).--noinhibit-execβ creates an output file even if errors occur. messy but productive, we've all been there π-nostdlibβ only searches directories specified on the command line.-o FILE,--output FILEβ sets the output file name.--oformat [binary]β sets the output format.-O LEVEL,-optimize LEVELβ optimizes output file size.--orphan-handling [place,discard,warn,error]β orphan section handling.-pβ ignored, kept for ARM compatibility.
--package-metadata [=JSON]β drop a package metadata note in there π-pieβ make a position independent executable β¨-no-pieβ do NOT make a position independent executable (this is the default, bestie) π«--pic-executableβ same vibe as-pie: position independent executable, slay π--no-pic-executableβ nope, no position independent executable here (default) π ββοΈ--pic-veneerβ force PIC sequences for ARM/Thumb interworking veneers π¦Ύ-no-pipeline-knowledgeβ (ARM only) ignore for backward compatibility (default) π°οΈ--plt-align [=P2ALIGN]β (PowerPC only) align PLT call stubs so they fit cache lines π--plt-localentryβ (PowerPC64 only) optimize calls to ELFv2localentry:0functions π--no-plt-localentryβ (PowerPC64 only) don't optimize those ELFv2 calls (default) π--plt-static-chainβ (PowerPC64 only) PLT call stubs should loadr11πͺ--no-plt-static-chainβ (PowerPC64 only) PLT call stubs should not loadr11(default) π«--plt-thread-safeβ (PowerPC64 only) PLT call stubs with a load-load barrier π§±--no-plt-thread-safeβ (PowerPC64 only) PLT call stubs without a barrier (default) π--plugin PLUGINβ load a plugin library π--plugin-opt OPTIONβ pass an option to the plugin π£οΈ--posix-fallocateβ useposix_fallocateto reserve space in the output file (default) π¦--no-posix-fallocateβ usefallocateorftruncateto reserve space βοΈ--power10-stubs [=auto,no,yes]β (PowerPC64 only) stubs use power10 insns β‘--no-power10-stubsβ (PowerPC64 only) stubs do not use power10 insns π«--preread-archive-symbolsβ preread archive symbols when multi-threaded π--print-gc-sectionsβ list removed unused sections on stderr ποΈ--no-print-gc-sectionsβ do not list removed unused sections (default) π--print-icf-sectionsβ list folded identical sections on stderr πͺ--no-print-icf-sectionsβ do not list folded identical sections (default) π€--print-output-formatβ print default output format π¨οΈ--print-symbol-counts FILENAMEβ print symbols defined and used for each input π’--push-stateβ save the state of flags related to input files πΎ--pop-stateβ restore the state of flags related to input files βͺ-q,--emit-relocsβ generate relocations in output π οΈ-Qyβ ignored for SVR4 compatibility π€·ββοΈ-r,-relocatableβ generate relocatable output π--relaxβ relax branches on certain targets π§--no-relaxβ do not relax branches (default) π«--retain-symbols-file FILEβ keep only symbols listed in this file π--rosegmentβ put read-only non-executable sections in their own segment πΉ--no-rosegmentβ do not put read-only non-executable sections in their own segment (default) π₯--rosegment-gap OFFSETβ set offset between executable and read-only segments π-R DIRβ addDIRto runtime search path π-rpath DIRβ addDIRto runtime search path (same energy) π--rpath-link DIRβ addDIRto link time shared library search path π-s,--strip-allβ strip all symbols βοΈ-S,--strip-debugβ strip debugging information π--strip-debug-non-lineβ emit only debug line number information π--strip-debug-gdbβ strip debug symbols that are unused by gdb (at least versions <=7.4) π§Ή--strip-lto-sectionsβ strip LTO intermediate code sections (default) π§Ό--section-ordering-file FILENAMEβ layout sections in the order specified π--section-start SECTION=ADDRESSβ set address of section π--secure-pltβ (PowerPC only) use new-style PLT (default) π--sort-common [={ascending,descending}]β sort common symbols by alignment π--sort-section [none,name]β sort sections by name.'--no-text-reorder'will override'--sort-section=name'for.textπ€--spare-dynamic-tags COUNTβ dynamic tag slots to reserve (default5) π·οΈ--stub-group-size SIZEβ (ARM, PowerPC only) the maximum distance from instructions in a group of sections to their stubs. Negative values mean stubs are always after the group.1means use default size π¦--stub-group-multiβ (PowerPC only) allow a group of stubs to serve multiple output sections (default) π―ββοΈ--no-stub-group-multiβ (PowerPC only) each output section has its own stubs π--split-stack-adjust-size SIZEβ stack size when-fsplit-stackfunction calls non-split π§΅-staticβ do not link against shared libraries π«--start-libβ start a library π--end-libβ end a library π--statsβ print resource usage statistics π--sysroot DIRβ set target system root directory π³-t,--traceβ print the name of each input file π£οΈ--target1-absβ (ARM only) forceR_ARM_TARGET1type toR_ARM_ABS32π―--target1-relβ (ARM only) forceR_ARM_TARGET1type toR_ARM_REL32π―--target2 [rel, abs, got-relβ (ARM only) setR_ARM_TARGET2relocation type π§©--text-reorderβ enable text section reordering for GCC section names (default) π--no-text-reorderβ disable text section reordering for GCC section names π«--threadsβ run the linker multi-threaded π§΅--no-threadsβ do not run the linker multi-threaded (default) π«--thread-count COUNTβ number of threads to use π’--thread-count-initial COUNTβ number of threads to use in initial pass π--thread-count-middle COUNTβ number of threads to use in middle pass π--thread-count-final COUNTβ number of threads to use in final pass π--tls-optimizeβ (PowerPC/64 only) optimize GD/LD/IE code to IE/LE (default) β‘--no-tls-optimizeβ (PowerPC/64 only)Don'''ttry to optimize TLS accesses π«--tls-get-addr-optimizeβ (PowerPC/64 only) use a special__tls_get_addrcall (default) π--no-tls-get-addr-optimizeβ (PowerPC/64 only) don't use a special__tls_get_addrcall π«--toc-optimizeβ (PowerPC64 only) optimize TOC code sequences (default) π§--no-toc-optimizeβ (PowerPC64 only) don't optimize TOC code sequences π«--toc-sortβ (PowerPC64 only) sort TOC and GOT sections (default) π€--no-toc-sortβ (PowerPC64 only) don't sort TOC and GOT sections π«-T FILE,--script FILEβ read linker script π-Tbss ADDRESSβ set the address of the bss segment π-Tdata ADDRESSβ set the address of the data segment π-Ttext ADDRESSβ set the address of the text segment π-Ttext-segment ADDRESSβ set the address of the text segment π-Trodata-segment ADDRESSβ set the address of the rodata segment π-u SYMBOL,--undefined SYMBOLβ create undefined reference toSYMBOLπ--unresolved-symbolsβ how to handle unresolved symbols. Values:ignore-all,report-all,ignore-in-object-files,ignore-in-shared-libsπ€--verboseβ alias for--debug=filesπ£οΈ--version-script FILEβ read version script π--warn-commonβ warn about duplicate common symbols β οΈ--no-warn-commonβ do not warn about duplicate common symbols (default) π€--warn-constructorsβ ignored π--no-warn-constructorsβ ignored π--warn-drop-versionβ warn when discarding version information β οΈ--no-warn-drop-versionβ do not warn when discarding version information (default) π€--warn-execstackβ warn if the stack is executable β οΈ--no-warn-execstackβ do not warn if the stack is executable (default) π€--no-warn-mismatchβ don't warn about mismatched input files π€--warn-multiple-gpβ ignored π--warn-search-mismatchβ warn when skipping an incompatible library (default) β οΈ--no-warn-search-mismatchβ don't warn when skipping an incompatible library π€--warn-shared-textrelβ warn if text segment is not shareable β οΈ--no-warn-shared-textrelβ do not warn if text segment is not shareable (default) π€--warn-unresolved-symbolsβ report unresolved symbols as warnings β οΈ--error-unresolved-symbolsβ report unresolved symbols as errors (default) β-z builddβ dummy z option π§Έ--no-wchar-size-warningβ (ARM only) do not warn about objects with incompatiblewchar_tsizes π€--weak-unresolved-symbolsβ convert unresolved symbols to weak references π«--whole-archiveβ include all archive contents π¦--no-whole-archiveβ include only needed archive contents (default) π―--wrap SYMBOLβ use wrapper functions forSYMBOLπ-x,--discard-allβ delete all local symbols ποΈ-X,--discard-localsβ delete all temporary local symbols ποΈ--discard-noneβ keep all local symbols π-y SYMBOL,--trace-symbol SYMBOLβ trace references to symbol π--undefined-versionβ allow unused version in script (default) β--no-undefined-versionβ do not allow unused version in script π«-Y PATHβ default search path for Solaris compatibility βοΈ-(,--start-groupβ start a library search group π-),--end-groupβ end a library search group π-z combrelocβ sort dynamic relocs (default) π€-z nocombrelocβ do not sort dynamic relocs π«-z common-page-size=SIZEβ set common page size toSIZEπ-z defsβ report undefined symbols (even with--shared) β-z execstackβ mark output as requiring executable stack π₯-z globalβ make symbols in DSO available for subsequently loaded objects π-z initfirstβ mark DSO to be initialized first at runtime π₯-z interposeβ mark object to interpose all DSOs but executable π-z uniqueβ mark DSO to be loaded at most once, and only in the main namespace 1οΈβ£-z nouniqueβ do not mark the DSO as one to be loaded only in the main namespace (default) π«-z lazyβ mark object for lazy runtime binding (default) π΄-z loadfltrβ mark object requiring immediate process β‘-z max-page-size=SIZEβ set maximum page size toSIZEπ-z muldefsβ allow multiple definitions of symbols π-z nocopyrelocβ do not create copy relocs π«-z nodefaultlibβ mark object not to use default search paths π«-z nodeleteβ mark DSO non-deletable at runtime π-z nodlopenβ mark DSO not available todlopenπ«-z nodumpβ mark DSO not available todldumpπ«-z noexecstackβ mark output as not requiring executable stack π«-z nowβ marks the object for immediate function binding, like it said "no waiting, we're doing this NOW" β¨-z originβ marks the DSO to say it needs immediate$ORIGINprocessing at runtime πββοΈ-z relroβ where possible, marks variables read-only after relocation. This is the default, bestie, it's the moment π-z norelroβ don't do that. don't mark variables read-only after relocation π-z stack-size=SIZEβ sets thePT_GNU_STACKsegmentp_memszto SIZE. literally just that number, queen π-z start-stop-visibility=[default,internal,hidden,protected]β picks the ELF symbol visibility for the synthesized__start_*and__stop_*symbols π¦-z textβ do not permit relocations in read-only segments π«-z notextβ permit relocations in read-only segments. this one is the default πΈ-z textoffβ also permits relocations in read-only segments. yep, still the default π-z text-unlikely-segmentβ moves.text.unlikelysections into a separate segment β¨-z notext-unlikely-segmentβ does not move.text.unlikelysections to a separate segment. (default, if you were wondering) π-z keep-text-section-prefixβ keeps.text.hot,.text.startup,.text.exitand.text.unlikelyas separate sections in the final binary. main character sections, they don't share a room π-z nokeep-text-section-prefixβ merges all.text.*prefix sections together. (default) π
and if you ever forget all of this (you won't, you're doing amazing), just run
gold --help
for a list of supported targets and emulations π«Ά
π REPORTING BUGS π
Found a bug? First of all, not your fault, and second of all β tell the people who can fix it:
Report bugs to <https://sourceware.org/bugzilla/>
fr fr, they want to hear about it π
Β©οΈ COPYRIGHT Β©οΈ
Copyright Β© 2024 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty π (yes, really β no warranty, no cap, zero, nada, don't come for them if it breaks)
okay bestie that's the whole page, you ate it, you read the entire manual π β¨
this was GNU gold (from GNU Binutils for Ubuntu), dated December 2025 β go compile something iconic, ily, bye ππ¦π
π¦ where this page comes from
- ubuntu noble: binutils-common 2.42-4ubuntu2.8
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms