OS Manuals

/usr/bin/ld.mold

mold linker

From mold 3.0.0-r2 (os), captured 2026-11-05 by running ld.mold --help (exit 0). permalink

Usage: /usr/bin/ld.mold [options] file...

Options:
  --help                      Report usage information
  -v, --version               Report version information
  -V                          Report version and target information
  -(, --start-group           Ignored
  -), --end-group             Ignored
  -C DIR, --directory DIR     Change to DIR before doing anything
  -E, --export-dynamic        Put symbols in the dynamic symbol table
    --no-export-dynamic
  -F LIBNAME, --filter LIBNAME
                              Set DT_FILTER to the specified value
  -I FILE, --dynamic-linker FILE
                              Set dynamic linker path
    --no-dynamic-linker
  -L DIR, --library-path DIR  Add DIR to library search path
  -M, --print-map             Write map file to stdout
  -N, --omagic                Do not page align data; do not make text readonly
    --no-omagic
  -O NUMBER                   Ignored
  -P AUDITLIB, --depaudit AUDITLIB
                              Set DT_DEPAUDIT to the specified value
  -S, --strip-debug           Strip .debug_* sections
  -T FILE, --script FILE      Read linker script
  -X, --discard-locals        Discard temporary local symbols (default)
  -e SYMBOL, --entry SYMBOL   Set program entry point
  -f SHLIB, --auxiliary SHLIB Set DT_AUXILIARY to the specified value
  -h LIBNAME, --soname LIBNAME
                              Set shared library name
  -l LIBNAME, --library LIBNAME
                              Search for a given library
  -m TARGET                   Set target
  -o FILE, --output FILE      Set output filename
  -q, --emit-relocs           Leaves relocation sections in the output
  -r, --relocatable           Generate relocatable output
  -s, --strip-all             Strip .symtab section
  -u SYMBOL, --undefined SYMBOL
                              Force to resolve SYMBOL
  -w, --no-warnings           Suppress warnings
  -y SYMBOL, --trace-symbol SYMBOL
                              Trace references to SYMBOL
  --Bdynamic, --dy            Link against shared libraries (default)
  --Bstatic, --dn, --static   Do not link against shared libraries
  --Bsymbolic                 Bind all symbols locally
  --Bsymbolic-functions       Bind function symbols locally
  --Bsymbolic-non-weak        Bind all but weak symbols locally
  --Bsymbolic-non-weak-functions
                              Bind all but weak function symbols locally
  --Bno-symbolic              Cancel --Bsymbolic options
  --Map FILE                  Write map file to a given file
  --Tbss=ADDR                 Set address to .bss
  --Tdata=ADDR                Set address to .data
  --Ttext=ADDR                Set address to .text
  --Ttext-segment=ADDR        Set address of text segment
  --allow-multiple-definition Allow multiple definitions
  --apply-dynamic-relocs      Apply link-time values for dynamic relocations (default)
    --no-apply-dynamic-relocs
  --as-needed                 Only set DT_NEEDED if used
    --no-as-needed
  --audit LIBNAME             Set DT_AUDIT to the specified value
  --build-id [none,md5,sha1,sha256,fast,uuid,HEXSTRING]
                              Generate build ID
    --no-build-id
  --chroot DIR                Set a given path to the root directory
  --color-diagnostics=[auto,always,never]
                              Use colors in diagnostics
  --color-diagnostics         Alias for --color-diagnostics=auto
    --no-color-diagnostics    Alias for --color-diagnostics=never
  --compress-debug-sections=[none,zlib,zlib:0,...,zlib:9,zstd,zstd:1,...,zstd:22]
                              Compress .debug_* sections
  --dc                        Ignored
  --dependency-file=FILE      Write Makefile-style dependency rules to FILE
  --defsym=SYMBOL=VALUE       Define a symbol alias
  --demangle                  Demangle C++ symbols in log messages (default)
    --no-demangle
  --detach                    Create separate debug info file in the background (default)
    --no-detach
  --discard-none              Keep all local symbols in the symbol table
  --enable-new-dtags          Emit DT_RUNPATH for --rpath (default)
    --disable-new-dtags       Emit DT_RPATH for --rpath
  --execute-only              Make executable segments unreadable
  --dp                        Ignored
  --dynamic-list=FILE         Read a list of dynamic symbols (implies -Bsymbolic)
  --dynamic-list-data         Add data symbols to dynamic symbols
  --eh-frame-hdr              Create .eh_frame_hdr section
    --no-eh-frame-hdr
  --exclude-libs LIB,LIB,..   Mark all symbols in given libraries as hidden
  --export-dynamic-symbol     Put symbols matching glob in the dynamic symbol table
  --export-dynamic-symbol-list=FILE
                              Read a list of dynamic symbols
  --fatal-warnings            Treat warnings as errors
    --no-fatal-warnings       Do not treat warnings as errors (default)
  --fini SYMBOL               Call SYMBOL at unload-time
  --fork                      Spawn a child process (default)
    --no-fork
  --gc-sections               Remove unreferenced sections
    --no-gc-sections
  --gdb-index                 Create .gdb_index for faster gdb startup
  --hash-style [sysv,gnu,both,none]
                              Set hash style
  --icf=[all,safe,none]       Fold identical code
    --no-icf
  --ignore-data-address-equality
                              Allow merging non-executable sections with --icf
  --image-base ADDR           Set the base address to a given value
  --init SYMBOL               Call SYMBOL at load-time
  --nmagic                    Do not page align sections
    --no-nmagic
  --no-undefined              Report undefined symbols (even with --shared)
  --noinhibit-exec            Create an output file even if errors occur
  --oformat=binary            Omit ELF, section, and program headers
  --pack-dyn-relocs=[relr,android,android+relr,none]
                              Pack dynamic relocations
  --package-metadata=PERCENT_ENCODED_STRING
                              Set a given string to .note.package
  --perf                      Print performance statistics
  --pie, --pic-executable     Create a position-independent executable
    --no-pie, --no-pic-executable
  --pop-state                 Restore the state of flags governing input file handling
  --print-gc-sections[=FILE]  Print, or save in FILE, removed unreferenced sections
    --no-print-gc-sections
  --print-icf-sections[=FILE] Print, or save in FILE, folded identical sections
    --no-print-icf-sections
  --push-state                Save the state of flags governing input file handling
  --quick-exit                Use quick_exit to exit (default)
    --no-quick-exit
  --relax                     Optimize instructions (default)
    --no-relax
  --repro                     Embed input files in .repro section
  --require-defined SYMBOL    Require SYMBOL be defined in the final output
  --retain-symbols-file FILE  Keep only symbols listed in FILE
  --reverse-sections          Reverse input sections in the output file
  --rosegment                 Put read-only non-executable sections in their own segment (default)
    --no-rosegment            Put read-only non-executable sections in an executable segment
  --rpath DIR                 Add DIR to the runtime search path
  --rpath-link DIR            Ignored
  --run COMMAND ARG...        Run COMMAND with mold as /usr/bin/ld
  --section-start=SECTION=ADDR Set address for section
  --separate-debug-file[=FILE] Separate debug info to the specified file
    --no-separate-debug-file
  --shared, --Bshareable      Create a shared library
  --shuffle-sections[=SEED]   Randomize the output by shuffling input sections
  --sort-common               Ignored
  --sort-section              Ignored
  --spare-dynamic-tags NUMBER Reserve the given number of tags in the .dynamic section
  --spare-program-headers NUMBER
                              Reserve the given number of slots in the program header
  --start-lib                 Give following object files in-archive-file semantics
    --end-lib                 End the effect of --start-lib
  --stats                     Print input statistics
  --sysroot DIR               Set the target system root directory
  --thread-count COUNT, --threads=COUNT
                              Use COUNT number of threads
  --threads                   Use multiple threads (default)
    --no-threads
  --trace                     Print the name of each input file
  --undefined-glob PATTERN    Force to resolve all symbols that match a given pattern
  --undefined-version         Do not report version scripts that refer to undefined symbols
    --no-undefined-version    Report version scripts that refer to undefined symbols (default)
  --unique PATTERN            Don't merge input sections that match a given pattern
  --unresolved-symbols [report-all,ignore-all,ignore-in-object-files,ignore-in-shared-libs]
                              Handle unresolved symbols
  --version-script FILE       Read version script
  --warn-common               Warn about common symbols
    --no-warn-common
  --warn-once                 Only warn once for each undefined symbol
  --warn-shared-textrel       Warn if the output .so needs text relocations
  --warn-textrel              Warn if the output file needs text relocations
  --warn-unresolved-symbols   Report unresolved symbols as warnings
    --error-unresolved-symbols
                              Report unresolved symbols as errors (default)
  --whole-archive             Include all objects from static archives
    --no-whole-archive
  --wrap SYMBOL               Use a wrapper function for a given symbol
  --zero-to-bss               Convert all-zero data sections into BSS
  -z defs                     Report undefined symbols (even with --shared)
    -z undefs
  -z common-page-size=VALUE   Ignored
  -z execstack                Require an executable stack
    -z noexecstack
  -z execstack-if-needed      Make the stack area executable if an input file explicitly requests it
  -z initfirst                Mark DSO to be initialized first at runtime
  -z interpose                Mark object to interpose all DSOs but the executable
  -z keep-text-section-prefix Keep .text.{hot,unknown,unlikely,startup,exit} as separate sections in the final binary
    -z nokeep-text-section-prefix
  -z lazy                     Enable lazy function resolution (default)
  -z max-page-size=VALUE      Use VALUE as the memory page size
  -z nocopyreloc              Do not create copy relocations
  -z nodefaultlib             Make the dynamic loader ignore default search paths
  -z nodelete                 Mark DSO non-deletable at runtime
  -z nodlopen                 Mark DSO not available to dlopen
  -z nodump                   Mark DSO not available to dldump
  -z now                      Disable lazy function resolution
  -z origin                   Mark object requiring immediate $ORIGIN processing at runtime
  -z pack-relative-relocs     Alias for --pack-dyn-relocs=relr
    -z nopack-relative-relocs
  -z sectionheader            Do not omit section header (default)
    -z nosectionheader        Omit section header
  -z start-stop-visibility=[hidden,protected]
                              Specify symbol visibility for "__start_SECNAME" and "__stop_SECNAME" symbols
  -z separate-loadable-segments
                              Separate all loadable segments onto different pages
    -z separate-code          Separate code and data onto different pages
    -z noseparate-code        Allow overlap in pages
  -z stack-size=VALUE         Set the size of the stack segment
  -z relro                    Make some sections read-only after relocation (default)
    -z norelro
  -z rewrite-endbr            Rewrite indirect branch target instructions with NOPs
    -z norewrite-endbr
  -z rodynamic                Make the .dynamic section read-only
  -z text                     Report error if DT_TEXTREL is set
    -z notext
    -z textoff

