1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-26 13:10:46 +03:00
Commit Graph

1924 Commits

Author SHA1 Message Date
Rui Ueyama
a9e76295ff Simplify 2024-03-28 11:52:33 +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
8df5a76203 Attempt to fix Windows CI 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
03640029db Refactor 2024-03-21 15:03:45 +09:00
Rui Ueyama
caad70dd6f Do not group mergeable sections in an output file
Runtime doesn't care where mergeable sections are, but it's reported
that Valgrind does. So, grouping mergeable sections just doesn't seem
to make sense.

https://github.com/rui314/mold/pull/1223
2024-03-20 22:15:05 +09:00
Rui Ueyama
7c8ed4d2e1 Refactor 2024-03-20 15:05:16 +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
e7dc90dadc Refactor 2024-03-18 17:10:18 +09:00
Rui Ueyama
c26260e38d Do not set symbol size to imported dynamic symbols
The dynamic linker does not seem to care about st_size of undefined
dynamic symbols, but semantically it shouldn't be an arbitrary number.
2024-03-15 11:35:48 +09:00
Rui Ueyama
c395da1c54 Do not create an unnecessary gap in file for BSS
Fixes https://github.com/rui314/mold/issues/1216
2024-03-13 16:01:04 +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
c85dd8881b Refactor 2024-03-10 18:21:04 +09:00
Rui Ueyama
8eae0a33b3 [PPC32] Do not discard .got2 even if --gc-sections is given
Even though .got2 may not be referenced directly, we use that section
when processing relocations.
2024-03-10 18:16:11 +09:00
Rui Ueyama
641e7c2b05 Use madvise instead of munmap
Using madvise(2) is clearer than munmap(2), and the madvise approach
seems to be slightly faster than mmap on my machine.
2024-03-09 13:39:59 +09:00
Rui Ueyama
c60d1d0877 Use xxhash instead of gdb_hash for the internal hashmap for .gdb_index
Our ConcurrentMap uses linear probing to find unused hash table entry.
It gives up if 128 consective slots are occupied, and the whole process
dies with the "ConcurrentMap is full" error message. So our hash
function's quality must be high.

For .gdb_index, we used to use gdb_index() to compute keys for the
ConcurrentMap. It turned out that the function's quality is poor,
generating very similar output for short strings.

This commit changes the hash function to xxhash.

Fixes https://issues.chromium.org/issues/40276991#comment5
2024-03-06 13:12:53 +09:00
Rui Ueyama
51f871f43b Silently ignore broken .llvm_addrsig
Fixes https://github.com/rui314/mold/issues/1213
2024-03-04 16:57:12 +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
1e413d4121 Fix GCC warning
Fixes https://github.com/rui314/mold/issues/1205
2024-02-28 14:03:41 +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
58558e319c RISC-V: Define __global_pointer$ for DSO
Fixes https://github.com/rui314/mold/issues/1182
2024-02-26 14:38:38 +09:00
Rui Ueyama
01e9f42c10
Merge pull request #1198 from nga888/win-build-tidy
Minor fixes for the Windows build
2024-02-26 12:12:11 +09:00
Rui Ueyama
6d8e6afbf2 Fix R_PPC64_DTPREL16_LO_DS
Fixes https://github.com/rui314/mold/issues/1192
2024-02-23 17:14:25 +09:00
Rui Ueyama
5b5f431717 Fix CI 2024-02-22 09:13:26 +09:00
Andrew Ng
796e2556b6 Minor fixes for the Windows build
Removes some Windows build warnings.

Fixes conversion of Windows FILETIME to nsec in get_usage() used by
TimerRecord.
2024-02-21 15:24:07 +00: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
d39a0c7035 Refactor 2024-02-21 18:21:03 +09:00
Rui Ueyama
de696ba5a4 --repro: Do not try to reopen files with different paths
Fixes https://github.com/rui314/mold/issues/1197
2024-02-21 17:11:04 +09:00
Rui Ueyama
9f07fd035c Support R_PPC64_DTPREL16_LO_DS
Fixes https://github.com/rui314/mold/issues/1192
2024-02-20 13:07:02 +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
64c2084c8a Pass GCC offload data to the LTO backend
Fixes https://github.com/rui314/mold/issues/1190
2024-02-19 15:12:43 +09:00
Rui Ueyama
4c355239ad Refactor 2024-02-19 15:12:43 +09:00
Rui Ueyama
79169ea315 Format 2024-02-19 15:12:43 +09:00
Christoph Grüninger
83a5bfbfb1 elf/cmdline.cc: Add missing references in range-for loops
std::string is a non-trivial type, this change ensures its
copy-ctor and dtor don't get called.
Found by Clazy (range-loop-reference)


Signed-off-by: Christoph Grüninger <foss@grueninger.de>
2024-02-10 17:42:07 +01:00
aokblast
8c99dd0f2c
Feat: use accumulate address on sections with SHT_ALLOC 2024-02-03 22:03:55 +08: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
Dan Cross
bed5b1731b illumos: Treat absolute symbols specially
illumos is a descendent of Solaris/OpenSolaris, and treats
symbols with shndx=SHN_ABS and st_value=0 specially, such that
they should be marked imported.  This change adds a special
case for this behavior, wrapped up in a function that #ifdef's
out on other platforms.  With this patch, executables linked
with mold on illumos run; without it, they do not.

The original behavior was spotted by Luqman Aden (@luqmana).
This also patches a small bogon in the third-party `mimalloc`
code.  I've sent that same fix upstream, but so far the
maintainer has not resonded, so replicate here.

Fixes #1183

Signed-off-by: Dan Cross <cross@oxidecomputer.com>
2024-02-01 13:55:05 +00:00
Tatsuyuki Ishi
fede4a8102 Ignore addrsig sections corrupted by strip
When removing symbols, the indices in .llvm_addrsig also needs to be
updated, but binutils is not aware of this and leaves the table in a
corrupt state.

Use the same test as what LLD uses to reject potentially corrupted addrsig
sections.

Unfortunately, testing this seems tricky. While producing a file with OOB
addrsig index is not hard, it's hard to consistently trigger a segfault
with that access.

Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
2024-01-20 17:28:51 +09:00
Filip Navara
d832547ba2 Add support for .eh_frame section on arm32 2024-01-18 18:28:26 +01: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
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