github rui314/mold v2.41.0
mold 2.41.0

11 hours ago

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-bss option 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-sections and --print-icf-sections can now take =FILE to save their output to a file (e.g., --print-gc-sections=output.txt). (7dd7db0)

  • A new MOLD_TARGETS CMake 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-index performance 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 --omagic to pack all sections into a single PT_LOAD segment, matching GNU ld behavior. Previously, it only flipped permissions to RWX but still emitted separate page-aligned segments. --omagic now also implies --Bstatic and 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-file emitting a bogus "PHDR" section in the debug file. (4798f43)

  • Fixed --no-allow-shlib-undefined to 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-state not correctly tracking the --static flag. (001f718)

  • Fixed linker script processing to support AS_NEEDED inside INPUT or GROUP commands, which is used by GCC 16's libatomic linker script. (e0a6f8e)

  • Fixed a performance issue where fallocate on tmpfs was unexpectedly slow (nearly a second for a ~5 GiB file). mold now avoids calling fallocate on tmpfs. (fc96c1b)

  • Fixed RELRO segment alignment when -z separate-loadable-segment is 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-threads is now respected with --compress-debug-sections. (fce89c2)

  • --section-order now reports an error if the specified order would cause section addresses to go backward. (91439be)

  • ICF now considers .gcc_except_table sections, 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_GOTPCREL32 relocation, used by Clang's experimental relative C++ ABI vtables. (be28db1)

  • [RISC-V] Added support for R_RISCV_GOT32_PCREL relocation. (f378b18)

  • [PPC32] Added support for R_PPC_DTPREL32 in 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, and TLS_GD_CALL transformations, and fixed R_SPARC_GOTDATA_OP assuming 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-relocs is now honored for R_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:

Don't miss a new mold release

NewReleases is sending notifications on new releases.