mold 1.1.1
mold 1.1.1 is a maintenance release of the high-performance linker. It contains the following new features, bug fixes and performance improvements including memory usage reduction.
New features
- The
--dependency-file
option has been added. The option is analogous to the compiler's-MM
option; it generates a text file containing dependency information in the Makefile format, so that you can include a generated file into a Makefile to automate the file dependency management. (a054bcd) - mold has gained the
--reverse-sections
option. If the option is given, mold reverses the list of input sections before assigning them the addresses in an output file. This option is useful to find a bug in global initializers (e.g. constructors of global variables.) In C++, the execution order of global initializers is guaranteed only within a single compilation unit (they are executed from top to bottom.) If two global initializers are in different object files, they can be executed in any order. Reversing the execution order of the global initializers in different input files should help you identify a bug in your program. If your program does not work with-Wl,--reverse-sections
, your program depends on the undefined behavior. --shuffle-sections
now takes an optional seed for the random number generator in the form of--shuffle-sections=<number>
. (8f21cc3)- mold now supports the following LTO-related options for compatibility with LLVM lld:
--disable-verify
,--lto-O
,--lto-cs-profile-file
,--lto-cs-profile-generate
,--lto-debug-pass-manager
,--lto-emit-asm
,--lto-obj-path
,--lto-partitions
,--lto-pseudo-probe-for-profiling
,--lto-sample-profile
,--no-legacy-pass-manager
,--no-lto-legacy-pass-manager
,--opt-remarks-filename
,--opt-remarks-format
,--opt-remarks-hotness-threshold
,--opt-remarks-passes
,--opt-remarks-with_hotness
,--save-temps
,--thinlto-emit-imports-files
,--thinlto-index-only
,--thinlto-index-only
,--thinlto-jobs
,--thinlto-jobs
,--thinlto-object-suffix-replace
,--thinlto-prefix-replace
(e413433) -noinhibit-exec
and--warn-shared-textrel
have been supported.
Performance improvements
- We optimized mold's memory usage by reducing the sizes of frequently-allocated objects. Compared to mold 1.1, we observed ~6% reduction of maximum resident set size (RSS) when linking Chromium. Our maximum RSS is smaller than LLVM lld and GNU gold as far as we tested. We measured maximum RSSes with
time -v
. (f2d27d8, 7068c0c, 83e05da, 4dae896) - If Intel CET-based security-enhanced PLT is enabled (i.e.
-z ibtplt
is given), mold used to create a PLT section in which each entry is 32 bytes long. We optimized the machine code sequence of the CET-enabled PLT section, so each PLT entry now occupies only 16 bytes, reducing the size of.plt
by almost half. (480efde)
Bug fixes and compatibility improvements
-static-pie
now works with recent versions of glibc. Previously, statically-linked position-independent executable would crash on startup when linked with mold. (3999aa8)- Previously, mold sometimes created corrupted output file on x86-64 if an input file containing thread-local variables were compiled with
-mcmodel=large
(#360). This issue has been fixed. (4aa4bfa) - Previously, mold created corrupted debug info section on i386 if an input debug section is also compressed using the compiler
-gz
option. (#361) This issue has been fixed. (3068364) - mold used to create multiple
.init_array
sections if input files contain both writable and non-writable.int_array
sections. That caused an issue that some initializer functions would not be executed on process startup. (#363). This issue has been fixed. (4198627) - When building a large program with GCC LTO, mold occasionally failed with "too many open files" error. This issue has been resolved. (e67f460)
- Previously, mold created a corrupted dynamic relocation table if
.got.plt
is missing. This issue has been fixed by always creating_GLOBAL_OFFSET_TABLE_
symbol in.got
on any target. mold used to try to create the symbol in.got.plt
on x86-64 or i386. (eb79859)