diff --git a/docs/mold.1 b/docs/mold.1 index 2b3a3d6a19..88e4ca4317 100644 --- a/docs/mold.1 +++ b/docs/mold.1 @@ -1,6 +1,6 @@ .\" generated with Ronn-NG/v0.9.1 .\" http://github.com/apjanke/ronn-ng/tree/0.9.1 -.TH "MOLD" "1" "October 2024" "" +.TH "MOLD" "1" "January 2025" "" .SH "NAME" \fBmold\fR \- a modern linker .SH "SYNOPSIS" @@ -141,194 +141,142 @@ If \fB\-\-rewrite\-endbr\fR is given, mold conducts a whole program analysis to .IP This feature is currently available only on x86\-64\. .SH "GNU\-COMPATIBLE OPTIONS" -.TP -\fB\-\-help\fR -Report usage information to stdout and exit\. -.TP -\fB\-v\fR, \fB\-\-version\fR -Report version information to stdout\. -.TP -\fB\-V\fR -Report version and target information to stdout\. -.TP -\fB\-E\fR, \fB\-\-export\-dynamic\fR, \fB\-\-no\-export\-dynamic\fR -When creating an executable, using the \fB\-E\fR 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\. +.IP "\[ci]" 4 +\fB\-\-help\fR: Report usage information to stdout and exit\. +.IP "\[ci]" 4 +\fB\-v\fR, \fB\-\-version\fR: Report version information to stdout\. +.IP "\[ci]" 4 +\fB\-V\fR: Report version and target information to stdout\. +.IP "\[ci]" 4 +\fB\-E\fR, \fB\-\-export\-dynamic\fR, \fB\-\-no\-export\-dynamic\fR: When creating an executable, using the \fB\-E\fR 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\. .IP By default, or if \fB\-\-no\-export\-dynamic\fR is given, only symbols that are referenced by DSOs at link\-time are exported from an executable\. -.TP -\fB\-F\fR \fIlibname\fR, \fB\-\-filter\fR=\fIlibname\fR -Set the \fBDT_FILTER\fR dynamic section field to \fIlibname\fR\. -.TP -\fB\-I\fR \fIfile\fR, \fB\-\-dynamic\-linker\fR=\fIfile\fR, \fB\-\-no\-dynamic\-linker\fR -Set the dynamic linker path to \fIfile\fR\. If no \fB\-I\fR option is given, or if \fB\-\-no\-dynamic\-linker\fR is given, no dynamic linker path is set to an output file\. This is contrary to the GNU linkers which set a default dynamic linker path in that case\. This difference doesn't usually make any difference because the compiler driver always passes \fB\-I\fR to the linker\. -.TP -\fB\-L\fR \fIdir\fR, \fB\-\-library\-path\fR=\fIdir\fR -Add \fIdir\fR to the list of library search paths from which \fBmold\fR searches libraries for the \fB\-l\fR option\. +.IP "\[ci]" 4 +\fB\-F\fR \fIlibname\fR, \fB\-\-filter\fR=\fIlibname\fR: Set the \fBDT_FILTER\fR dynamic section field to \fIlibname\fR\. +.IP "\[ci]" 4 +\fB\-I\fR \fIfile\fR, \fB\-\-dynamic\-linker\fR=\fIfile\fR, \fB\-\-no\-dynamic\-linker\fR: Set the dynamic linker path to \fIfile\fR\. If no \fB\-I\fR option is given, or if \fB\-\-no\-dynamic\-linker\fR is given, no dynamic linker path is set to an output file\. This is contrary to the GNU linkers which set a default dynamic linker path in that case\. This difference doesn't usually make any difference because the compiler driver always passes \fB\-I\fR to the linker\. +.IP "\[ci]" 4 +\fB\-L\fR \fIdir\fR, \fB\-\-library\-path\fR=\fIdir\fR: Add \fIdir\fR to the list of library search paths from which \fBmold\fR searches libraries for the \fB\-l\fR option\. .IP Unlike the GNU linkers, \fBmold\fR does not have default search paths\. This difference doesn't usually make any difference because the compiler driver always passes all necessary search paths to the linker\. -.TP -\fB\-M\fR, \fB\-\-print\-map\fR -Write a map file to stdout\. -.TP -\fB\-N\fR, \fB\-\-omagic\fR, \fB\-\-no\-omagic\fR -Force \fBmold\fR to emit an output file with an old\-fashioned memory layout\. First, it makes the first data segment not aligned to a page boundary\. Second, text segments are marked as writable if the option is given\. -.TP -\fB\-S\fR, \fB\-\-strip\-debug\fR -Omit \fB\.debug_*\fR sections from the output file\. -.TP -\fB\-T\fR \fIfile\fR, \fB\-\-script\fR=\fIfile\fR -Read linker script from \fIfile\fR\. -.TP -\fB\-X\fR, \fB\-\-discard\-locals\fR -Discard temporary local symbols to reduce the sizes of the symbol table and the string table\. Temporary local symbols are local symbols starting with \fB\.L\fR\. Compilers usually generate such symbols for unnamed program elements such as string literals or floating\-point literals\. -.TP +.IP "\[ci]" 4 +\fB\-M\fR, \fB\-\-print\-map\fR: Write a map file to stdout\. +.IP "\[ci]" 4 +\fB\-N\fR, \fB\-\-omagic\fR, \fB\-\-no\-omagic\fR: Force \fBmold\fR to emit an output file with an old\-fashioned memory layout\. First, it makes the first data segment not aligned to a page boundary\. Second, text segments are marked as writable if the option is given\. +.IP "\[ci]" 4 +\fB\-S\fR, \fB\-\-strip\-debug\fR: Omit \fB\.debug_*\fR sections from the output file\. +.IP "\[ci]" 4 +\fB\-T\fR \fIfile\fR, \fB\-\-script\fR=\fIfile\fR: Read linker script from \fIfile\fR\. +.IP "\[ci]" 4 +\fB\-X\fR, \fB\-\-discard\-locals\fR: Discard temporary local symbols to reduce the sizes of the symbol table and the string table\. Temporary local symbols are local symbols starting with \fB\.L\fR\. Compilers usually generate such symbols for unnamed program elements such as string literals or floating\-point literals\. +.IP "\[ci]" 4 \fB\-e\fR \fIsymbol\fR, \fB\-\-entry\fR=\fIsymbol\fR: - -.TP -\fB\-f\fR \fIshlib\fR, \fB\-\-auxiliary\fR=\fIshlib\fR -Set the \fBDT_AUXILIARY\fR dynamic section field to \fIshlib\fR\. -.TP -\fB\-h\fR \fIlibname\fR, \fB\-\-soname\fR=\fIlibname\fR -Set the \fBDT_SONAME\fR dynamic section field to \fIlibname\fR\. This option is used when creating a shared object file\. Typically, when you create \fBlibfoo\.so\fR, you want to pass \fB\-\-soname=foo\fR to a linker\. -.TP -\fB\-l\fR \fIlibname\fR -Search for \fBlib\fR\fIlibname\fR\fB\.so\fR or \fBlib\fR\fIlibname\fR\fB\.a\fR from library search paths\. -.TP -\fB\-m\fR \fItarget\fR -Choose a \fItarget\fR\. -.TP -\fB\-o\fR \fIfile\fR, \fB\-\-output\fR=\fIfile\fR -Use \fIfile\fR as the output file name instead of the default name \fBa\.out\fR\. -.TP -\fB\-r\fR, \fB\-\-relocatable\fR -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\. -.TP -\fB\-s\fR, \fB\-\-strip\-all\fR -Omit \fB\.symtab\fR section from the output file\. -.TP -\fB\-u\fR \fIsymbol\fR, \fB\-\-undefined\fR=\fIsymbol\fR -If \fIsymbol\fR remains as an undefined symbol after reading all object files, and if there is a static archive that contains an object file defining \fIsymbol\fR, pull out the object file and link it so that the output file contains a definition of \fIsymbol\fR\. -.TP -\fB\-y\fR \fIsymbol\fR, \fB\-\-trace\-symbol\fR=\fIsymbol\fR -Trace references to \fIsymbol\fR\. -.TP -\fB\-\-Bdynamic\fR -Link against shared libraries\. -.TP -\fB\-\-Bstatic\fR -Do not link against shared libraries\. -.TP -\fB\-\-Bsymbolic\fR -When creating a shared library, make global symbols export\-only (i\.e\. do not import the same symbol)\. As a result, references within a shared library are always resolved locally, negating symbol override at runtime\. See "Dynamic symbol resolution" for more information about symbol imports and exports\. -.TP -\fB\-\-Bsymbolic\-functions\fR -This option has the same effect as \fB\-\-Bsymbolic\fR but works only for function symbols\. Data symbols remain being both imported and exported\. -.TP -\fB\-\-Bsymbolic\-non\-weak\fR -This option has the same effect as \fB\-\-Bsymbolic\fR but works only for non\-weak symbols\. Weak symbols remain being both imported and exported\. -.TP -\fB\-\-Bsymbolic\-non\-weak\-functions\fR -This option has the same effect as \fB\-\-Bsymbolic\fR but works only for non\-weak function symbols\. Data symbols and weak function symbols remain being both imported and exported\. -.TP -\fB\-\-Bno\-symbolic\fR -Cancel \fB\-\-Bsymbolic\fR, \fB\-\-Bsymbolic\-functions\fR, \fB\-\-Bsymbolic\-non\-weak\fR and \fB\-\-Bsymbolic\-non\-weak\-functions\fR\. -.TP -\fB\-\-Map\fR=\fIfile\fR -Write map file to \fIfile\fR\. -.TP -\fB\-\-Tbss\fR=\fIaddress\fR -Alias for \fB\-\-section\-start=\.bss=\fR\fIaddress\fR\. -.TP -\fB\-\-Tdata\fR=\fIaddress\fR -Alias for \fB\-\-section\-start=\.data=\fR\fIaddress\fR\. -.TP -\fB\-\-Ttext\fR=\fIaddress\fR -Alias for \fB\-\-section\-start=\.text=\fR\fIaddress\fR\. -.TP -\fB\-\-allow\-multiple\-definition\fR -Normally, the linker reports an error if there are more than one definition of a symbol\. This option changes the default behavior so that it doesn't report an error for duplicate definitions and instead use the first definition\. -.TP -\fB\-\-allow\-shlib\-undefined\fR, \fB\-\-no\-allow\-shlib\-undefined\fR -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 shared libraries in any ELF module\. This occurs because mold ignores undefined symbols in shared libraries by default\. +.IP +Use \fIsymbol\fR as the entry point symbol instead of the default entry point symbol _start\. +.IP "\[ci]" 4 +\fB\-f\fR \fIshlib\fR, \fB\-\-auxiliary\fR=\fIshlib\fR: Set the \fBDT_AUXILIARY\fR dynamic section field to \fIshlib\fR\. +.IP "\[ci]" 4 +\fB\-h\fR \fIlibname\fR, \fB\-\-soname\fR=\fIlibname\fR: Set the \fBDT_SONAME\fR dynamic section field to \fIlibname\fR\. This option is used when creating a shared object file\. Typically, when you create \fBlibfoo\.so\fR, you want to pass \fB\-\-soname=foo\fR to a linker\. +.IP "\[ci]" 4 +\fB\-l\fR \fIlibname\fR: Search for \fBlib\fR\fIlibname\fR\fB\.so\fR or \fBlib\fR\fIlibname\fR\fB\.a\fR from library search paths\. +.IP "\[ci]" 4 +\fB\-m\fR \fItarget\fR: Choose a \fItarget\fR\. +.IP "\[ci]" 4 +\fB\-o\fR \fIfile\fR, \fB\-\-output\fR=\fIfile\fR: Use \fIfile\fR as the output file name instead of the default name \fBa\.out\fR\. +.IP "\[ci]" 4 +\fB\-r\fR, \fB\-\-relocatable\fR: 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\. +.IP "\[ci]" 4 +\fB\-s\fR, \fB\-\-strip\-all\fR: Omit \fB\.symtab\fR section from the output file\. +.IP "\[ci]" 4 +\fB\-u\fR \fIsymbol\fR, \fB\-\-undefined\fR=\fIsymbol\fR: If \fIsymbol\fR remains as an undefined symbol after reading all object files, and if there is a static archive that contains an object file defining \fIsymbol\fR, pull out the object file and link it so that the output file contains a definition of \fIsymbol\fR\. +.IP "\[ci]" 4 +\fB\-y\fR \fIsymbol\fR, \fB\-\-trace\-symbol\fR=\fIsymbol\fR: Trace references to \fIsymbol\fR\. +.IP "\[ci]" 4 +\fB\-\-Bdynamic\fR: Link against shared libraries\. +.IP "\[ci]" 4 +\fB\-\-Bstatic\fR: Do not link against shared libraries\. +.IP "\[ci]" 4 +\fB\-\-Bsymbolic\fR: When creating a shared library, make global symbols export\-only (i\.e\. do not import the same symbol)\. As a result, references within a shared library are always resolved locally, negating symbol override at runtime\. See "Dynamic symbol resolution" for more information about symbol imports and exports\. +.IP "\[ci]" 4 +\fB\-\-Bsymbolic\-functions\fR: This option has the same effect as \fB\-\-Bsymbolic\fR but works only for function symbols\. Data symbols remain being both imported and exported\. +.IP "\[ci]" 4 +\fB\-\-Bsymbolic\-non\-weak\fR: This option has the same effect as \fB\-\-Bsymbolic\fR but works only for non\-weak symbols\. Weak symbols remain being both imported and exported\. +.IP "\[ci]" 4 +\fB\-\-Bsymbolic\-non\-weak\-functions\fR: This option has the same effect as \fB\-\-Bsymbolic\fR but works only for non\-weak function symbols\. Data symbols and weak function symbols remain being both imported and exported\. +.IP "\[ci]" 4 +\fB\-\-Bno\-symbolic\fR: Cancel \fB\-\-Bsymbolic\fR, \fB\-\-Bsymbolic\-functions\fR, \fB\-\-Bsymbolic\-non\-weak\fR and \fB\-\-Bsymbolic\-non\-weak\-functions\fR\. +.IP "\[ci]" 4 +\fB\-\-Map\fR=\fIfile\fR: Write map file to \fIfile\fR\. +.IP "\[ci]" 4 +\fB\-\-Tbss\fR=\fIaddress\fR: Alias for \fB\-\-section\-start=\.bss=\fR\fIaddress\fR\. +.IP "\[ci]" 4 +\fB\-\-Tdata\fR=\fIaddress\fR: Alias for \fB\-\-section\-start=\.data=\fR\fIaddress\fR\. +.IP "\[ci]" 4 +\fB\-\-Ttext\fR=\fIaddress\fR: Alias for \fB\-\-section\-start=\.text=\fR\fIaddress\fR\. +.IP "\[ci]" 4 +\fB\-\-allow\-multiple\-definition\fR: Normally, the linker reports an error if there are more than one definition of a symbol\. This option changes the default behavior so that it doesn't report an error for duplicate definitions and instead use the first definition\. +.IP "\[ci]" 4 +\fB\-\-allow\-shlib\-undefined\fR, \fB\-\-no\-allow\-shlib\-undefined\fR: 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 shared libraries in any ELF module\. This occurs because mold ignores undefined symbols in shared libraries by default\. .IP If you pass \fB\-\-no\-allow\-shlib\-undefined\fR, mold verifies that undefined symbols in shared libraries given to the linker can be resolved at link\-time\. In other words, this converts the runtime error to a link\-time error\. .IP Note that you need to pass all shared libraries, including indirectly dependent ones, to the linker as arguments for \fB\-l\fR\. If a shared library depends on a library that's not passed to the linker, the verification will be skipped for that file\. -.TP -\fB\-\-as\-needed\fR, \fB\-\-no\-as\-needed\fR -By default, shared libraries given to the linker are unconditionally added to the list of required libraries in an output file\. However, shared libraries after \fB\-\-as\-needed\fR are added to the list only when at least one symbol is actually used by the output file\. In other words, shared libraries after \fB\-\-as\-needed\fR are not added to the list of needed libraries if they are not needed by a program\. +.IP "\[ci]" 4 +\fB\-\-as\-needed\fR, \fB\-\-no\-as\-needed\fR: By default, shared libraries given to the linker are unconditionally added to the list of required libraries in an output file\. However, shared libraries after \fB\-\-as\-needed\fR are added to the list only when at least one symbol is actually used by the output file\. In other words, shared libraries after \fB\-\-as\-needed\fR are not added to the list of needed libraries if they are not needed by a program\. .IP The \fB\-\-no\-as\-needed\fR option restores the default behavior for subsequent files\. -.TP -\fB\-\-build\-id\fR=[ \fBmd5\fR | \fBsha1\fR | \fBsha256\fR | \fBfast\fR | \fBuuid\fR | \fB0x\fR\fIhexstring\fR | \fBnone\fR ] -Create a \fB\.note\.gnu\.build\-id\fR section containing a byte string to uniquely identify an output file\. \fBsha256\fR compute a 256\-bit cryptographic hash of an output file and set it to build\-id\. \fBmd5\fR and \fBsha1\fR compute the same hash but truncate it to 128 and 160 bits, respectively, before setting it to build\-id\. \fBuuid\fR sets a random 128\-bit UUID\. \fB0x\fR\fIhexstring\fR sets \fIhexstring\fR\. \fBfast\fR is a synonym for \fBsha256\fR\. -.TP -\fB\-\-build\-id\fR -Synonym for \fB\-\-build\-id=sha256\fR\. -.TP -\fB\-\-no\-build\-id\fR -Synonym for \fB\-\-build\-id=none\fR\. -.TP -\fB\-\-compress\-debug\-sections\fR=[ \fBzlib\fR | \fBzlib\-gabi\fR | \fBzstd\fR | \fBnone\fR ] -Compress DWARF debug info (\fB\.debug_*\fR sections) using the zlib or zstd compression algorithm\. \fBzlib\-gabi\fR is an alias for \fBzlib\fR\. -.TP -\fB\-\-defsym\fR=\fIsymbol\fR=\fIvalue\fR -Define \fIsymbol\fR as an alias for \fIvalue\fR\. +.IP "\[ci]" 4 +\fB\-\-build\-id\fR=[ \fBmd5\fR | \fBsha1\fR | \fBsha256\fR | \fBfast\fR | \fBuuid\fR | \fB0x\fR\fIhexstring\fR | \fBnone\fR ]: Create a \fB\.note\.gnu\.build\-id\fR section containing a byte string to uniquely identify an output file\. \fBsha256\fR compute a 256\-bit cryptographic hash of an output file and set it to build\-id\. \fBmd5\fR and \fBsha1\fR compute the same hash but truncate it to 128 and 160 bits, respectively, before setting it to build\-id\. \fBuuid\fR sets a random 128\-bit UUID\. \fB0x\fR\fIhexstring\fR sets \fIhexstring\fR\. \fBfast\fR is a synonym for \fBsha256\fR\. +.IP "\[ci]" 4 +\fB\-\-build\-id\fR: Synonym for \fB\-\-build\-id=sha256\fR\. +.IP "\[ci]" 4 +\fB\-\-no\-build\-id\fR: Synonym for \fB\-\-build\-id=none\fR\. +.IP "\[ci]" 4 +\fB\-\-compress\-debug\-sections\fR=[ \fBzlib\fR | \fBzlib\-gabi\fR | \fBzstd\fR | \fBnone\fR ]: Compress DWARF debug info (\fB\.debug_*\fR sections) using the zlib or zstd compression algorithm\. \fBzlib\-gabi\fR is an alias for \fBzlib\fR\. +.IP "\[ci]" 4 +\fB\-\-defsym\fR=\fIsymbol\fR=\fIvalue\fR: Define \fIsymbol\fR as an alias for \fIvalue\fR\. .IP \fIvalue\fR is either an integer (in decimal or hexadecimal with \fB0x\fR prefix) or a symbol name\. If an integer is given as a value, \fIsymbol\fR is defined as an absolute symbol with the given value\. -.TP -\fB\-\-default\-symver\fR -Use soname as a symbol version and append that version to all symbols\. -.TP -\fB\-\-demangle\fR, \fB\-\-no\-demangle\fR -Demangle C++ and Rust symbols in log messages\. -.TP -\fB\-\-dependency\-file\fR=\fIfile\fR -Write a dependency file to \fIfile\fR\. The contents of the written file is readable by make(1), which defines only one rule with the linker's output file as a target and all input files as its prerequisites\. Users are expected to include the generated dependency file into a Makefile to automate the dependency management\. This option is analogous to the compiler's \fB\-MM \-MF\fR options\. -.TP -\fB\-\-dynamic\-list\fR=\fIfile\fR -Read a list of dynamic symbols from \fIfile\fR\. Same as \fB\-\-export\-dynamic\-symbol\-list\fR, except that it implies \fB\-\-Bsymbolic\fR\. If \fIfile\fR does not exist in the current directory, it is searched from library search paths for the sake of compatibility with GNU ld\. -.TP -\fB\-\-eh\-frame\-hdr\fR, \fB\-\-no\-eh\-frame\-hdr\fR -Create \fB\.eh_frame_hdr\fR section\. -.TP -\fB\-\-emit\-relocs\fR -The linker usually "consumes" relocation sections\. That is, the linker applies relocations to other sections, and relocation sections themselves are discarded\. +.IP "\[ci]" 4 +\fB\-\-default\-symver\fR: Use soname as a symbol version and append that version to all symbols\. +.IP "\[ci]" 4 +\fB\-\-demangle\fR, \fB\-\-no\-demangle\fR: Demangle C++ and Rust symbols in log messages\. +.IP "\[ci]" 4 +\fB\-\-dependency\-file\fR=\fIfile\fR: Write a dependency file to \fIfile\fR\. The contents of the written file is readable by make(1), which defines only one rule with the linker's output file as a target and all input files as its prerequisites\. Users are expected to include the generated dependency file into a Makefile to automate the dependency management\. This option is analogous to the compiler's \fB\-MM \-MF\fR options\. +.IP "\[ci]" 4 +\fB\-\-dynamic\-list\fR=\fIfile\fR: Read a list of dynamic symbols from \fIfile\fR\. Same as \fB\-\-export\-dynamic\-symbol\-list\fR, except that it implies \fB\-\-Bsymbolic\fR\. If \fIfile\fR does not exist in the current directory, it is searched from library search paths for the sake of compatibility with GNU ld\. +.IP "\[ci]" 4 +\fB\-\-eh\-frame\-hdr\fR, \fB\-\-no\-eh\-frame\-hdr\fR: Create \fB\.eh_frame_hdr\fR section\. +.IP "\[ci]" 4 +\fB\-\-emit\-relocs\fR: The linker usually "consumes" relocation sections\. That is, the linker applies relocations to other sections, and relocation sections themselves are discarded\. .IP The \fB\-\-emit\-relocs\fR instructs the linker to leave relocation sections in the output file\. Some post\-link binary analysis or optimization tools such as LLVM Bolt need them\. -.TP -\fB\-\-enable\-new\-dtags\fR, \fB\-\-disable\-new\-dtags\fR -By default, \fBmold\fR emits \fBDT_RUNPATH\fR for \fB\-\-rpath\fR\. If you pass \fB\-\-disable\-new\-dtags\fR, \fBmold\fR emits \fBDT_RPATH\fR for \fB\-\-rpath\fR instead\. -.TP +.IP "\[ci]" 4 +\fB\-\-enable\-new\-dtags\fR, \fB\-\-disable\-new\-dtags\fR: By default, \fBmold\fR emits \fBDT_RUNPATH\fR for \fB\-\-rpath\fR\. If you pass \fB\-\-disable\-new\-dtags\fR, \fBmold\fR emits \fBDT_RPATH\fR for \fB\-\-rpath\fR instead\. +.IP "\[ci]" 4 \fB\-\-execute\-only\fR: - -.TP -\fB\-\-exclude\-libs\fR=\fIlibraries\fR \|\.\|\.\|\. -Mark all symbols in the given \fIlibraries\fR hidden\. -.TP -\fB\-\-export\-dynamic\-symbol\fR=\fIsymbol\fR -Put symbols matching \fIsymbol\fR in the dynamic symbol table\. \fIsymbol\fR may be a glob pattern in the same syntax as for the \fB\-\-export\-dynamic\-symbol\-list\fR or \fB\-\-version\-script\fR options\. -.TP -\fB\-\-export\-dynamic\-symbol\-list\fR=\fIfile\fR -Read a list of dynamic symbols from \fIfile\fR\. -.TP -\fB\-\-fatal\-warnings\fR, \fB\-\-no\-fatal\-warnings\fR -Treat warnings as errors\. -.TP -\fB\-\-fini\fR=\fIsymbol\fR -Call \fIsymbol\fR at unload\-time\. -.TP -\fB\-\-gc\-sections\fR, \fB\-\-no\-gc\-sections\fR -Remove unreferenced sections\. -.TP -\fB\-\-gdb\-index\fR -Create a \fB\.gdb_index\fR section to speed up GNU debugger\. To use this, you need to compile source files with the \fB\-ggnu\-pubnames\fR compiler flag\. -.TP -\fB\-\-hash\-style\fR=[ \fBsysv\fR | \fBgnu\fR | \fBboth\fR | \fBnone\fR ] -Set hash style\. -.TP -\fB\-\-icf\fR=[ \fBsafe\fR | \fBall\fR | \fBnone\fR ], \fB\-\-no\-icf\fR -It is not uncommon for a program to contain many identical functions that differ only in name\. For example, a C++ template \fBstd::vector\fR is very likely to be instantiated to the identical code for \fBstd::vector\fR and \fBstd::vector\fR because the container cares only about the size of the parameter type\. Identical Code Folding (ICF) is a size optimization to identify and merge such identical functions\. +.IP +Traditionally, setting the executable bit to 1 for a memory page implies that the page also become readable, which allows machine code to be read as data at runtime\. That is actually what an attacker often does after gaining a limited control of a process to find pieces of machine code they can use to gain the full control of the process\. As a mitigation, recent processors including some ARM64 ones allows "execute\-only" pages\. If a page is execute\-only, you can call a function there as long as you know its address but can't read it as data\. +.IP +This option marks text segments as execute\-only by setting just the "X" bit instead of "RX"\. Note that on most systems, the absence of the "R" bit in the text segment serves just as a hint\. If you run a program linked with \fB\-\-execute\-only\fR on a processor that doesn't support execute\-only pages, your executable will likely still function normally, but the text segment will remain readable\. +.IP "\[ci]" 4 +\fB\-\-exclude\-libs\fR=\fIlibraries\fR \|\.\|\.\|\.: Mark all symbols in the given \fIlibraries\fR hidden\. +.IP "\[ci]" 4 +\fB\-\-export\-dynamic\-symbol\fR=\fIsymbol\fR: Put symbols matching \fIsymbol\fR in the dynamic symbol table\. \fIsymbol\fR may be a glob pattern in the same syntax as for the \fB\-\-export\-dynamic\-symbol\-list\fR or \fB\-\-version\-script\fR options\. +.IP "\[ci]" 4 +\fB\-\-export\-dynamic\-symbol\-list\fR=\fIfile\fR: Read a list of dynamic symbols from \fIfile\fR\. +.IP "\[ci]" 4 +\fB\-\-fatal\-warnings\fR, \fB\-\-no\-fatal\-warnings\fR: Treat warnings as errors\. +.IP "\[ci]" 4 +\fB\-\-fini\fR=\fIsymbol\fR: Call \fIsymbol\fR at unload\-time\. +.IP "\[ci]" 4 +\fB\-\-gc\-sections\fR, \fB\-\-no\-gc\-sections\fR: Remove unreferenced sections\. +.IP "\[ci]" 4 +\fB\-\-gdb\-index\fR: Create a \fB\.gdb_index\fR section to speed up GNU debugger\. To use this, you need to compile source files with the \fB\-ggnu\-pubnames\fR compiler flag\. +.IP "\[ci]" 4 +\fB\-\-hash\-style\fR=[ \fBsysv\fR | \fBgnu\fR | \fBboth\fR | \fBnone\fR ]: Set hash style\. +.IP "\[ci]" 4 +\fB\-\-icf\fR=[ \fBsafe\fR | \fBall\fR | \fBnone\fR ], \fB\-\-no\-icf\fR: It is not uncommon for a program to contain many identical functions that differ only in name\. For example, a C++ template \fBstd::vector\fR is very likely to be instantiated to the identical code for \fBstd::vector\fR and \fBstd::vector\fR because the container cares only about the size of the parameter type\. Identical Code Folding (ICF) is a size optimization to identify and merge such identical functions\. .IP If \fB\-\-icf=all\fR is given, \fBmold\fR tries to merge all identical functions\. This reduces the size of the output most, but it is not a "safe" optimization\. It is guaranteed in C and C++ that two pointers pointing two different functions will never be equal, but \fB\-\-icf=all\fR breaks that assumption as two identical functions have the same address after merging\. So a care must be taken when you use this flag that your program does not depend on the function pointer uniqueness\. .IP @@ -337,193 +285,145 @@ If \fB\-\-icf=all\fR is given, \fBmold\fR tries to merge all identical functions \fB\-\-icf=safe\fR needs to be used with a compiler that supports \fB\.llvm_addrsig\fR section which contains the information as to what symbols are address\-taken\. LLVM/Clang supports that section by default\. Since GCC does not support it yet, you cannot use \fB\-\-icf=safe\fR with GCC (it doesn't do any harm but can't optimize at all\.) .IP \fB\-\-icf=none\fR and \fB\-\-no\-icf\fR disables ICF\. -.TP -\fB\-\-ignore\-data\-address\-equality\fR -Make ICF to merge not only functions but also data\. This option should be used in combination with \fB\-\-icf=all\fR\. -.TP -\fB\-\-image\-base\fR=\fIaddr\fR -Set the base address to \fIaddr\fR\. -.TP -\fB\-\-init\fR=\fIsymbol\fR -Call \fIsymbol\fR at load\-time\. -.TP -\fB\-\-no\-undefined\fR -Report undefined symbols (even with \fB\-\-shared\fR)\. -.TP -\fB\-\-noinhibit\-exec\fR -Create an output file even if errors occur\. -.TP -\fB\-\-pack\-dyn\-relocs\fR=[ \fBrelr\fR | \fBnone\fR ] -If \fBrelr\fR is specified, all \fBR_*_RELATIVE\fR relocations are put into \fB\.relr\.dyn\fR section instead of \fB\.rel\.dyn\fR or \fB\.rela\.dyn\fR section\. Since \fB\.relr\.dyn\fR section uses a space\-efficient encoding scheme, specifying this flag can reduce the size of the output\. This is typically most effective for position\-independent executable\. +.IP "\[ci]" 4 +\fB\-\-ignore\-data\-address\-equality\fR: Make ICF to merge not only functions but also data\. This option should be used in combination with \fB\-\-icf=all\fR\. +.IP "\[ci]" 4 +\fB\-\-image\-base\fR=\fIaddr\fR: Set the base address to \fIaddr\fR\. +.IP "\[ci]" 4 +\fB\-\-init\fR=\fIsymbol\fR: Call \fIsymbol\fR at load\-time\. +.IP "\[ci]" 4 +\fB\-\-no\-undefined\fR: Report undefined symbols (even with \fB\-\-shared\fR)\. +.IP "\[ci]" 4 +\fB\-\-noinhibit\-exec\fR: Create an output file even if errors occur\. +.IP "\[ci]" 4 +\fB\-\-package\-metadata\fR==\fIpercent\-encoded\-string\fR +.IP +Embed a specified string into the \fB\.note\.package\fR section\. This option is designed for build scripts that generate binary packages, such as \fB\.rpm\fR or \fB\.deb\fR, to include package metadata in each executable\. It simplifies the process of identifying the corresponding package for a given executable or core file\. +.IP +An argument to this option is treated as percent\-encoded and decoded before being inserted into the section, allowing you to avoid the use of the comma (\fB,\fR) character in the argument\. This is useful because the compiler replaces all occurrences of commas in \fB\-Wl,\fR with spaces before forwarding them to the linker\. Note that \fBmold\fR always interprets the argument as percent\-encoded, so you also need to escape all occurrences of \fB%\fR as \fB%25\fR\. +.IP "\[ci]" 4 +\fB\-\-pack\-dyn\-relocs\fR=[ \fBrelr\fR | \fBnone\fR ]: If \fBrelr\fR is specified, all \fBR_*_RELATIVE\fR relocations are put into \fB\.relr\.dyn\fR section instead of \fB\.rel\.dyn\fR or \fB\.rela\.dyn\fR section\. Since \fB\.relr\.dyn\fR section uses a space\-efficient encoding scheme, specifying this flag can reduce the size of the output\. This is typically most effective for position\-independent executable\. .IP Note that a runtime loader has to support \fB\.relr\.dyn\fR to run executables or shared libraries linked with \fB\-\-pack\-dyn\-relocs=relr\fR\. As of 2022, only ChromeOS, Android and Fuchsia support it\. -.TP -\fB\-\-pie\fR, \fB\-\-pic\-executable\fR, \fB\-\-no\-pie\fR, \fB\-\-no\-pic\-executable\fR -Create a position\-independent executable\. -.TP -\fB\-\-print\-gc\-sections\fR, \fB\-\-no\-print\-gc\-sections\fR -Print removed unreferenced sections\. -.TP -\fB\-\-print\-icf\-sections\fR, \fB\-\-no\-print\-icf\-sections\fR -Print folded identical sections\. -.TP -\fB\-\-push\-state\fR, \fB\-\-pop\-state\fR -\fB\-\-push\-state\fR saves the current values of \fB\-\-as\-needed\fR, \fB\-\-whole\-archive\fR, \fB\-\-static\fR, and \fB\-\-start\-lib\fR\. The saved values can be restored by pop\-state\. +.IP "\[ci]" 4 +\fB\-\-pie\fR, \fB\-\-pic\-executable\fR, \fB\-\-no\-pie\fR, \fB\-\-no\-pic\-executable\fR: Create a position\-independent executable\. +.IP "\[ci]" 4 +\fB\-\-print\-gc\-sections\fR, \fB\-\-no\-print\-gc\-sections\fR: Print removed unreferenced sections\. +.IP "\[ci]" 4 +\fB\-\-print\-icf\-sections\fR, \fB\-\-no\-print\-icf\-sections\fR: Print folded identical sections\. +.IP "\[ci]" 4 +\fB\-\-push\-state\fR, \fB\-\-pop\-state\fR: \fB\-\-push\-state\fR saves the current values of \fB\-\-as\-needed\fR, \fB\-\-whole\-archive\fR, \fB\-\-static\fR, and \fB\-\-start\-lib\fR\. The saved values can be restored by pop\-state\. .IP \fB\-\-push\-state\fR and \fB\-\-pop\-state\fR pairs can nest\. .IP These options are useful when you want to construct linker command line options programmatically\. For example, if you want to link \fBlibfoo\.so\fR by as\-needed basis but don't want to change the global state of \fB\-\-as\-needed\fR, you can append \fB\-\-push\-state \-\-as\-needed \-lfoo \-\-pop\-state\fR to the linker command line options\. -.TP -\fB\-\-relax, \-\-no\-relax\fR -Rewrite machine instructions with more efficient ones for some relocations\. The feature is enabled by default\. -.TP -\fB\-\-require\-defined\fR=\fIsymbol\fR -Like \fB\-\-undefined\fR, except the new symbol must be defined by the end of the link\. -.TP -\fB\-\-retain\-symbols\-file\fR=\fIfile\fR -Keep only symbols listed in \fIfile\fR\. \fIfile\fR is a text file containing a symbol name on each line\. \fBmold\fR discards all local symbols as well as global symbol that are not in \fIfile\fR\. Note that this option removes symbols only from \fB\.symtab\fR section and does not affect \fB\.dynsym\fR section, which is used for dynamic linking\. -.TP -\fB\-\-rpath\fR=\fIdir\fR -Add \fIdir\fR to runtime search paths\. -.TP -\fB\-\-section\-start\fR=\fIsection\fR=\fIaddress\fR -Set \fIaddress\fR to section\. \fIaddress\fR is a hexadecimal number that may start with an optional \fB0x\fR\. -.TP -\fB\-\-shared\fR, \fB\-\-Bshareable\fR -Create a share library\. -.TP -\fB\-\-spare\-dynamic\-tags\fR=\fInumber\fR -Append the given number of \fBDT_NULL\fR entries to the end of the \fB\.dynamic\fR section, so that post\-link processing tools can easily add new dynamic tags by overwriting the null entries\. -.TP -\fB\-\-start\-lib\fR, \fB\-\-end\-lib\fR -Handle object files between \fB\-\-start\-lib\fR and \fB\-\-end\-lib\fR as if they were in an archive file\. That means object files between them are linked only when they are needed to resolve undefined symbols\. The options are useful if you want to link object files only when they are needed but want to avoid the overhead of running ar(3)\. -.TP -\fB\-\-static\fR -Do not link against shared libraries\. -.TP -\fB\-\-sysroot\fR=\fIdir\fR -Set target system root directory to \fIdir\fR\. -.TP -\fB\-\-trace\fR -Print name of each input file\. -.TP -\fB\-\-undefined\-glob\fR=\fIpattern\fR -Synonym for \fB\-\-undefined\fR, except that \fB\-\-undefined\-glob\fR takes a glob pattern instead of just a single symbol name\. -.TP -\fB\-\-undefined\-version\fR, \fB\-\-no\-undefined\-version\fR -By default, \fBmold\fR warns on a symbol specified by a version script or by \fB\-\-export\-dynamic\-symbol\fR if it is not defined\. You can silence the warning by \fB\-\-undefined\-version\fR\. -.TP -\fB\-\-unique\fR=\fIpattern\fR -Don't merge input sections that match the given glob pattern \fIpattern\fR\. -.TP -\fB\-\-unresolved\-symbols\fR=[ \fBreport\-all\fR | \fBignore\-all\fR | \fBignore\-in\-object\-files\fR | \fBignore\-in\-shared\-libs\fR ] -How to handle undefined symbols\. -.TP -\fB\-\-version\-script\fR=\fIfile\fR -Read version script from \fIfile\fR\. If \fIfile\fR does not exist in the current directory, it is searched from library search paths for the sake of compatibility with GNU ld\. -.TP -\fB\-\-warn\-common\fR, \fB\-\-no\-warn\-common\fR -Warn about common symbols\. -.TP -\fB\-\-warn\-once\fR -Only warn once for each undefined symbol instead of warn for each relocation referring an undefined symbol\. -.TP -\fB\-\-warn\-unresolved\-symbols\fR, \fB\-\-error\-unresolved\-symbols\fR -Normally, the linker reports an error for unresolved symbols\. \fB\-\-warn\-unresolved\-symbols\fR option turns it into a warning\. \fB\-\-error\-unresolved\-symbols\fR option restores the default behavior\. -.TP -\fB\-\-whole\-archive\fR, \fB\-\-no\-whole\-archive\fR -When archive files (\fB\.a\fR 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\. \fB\-\-whole\-archive\fR changes that behavior for subsequent archives so that the linker extracts all object files and links them to an output\. For example, if you are creating a shared object file and you want to include all archive members to the output, you should pass \fB\-\-whole\-archive\fR\. \fB\-\-no\-whole\-archive\fR restores the default behavior for subsequent archives\. -.TP -\fB\-\-wrap\fR=\fIsymbol\fR -Make \fIsymbol\fR be resolved to \fB__wrap_\fR\fIsymbol\fR\. The original symbol can be resolved as \fB__real_\fR\fIsymbol\fR\. This option is typically used for wrapping an existing function\. -.TP -\fB\-z cet\-report\fR=[ \fBwarning\fR | \fBerror\fR | \fBnone\fR ] -Intel Control\-flow Enforcement Technology (CET) is a new x86 feature available since Tiger Lake which is released in 2020\. It defines new instructions to harden security to protect programs from control hijacking attacks\. You can tell the compiler to use the feature by specifying the \fB\-fcf\-protection\fR flag\. +.IP "\[ci]" 4 +\fB\-\-relax, \-\-no\-relax\fR: Rewrite machine instructions with more efficient ones for some relocations\. The feature is enabled by default\. +.IP "\[ci]" 4 +\fB\-\-require\-defined\fR=\fIsymbol\fR: Like \fB\-\-undefined\fR, except the new symbol must be defined by the end of the link\. +.IP "\[ci]" 4 +\fB\-\-retain\-symbols\-file\fR=\fIfile\fR: Keep only symbols listed in \fIfile\fR\. \fIfile\fR is a text file containing a symbol name on each line\. \fBmold\fR discards all local symbols as well as global symbol that are not in \fIfile\fR\. Note that this option removes symbols only from \fB\.symtab\fR section and does not affect \fB\.dynsym\fR section, which is used for dynamic linking\. +.IP "\[ci]" 4 +\fB\-\-rpath\fR=\fIdir\fR: Add \fIdir\fR to runtime search paths\. +.IP "\[ci]" 4 +\fB\-\-section\-start\fR=\fIsection\fR=\fIaddress\fR: Set \fIaddress\fR to section\. \fIaddress\fR is a hexadecimal number that may start with an optional \fB0x\fR\. +.IP "\[ci]" 4 +\fB\-\-shared\fR, \fB\-\-Bshareable\fR: Create a share library\. +.IP "\[ci]" 4 +\fB\-\-spare\-dynamic\-tags\fR=\fInumber\fR: Append the given number of \fBDT_NULL\fR entries to the end of the \fB\.dynamic\fR section, so that post\-link processing tools can easily add new dynamic tags by overwriting the null entries\. +.IP "\[ci]" 4 +\fB\-\-start\-lib\fR, \fB\-\-end\-lib\fR: Handle object files between \fB\-\-start\-lib\fR and \fB\-\-end\-lib\fR as if they were in an archive file\. That means object files between them are linked only when they are needed to resolve undefined symbols\. The options are useful if you want to link object files only when they are needed but want to avoid the overhead of running ar(3)\. +.IP "\[ci]" 4 +\fB\-\-static\fR: Do not link against shared libraries\. +.IP "\[ci]" 4 +\fB\-\-sysroot\fR=\fIdir\fR: Set target system root directory to \fIdir\fR\. +.IP "\[ci]" 4 +\fB\-\-trace\fR: Print name of each input file\. +.IP "\[ci]" 4 +\fB\-\-undefined\-glob\fR=\fIpattern\fR: Synonym for \fB\-\-undefined\fR, except that \fB\-\-undefined\-glob\fR takes a glob pattern instead of just a single symbol name\. +.IP "\[ci]" 4 +\fB\-\-undefined\-version\fR, \fB\-\-no\-undefined\-version\fR: By default, \fBmold\fR warns on a symbol specified by a version script or by \fB\-\-export\-dynamic\-symbol\fR if it is not defined\. You can silence the warning by \fB\-\-undefined\-version\fR\. +.IP "\[ci]" 4 +\fB\-\-unique\fR=\fIpattern\fR: Don't merge input sections that match the given glob pattern \fIpattern\fR\. +.IP "\[ci]" 4 +\fB\-\-unresolved\-symbols\fR=[ \fBreport\-all\fR | \fBignore\-all\fR | \fBignore\-in\-object\-files\fR | \fBignore\-in\-shared\-libs\fR ]: How to handle undefined symbols\. +.IP "\[ci]" 4 +\fB\-\-version\-script\fR=\fIfile\fR: Read version script from \fIfile\fR\. If \fIfile\fR does not exist in the current directory, it is searched from library search paths for the sake of compatibility with GNU ld\. +.IP "\[ci]" 4 +\fB\-\-warn\-common\fR, \fB\-\-no\-warn\-common\fR: Warn about common symbols\. +.IP "\[ci]" 4 +\fB\-\-warn\-once\fR: Only warn once for each undefined symbol instead of warn for each relocation referring an undefined symbol\. +.IP "\[ci]" 4 +\fB\-\-warn\-unresolved\-symbols\fR, \fB\-\-error\-unresolved\-symbols\fR: Normally, the linker reports an error for unresolved symbols\. \fB\-\-warn\-unresolved\-symbols\fR option turns it into a warning\. \fB\-\-error\-unresolved\-symbols\fR option restores the default behavior\. +.IP "\[ci]" 4 +\fB\-\-whole\-archive\fR, \fB\-\-no\-whole\-archive\fR: When archive files (\fB\.a\fR 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\. \fB\-\-whole\-archive\fR changes that behavior for subsequent archives so that the linker extracts all object files and links them to an output\. For example, if you are creating a shared object file and you want to include all archive members to the output, you should pass \fB\-\-whole\-archive\fR\. \fB\-\-no\-whole\-archive\fR restores the default behavior for subsequent archives\. +.IP "\[ci]" 4 +\fB\-\-wrap\fR=\fIsymbol\fR: Make \fIsymbol\fR be resolved to \fB__wrap_\fR\fIsymbol\fR\. The original symbol can be resolved as \fB__real_\fR\fIsymbol\fR\. This option is typically used for wrapping an existing function\. +.IP "\[ci]" 4 +\fB\-z cet\-report\fR=[ \fBwarning\fR | \fBerror\fR | \fBnone\fR ]: Intel Control\-flow Enforcement Technology (CET) is a new x86 feature available since Tiger Lake which is released in 2020\. It defines new instructions to harden security to protect programs from control hijacking attacks\. You can tell the compiler to use the feature by specifying the \fB\-fcf\-protection\fR flag\. .IP \fB\-z cet\-report\fR flag is used to make sure that all object files were compiled with a correct \fB\-fcf\-protection\fR flag\. If \fBwarning\fR or \fBerror\fR are given, \fBmold\fR prints out a warning or an error message if an object file was not compiled with the compiler flag\. .IP \fBmold\fR looks for \fBGNU_PROPERTY_X86_FEATURE_1_IBT\fR bit and \fBGNU_PROPERTY_X86_FEATURE_1_SHSTK\fR bit in \fB\.note\.gnu\.property\fR section to determine whether or not an object file was compiled with \fB\-fcf\-protection\fR\. -.TP -\fB\-z now\fR, \fB\-z lazy\fR -By default, functions referring to other ELF modules are resolved by the dynamic linker when they are called for the first time\. \fB\-z now\fR marks an executable or a shared library file so that all dynamic symbols are resolved when a file is loaded to memory\. \fB\-z lazy\fR restores the default behavior\. -.TP -\fB\-z origin\fR -Mark object requiring immediate \fB$ORIGIN\fR processing at runtime\. -.TP -\fB\-z ibt\fR -Turn on \fBGNU_PROPERTY_X86_FEATURE_1_IBT\fR bit in \fB\.note\.gnu\.property\fR section to indicate that the output uses IBT\-enabled PLT\. This option implies \fB\-z ibtplt\fR\. -.TP -\fB\-z ibtplt\fR -Generate Intel Branch Tracking (IBT)\-enabled PLT which is the default on x86\-64\. This is the default\. -.TP -\fB\-z execstack\fR, \fB\-z noexecstack\fR -By default, the pages for the stack area (i\.e\. the pages where local variables reside) are not executable for security reasons\. \fB\-z execstack\fR makes it executable\. \fB\-z noexecstack\fR restores the default behavior\. -.TP -\fB\-z keep\-text\-section\-prefix\fR, \fB\-z nokeep\-text\-section\-prefix\fR -Keep \fB\.text\.hot\fR, \fB\.text\.unknown\fR, \fB\.text\.unlikely\fR, \fB\.text\.startup\fR, and \fB\.text\.exit\fR as separate sections in the final binary instead of merging them as \fB\.text\fR\. -.TP -\fB\-z rodynamic\fR -Make the \fB\.dynamic\fR section read\-only\. -.TP -\fB\-z relro\fR, \fB\-z norelro\fR -Some sections such as \fB\.dynamic\fR have to be writable only during a module is being loaded to memory\. Once the dynamic linker finishes its job, such sections won't be mutated by anyone\. As a security mitigation, it is preferred to make such segments read\-only during program execution\. +.IP "\[ci]" 4 +\fB\-z now\fR, \fB\-z lazy\fR: By default, functions referring to other ELF modules are resolved by the dynamic linker when they are called for the first time\. \fB\-z now\fR marks an executable or a shared library file so that all dynamic symbols are resolved when a file is loaded to memory\. \fB\-z lazy\fR restores the default behavior\. +.IP "\[ci]" 4 +\fB\-z origin\fR: Mark object requiring immediate \fB$ORIGIN\fR processing at runtime\. +.IP "\[ci]" 4 +\fB\-z ibt\fR: Turn on \fBGNU_PROPERTY_X86_FEATURE_1_IBT\fR bit in \fB\.note\.gnu\.property\fR section to indicate that the output uses IBT\-enabled PLT\. This option implies \fB\-z ibtplt\fR\. +.IP "\[ci]" 4 +\fB\-z ibtplt\fR: Generate Intel Branch Tracking (IBT)\-enabled PLT which is the default on x86\-64\. This is the default\. +.IP "\[ci]" 4 +\fB\-z execstack\fR, \fB\-z noexecstack\fR: By default, the pages for the stack area (i\.e\. the pages where local variables reside) are not executable for security reasons\. \fB\-z execstack\fR makes it executable\. \fB\-z noexecstack\fR restores the default behavior\. +.IP "\[ci]" 4 +\fB\-z keep\-text\-section\-prefix\fR, \fB\-z nokeep\-text\-section\-prefix\fR: Keep \fB\.text\.hot\fR, \fB\.text\.unknown\fR, \fB\.text\.unlikely\fR, \fB\.text\.startup\fR, and \fB\.text\.exit\fR as separate sections in the final binary instead of merging them as \fB\.text\fR\. +.IP "\[ci]" 4 +\fB\-z rodynamic\fR: Make the \fB\.dynamic\fR section read\-only\. +.IP "\[ci]" 4 +\fB\-z relro\fR, \fB\-z norelro\fR: Some sections such as \fB\.dynamic\fR have to be writable only during a module is being loaded to memory\. Once the dynamic linker finishes its job, such sections won't be mutated by anyone\. As a security mitigation, it is preferred to make such segments read\-only during program execution\. .IP \fB\-z relro\fR puts such sections into a special segment called \fBrelro\fR\. The dynamic linker makes a relro segment read\-only after it finishes its job\. .IP By default, \fBmold\fR generates a relro segment\. \fB\-z norelro\fR disables the feature\. -.TP -\fB\-z sectionheader\fR, \fB\-z nosectionheader\fR -\fB\-z nosectionheader\fR tell the linker to omit the section header\. By default, the linker does not omit the section header\. -.TP -\fB\-z separate\-loadable\-segments\fR, \fB\-z separate\-code\fR, \fB\-z noseparate\-code\fR -If one memory page contains multiple segments, the page protection bits are set in such a way that the needed attributes (writable or executable) are satisfied for all segments\. This usually happens at a boundary of two segments with two different attributes\. +.IP "\[ci]" 4 +\fB\-z sectionheader\fR, \fB\-z nosectionheader\fR: \fB\-z nosectionheader\fR tell the linker to omit the section header\. By default, the linker does not omit the section header\. +.IP "\[ci]" 4 +\fB\-z separate\-loadable\-segments\fR, \fB\-z separate\-code\fR, \fB\-z noseparate\-code\fR: If one memory page contains multiple segments, the page protection bits are set in such a way that the needed attributes (writable or executable) are satisfied for all segments\. This usually happens at a boundary of two segments with two different attributes\. .IP \fBseparate\-loadable\-segments\fR adds paddings between segments with different attributes so that they do not share the same page\. This is the default\. .IP \fBseparate\-code\fR adds paddings only between executable and non\-executable segments\. .IP \fBnoseparate\-code\fR does not add any paddings between segments\. -.TP -\fB\-z defs\fR, \fB\-z nodefs\fR -Report undefined symbols (even with \fB\-\-shared\fR)\. -.TP -\fB\-z shstk\fR -Enforce shadow stack by turning \fBGNU_PROPERTY_X86_FEATURE_1_SHSTK\fR bit in \fB\.note\.gnu\.property\fR output section\. Shadow stack is part of Intel Control\-flow Enforcement Technology (CET), which is available since Tiger Lake (2020)\. -.TP -\fB\-z start_stop_visibility\fR=[ \fBhidden\fR | \fBprotected\fR ] -If a section name is valid as a C identifier (i\.e\., it matches \fB/^[_a\-zA\-Z][_a\-zA\-Z0\-9]*$/\fR), mold creates \fB__start_SECNAME\fR and \fB__stop_SECNAME\fR symbols to mark the beginning and end of the section, where \fBSECNAME\fR is the section name\. +.IP "\[ci]" 4 +\fB\-z defs\fR, \fB\-z nodefs\fR: Report undefined symbols (even with \fB\-\-shared\fR)\. +.IP "\[ci]" 4 +\fB\-z shstk\fR: Enforce shadow stack by turning \fBGNU_PROPERTY_X86_FEATURE_1_SHSTK\fR bit in \fB\.note\.gnu\.property\fR output section\. Shadow stack is part of Intel Control\-flow Enforcement Technology (CET), which is available since Tiger Lake (2020)\. +.IP "\[ci]" 4 +\fB\-z start_stop_visibility\fR=[ \fBhidden\fR | \fBprotected\fR ]: If a section name is valid as a C identifier (i\.e\., it matches \fB/^[_a\-zA\-Z][_a\-zA\-Z0\-9]*$/\fR), mold creates \fB__start_SECNAME\fR and \fB__stop_SECNAME\fR symbols to mark the beginning and end of the section, where \fBSECNAME\fR is the section name\. .IP You can make these marker symbols visible from other ELF modules by passing \fB\-z start_stop_visibility=protected\fR\. Default is \fBhidden\fR\. -.TP -\fB\-z text\fR, \fB\-z notext\fR, \fB\-z textoff\fR -\fBmold\fR by default reports an error if dynamic relocations are created in read\-only sections\. If \fB\-z notext\fR or \fB\-z textoff\fR are given, \fBmold\fR creates such dynamic relocations without reporting an error\. \fB\-z text\fR restores the default behavior\. -.TP -\fB\-z max\-page\-size\fR=\fInumber\fR -Some CPU ISAs support multiple memory page sizes\. This option specifies the maximum page size that an output binary can run on\. In general, binaries built for a larger page size can run on a system with a smaller page size, but not vice versa\. The default value is 4 KiB for i386, x86\-64, and RISC\-V, and 64 KiB for ARM64\. -.TP -\fB\-z nodefaultlib\fR -Make the dynamic loader ignore default search paths\. -.TP -\fB\-z nodelete\fR -Mark DSO non\-deletable at runtime\. -.TP -\fB\-z nodlopen\fR -Mark DSO not available to dlopen(3)\. This option makes it possible for the linker to optimize thread\-local variable accesses by rewriting instructions for some targets\. -.TP -\fB\-z nodump\fR -Mark DSO not available to dldump(3)\. -.TP -\fB\-z nocopyreloc\fR -Do not create copy relocations\. -.TP -\fB\-z initfirst\fR -Mark DSO to be initialized first at runtime\. -.TP -\fB\-z interpose\fR -Mark object to interpose all DSOs but executable\. -.TP -\fB\-(\fR, \fB\-)\fR, \fB\-EL\fR, \fB\-O\fR\fInumber\fR, \fB\-\-dc\fR, \fB\-\-dp\fR, \fB\-\-end\-group\fR, \fB\-\-no\-add\-needed\fR, \fB\-\-no\-copy\-dt\-needed\-entries\fR, \fB\-\-nostdlib\fR, \fB\-\-rpath\-link=Ar dir\fR, \fB\-\-sort\-common\fR, \fB\-\-sort\-section\fR, \fB\-\-start\-group\fR, \fB\-\-warn\-constructors\fR, \fB\-\-warn\-once\fR, \fB\-\-fix\-cortex\-a53\-835769\fR, \fB\-\-fix\-cortex\-a53\-843419\fR, \fB\-z combreloc\fR, \fB\-z common\-page\-size\fR, \fB\-z nocombreloc\fR -Ignored +.IP "\[ci]" 4 +\fB\-z text\fR, \fB\-z notext\fR, \fB\-z textoff\fR: \fBmold\fR by default reports an error if dynamic relocations are created in read\-only sections\. If \fB\-z notext\fR or \fB\-z textoff\fR are given, \fBmold\fR creates such dynamic relocations without reporting an error\. \fB\-z text\fR restores the default behavior\. +.IP "\[ci]" 4 +\fB\-z max\-page\-size\fR=\fInumber\fR: Some CPU ISAs support multiple memory page sizes\. This option specifies the maximum page size that an output binary can run on\. In general, binaries built for a larger page size can run on a system with a smaller page size, but not vice versa\. The default value is 4 KiB for i386, x86\-64, and RISC\-V, and 64 KiB for ARM64\. +.IP "\[ci]" 4 +\fB\-z nodefaultlib\fR: Make the dynamic loader ignore default search paths\. +.IP "\[ci]" 4 +\fB\-z nodelete\fR: Mark DSO non\-deletable at runtime\. +.IP "\[ci]" 4 +\fB\-z nodlopen\fR: Mark DSO not available to dlopen(3)\. This option makes it possible for the linker to optimize thread\-local variable accesses by rewriting instructions for some targets\. +.IP "\[ci]" 4 +\fB\-z nodump\fR: Mark DSO not available to dldump(3)\. +.IP "\[ci]" 4 +\fB\-z nocopyreloc\fR: Do not create copy relocations\. +.IP "\[ci]" 4 +\fB\-z initfirst\fR: Mark DSO to be initialized first at runtime\. +.IP "\[ci]" 4 +\fB\-z interpose\fR: Mark object to interpose all DSOs but executable\. +.IP "\[ci]" 4 +\fB\-(\fR, \fB\-)\fR, \fB\-EL\fR, \fB\-O\fR\fInumber\fR, \fB\-\-dc\fR, \fB\-\-dp\fR, \fB\-\-end\-group\fR, \fB\-\-no\-add\-needed\fR, \fB\-\-no\-copy\-dt\-needed\-entries\fR, \fB\-\-nostdlib\fR, \fB\-\-rpath\-link=Ar dir\fR, \fB\-\-sort\-common\fR, \fB\-\-sort\-section\fR, \fB\-\-start\-group\fR, \fB\-\-warn\-constructors\fR, \fB\-\-warn\-once\fR, \fB\-\-fix\-cortex\-a53\-835769\fR, \fB\-\-fix\-cortex\-a53\-843419\fR, \fB\-z combreloc\fR, \fB\-z common\-page\-size\fR, \fB\-z nocombreloc\fR: Ignored +.IP "" 0 .SH "ENVIRONMENT VARIABLES" .TP \fBMOLD_JOBS\fR