1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-11 05:46:58 +03:00
Commit Graph

1033 Commits

Author SHA1 Message Date
Rui Ueyama
5e3f526bc1 Refactor 2021-09-28 16:40:07 +09:00
Rui Ueyama
c74b2197f9 Refactor 2021-09-28 16:24:41 +09:00
Rui Ueyama
6ab3ddaf8e Move cleanup handlers from mold::elf to mold 2021-09-15 15:25:14 +09:00
Rui Ueyama
7ffc3a4545 [Mach-O] Add a feature to dump an executable
This is not a linker feature, but in order to learn how Mach-O
executables are constructed, I'll implement a dump feature.
I'll remove the feature once I understand the structure of Mach-O
binaries.
2021-09-13 18:16:13 +09:00
Rui Ueyama
68ff4a8408 Rename functions 2021-09-08 20:15:03 +09:00
Rui Ueyama
78bddacd5b Move target-independent files to the top directory 2021-09-08 19:49:51 +09:00
Rui Ueyama
cab0ccf0bd [Mach-O] Add a stub for Mach-O 2021-09-08 19:03:07 +09:00
Rui Ueyama
459b5973bb Move code to elf sub-directory 2021-09-02 23:16:49 +09:00
Rui Ueyama
fd391b03ef Move everything into mold::elf namespace 2021-09-02 18:19:43 +09:00
Rui Ueyama
e7537116b3 Fix a build issue on macOS
macOS does not define std::quick_exit.
2021-09-01 14:12:05 +09:00
Rui Ueyama
81cb2fab89 Refactor 2021-08-24 10:37:38 +00:00
Rui Ueyama
34558f410d Do not generate dynrels against RO sections for weak undef symbols
Previously, we created dynamic relocations against read-only sections
if the sections contain relocations against weak undefined symbols.
Since such dynamic relocations cannot be applied at load-time, the
generated executables failed with SEGV.

Now, such relocations are resolved to address 0.

Reported at https://github.com/rui314/mold/pull/110
2021-08-17 17:23:22 +09:00
Rui Ueyama
05b532af79 Refactor 2021-07-29 20:57:05 +09:00
Rui Ueyama
fb100f21b3 Do not print out stacktrace on crash
This commit partially reverts e855b90344
because that change was not portable to non-glibc systems.
2021-07-16 14:33:20 +09:00
Rui Ueyama
41b2fa7375 Optimize string merging
Linking clang-13 with debug info takes ~3.6 seconds on a simulated
10-core/20-threads machine. mold spends most of its time (~2.3 seconds)
merging string literals in .debug_str. Input .debug_str sections contain
70 million string literals in total, which is reduced to 2 million after
de-duplication. The input object files contain a lot of duplicates.
clang-13 with debug info is enormous -- it is ~3.1 GiB after linking.

It looks like TBB's concurrent hashmap doesn't scale well with the
input.

In this patch, I implemented our own concurrent hashmap. The hashmap
is extremely lightweight and support only the key-value insertion
operation. It doesn't even support rehashing. It aborts once the hash
table becomes full.

In order to know the correct size for the hashmap before inserting
strings into it, I also implemented HyperLogLog algorithm in this patch.
HyperLogLog is an algorithm that gives a fairly accurate estimate on
the number of unique elements.

With this patch, mold can link clang-13 in ~2.5 seconds, which is ~30%
faster than before.

https://github.com/rui314/mold/issues/73
2021-07-13 16:54:09 +09:00
Rui Ueyama
e855b90344 Show stacktrace on SEGV and assertion failure 2021-07-09 23:34:39 +09:00
Rui Ueyama
accf96877f Add a stub for AArch64
It can generate an executable, but generated executable won't run
correctly because we don't process relocations at all yet.
2021-07-03 21:39:44 +09:00
Rui Ueyama
6432114e2a Fix handling of --sysroot
Fixes https://github.com/rui314/mold/issues/59
2021-06-30 22:15:19 +09:00
Rui Ueyama
4436e4a57d Improve error message for an attempt of LTO 2021-06-26 15:05:05 +09:00
Rui Ueyama
0b0e066cc5 Refactor 2021-06-25 23:36:53 +09:00
Rui Ueyama
d9ecc2e3e6 Promote weak undefined symbols to weak dynamic symbols
Previously, if a weak undefined symbol cannot be resolved within
an output of the linker, mold turned it into an absolute symbol
with value 0. However, other linkers export such symbols as a
weak dynamic symbol, so that the symbol gets another chance to be
resolved at runtime.

