1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-11 13:06:59 +03:00
Commit Graph

6423 Commits

Author SHA1 Message Date
Muhammad Mominul Huque
f05e32df4a
Update README.md
GCC doesn't accept a path as an argument to `-fuse-ld`. `-fuse-ld=mold` is enough.

Tested with
```
gcc (GCC) 13.2.1 20231205 (Red Hat 13.2.1-6)
```
2023-12-31 18:21:30 +06:00
Rui Ueyama
fe118f6347 Fix CI 2023-12-24 14:42:01 +09:00
Rui Ueyama
9554b92c86 Allow escaped meta-characters in version script patterns 2023-12-24 14:04:51 +09:00
Rui Ueyama
669ada024e Simplify 2023-12-24 13:53:02 +09:00
Rui Ueyama
e1e16bf85a Fix version script priority
Previously, if two or more VERSION clauses match to the same symbol,
the first one took precedence. This was incompatible with GNU ld, which
gives the last one the highesth priority.

This change inverted the priority so that the last one will take
precedence other the others.

Fixes https://github.com/rui314/mold/issues/1158
2023-12-23 18:20:22 +09:00
Rui Ueyama
35516a6fc2 Do not include '@' in symbol name
Fixes https://github.com/rui314/mold/issues/1168
2023-12-23 15:37:39 +09:00
Rui Ueyama
51ecb10b01 Refactor 2023-12-23 15:35:43 +09:00
Rui Ueyama
10ce09fe0c Refactor 2023-12-23 15:16:02 +09:00
Rui Ueyama
0702d4185a Refactor 2023-12-19 15:32:43 +09:00
Rui Ueyama
afe57e99d1 Update comments 2023-12-15 11:55:53 +09:00
Rui Ueyama
e921486008 Fix CI
It seems some versions of objdump cannot disassemble c.li instruction.
2023-12-13 13:26:56 +09:00
Rui Ueyama
70d59ca1cd Improve test 2023-12-12 22:11:35 +09:00
Rui Ueyama
2ccaa81aab Relax a GOT load into a direct address materialization
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/397
2023-12-12 16:41:18 +09:00
Rui Ueyama
4db2eb91e9 Do not rewrite endbr64 of exported functions
Pointed out by @MaskRay at
https://github.com/llvm/llvm-project/issues/74400#issuecomment-1848686317.
2023-12-12 15:36:43 +09:00
Badini Rachid Rodrigue
a4daff2d83
Add entry for EndeavouOS (#1165)
---------

Co-authored-by: BADINI Rachid Rodrigue <bsrodrigue@gmail.com>
2023-12-12 04:08:42 +09:00
Rui Ueyama
cc884d57ca Fix cross building of ARM64 binaries on big-endian machines
It's probably very rare to do so, but mold couldn't create ARM64
binaries on big-endian machines due to a typo in an ELF struct
definition.
2023-12-10 16:06:52 +09:00
Rui Ueyama
0c8a872c37 Avoid using the HOST environment variable
It seems HOST is a fairly common environment variable. Let's use
MACHINE instead.

Fixes https://github.com/rui314/mold/issues/1163
2023-12-07 09:45:29 +09:00
Rui Ueyama
663ac74610 Simplify 2023-12-06 19:51:22 +09:00
Rui Ueyama
f04aebf1e0 Simplify 2023-12-06 13:04:58 +09:00
Rui Ueyama
bcf3b48e98 Simplify 2023-12-06 11:33:46 +09:00
Rui Ueyama
e7cc9455c9
Merge pull request #1161 from ishitatsuyuki/prealloc
Use fallocate when creating a new output
2023-12-06 11:05:17 +09:00
Tatsuyuki Ishi
e909535684 Use fallocate when creating a new output
Using ftruncate() creates holes inside files, that on first (write) page
fault gets allocated an actual disk block.  There are several
disadvantages with this:
- Allocating block one-by-one is slower than doing it all at once.
- As we write to the output in parallel the write order is not exactly
  sequential.  The allocated blocks can also be out-of-order and make the
  on-disk representation fragmented.

Instead, use posix_fallocate() which allocates a contiguous on-disk block
(if possible).  It's arguably a better fit for linker output, since holes
are unlikely to be present after writing all the output (any contiguous
zeroes should just go into .bss).

I benchmarked this by linking mold with debug symbols.  On an 8-core
desktop, it is 5% (1.0s -> 0.95s) faster, but on a 64-core workstation it
is actually 40% slower (0.37s -> 0.52s).  The total amount of System time
is reduced (6.7s -> 5.2s), however.  I suspect that the reduced page fault
work ends up causing more lock contention.

Despite potential regression on high-core systems I still think this
change is justified because of the better on-disk layout.

Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
2023-12-05 16:07:48 +09:00
Rui Ueyama
cea54cb865 Check the runtime libtbb version to handle sigabrt 2023-12-05 12:25:52 +09:00
Rui Ueyama
3bc2e9bdb1 Revert "Set DF_SYMBOLIC if -Bsymbolic is given"
This reverts commit 9d35710419 to unbreak CI.
2023-12-04 16:07:56 +09:00
Rui Ueyama
159960c72e Fix errors in the help message; this change was made using ChatGPT 2023-12-04 15:34:56 +09:00
Rui Ueyama
9d35710419 Set DF_SYMBOLIC if -Bsymbolic is given
I don't think this would make any difference, but the ELF spec says
that the flag is set if symbols are bound locally.
2023-12-04 15:10:01 +09:00
Rui Ueyama
bdcf448605 Emit TLS common symbols in .tls_common
Section names are not significant in executables or DSOs, so this is
a purely aesthetic change.
2023-12-04 13:13:33 +09:00
Rui Ueyama
72eb180028 Upgrade OneTBB to version 2021.11.0 2023-12-02 12:34:16 +09:00
Rui Ueyama
fe427bfe7a Do not compute per-InputSection address-taken bit for -z rewrite-endbr
We now compute per-Symbol address-taken bit in rewrite_endbr,
so this step is not necessary anymore.
2023-12-02 12:34:16 +09:00
Rui Ueyama
348f5c7086
Merge pull request #1160 from tzussman/ci_fix 2023-12-02 07:52:41 +09:00
Tal Zussman
e09b877146
Fix typos in ci.yml 2023-12-01 10:01:25 -05:00
Rui Ueyama
aeb7ba4731 Add asserts 2023-12-01 21:03:15 +09:00
Rui Ueyama
421cd1c3ca Revert "Attempt to fix CI"
This reverts commit 5e8729bd6f.
2023-12-01 10:26:10 +09:00
Rui Ueyama
5e8729bd6f Attempt to fix CI 2023-12-01 10:19:48 +09:00
Rui Ueyama
76d057a418 Archive entire build directory when CI fails 2023-11-30 19:34:08 +09:00
Rui Ueyama
ea9864bbd5 Do not try to demangle C++ symbols as Rust ones
Previously, we always tried to demangle a symbol name as a Rust
symbol first and then attempted to demangle it as a C++ symbol.
This resulted in an incorrect demangled result, as the Rust legacy
mangling scheme is not distinguishable from C++.

This patch fix the issue by adding the "is_rust_obj" flag to the
ObjectFile. We try to demangle a symbol as a Rust one before as a C++
only if the flag is true.

Fixes https://github.com/rui314/mold/issues/1159
2023-11-30 13:53:23 +09:00
Rui Ueyama
3d9b4d5c05 Bump mold version to 2.4.0 2023-11-29 17:58:00 +09:00
Rui Ueyama
d06bfe0ac3 Update GitHub sponsor list 2023-11-29 17:48:11 +09:00
Rui Ueyama
6540294a81 Fix CI 2023-11-29 17:15:39 +09:00
Rui Ueyama
02a7640047 Fix build artifact pathnames 2023-11-29 16:59:23 +09:00
Rui Ueyama
f4c5a8a42e Allow multiple .eh_frame sections in a single object file
A `.eh_frame` section contains data for exception handling. Usually,
an object file contains only one `.eh_frame` section, which explains
how to handle exceptions for all text sections in the same object file.

However, it appears that, in rare cases, we need to handle object
files containing multiple `.eh_frame` sections. An example of this is
the `/usr/lib/clang/17/lib/x86_64-redhat-linux-gnu/clang_rt.crtbegin.o`
file, which is provided by the `compiler-rt` package of Fedora 39.
Specifically, I'm using the `quay.io/fedora/fedora:39` Docker image.
The file contains two `.eh_frame` sections.

One `.eh_frame` in the file is of type `STT_X86_64_UNWIND` and the
other is of `STT_PROGBITS`. It's possible that the file was created
with `ld -r`, and the linker failed to merge the two incoming
`.eh_frame` sections into one output section due to the difference in
section types.

We did not expect such inputs and consequently produced corrupted
output files.

This commit improves our linker so that mold can handle multiple
`.eh_frame` sections in a single object file.

Fixes https://github.com/rui314/mold/issues/1157
2023-11-29 16:10:36 +09:00
Rui Ueyama
0fdbace9b2 Improve compatibility of precedences in version script patterns
Previously, symbol names or wildcard patterns in version script files
were processed strictly from top to bottom. When a single symbol
matches two or more patterns, the first one was given precedence.

However, GNU ld appears to treat exact matches differently, assigning
them higher precedence over wildcard patterns. This discrepancy led to
programs linked with Qt 6.6.1 using mold failing to launch.

Fixes https://github.com/rui314/mold/issues/1158
2023-11-28 15:43:48 +09:00
Rui Ueyama
cab6014154
Merge pull request #1156 from ywgrit/main
Remove assertions to make errors exposed in a customized way
2023-11-26 18:55:40 +09:00
Rui Ueyama
000ce0ee52 Handle LLVM-generated TLSDESC code sequence
It had been assumed that the TLSDESC code seqeunce looks like this:

  lea    0(%rip), %rax
      R_X86_64_GOTPC32_TLSDESC    foo
  call   *(%rax)
      R_X86_64_TLSDESC_CALL       foo

However, LLVM seems to also emit something like this:

  lea    0(%rip), %reg
      R_X86_64_GOTPC32_TLSDESC    foo
  ...
  mov    %reg, %rax
  ...
  call   *(%rax)
      R_X86_64_TLSDESC_CALL       foo

That means when we rewrite the LEA instruction to relax the code
sequence, we need to handle destination registers other than %rax.

The wrong assumption caused a program crash as reported as
https://bugs.gentoo.org/914849.
2023-11-26 18:49:20 +09:00
ywgrit
d720a2011c Remove assertions to make errors exposed in a customized way 2023-11-26 17:04:28 +08:00
Rui Ueyama
c91055271b Simplify 2023-11-24 16:15:37 +09:00
Rui Ueyama
1478acd551 Do not save strings if not necessary 2023-11-24 11:48:19 +09:00
Rui Ueyama
b3404c07d7 Add a timer prober 2023-11-24 10:44:18 +09:00
Rui Ueyama
94767dc0e7 Fix a crash bug 2023-11-24 10:14:00 +09:00
Rui Ueyama
f957acfe11 Add an entry for Amazon Linux 2023-11-24 09:30:56 +09:00