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

1224 Commits

Author SHA1 Message Date
Rui Ueyama
4e3364ddd3 Format 2024-03-27 18:42:55 +09:00
Rui Ueyama
6e5ae45c1a Disable test on ppc64le
Fixes https://github.com/rui314/mold/issues/1221
2024-03-27 16:27:37 +09:00
Rui Ueyama
11c9376a50 Fix tests for musl libc-based systems
Fixes https://github.com/rui314/mold/issues/1221
2024-03-27 16:27:37 +09:00
Rui Ueyama
b5f2a7b1ce Do not call do_lto() if all LTO input files are dead
Fixes https://github.com/rui314/mold/issues/1226
2024-03-27 15:27:52 +09:00
Rui Ueyama
3df7c8e89c Export __global_pointer$ from executable
RISC-V psABI requires that symbol to be exported from an executable
if there's a GP-relative reference. For simplicity, we always export
it from executable as long as it has a .dynamic section.

https://github.com/rui314/mold/issues/1222
2024-03-25 17:57:52 +09:00
Rui Ueyama
0edbe29d38 Simplify 2024-03-25 17:57:52 +09:00
Rui Ueyama
32c4a09deb Fix file paths in .repro tar file
Previously, all pathnames were accidentally recorded as the name of
the tar file itself.

Fixes https://github.com/rui314/mold/issues/1227
2024-03-25 17:15:51 +09:00
Rui Ueyama
ee6907f678 Fix "skipping incompatible file" errors
https://github.com/rui314/mold/pull/1217
2024-03-25 14:52:54 +09:00
Rui Ueyama
163975d82a Make linker script INPUT command to look for a file from the script's directory
https://github.com/rui314/mold/pull/1217
2024-03-19 17:16:38 +09:00
Rui Ueyama
dda521e2bc [ARM32] Show "recompile with -fPIC" error for absolute relocations
Fixes https://github.com/rui314/mold/issues/1220
2024-03-19 13:19:05 +09:00
Rui Ueyama
ac04d79ad2 Extend test timeout from 1 hour to 3 hours 2024-03-15 11:35:43 +09:00
Rui Ueyama
16b0564d49 Fix CI 2024-03-12 14:38:42 +09:00
Rui Ueyama
d21207cc79 Handle sections with an unknown section type as errors
Fixes https://github.com/rui314/mold/issues/1215
2024-03-12 14:13:52 +09:00
Rui Ueyama
6356fa09e9 Fix gentoo package name 2024-03-09 16:18:07 +09:00
Rui Ueyama
50bdf39ba5 Mark shared symbols as weak if all references are weak
Previously, mold marked an imported symbol as a strong one if the
symbol came from a DSO and was exported as a strong symbol by the DSO.
This logic resulted in a miscomputation of the weakness bit, causing a
compatibility issue with other linkers.

Now, an imported symbol is marked as strong only when there's at least
one strong reference to it. In other words, if all references to an
imported symbol are weak, the symbol will be imported as a weak one.

Fixes https://github.com/llvm/llvm-project/issues/83080
2024-02-29 12:57:11 +09:00
Rui Ueyama
d4ff48a07e [PPC64V2] Emit _savegpr0_*, _restgpr0_*, _savegpr1_* and _restgpr1_* symbols
Fixes https://github.com/rui314/mold/issues/1203
2024-02-27 14:35:19 +09:00
Rui Ueyama
8090737d56 Merge sections with different flags into a single section
Previously, mold didn't merge sections with the same name but different
section flags into a single section. This behavior is different from other
linkers and caused a compatibility issue.

Now, mold merges input sections by their names and types.

Fixes https://github.com/rui314/mold/issues/1196
2024-02-21 18:50:47 +09:00
Rui Ueyama
7ead7231c9 Fix CI 2024-02-19 16:50:23 +09:00
Rui Ueyama
b0a3a5ce62 Drop SHF_COMPRESSED when creating a relocatable file
We always uncompress compressed sections when copying, so we should
not propagate the flag.

Fixes https://github.com/rui314/mold/issues/1195
2024-02-19 16:22:39 +09:00
Rui Ueyama
25351379ab Fix CI 2024-02-02 02:59:50 +09:00
Rui Ueyama
ba67c5d977 Fix CI 2024-02-02 02:35:12 +09:00
Rui Ueyama
7f8d77d84e Do not optimize absolute symbols in DSOs 2024-02-02 01:28:09 +09:00
Christoph Erhardt
2415b3e0bb [ELF][S390X] Skip tests that still fail with GCC 14
Signed-off-by: Christoph Erhardt <github@sicherha.de>
2024-01-18 21:53:12 +01: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
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
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
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
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
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
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
6540294a81 Fix CI 2023-11-29 17:15:39 +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
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
Rui Ueyama
de7d37e1fc Do not count .tbss into account when creating PT_GNU_RELRO
Fixes https://github.com/rui314/mold/issues/1151
2023-11-21 11:44:52 +09:00
Rui Ueyama
3cb8a528a5 Make -z rewrite-endbr to work without -ffunction-sections
Now we can rewrite an endbr64 instruction even if it is not at the
beginning of a section.
2023-11-20 17:36:23 +09:00
Rui Ueyama
8bb01e1a0e Fix CI 2023-11-20 14:25:03 +09:00
Rui Ueyama
0416d7ed80 Add --nmagic
Fixes https://github.com/rui314/mold/issues/1144
2023-11-20 13:35:04 +09:00
Rui Ueyama
eb6c213f2a Add --spare-program-headers
This is a new experimental flag to make room at the end of PHDR
so that post-processing tools can add more entries as needed.

Fixes https://github.com/rui314/mold/issues/1148
2023-11-16 12:07:13 +09:00
Rui Ueyama
6e97393740 Fix tests 2023-11-14 12:44:02 +09:00
Rui Ueyama
ff3d54d26f Fix a crash bug in --defsym
Fixes https://github.com/rui314/mold/issues/1108
2023-11-13 20:09:25 +09:00
Rui Ueyama
60bc56848f Fix tests for Debian 9 2023-11-13 13:37:35 +09:00
Rui Ueyama
da3f5dd4ec Fix --dynamic-list for DSOs
--dynamic-list, --export-dynamic-symbol and --export-dynamic-symbol-list
have different semantics for executables and DSOs. If the output is an
executable, they specify a list of symbols that are to be exported.
If the output is a shared object, they specify the list of symbols that
are to be interposable.

mold havne't implemented the latter semantics. This commit fixes that
issue.

Fixes https://github.com/rui314/mold/issues/1071
2023-11-12 13:00:24 +09:00
Rui Ueyama
8131528305 Rename long .rodata section names 2023-11-10 15:07:19 +09:00
Rui Ueyama
3f88964527 Map .ctors/.dtors into .init_array/.fini_array
.init_array/.fini_array haven't completely replace .ctors/.dtors, so
we need to convert .ctors/.dtors to .init_array/.fini_array.

Fixes https://github.com/rui314/mold/issues/1113
2023-11-09 12:43:58 +09:00