This patch implements the behavior.

This is needed by Gentoo's dev-libs/nsync-1.20.1 package.
2021-06-25 00:44:35 +09:00
Rui Ueyama
9519e4ce20 Change how to handle --unresolved-symbols=ignore
Previously, we turned unresolved undefined symbols into dynamic
symbols. This patch changed the behavior so that such symbols
are turned into non-dynamic absolute symbols with value zero.

This change is needed by Gentoo's dev-libs/wayland-protocols-1.21
package.
2021-06-20 14:31:36 +09:00
Rui Ueyama
b21ade127c Simplify 2021-06-20 00:51:38 +09:00
Rui Ueyama
9febec6c69 Rename a function 2021-06-19 20:29:16 +09:00
Rui Ueyama
a0ecd0c8dc Add --unique=PATTERN
This is needed by Gentoo's sys-fabric/infinipath-psm-3.2 package.
2021-06-19 01:09:26 +09:00
Rui Ueyama
37b88e3f5a Do not set executable bit for --relocatable outputs 2021-06-18 01:45:38 +09:00
Rui Ueyama
e1a964acb2 Do not write duplicate entries to .dynsym
Fixes Gentoo's sys-libs/slang package.
2021-06-16 19:50:42 +09:00
Rui Ueyama
333843a33d Add --warn-unresolved-symbols and --error-unresolved-symbols 2021-06-14 00:04:07 +09:00
Rui Ueyama
9cc309af75 Implement --relocatable
Fixes https://github.com/rui314/mold/issues/46
2021-06-11 21:57:43 +09:00
Rui Ueyama
3102ab867c Refactor 2021-06-11 02:12:19 +09:00
Rui Ueyama
a0c3fcb1bb Do not put local symbols to .dynsym 2021-06-06 17:24:49 +09:00
Rui Ueyama
3fb870c80b Add --compress-debug-info=zlib-gnu 2021-06-03 23:57:06 +09:00
Rui Ueyama
f9e91aa391 Do not embed a library fullpath if it is given by -l 2021-06-01 15:15:25 +09:00
Rui Ueyama
8219fdd688 Simplify input file priority
This change is required to build Gentoo's net-libs/libtorrent-0.13.8-r1
package with FEATURES=test, e.g.

  $ FEATURES=test emerge net-libs/libtorrent
2021-05-31 17:09:40 +09:00
Rui Ueyama
2a61e5af51 Format 2021-05-31 12:48:52 +09:00
Rui Ueyama
8940abf807 Sort .{init,fini}_array and .[cd]tors 2021-05-31 01:11:45 +09:00
Rui Ueyama
a2017e5d3a Skip incompatible library files
This change is required to build Gentoo's net-libs/libtorrent-0.13.8-r1
package.
2021-05-29 20:47:16 +09:00
Rui Ueyama
3cfbc0d66c Parallelize tests 2021-05-29 16:05:38 +09:00
Rui Ueyama
de7ba9014f Add "GNU gold" to the --version string
The configure script in Gentoo's dev-libs/jansson-2.13.1-r1 package
treats mold 0.1.1 as GNU ld 0.1.1, which is from 1980s if existed.

Adding "GNU gold" to the help message solves the nasty issue, as the
configure script considers any version of GNU gold supports modern
features.
2021-05-27 15:24:30 +09:00
Rui Ueyama
310980fb7e Add --retain-symbols-file 2021-05-27 00:31:08 +09:00
Rui Ueyama
a0a94f4637 Add -wrap option 2021-05-22 01:54:08 +09:00
Rui Ueyama
d279da3435 Enable -Wswitch 2021-05-21 16:06:47 +09:00
Rui Ueyama
2e73024e18 Do not assume that the main directory is a git checkout 2021-05-21 13:58:59 +09:00
Rui Ueyama
18acebad2d Add a missing newline 2021-05-10 16:53:04 +09:00
Rui Ueyama
508702b18b Simplify 2021-05-09 00:18:44 +09:00
Rui Ueyama
033834a28e Add --help 2021-05-08 20:10:41 +09:00
Rui Ueyama
13003d2479 Add --compress-debug-sections 2021-05-06 17:20:07 +09:00
Rui Ueyama
92a3e78ee0 Simplify 2021-05-05 23:37:48 +09:00
Rui Ueyama
6fb5754c5b Use u8[] instead of std::vector to avoid zero-initialization cost 2021-05-04 14:41:32 +09:00
Rui Ueyama
d11c383147 Replace --reproduce with --repro 2021-05-02 20:49:00 +09:00