mold: supported targets: elf32-i386 elf64-x86-64 elf32-littlearm elf64-littleaarch64 elf64-bigaarch64 elf32-littleriscv elf32-bigriscv elf64-littleriscv elf64-bigriscv elf32-powerpc elf64-powerpc elf64-powerpc elf64-powerpcle elf64-s390 elf64-sparc elf32-m68k elf32-sh-linux elf64-loongarch elf32-loongarch
mold: supported emulations: elf_i386 elf_x86_64 armelf_linux_eabi aarch64elf aarch64linux aarch64elfb aarch64linuxb elf32lriscv elf32briscv elf64lriscv elf64briscv elf32ppc elf32ppclinux elf64ppc elf64lppc elf64_s390 elf64_sparc m68kelf shlelf_linux shelf_linux elf64loongarch elf32loongarch
Options (153)
OptionDescriptionSource
--helpReport usage information to stdout and exit.help + man
-v, --versionReport version information to stdout.help + man
-VReport version and target information to stdout.help + man
--start-groupIgnoredhelp
--end-groupIgnoredhelp
-C, --directory DIRChange to DIR before doing anythinghelp
-E, --export-dynamicWhen creating an executable, using the -E option causes all global symbols to be put into the dynamic symbol table, so that the symbols are visible from other ELF modules at runtime.help + man
--no-export-dynamichelp
--no-dynamic-linker, -I, --dynamic-linker fileSet the dynamic linker path to file.help + man
-L, --library-path DIRAdd dir to the list of library search paths from which mold searches libraries for the -l option.help + man
-M, --print-mapWrite a map file to stdout.help + man
-N, --omagicForce mold to emit an output file with an old-fashioned memory layout.help + man
--no-omagichelp
-O NUMBERIgnoredhelp
-S, --strip-debugOmit .debug_ sections from the output file.help + man
-T, --script FILERead linker script from file.help + man
-X, --discard-localsDiscard temporary local symbols to reduce the sizes of the symbol table and the string table.help + man
-e, --entry SYMBOLSet program entry pointhelp + man
-m TARGETChoose a target.help + man
-o, --output FILEUse file as the output file name instead of the default name a.out.help + man
-q, --emit-relocsThe linker usually "consumes" relocation sections.help + man
-r, --relocatableInstead of generating an executable or a shared object file, combine input object files to generate another object file that can be used as an input to a linker.help + man
-s, --strip-allOmit .symtab section from the output file.help + man
-w, --no-warningsSuppress warnings and cancel --fatal-warnings.help + man
--Bdynamic, --dyLink against shared libraries (default)help + man
--Bstatic, --dn, --staticDo not link against shared libraries.help + man + man
--BsymbolicWhen creating a shared library, make global symbols export-only (i.e. do not import the same symbol).help + man
--Bsymbolic-functionsThis option has the same effect as --Bsymbolic but works only for function symbols.help + man
--Bsymbolic-non-weakThis option has the same effect as --Bsymbolic but works only for non-weak symbols.help + man
--Bsymbolic-non-weak-functionsThis option has the same effect as --Bsymbolic but works only for non-weak function symbols.help + man
--Bno-symbolicCancel --Bsymbolic, --Bsymbolic-functions, --Bsymbolic-non-weak and --Bsymbolic-non-weak-functions.help + man
--Map FILEWrite map file to a given filehelp + man
--Tbss ADDRAlias for --section-start=.bss=address.help + man
--Tdata ADDRAlias for --section-start=.data=address.help + man
--Ttext ADDRAlias for --section-start=.text=address.help + man
--Ttext-segment ADDRSet the address of the first byte of the text segment.help + man
--apply-dynamic-relocsApply link-time values for dynamic relocations (default)help
--no-apply-dynamic-relocshelp
--as-neededBy default, shared libraries given to the linker are unconditionally added to the list of required libraries in an output file.help + man
--no-as-neededhelp
--audit LIBNAMESet DT_AUDIT to the specified valuehelp
--build-id noneSynonym for --build-id=sha256.help + man
--no-build-idSynonym for --build-id=none.help + man
--chroot DIRSet a given path to the root directoryhelp + man
--color-diagnostics autoSynonym for --color-diagnostics=auto.help + man
--no-color-diagnosticsSynonym for --color-diagnostics=never.help + man
--compress-debug-sections noneCompress .debug_* sectionshelp
--dcIgnoredhelp
--dependency-file FILEWrite Makefile-style dependency rules to FILEhelp + man
--defsym SYMBOL=VALUEDefine symbol as an alias for value.help + man
--demangleDemangle C++ symbols in log messages (default)help + man
--no-demanglehelp
--detachPermit or do not permit mold to create a debug info file in the background.help + man
--no-detachhelp
--discard-noneKeep all local symbols in the symbol table, including temporary ones starting with .L, except ones in mergeable sections.help + man
--enable-new-dtagsBy default, mold emits DT_RUNPATH for --rpath.help + man
--disable-new-dtagsEmit DT_RPATH for --rpathhelp
--execute-onlyMake executable segments unreadablehelp + man
--dpIgnoredhelp
--dynamic-list FILERead a list of dynamic symbols (implies -Bsymbolic)help + man
--dynamic-list-dataAdd data symbols to dynamic symbolshelp
--eh-frame-hdrCreate .eh_frame_hdr section.help + man
--no-eh-frame-hdrhelp
--exclude-libs LIBMark all symbols in the given libraries hidden.help + man
--export-dynamic-symbol symbolPut symbols matching symbol in the dynamic symbol table.help + man
--export-dynamic-symbol-list FILERead a list of dynamic symbols from file.help + man
--fatal-warningsTreat warnings as errors.help + man
--no-fatal-warningsDo not treat warnings as errors (default)help
--fini SYMBOLCall symbol at unload-time.help + man
--forkSpawn a child process and let it do the actual linking.help + man
--no-forkhelp
--gc-sectionsRemove unreferenced sections.help + man
--no-gc-sectionshelp
--gdb-indexCreate a .gdb_index section to speed up GNU debugger.help + man
--hash-style sysvSet hash stylehelp
--icf allFold identical codehelp + man
--no-icfhelp
--ignore-data-address-equalityMake ICF to merge not only functions but also data.help + man
--image-base ADDRSet the base address to a given valuehelp + man
--init SYMBOLCall symbol at load-time.help + man
--nmagicDo not page align sectionshelp
--no-nmagichelp
--no-undefinedReport undefined symbols (even with --shared).help + man
--noinhibit-execCreate an output file even if errors occur.help + man
--oformat binaryOmit ELF, section, and program headershelp
--pack-dyn-relocs relrPack dynamic relocationshelp
--package-metadata PERCENT_ENCODED_STRINGEmbed a specified string into the .note.package section.help + man
--perfPrint performance statistics.help + man
--pie, --pic-executableCreate a position-independent executable.help + man
--no-pie, --no-pic-executablehelp
--pop-stateRestore the state of flags governing input file handlinghelp
--print-gc-sections FILEPrint, or save in FILE, removed unreferenced sectionshelp + man
--no-print-gc-sectionshelp
--no-print-icf-sections, --print-icf-sectionsPrint folded identical sections.help + man
--push-stateSave the state of flags governing input file handlinghelp + man
--quick-exitUse or do not use quick_exit to exit.help + man
--no-quick-exithelp
--relaxRewrite machine instructions with more efficient ones for some relocations.help + man
--no-relaxhelp
--reproArchive input files, as well as a text file containing command line options, in a tar file so that you can run mold with the exact same inputs again.help + man
--require-defined SYMBOLLike --undefined, except the new symbol must be defined by the end of the link.help + man
--retain-symbols-file FILEKeep only symbols listed in file.help + man
--reverse-sectionsReverse the order of input sections before assigning them the offsets in the output file.help + man
--rosegmentPut read-only non-executable sections in their own segment (default)help
--no-rosegmentPut read-only non-executable sections in an executable segmenthelp
--rpath DIRAdd DIR to the runtime search pathhelp + man
--rpath-link DIRIgnoredhelp
--run COMMANDRun command with mold as /usr/bin/ld.help + man
--no-separate-debug-filehelp
--shared, --BshareableCreate a shared libraryhelp + man
--shuffle-sections SEEDRandomize the output by shuffling the order of input sections before assigning them the offsets in the output file.help + man
--sort-commonIgnoredhelp
--sort-sectionIgnoredhelp
--spare-program-headers NUMBERAppend the given number of PT_NULL entries to the end of the program header, so that post-link processing tools can easily add new segments by overwriting the null entries.help + man
--start-libHandle object files between --start-lib and --end-lib as if they were in an archive file.help + man
--end-libEnd the effect of --start-libhelp
--statsPrint input statistics.help + man
--sysroot DIRSet target system root directory to dir.help + man
--thread-count, --threads COUNTUse count number of threads.help + man + man
--no-threadshelp
--tracePrint the name of each input filehelp + man
--undefined-glob PATTERNSynonym for --undefined, except that --undefined-glob takes a glob pattern instead of just a single symbol name.help + man
--undefined-versionBy default, mold warns on a symbol specified by a version script or by --export-dynamic-symbol if it is not defined.help + man
--no-undefined-versionReport version scripts that refer to undefined symbols (default)help
--unique PATTERNDon't merge input sections that match the given glob pattern pattern.help + man
--unresolved-symbols report-allHandle unresolved symbolshelp
--version-script FILERead version script from file.help + man
--warn-commonWarn about common symbols.help + man
--no-warn-commonhelp
--warn-onceOnly warn once for each undefined symbol instead of warn for each relocation referring an undefined symbol.help + man
--warn-shared-textrelWarn if the output .so needs text relocationshelp
--warn-textrelWarn if the output file needs text relocationshelp
--warn-unresolved-symbolsNormally, the linker reports an error for unresolved symbols.help + man
--error-unresolved-symbolsReport unresolved symbols as errors (default)help
--whole-archiveWhen archive files (.a files) are given to the linker, only object files that are needed to resolve undefined symbols are extracted from them and linked to an output file.help + man
--no-whole-archivehelp
--wrap SYMBOLUse a wrapper function for a given symbolhelp + man
--zero-to-bssConvert all-zero data sections into BSS.help + man
-z defsAs a security measure, some CPU instruction sets have recently gained a feature to protect control flow integrity by disallowing indirect branches by default.help + man
--print-dependenciesPrint out dependency information for input files. (in the manual page but not in --help)man
--relocatable-merge-sectionsBy default, mold doesn't merge input sections by name when merging input object files into a single output object file for -r. (in the manual page but not in --help)man
--separate-debug-file, --separate-debug-file fileBundle debug info sections into a separate file instead of embedding them in an output executable or a shared library. (in the manual page but not in --help)man
-F, --filter libnameSet the DT_FILTER dynamic section field to libname. (in the manual page but not in --help)man
-f, --auxiliary shlibSet the DT_AUXILIARY dynamic section field to shlib. (in the manual page but not in --help)man
-h, --soname libnameSet the DT_SONAME dynamic section field to libname. (in the manual page but not in --help)man
-l libnameSearch for liblibname.so or liblibname.a from library search paths. (in the manual page but not in --help)man
-u, --undefined symbolIf symbol remains as an undefined symbol after reading all object files, and if there is a static archive that contains an object file defining symbol, pull out the object file and link it so that… (in the manual page but not in --help)man
-y, --trace-symbol symbolTrace references to symbol. (in the manual page but not in --help)man
--allow-multiple-definitionNormally, the linker reports an error if there are more than one definition of a symbol. (in the manual page but not in --help)man
--allow-shlib-undefined, --no-allow-shlib-undefinedEven if mold succeeds in linking a main executable without undefined symbol errors, you may still encounter symbol lookup errors at runtime because the dynamic linker cannot find some symbols in… (in the manual page but not in --help)man
--default-symverUse soname as a symbol version and append that version to all symbols. (in the manual page but not in --help)man
--section-start section=addressSet address to section. (in the manual page but not in --help)man
--spare-dynamic-tags numberAppend the given number of DT_NULL entries to the end of the .dynamic section, so that post-link processing tools can easily add new dynamic tags by overwriting the null entries. (in the manual page but not in --help)man

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.