Skip to content

mold 1.1

Compare
Choose a tag to compare
@rui314 rui314 released this 21 Feb 01:19
· 3319 commits to main since this release

mold 1.1 is a new release of the high-performance linker. It contains a few new major features and various bug fixes.

Starting from this release, we distribute not only source but pre-compiled binaries for Linux. You can download a tar file containing mold executable at the bottom of the page. You can copy the contents of the tar file to /usr/local or just use without installation by directly specifying its full path.

New features

  • Native LTO (link-time optimization) support has been added. mold used to invoke ld.bfd or ld.lld if it encountered a GCC IR (intermediate representation) file or an LLVM IR file to delegate the task to the LTO-capable linkers, respectively. Now, mold handles IR files directly. This feature is implemented using the linker plugin API which is also used by GNU ld and GNU gold. Note that the LTO support has been added for completeness and not for speed. mold is only marginally faster than the other linkers for LTO builds because not linking but code optimization dominates. (46995bc)
  • RISC-V (RV64) is now supported as both host and target platforms. mold can link real-world large programs such as mold itself or LLVM Clang for RISC-V. (e76f7c0)
  • The -emit-relocs option is supported. If the option is given, mold copies relocation sections from input files to an output file. This feature is used by some post-link binary optimization or analysis tools such as Facebook's Bolt. (26fe71d)
  • mold gained the --shuffle-sections option. If the option is given, the linker randomly shuffle the order of input sections before fixing their addresses in the virtual address space. This feature is useful in some situations. First, it can be used as a strong form of ASLR (address space layout randomization). Second, you can enable it when you are benchmarking some other program to get more reliable benchmark numbers, because even the same machine code can vary in performance if they are laid out differently in the virtual address space. You want to make sure that you got good/bad benchmark numbers not by coincidence by shuffling input sections. (7e91897)
  • The --print-dependencies and --print-dependencies=full options were added. They print out dependencies between input files in the CSV format. That is, they print out the information as to which file depends on which file to use which symbol. We added this feature with a few use cases in mind. First, you can use this to analyze why some object file was pulled out from an archive and got linked to an output file. Second, when you want to eliminate all dependencies to some library, you can find all of them very easy with this feature. Note that this is an experimental feature and may change or removed in feature releases of mold. (a1287c2)
  • The following options are added: --warn-once (f24b997), --warn-textrel (6ffcae4)
  • Runtime dependency to libxxhash has been eliminated. (e5f4b96)

Bug fixes and compatibility improvements

  • A PT_GNU_RELRO segment is now aligned up to the next page boundary. Previously, mold didn't align it up, and the runtime loader align it down, so the last partial page would not be protected by the RELRO mechanism. Now, the entire RELRO segment is guaranteed to be read-only at runtime. (0a0f9b3)
  • The .got.plt section is now protected by RELRO if -z now is given. This is possible because writes to .got.plt happen only during process startup if all symbols are resolved on process startup. (73159e2)
  • Previously, mold reported an error if object files created with old GCC (with -fgnu-unique) are mixed with ones created with newer GCC or Clang (with -fno-gnu-unique) (#324). Now, mold accepts such input files. (e65c5d2)
  • mold can now be built with musl libc. (42b7eb8)
  • mold-generated .symtab section now contains section symbols and symbols derived from input shared object files. (e4c03c2, 1550b5a)
  • mold-generated executables can now run under valgrind. Previously, valgrind aborted on startup due to an assertion failure because it didn't expect for an executable to have both .bss and .dynbss sections. mold generated .dynbss to contain copy-relocated symbols. The section has been renamed .copyrel to workaround the valgrind's issue. (0f8bf23)