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)
| Option | Description | Source |
|---|---|---|
--help | Report usage information to stdout and exit. | help + man |
-v, --version | Report version information to stdout. | help + man |
-V | Report version and target information to stdout. | help + man |
--start-group | Ignored | help |
--end-group | Ignored | help |
-C, --directory DIR | Change to DIR before doing anything | help |
-E, --export-dynamic | When 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-dynamic | help | |
--no-dynamic-linker, -I, --dynamic-linker file | Set the dynamic linker path to file. | help + man |
-L, --library-path DIR | Add dir to the list of library search paths from which mold searches libraries for the -l option. | help + man |
-M, --print-map | Write a map file to stdout. | help + man |
-N, --omagic | Force mold to emit an output file with an old-fashioned memory layout. | help + man |
--no-omagic | help | |
-O NUMBER | Ignored | help |
-S, --strip-debug | Omit .debug_ sections from the output file. | help + man |
-T, --script FILE | Read linker script from file. | help + man |
-X, --discard-locals | Discard temporary local symbols to reduce the sizes of the symbol table and the string table. | help + man |
-e, --entry SYMBOL | Set program entry point | help + man |
-m TARGET | Choose a target. | help + man |
-o, --output FILE | Use file as the output file name instead of the default name a.out. | help + man |
-q, --emit-relocs | The linker usually "consumes" relocation sections. | help + man |
-r, --relocatable | Instead 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-all | Omit .symtab section from the output file. | help + man |
-w, --no-warnings | Suppress warnings and cancel --fatal-warnings. | help + man |
--Bdynamic, --dy | Link against shared libraries (default) | help + man |
--Bstatic, --dn, --static | Do not link against shared libraries. | help + man + man |
--Bsymbolic | When creating a shared library, make global symbols export-only (i.e. do not import the same symbol). | help + man |
--Bsymbolic-functions | This option has the same effect as --Bsymbolic but works only for function symbols. | help + man |
--Bsymbolic-non-weak | This option has the same effect as --Bsymbolic but works only for non-weak symbols. | help + man |
--Bsymbolic-non-weak-functions | This option has the same effect as --Bsymbolic but works only for non-weak function symbols. | help + man |
--Bno-symbolic | Cancel --Bsymbolic, --Bsymbolic-functions, --Bsymbolic-non-weak and --Bsymbolic-non-weak-functions. | help + man |
--Map FILE | Write map file to a given file | help + man |
--Tbss ADDR | Alias for --section-start=.bss=address. | help + man |
--Tdata ADDR | Alias for --section-start=.data=address. | help + man |
--Ttext ADDR | Alias for --section-start=.text=address. | help + man |
--Ttext-segment ADDR | Set the address of the first byte of the text segment. | help + man |
--apply-dynamic-relocs | Apply link-time values for dynamic relocations (default) | help |
--no-apply-dynamic-relocs | help | |
--as-needed | By default, shared libraries given to the linker are unconditionally added to the list of required libraries in an output file. | help + man |
--no-as-needed | help | |
--audit LIBNAME | Set DT_AUDIT to the specified value | help |
--build-id none | Synonym for --build-id=sha256. | help + man |
--no-build-id | Synonym for --build-id=none. | help + man |
--chroot DIR | Set a given path to the root directory | help + man |
--color-diagnostics auto | Synonym for --color-diagnostics=auto. | help + man |
--no-color-diagnostics | Synonym for --color-diagnostics=never. | help + man |
--compress-debug-sections none | Compress .debug_* sections | help |
--dc | Ignored | help |
--dependency-file FILE | Write Makefile-style dependency rules to FILE | help + man |
--defsym SYMBOL=VALUE | Define symbol as an alias for value. | help + man |
--demangle | Demangle C++ symbols in log messages (default) | help + man |
--no-demangle | help | |
--detach | Permit or do not permit mold to create a debug info file in the background. | help + man |
--no-detach | help | |
--discard-none | Keep all local symbols in the symbol table, including temporary ones starting with .L, except ones in mergeable sections. | help + man |
--enable-new-dtags | By default, mold emits DT_RUNPATH for --rpath. | help + man |
--disable-new-dtags | Emit DT_RPATH for --rpath | help |
--execute-only | Make executable segments unreadable | help + man |
--dp | Ignored | help |
--dynamic-list FILE | Read a list of dynamic symbols (implies -Bsymbolic) | help + man |
--dynamic-list-data | Add data symbols to dynamic symbols | help |
--eh-frame-hdr | Create .eh_frame_hdr section. | help + man |
--no-eh-frame-hdr | help | |
--exclude-libs LIB | Mark all symbols in the given libraries hidden. | help + man |
--export-dynamic-symbol symbol | Put symbols matching symbol in the dynamic symbol table. | help + man |
--export-dynamic-symbol-list FILE | Read a list of dynamic symbols from file. | help + man |
--fatal-warnings | Treat warnings as errors. | help + man |
--no-fatal-warnings | Do not treat warnings as errors (default) | help |
--fini SYMBOL | Call symbol at unload-time. | help + man |
--fork | Spawn a child process and let it do the actual linking. | help + man |
--no-fork | help | |
--gc-sections | Remove unreferenced sections. | help + man |
--no-gc-sections | help | |
--gdb-index | Create a .gdb_index section to speed up GNU debugger. | help + man |
--hash-style sysv | Set hash style | help |
--icf all | Fold identical code | help + man |
--no-icf | help | |
--ignore-data-address-equality | Make ICF to merge not only functions but also data. | help + man |
--image-base ADDR | Set the base address to a given value | help + man |
--init SYMBOL | Call symbol at load-time. | help + man |
--nmagic | Do not page align sections | help |
--no-nmagic | help | |
--no-undefined | Report undefined symbols (even with --shared). | help + man |
--noinhibit-exec | Create an output file even if errors occur. | help + man |
--oformat binary | Omit ELF, section, and program headers | help |
--pack-dyn-relocs relr | Pack dynamic relocations | help |
--package-metadata PERCENT_ENCODED_STRING | Embed a specified string into the .note.package section. | help + man |
--perf | Print performance statistics. | help + man |
--pie, --pic-executable | Create a position-independent executable. | help + man |
--no-pie, --no-pic-executable | help | |
--pop-state | Restore the state of flags governing input file handling | help |
--print-gc-sections FILE | Print, or save in FILE, removed unreferenced sections | help + man |
--no-print-gc-sections | help | |
--no-print-icf-sections, --print-icf-sections | Print folded identical sections. | help + man |
--push-state | Save the state of flags governing input file handling | help + man |
--quick-exit | Use or do not use quick_exit to exit. | help + man |
--no-quick-exit | help | |
--relax | Rewrite machine instructions with more efficient ones for some relocations. | help + man |
--no-relax | help | |
--repro | Archive 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 SYMBOL | Like --undefined, except the new symbol must be defined by the end of the link. | help + man |
--retain-symbols-file FILE | Keep only symbols listed in file. | help + man |
--reverse-sections | Reverse the order of input sections before assigning them the offsets in the output file. | help + man |
--rosegment | Put read-only non-executable sections in their own segment (default) | help |
--no-rosegment | Put read-only non-executable sections in an executable segment | help |
--rpath DIR | Add DIR to the runtime search path | help + man |
--rpath-link DIR | Ignored | help |
--run COMMAND | Run command with mold as /usr/bin/ld. | help + man |
--no-separate-debug-file | help | |
--shared, --Bshareable | Create a shared library | help + man |
--shuffle-sections SEED | Randomize the output by shuffling the order of input sections before assigning them the offsets in the output file. | help + man |
--sort-common | Ignored | help |
--sort-section | Ignored | help |
--spare-program-headers NUMBER | Append 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-lib | Handle object files between --start-lib and --end-lib as if they were in an archive file. | help + man |
--end-lib | End the effect of --start-lib | help |
--stats | Print input statistics. | help + man |
--sysroot DIR | Set target system root directory to dir. | help + man |
--thread-count, --threads COUNT | Use count number of threads. | help + man + man |
--no-threads | help | |
--trace | Print the name of each input file | help + man |
--undefined-glob PATTERN | Synonym for --undefined, except that --undefined-glob takes a glob pattern instead of just a single symbol name. | help + man |
--undefined-version | By 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-version | Report version scripts that refer to undefined symbols (default) | help |
--unique PATTERN | Don't merge input sections that match the given glob pattern pattern. | help + man |
--unresolved-symbols report-all | Handle unresolved symbols | help |
--version-script FILE | Read version script from file. | help + man |
--warn-common | Warn about common symbols. | help + man |
--no-warn-common | help | |
--warn-once | Only warn once for each undefined symbol instead of warn for each relocation referring an undefined symbol. | help + man |
--warn-shared-textrel | Warn if the output .so needs text relocations | help |
--warn-textrel | Warn if the output file needs text relocations | help |
--warn-unresolved-symbols | Normally, the linker reports an error for unresolved symbols. | help + man |
--error-unresolved-symbols | Report unresolved symbols as errors (default) | help |
--whole-archive | When 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-archive | help | |
--wrap SYMBOL | Use a wrapper function for a given symbol | help + man |
--zero-to-bss | Convert all-zero data sections into BSS. | help + man |
-z defs | As 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-dependencies | Print out dependency information for input files. (in the manual page but not in --help) | man |
--relocatable-merge-sections | By 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 file | Bundle 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 libname | Set the DT_FILTER dynamic section field to libname. (in the manual page but not in --help) | man |
-f, --auxiliary shlib | Set the DT_AUXILIARY dynamic section field to shlib. (in the manual page but not in --help) | man |
-h, --soname libname | Set the DT_SONAME dynamic section field to libname. (in the manual page but not in --help) | man |
-l libname | Search for liblibname.so or liblibname.a from library search paths. (in the manual page but not in --help) | man |
-u, --undefined symbol | If 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 symbol | Trace references to symbol. (in the manual page but not in --help) | man |
--allow-multiple-definition | Normally, 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-undefined | Even 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-symver | Use soname as a symbol version and append that version to all symbols. (in the manual page but not in --help) | man |
--section-start section=address | Set address to section. (in the manual page but not in --help) | man |
--spare-dynamic-tags number | Append 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 |