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

3216 Commits

Author SHA1 Message Date
Rui Ueyama
7b3c640472 Fix --dynamic-list
Previously, symbols were not exported from an executable even if
they are specified so by a dynamic list.
2021-12-25 13:38:24 +09:00
Rui Ueyama
d9606d65b5 [ELF] Remove R_X86_64_{TLSLD,TPOFF32,TPOFF64} error checks
Compiler should not emit these types of relocations unless it knows
they will never refer imported symbols. However, it looks like GCC 7
emits these relocations against global symbols with STB_GNU_UNIQUE
attribute, which can be resolved to a symbol in other ELF module at
runtime. It looks like the bug only exists in GCC 7 and fixed in
recent versions of GCC.

mold verifies the above conditions and reports an error if the
condition is violated. On the other hand, GNU ld and LLVM lld don't
verify and simply create a shared library that is not always
guaranteed to work.

Give this situation, I decided to simply remove the verification code
from mold. This is what other linkers do, and it make mold "compatible"
with GCC 7.

Fixes https://github.com/rui314/mold/issues/145
2021-12-24 22:50:15 +09:00
Rui Ueyama
13245fd9a8
Merge pull request #194 from sicherha/container-improvements
Container improvements
2021-12-24 22:12:08 +09:00
Rui Ueyama
04ccd4dbdd [ELF] Export undef symbols if both -z defs and -warn-undefined-symbols are given
When we are creating a DSO, unresolved undefined symbols are promoted to
dynamic symbols by default so that they will get another chance to be
resolved at runtime.

You can suppress this behavior by passing `-z defs`. If that option is
given, remaining undefs are reported as errors instead of being silently
promoted.

It looks like `-warn-undefined-symbols` negates the effect of `-z defs`.
So, if both options are given, remaining undefs are promoted to dynamic
symbols. mold previously silently make such symbols absolute symbols with
value 0.

Fixed https://github.com/rui314/mold/issues/152
2021-12-24 21:13:15 +09:00
Rui Ueyama
5601cf4236 [ELF] Add -z separate-code, -z noseparate-code and -z separate-lodable-segments
Fixes https://github.com/rui314/mold/issues/172
2021-12-24 20:28:45 +09:00
Rui Ueyama
088912e2fc [ELF] Create less number of PT_NOTE segments 2021-12-24 20:15:56 +09:00
Rui Ueyama
29d956a7b0 [ELF] Fix handling of DSO symbols with default version
Fixes https://github.com/rui314/mold/issues/150
2021-12-24 16:10:01 +09:00
Rui Ueyama
1ba6cc9188 [ELF] Handle relocation referring 0th symbol correctly 2021-12-24 16:09:57 +09:00
Christoph Erhardt
27f0e8c0e5 Pass on command-line arguments to make inside the container
This allows the caller to pass extra build options if desired.
Moreover, it is possible to run `./build-static.sh test` in order to
execute the testsuite inside the container.

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2021-12-23 16:01:39 +01:00
Christoph Erhardt
92bc33eed4 Add test dependencies to Docker container
These packages contain the i686 toolchain as well as the `file` and
`hexdump` utilities. They increase the size of the container image by
approximately 10 % (70 MiB).

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2021-12-23 16:01:39 +01:00
Christoph Erhardt
6160f3874f Make build-static.sh compatible with Podman and SELinux
* Append the `Z` option for the mounted volume
* Add `--userns=keep-id` if Podman's `docker` wrapper is used

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2021-12-23 16:01:37 +01:00
Rui Ueyama
135f17c5aa [ELF] Handle --sysroot
Attempt to fix https://github.com/rui314/mold/issues/150
2021-12-23 21:23:00 +09:00
Rui Ueyama
d60e302f70
Merge pull request #192 from sicherha/fix-broken-mold-wrapper
Do not use custom `LDFLAGS` for linking `mold-wrapper.so`
2021-12-23 20:31:16 +09:00
Christoph Erhardt
d858068975 Do not use custom LDFLAGS for linking mold-wrapper.so
Linking a dynamic library with `-static` would prevent it from being
loadable.

