1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-05 09:07:10 +03:00
Commit Graph

2510 Commits

Author SHA1 Message Date
Rui Ueyama
fa543ae350 Attempt to fix a breakage
It looks like 564d7e044ff8a2534a2413d34762dd84be7eaf66 introduced
a concurrency issue.
2021-07-16 14:31:12 +09:00
Rui Ueyama
d8ad600b6a Improve MergedSection<E>::assign_offsets()
This patch parallelize MergedSection<E>::assign_offsets().
clang-13 link time is reduced from ~2.5s to ~2.35 with this patch.
2021-07-14 17:11:25 +09:00
Rui Ueyama
d79cdb8371 Fix a broken test
Fixes https://github.com/rui314/mold/issues/89
2021-07-13 19:24:26 +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
6bb091595e Refactor 2021-07-13 13:13:34 +09:00
Rui Ueyama
ecbd3eae14
Merge pull request #87 from Logarithmus/fix-run-sh
Fix test/run.sh for cases when /usr/bin/ld -> /usr/bin/mold
2021-07-12 13:49:39 +09:00
Artur Sinila
5fb7ecbd03
Fix test/run.sh for cases when /usr/bin/ld -> /usr/bin/mold
Signed-off-by: Artur Sinila <freesoftware@logarithmus.dev>
2021-07-12 05:27:21 +03:00
Rui Ueyama
e0d44b6678 Use concurrent_unorderd_map for string merging
With high contention rate, it looks like concurrent_unordered_map
outperforms concurrent_hash_map.
2021-07-12 00:02:01 +09:00
Rui Ueyama
3204bb01d9 Fix function pointer equality
Previously, a GOT relocation (e.g. R_X86_64_REX_GOTPCRELX) and a
R_X86_64_64 relocation referring the same imported symbols were
resolved to different addresses. Here is why:

 - When we saw a R_X86_64_64 relocation against an imported symbol,
   we created a PLT and resolve the relocation there.

 - GOT relocation is resolved to a GOT entry, which has a true
   address of an imported function at runtime, which is different
   from PLT entries that redirect calls to the real function.

With this patch, we no longer create a PLT entry for R_X86_64_64.
Instead, we emit a dynamic relocation so that it is always resolved
to a real function address.

Fixes GNU MP's `make check` failure, which was reported at
https://github.com/rui314/mold/issues/81
2021-07-10 17:54:57 +09:00
Rui Ueyama
faac31f217 Support VERSION linker script command
The grammar of the command is this

  VERSION { <version-script> }

where <version-script> is a version script you can specify with
the --version-script option.
2021-07-09 23:34:44 +09:00
Rui Ueyama
e855b90344 Show stacktrace on SEGV and assertion failure 2021-07-09 23:34:39 +09:00
Rui Ueyama
63b6d30876 Compress .repro section contents
Previously, .repro contains an uncompressed tar file containing all
input files. This patch compresses the contents in the gzip format.
2021-07-09 00:47:15 +09:00
Rui Ueyama
3acb7c8e2f Update README
Pointed out by @pecak.
2021-07-08 17:17:10 +09:00
Rui Ueyama
50b7497e19 Align section header to a E::wordsize boundary
Fixes https://github.com/rui314/mold/issues/80
2021-07-08 15:58:55 +09:00
Rui Ueyama
64913ba610
Merge pull request #77 from Logarithmus/fix-tests
Optimize CI build (enable ccache & run tests in parallel)
2021-07-08 00:43:40 +09:00
Artur Sinila
f9a5e9171e
ci.yml: enable ccache
Signed-off-by: Artur Sinila <freesoftware@logarithmus.dev>
2021-07-07 18:37:14 +03:00
Artur Sinila
67948ac222
ci.yml: run tests in parallel
Signed-off-by: Artur Sinila <freesoftware@logarithmus.dev>
2021-07-07 18:37:14 +03:00
Rui Ueyama
84d9e4d5ac Fix regexp 2021-07-07 23:12:24 +09:00
Rui Ueyama
72cc07fb42
Merge pull request #83 from nehaljwani/dynsym-IFUNC
Do not replace IFUNC with FUNC in .dynsym
2021-07-07 21:48:15 +09:00
Rui Ueyama
057fffb1dd Optimize regexes 2021-07-07 21:46:23 +09:00
Rui Ueyama
6ae115ac69 Support R_AARCH_ABS{32,64} relocations 2021-07-07 21:06:18 +09:00
Nehal J Wani
1aec54efdb
Do not replace IFUNC with FUNC in .dynsym
This is a partial revert of dd04357

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2021-07-07 07:59:51 -04:00
Rui Ueyama
e3dccd0157 Add a test 2021-07-07 20:38:48 +09:00
Rui Ueyama
048a478bab
Merge pull request #82 from nehaljwani/dynsym-visibility
Ensure correct visibility of symbols in .dynsym section
2021-07-07 20:25:33 +09:00
Nehal J Wani
36853d1669
Ensure correct visibility of symbols in .dynsym section
Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2021-07-07 07:19:10 -04:00
Rui Ueyama
6d6df45a23 Fix definition of __GLOBAL_OFFSET_TABLE__ for AArch64 2021-07-07 12:51:23 +09:00
Rui Ueyama
d4a67f6f38 Disable an AArch64 test 2021-07-06 23:06:02 +09:00
Rui Ueyama
b9c35e0009 Add R_AARCH64_LD64_GOTPAGE_LO15 2021-07-06 23:00:01 +09:00
Rui Ueyama
4dffb74762 Fix CI 2021-07-06 22:49:51 +09:00
Rui Ueyama
ce06ea80ca Fix CI 2021-07-06 22:38:41 +09:00
Rui Ueyama
41497d7990 Support AARCH64 relocations
With this change, mold can now create a "Hello world" program
for the AArch64 target.
2021-07-06 22:24:48 +09:00
Rui Ueyama
fc4aafa974 Fix assertion failures
mold failed with `make EXTRA_CPPFLAGS="-Wp,-D_GLIBCXX_ASSERTIONS" test`,
which enables extra assertions.

