1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-21 01:47:11 +03:00
Commit Graph

3229 Commits

Author SHA1 Message Date
Rui Ueyama
e8dcecfff0 [ELF] Create a symlink to mold as /usr/libexec/mold/ld
So that you can pass that directory name as an argument for `-B`.
2021-12-27 13:37:35 +09:00
Rui Ueyama
cfccfc247d Update README 2021-12-27 12:25:44 +09:00
Rui Ueyama
04ad22d326 [ELF] Refactor
std::string_view::find_first_of() is faster than compiling a regex
and runnning it.
2021-12-26 23:33:34 +09:00
Rui Ueyama
1228bf3865
Merge pull request #200 from jmglogow/fix_version_globbing
[ELF] Fix '?' for globbing + version scripts
2021-12-26 23:29:02 +09:00
Jan-Marek Glogowski
31b0248b05 [ELF] Fix '?' for globbing + version scripts
For globbing, '?' matches a single character, so must be replaced
with '.'. As a result, don't skip the later regex matching for
version scripts, if the pattern contains either '*' or '?'.

Signed-off-by: Jan-Marek Glogowski <glogow@fbihome.de>
2021-12-26 15:02:43 +01:00
Rui Ueyama
d1161137d9 [ELF] Fix Initial-Exec TLS variables
Previously, GOTTPOFF relocations against Initial-Exec TLS variables
got wrong value.

Fixes https://github.com/rui314/mold/issues/197
2021-12-26 20:51:37 +09:00
Rui Ueyama
888474b59c [ELF] Ignore --warn-execstack
mold never sets executable bit to the stack area, so we can
simply ignore the flag.

Fixes https://github.com/rui314/mold/issues/196
2021-12-26 10:29:16 +09:00
Rui Ueyama
5c35d2a41f [ELF] Fix a layout issue for thread-local bss sections
Previously, if there are more than one TLS BSS section (e.g. .tbss and
.tcommon), mold layout them in such a way that they overlap in memory.
That caused a mysterious program crash to the programs compiled with DMD,
a D compiler.

Fixes https://github.com/rui314/mold/issues/126
2021-12-25 20:32:33 +09:00
Rui Ueyama
eaa8bf8b30 [ELF] Fix an error message 2021-12-25 19:29:04 +09:00
Rui Ueyama
0d3c9811c1 Improve make test 2021-12-25 16:59:43 +09:00
Rui Ueyama
6e290aab3e [ELF] Implement --color-diagnostics 2021-12-25 16:55:51 +09:00
Rui Ueyama
d1a47ee57b [ELF] Ignore --apply-dynamic-relocs
We always write dynamic relocation addends for bug-compatibiltiy
with the Go toolchain. Therefore, this flag is no-op.

See 919e8cbc62 for the details of
the Go's bug.
2021-12-25 16:22:35 +09:00
Rui Ueyama
7aa5c393e4 [ELF] Support extern "C++" in dynamic lists
Fixes https://github.com/rui314/mold/issues/149
2021-12-25 15:10:24 +09:00
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