1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00
Commit Graph

1047 Commits

Author SHA1 Message Date
Rui Ueyama
7735cf5b95 Style change 2022-02-17 20:29:28 +09:00
Dmitry Antipov
630b262d2b Use explicit mimalloc new/delete overrides if SYSTEM_MIMALLOC
When building with SYSTEM_MIMALLOC=1, linking with (assuming
shared) '-lmimalloc' is not enough to override C++ new/delete
with mimalloc versions, and 'mimalloc-new-delete.h' should be
included from one (and the only) translation unit as well.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2022-02-17 10:44:58 +03:00
Rui Ueyama
c3466b9021 Move a use of strerror_r to a separate file 2022-01-13 13:55:34 +09:00
Rui Ueyama
cea6a569af [ELF] Remove "GNU gold" from the --version string
That substring was introduced in de7ba9014f
to appease Gentoo's dev-libs/jansson-2.13.1-r1 package. But I think I
shouldn't done that from the beginning to avoid the sitaution of the
"User-Agent" string of the web browser, which everybody claims they
are Mozilla, AppleWebKit, Chrome and Safari simultaneously.
2022-01-12 16:38:04 +09:00
Rui Ueyama
8590fd9947 Better way to suppress -Wint-to-pointer-cast 2022-01-03 18:15:51 +09:00
Rui Ueyama
7bb478b683 Fix macOS build 2022-01-03 18:05:33 +09:00
Rui Ueyama
ce2fee10b5 Use strerror_r() instead of strerror()
I have no idea why, but 2b818dbe44 made
mold's chrome link time slower by ~8%. This patch removes the use
of std::mutex.
2022-01-03 17:46:26 +09:00
Rui Ueyama
2b818dbe44 Use strerror() instead of strerror_r()
This should fix the build on Android.
Fixes https://github.com/rui314/mold/issues/231
2022-01-02 23:40:51 +09:00
Christoph Erhardt
a537509aa6 Fix errno_string() returning an empty string on GNU
Signed-off-by: Christoph Erhardt <github@sicherha.de>
2021-12-31 16:09:26 +01:00
Rui Ueyama
58e43633fc Revert "Revert "Use C++17 filesystem API""
This reverts commit f29a85f20a with a fix
for a build failure.
2021-12-31 16:39:54 +09:00
Rui Ueyama
f29a85f20a Revert "Use C++17 filesystem API"
This reverts commit f6e91df440 because
it causes build breakages for a lot of Gentoo packages.
2021-12-30 22:15:52 +09:00
Rui Ueyama
f6e91df440 Use C++17 filesystem API 2021-12-30 21:32:01 +09:00
Rui Ueyama
8f1c328d1a Cosmetic changes 2021-12-20 11:46:28 +09:00
Rui Ueyama
411706d147 [ELF] Accept any argv[0] other than ld64 or ld64.mold
ld is often named as x86_64-pc-linux-gnu-ld or some other system-
dependent name. We shouldn't report an error for an unknown argv[0].
2021-11-27 12:18:36 +09:00
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