Thanks for @nehaljwani to find out the flag.
2021-07-06 14:43:06 +09:00
Rui Ueyama
d0265554a7 Refactor 2021-07-06 13:39:33 +09:00
Rui Ueyama
713b3a9925
Merge pull request #78 from nehaljwani/oob
Fix out of bound check in get_shndx()
2021-07-06 10:49:41 +09:00
Nehal J Wani
b596248a1e
Fix out of bound check in get_shndx()
Assert failure:
/usr/include/c++/11.1.0/span:276:
  std::span::reference
  std::span<ElfSym<X86_64>, 18446744073709551615>
     ::operator[](std::span::size_type)
         const [_Type = ElfSym<X86_64>, _Extent = 18446744073709551615]:
           Assertion '__idx < size()' failed.

GDB stacktrace:
Thread 2.4 "mold" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fabc3d3f640 (LWP 17804)]
0x00007fabc496fd22 in raise () from /usr/lib/libc.so.6
(gdb) bt
 #0  0x00007fabc496fd22 in raise () from /usr/lib/libc.so.6
 #1  0x00007fabc4959862 in abort () from /usr/lib/libc.so.6
 #2  0x000055a9685eb018 in std::__replacement_assert (...)
     at /usr/include/c++/11.1.0/x86_64-pc-linux-gnu/bits/c++config.h:504
 #3  0x000055a968614c47 in std::span<ElfSym<X86_64>, ...>::operator[] (...)
     at /usr/include/c++/11.1.0/span:276
 #4  ObjectFile<X86_64>::get_shndx (this=<...>, esym=...) at ./mold.h:2145
 #5  ObjectFile<X86_64>::get_section (this=<...>, esym=...) at ./mold.h:2154

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2021-07-05 18:02:27 -04:00
Rui Ueyama
426a689d22 Fix i386 relocation handling 2021-07-05 14:00:16 +09:00
Rui Ueyama
b721514f98 Rename a variable 2021-07-05 14:00:16 +09:00
Rui Ueyama
4282ef24cd
Merge pull request #76 from Logarithmus/cache
.gitignore: add .cache & compile_commands.json (for clangd)
2021-07-05 10:15:08 +09:00
Artur Sinila
7bbfaac67a
.gitignore: add .cache & compile_commands.json (for clangd)
Signed-off-by: Artur Sinila <freesoftware@logarithmus.dev>
2021-07-04 21:09:51 +03:00
Rui Ueyama
11f7653daf Refactor 2021-07-04 21:01:39 +09:00
Rui Ueyama
19d29f25f2
Merge pull request #71 from nehaljwani/gcc-ci
[CI] Test code with GCC 11.1.0
2021-07-04 13:26:40 +09:00
Nehal J Wani
32dff0b877
[CI] Test code with GCC 11.1.0
Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2021-07-03 23:51:39 -04:00
Rui Ueyama
f3a7f86abb
Merge pull request #75 from nehaljwani/fix-spare-dynamic-tags-test
[tests] Improve test for -spare-dynamic-tags
2021-07-04 12:45:33 +09:00
Nehal J Wani
be6d443bc8
[tests] Improve test for -spare-dynamic-tags
The default size and offsets of the .dynamic section are not necessarily
same with different builds of clang. For example, some builds can make
clang pass --hash-style=gnu to the linker and some --hash-style=both.

This change updates the test to compute the difference in size of the
.dynamic section before and after using the flag -spare-dynamic-tags,
making it independent of the compiler build.

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2021-07-03 22:35:42 -04:00
Rui Ueyama
70d1acd744 Fix CI 2021-07-03 21:53:28 +09:00
Rui Ueyama
30ecba45c6 Update README 2021-07-03 21:48:18 +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
d502b6ec60 Initial AARCH64 support 2021-07-03 20:48:38 +09:00
Rui Ueyama
546df46eaf Define AARCH64 type and other constants for ARM64 2021-07-03 19:58:46 +09:00
Rui Ueyama
fe3af50fb8 Fix comment 2021-07-03 18:32:43 +09:00