Fixes #191.

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2021-12-23 10:41:53 +01:00
Rui Ueyama
8c86c28496 Add -z nodefaultlib
Fixes https://github.com/rui314/mold/issues/184
2021-12-23 15:01:57 +09:00
Rui Ueyama
76407a6646 Do not create a PT_NOTE segment for non-alloc .note sections
Fixes https://github.com/rui314/mold/issues/185
2021-12-23 14:04:08 +09:00
Rui Ueyama
56f63dd295
Merge pull request #186 from sicherha/fix-cppcheck-warnings
[ELF] Add missing calls to `va_end()`
2021-12-22 23:13:25 +09:00
Christoph Erhardt
c8cec61e1c [ELF] Add missing calls to va_end()
Reported by cppcheck. Omitting `va_end()` causes undefined behaviour:
https://en.cppreference.com/w/c/variadic/va_end

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2021-12-22 14:10:01 +01:00
Rui Ueyama
feb63f7b5b [ELF] Ignore -z nodefaultlib
Fixes https://github.com/rui314/mold/issues/184
2021-12-22 21:04:21 +09:00
Rui Ueyama
4d5e4730a2 Fix typo 2021-12-22 20:44:29 +09:00
Rui Ueyama
24bf92c27c [ELF] Fix a crash bug 2021-12-22 20:41:11 +09:00
Rui Ueyama
8bc57363c8 [ELF] Issue a warning instead of error for an unknown -z option
Fixes https://github.com/rui314/mold/issues/180
2021-12-22 20:08:14 +09:00
Rui Ueyama
e65560f963 Add the Repology badge 2021-12-22 19:59:39 +09:00
Rui Ueyama
9326f90d14 Remove dead code
Fixes https://github.com/rui314/mold/issues/175
2021-12-22 17:08:41 +09:00
Rui Ueyama
390e737dea Attempt to silence cppcheck warning
https://github.com/rui314/mold/issues/176
2021-12-22 17:06:23 +09:00
Rui Ueyama
358464d5ad Reduce docker image size for ./build-static.sh
Suggested by https://github.com/rui314/mold/issues/161#issuecomment-997184302.
2021-12-22 14:01:46 +09:00
Rui Ueyama
5bc8bc9d64 Fix -Wall warnings
Fixes https://github.com/rui314/mold/issues/174
2021-12-22 12:10:20 +09:00
Rui Ueyama
74fdf90d70 Fix a test for clang and clang-as
clang-as does not support --keep-locals, so use its synonym -L
which is supported both by GNU as and clang-as.

Fixes https://github.com/rui314/mold/issues/173
2021-12-22 11:42:29 +09:00
Rui Ueyama
530568e662 [ELF] Use a better type 2021-12-20 20:08:25 +09:00
Rui Ueyama
f9ff04866e [ELF] Add --threads=N option
Fixes https://github.com/rui314/mold/issues/168
2021-12-20 16:29:22 +09:00
Rui Ueyama
96c44be33d [ELF] Add an assertion 2021-12-20 14:38:36 +09:00
Rui Ueyama
2bd3bc6d47 Revert "[ELF] Relax TLSLD error check"
This reverts commit 1baac27e8c.

In order to link gcc 7's output, relaxing this error check wasn't
enough as reported on https://github.com/rui314/mold/issues/145.
We need to remove more error checks or keep them as-is.
For now, I'll restore all the error checks, but before making another
release, I may remove all error checks to accept gcc 7's buggy
output files.
2021-12-20 13:38:53 +09:00
Rui Ueyama
fb89ce22fd Update third-party/mimalloc to v2.0.3 2021-12-20 13:01:38 +09:00
Rui Ueyama
3e397d6e78 Cosmetic changes 2021-12-20 12:35:06 +09:00
Rui Ueyama
c824e7831a [ELF] Show a hint if -b binary is given
Fixes https://github.com/rui314/mold/issues/164
2021-12-20 12:26:02 +09:00
Rui Ueyama
8f1c328d1a Cosmetic changes 2021-12-20 11:46:28 +09:00
Rui Ueyama
4d78510cb0 [ELF] Keep SHF_MERGE and SHF_STRINGS bits
Once object files are linked into an executable or a shared object file,
sections are no longer splittable. So these bits don't make sense anymore.

