mold 2.41.0 is a new release of the high-speed linker. It includes the following new features and bug fixes.
New Features
-
A new
--zero-to-bssoption has been added. When given, mold scans input data sections and converts all-zero sections into BSS (SHT_NOBITS), reducing output file size. This is especially useful for user-defined sections created with__attribute__((section(...)))containing uninitialized global variables, which GCC and Clang emit as regular data sections even when their contents are entirely zero. (847341d) -
--print-gc-sectionsand--print-icf-sectionscan now take=FILEto save their output to a file (e.g.,--print-gc-sections=output.txt). (7dd7db0) -
A new
MOLD_TARGETSCMake variable has been added that allows building mold with a limited set of supported targets to reduce build time. The use of this variable is discouraged unless you build mold frequently for personal use; distributions should not use it. (dce9ac1) -
--gdb-indexperformance has been improved by eliminating unnecessary zero-initializations and parallelizing more of the index generation. (a4db238)
Bug Fixes and Compatibility Improvements
-
Fixed spurious "duplicate symbol" errors when linking with LTO. Archive members extracted pre-LTO could conflict with LTO output, causing false positives. (632a0ee)
-
Fixed
--omagicto pack all sections into a singlePT_LOADsegment, matching GNU ld behavior. Previously, it only flipped permissions to RWX but still emitted separate page-aligned segments.--omagicnow also implies--Bstaticand disables RELRO. (a1ae8da) -
Fixed corruption of the string table in separate debug files generated by
--separate-debug-file, which caused GDB to refuse to load them or display corrupt symbol entries. (4cd4d56) -
Fixed
--separate-debug-fileemitting a bogus "PHDR" section in the debug file. (4798f43) -
Fixed
--no-allow-shlib-undefinedto correctly reject symbols provided by static objects with hidden visibility, and to avoid false positives when LTO optimizes away symbols that are still available from loaded shared libraries. (f6bb117) -
Fixed
--push-state/--pop-statenot correctly tracking the--staticflag. (001f718) -
Fixed linker script processing to support
AS_NEEDEDinsideINPUTorGROUPcommands, which is used by GCC 16'slibatomiclinker script. (e0a6f8e) -
Fixed a performance issue where
fallocateon tmpfs was unexpectedly slow (nearly a second for a ~5 GiB file). mold now avoids callingfallocateon tmpfs. (fc96c1b) -
Fixed RELRO segment alignment when
-z separate-loadable-segmentis given. The end of the RELRO segment is now properly page-aligned so the runtime can protect it. (9f463a6) -
Fixed an issue where an IFUNC PLT entry was unnecessarily created in position-dependent executables when the ifunc was not referenced within the executable. (3ad34d4)
-
Improved LTO compatibility: mold now falls back to native code for GCC fat LTO objects when using the LLVM LTO plugin, and correctly preserves non-LTO comdat members in mixed LTO/non-LTO builds. (2a1e5c6, a660037, d4d5eae)
-
--no-threadsis now respected with--compress-debug-sections. (fce89c2) -
--section-ordernow reports an error if the specified order would cause section addresses to go backward. (91439be) -
ICF now considers
.gcc_except_tablesections, improving deduplication accuracy for functions with exception handling. (fd86590) -
Replaced an uninformative
abort()with a descriptive error message when mold auto-detects an unsupported target. (93e1aea) -
[AArch64] Added support for
R_AARCH64_GOTPCREL32relocation, used by Clang's experimental relative C++ ABI vtables. (be28db1) -
[RISC-V] Added support for
R_RISCV_GOT32_PCRELrelocation. (f378b18) -
[PPC32] Added support for
R_PPC_DTPREL32in non-allocatable sections. (0b20faa) -
[SPARC64] Fixed multiple TLS optimization bugs, including incorrect register handling in
R_SPARC_TLS_GD_ADD,R_SPARC_TLS_GD_LO10, andTLS_GD_CALLtransformations, and fixedR_SPARC_GOTDATA_OPassuming the destination register is always%g1. (92adbb1, a16bb13, ca0b597, a88a216, 4d94410, 069f4da, e459ed5) -
[SPARC64] Added support for emitting dynamic relocations for
R_SPARC_UA64. (f55ad91) -
[SPARC]
--no-apply-dynamic-relocsis now honored forR_SPARC_UA64. (7f8c50b)
Acknowledgements
mold is an open-source project, and we accept donations via GitHub Sponsors and OpenCollective. We thank everyone who sponsors our project. In particular, we would like to acknowledge the following organizations and people who have sponsored $32/month or more during this release cycle:
- Cybozu, Inc.
- Mercedes-Benz Group
- Signal Slot Inc.
- Mercury
- G-Research Open Source Software
- kraptor23
- Pedro Navarro
- Jinkyu Yi
- SAP
- Ahrefs
- CubeSoft, Inc.
- Wei Wu
- daquexian
- Josh Triplett
- nomeaning
- Bach Le
- David Wells
- Martin Liška
- Sebastian Dröge
- Jordan Miner
- Anson VanDoren
- Niklas Gögge
- Michal R
- Florian Plattner
- Victor Wang
- Bert Muthalaly
- TSY Capital
- Michael McLoughlin
- Brian Gianforcaro
- strager
- Julian Braha
- Zhihao Yuan
- Yutaro Ohno
- José M Rico
- Vladimir Miloserdov
- Artem Pianykh
- Taiju Muto
- Matt Heise
- Eric Semeniuc
- Yuxuan Chen
- Thomas Eizinger
- Kiril Mihaylov
- Tatsuya Kawano
- Rahul Butani
- Kyle Lacy
- Andrew McNulty
- kimonohanger
- Tetsuo Kiso
- Khyber Sen
- JoJo
- Martin Nordholts
- Nazar Mokrynskyi
- Max Bruckner
- Geoff Hill
- Marc Luqué
- Daniel Alley