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

3257 Commits

Author SHA1 Message Date
Rui Ueyama
baff2948d4
Merge pull request #213 from tklauser/test-fix-i386-mergable-strings
Fix skip check in i386-mergable-strings.sh
2021-12-31 00:07:04 +09:00
Tobias Klauser
66c9659f5a
Fix skip check in i386-mergable-strings.sh
Check for the ability to build 32-bit binaries like in the other i386
test cases.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2021-12-30 15:58:11 +01:00
Rui Ueyama
9697febd83
Merge pull request #212 from tklauser/macos-x86_64
Avoid infinite recursion in do_main<X86_64>
2021-12-30 22:18:58 +09:00
Rui Ueyama
f29a85f20a Revert "Use C++17 filesystem API"
This reverts commit f6e91df440 because
it causes build breakages for a lot of Gentoo packages.
2021-12-30 22:15:52 +09:00
Tobias Klauser
cc9f6f430b
Avoid infinite recursion in do_main<X86_64>
Running mold on x86_64 macOS 11 currently leads to a segfault due to
inifinite recursion in do_main<X86_64>. Protect against this case by
only calling into do_main<X86_64> once if cputype doesn't match.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2021-12-30 14:08:16 +01:00
Rui Ueyama
7776165ef7 Fix macOS build 2021-12-30 21:40:42 +09:00
Rui Ueyama
f6e91df440 Use C++17 filesystem API 2021-12-30 21:32:01 +09:00
Rui Ueyama
3f6e889449 Do not use exceptions
If a given path does not exist, std::filesystem::canonical throws an
exception unless `ec` is given.
2021-12-30 20:33:26 +09:00
Rui Ueyama
8d838e4fd1
Merge pull request #210 from sicherha/path-buffer-sizes
Fix handling of path buffer sizes
2021-12-30 16:51:02 +09:00
Christoph Erhardt
68c4b76352 Use std::filesystem to circumvent buffer-size issues
Signed-off-by: Christoph Erhardt <github@sicherha.de>
2021-12-30 08:43:36 +01:00
Rui Ueyama
f6e800655b [ELF] Add a description for --defsym to the man page 2021-12-30 15:44:08 +09:00
Rui Ueyama
35ca107361 Add a missing header 2021-12-30 15:10:07 +09:00
Rui Ueyama
3f8f2e89e5 Show "Passed all tests" message in green 2021-12-30 15:05:17 +09:00
Rui Ueyama
d49c50ddaf [ELF] Add --defsym
Fixes https://github.com/rui314/mold/issues/208
2021-12-30 14:48:39 +09:00
Rui Ueyama
44ae92c4ed Remove redundant "../../" from test script paths
So that it's easier to see the output of the test script running
with `bash -x` . This change was made using sed.
2021-12-30 11:11:27 +09:00
Rui Ueyama
ec628cb0bf
Merge pull request #209 from sicherha/fix-shellcheck-warnings
Add lots of quotes to shell scripts
2021-12-30 07:04:09 +09:00
Christoph Erhardt
0dcc910223 Add lots of quotes to shell scripts
This makes it possible to build and test mold in a path that contains
whitespace characters - with the notable exception of the tests where
`LD_PRELOAD` is used. That's because `LD_PRELOAD` unconditionally treats
any whitespace as separator, regardless of quoting.

The following ShellCheck warnings are eliminated by this commit:
* SC2046: Quote this to prevent word splitting.
* SC2086: Double quote to prevent globbing and word splitting.

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2021-12-29 22:18:19 +01:00
Rui Ueyama
1c6c8c3479 Update README 2021-12-29 21:36:06 +09:00
Rui Ueyama
99866f01b2 Update README as GCC 12.1.0 or later accepts -fuse-ld=mold
Fixes https://github.com/rui314/mold/issues/205
2021-12-29 21:21:45 +09:00
Rui Ueyama
f3766cda81 [ELF] Add -z {max,common}-page-size
Fixes https://github.com/rui314/mold/issues/203
2021-12-29 17:14:08 +09:00
Rui Ueyama
946e0c3acd Avoid uname -o
macOS's uname does not support the `-o` option.
2021-12-29 16:12:05 +09:00
Rui Ueyama
e1ce8994b9
Merge pull request #204 from Ingrater/fixAndroidBuild
Fix building on Android
2021-12-29 15:55:57 +09:00
Rui Ueyama
b151de6684 [ELF] Fix .tbss layout
Fixes https://github.com/rui314/mold/issues/126
2021-12-29 15:50:56 +09:00
Rui Ueyama
4bfaa964a7 Refactor 2021-12-29 12:42:51 +09:00
Rui Ueyama
cfed33ee42 Revert "[ELF] Fix a layout issue for thread-local bss sections"
This reverts commit 5c35d2a41f
because it causes a regression https://github.com/rui314/mold/issues/201.

I'll fix https://github.com/rui314/mold/issues/126 in another patch.
2021-12-28 18:36:31 +09:00
Rui Ueyama
aa972e5351 [ELF] Remove redundnat "mold: " from error messages 2021-12-28 12:42:25 +09:00
Rui Ueyama
27509f0408 Fix typo
https://github.com/rui314/mold/issues/203
2021-12-28 12:41:26 +09:00
Benjamin Thaut
f943da88d7 Do not use mimalloc when building on Android as it causes a infinite recursuion.
Signed-off-by: Benjamin Thaut <code@benjamin-thaut.de>
2021-12-27 17:13:25 +01:00
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