Previously, we cleared the bits. But it looks like there are tools that
are picky about them. So we'll just leave them as-is.

Fixes https://github.com/rui314/mold/issues/155
2021-12-18 17:05:41 +09:00
Rui Ueyama
dbc9869d7e Revert "[ELF] Use RE2 for version script symbol matching"
This reverts commit 27147dfe32.

I don't think the performance improvement wasn't large enough to
justify adding more dependencies to third-party libraries.

https://github.com/rui314/mold/issues/156
2021-12-18 13:26:35 +09:00
Rui Ueyama
27147dfe32 [ELF] Use RE2 for version script symbol matching
This is an attempt to speed up version script application.
It looks like RE2 is faster than libstdc++'s std::regex.
This change reduces libQt6Gui.so.6.3.0's link time by about 30%.

https://github.com/rui314/mold/issues/156
2021-12-18 13:23:18 +09:00
Rui Ueyama
665bffa52f Import xxhash library to third-party for ease of building
In some environment, XXH3 isn't available as a binary package.
If you do not like to use the imported xxhash library but instead
link to system's libxxhash.so, invoke make with `SYSTEM_XXHASH=1`.
2021-12-18 13:05:54 +09:00
Rui Ueyama
65dc32fdb8 Merge commit '0621402e0a83a71ee5a13e92ce6a5de0f14dc1f2' as 'third-party/xxhash' 2021-12-18 12:42:16 +09:00
Rui Ueyama
0621402e0a Squashed 'third-party/xxhash/' content from commit 35b0373c
git-subtree-dir: third-party/xxhash
git-subtree-split: 35b0373c697b5f160d3db26b1cbb45a0d5ba788c
2021-12-18 12:42:16 +09:00
Rui Ueyama
1d6d0e2fe3
Merge pull request #158 from sylvestre/second-fix
test/pie.sh: extend the check to other output
2021-12-17 20:16:07 +09:00
Rui Ueyama
4f37c3d024 Fix tests in non-English environment
These test files are not only invoked by make by also directly by hand.
Unsetting `LANG` on each file so that they don't fail in a non-English
environment.

This change is mechanically created by the following command:

  sed -i '1 a export LANG=' test/*/*.sh
2021-12-17 20:06:50 +09:00
Rui Ueyama
072cf0eb30
Merge pull request #153 from sylvestre/patch-1
Force the execution of tests in English
2021-12-17 20:02:31 +09:00
Rui Ueyama
455e729393 [ELF] Make version script application faster
Instead of calling regex match multiple times, create a single
regex and call regex match function only once.

https://github.com/rui314/mold/issues/156
2021-12-17 19:09:26 +09:00
Sylvestre Ledru
fbee0ec588 test/pie.sh: extend the check to other output
On debian unstable, the output doesn't contain 'Shared object file'
Parsing a different output

Signed-off-by: Sylvestre Ledru <sylvestre@debian.org>
2021-12-17 10:02:21 +01:00
Sylvestre Ledru
9a96dc1c33 Force the execution of tests in English
If the tests are executed in a different locale like French, some logs  (ex: ```out/test/elf/auxiliary/log```) can contain output like:

```La section dynamique à l'offset 0x2000 contient 10 entrées :```

which of course doesn't work as the grep is
```
fgrep -q 'Auxiliary library: [foo]' $t/log
```

Signed-off-by: Sylvestre Ledru <sylvestre@debian.org>
2021-12-17 09:25:42 +01:00
Rui Ueyama
36633895e5 [ELF] Fix undefined symbol versions
Previously, if the following conditions are met:

 - we are creating a shared object file,
 - there's an undefined symbol in an input object file that are
   to be promoted to a dynamic symbol, and
 - a version script defining a default version is given,

then the symbol gets the default version. But that's a wrong behavior
because version scripts should not affect symbols that are not defined
in an output file.

This change fixes the issue by not setting version to such symbol.

Fixes https://github.com/rui314/mold/issues/151
2021-12-17 17:07:36 +09:00
Rui Ueyama
1baac27e8c [ELF] Relax TLSLD error check
This is a workaround for https://github.com/rui314/mold/issues/145
2021-12-17 14:35:43 +09:00