1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-15 14:36:25 +03:00
Commit Graph

323 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
3c992c02ea
Merge pull request #72 from nehaljwani/fix-pie-test
[tests] Fix pie test when cc isn't built with --enable-default-pie
2021-07-03 14:30:05 +09:00
Rui Ueyama
2abca8b5c1 Fix tests for non-Ubuntu-20 systems
Fixes https://github.com/rui314/mold/issues/67
2021-07-03 14:26:38 +09:00
Nehal J Wani
3208ceaac6
[tests] Fix pie test when cc isn't built with --enable-default-pie
mold: /__w/mold/mold/test/tmp/pie/a.o:(.text): R_X86_64_32 relocation
       against symbol `.rodata' can not be used; recompile with -fPIE
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2021-07-03 01:05:28 -04:00
Rui Ueyama
475fad3a78 Allow sysroot to be a relative path
Chromium cannot be built with out this patch.
2021-07-03 12:02:32 +09:00
Rui Ueyama
0fd62ce693 Fix sysroot handling
Fix https://github.com/rui314/mold/issues/59
2021-07-01 17:40:45 +09:00
Rui Ueyama
9abfeee0e3 Split a function and add tests 2021-07-01 10:00:08 +09:00
Rui Ueyama
6432114e2a Fix handling of --sysroot
Fixes https://github.com/rui314/mold/issues/59
2021-06-30 22:15:19 +09:00
Rui Ueyama
989f69fdc5 Do not apply version scripts to DSO symbols
This is needed by Gentoo's dev-perl/Image-Imlib2-2.30.0-r1 package
because this fixes a mis-link issue of libbsd.
2021-06-27 21:44:42 +09:00
Rui Ueyama
5761dbc399 Fix a broken test 2021-06-27 17:03:59 +09:00
Rui Ueyama
570a3556c5 Fix exported weak symbol
This is needed by Gentoo's app-admin/filebeat-7.9.3 package.
2021-06-27 12:37:14 +09:00
Rui Ueyama
4436e4a57d Improve error message for an attempt of LTO 2021-06-26 15:05:05 +09:00
Rui Ueyama
bd1b044afc Accept extern "C" in version script
This is needed by Gentoo's dev-libs/opencl-clang-10.0.0.1-r1 package.
2021-06-25 16:48:40 +09:00
Rui Ueyama
2e5088a001 Fix common symbol
This is needed by Gentoo's sci-electronics/voacapl-0.7.6 package.
2021-06-25 15:42:16 +09:00
Rui Ueyama
bd8059a366 Fix an issue that a .dynsym for PLT refers itself 2021-06-25 13:33:14 +09:00
Rui Ueyama
5046fae0cf Do not directly call imported functions
This is needed by Gentoo's sci-libs/lapack-3.9.0-r1 package.
2021-06-25 01:05:57 +09:00
Rui Ueyama
d9ecc2e3e6 Promote weak undefined symbols to weak dynamic symbols
Previously, if a weak undefined symbol cannot be resolved within
an output of the linker, mold turned it into an absolute symbol
with value 0. However, other linkers export such symbols as a
weak dynamic symbol, so that the symbol gets another chance to be
resolved at runtime.

This patch implements the behavior.

This is needed by Gentoo's dev-libs/nsync-1.20.1 package.
2021-06-25 00:44:35 +09:00
Rui Ueyama
fd1855a67b Make --version to exit immediately
This is needed by Gentoo's dev-lang/spidermonkey-78.10.1 package,
as its configure script assumes that the linker exit normally
even if extra options are given after `--version`.
2021-06-24 16:45:04 +09:00
Rui Ueyama
81dbbdda62 DSOs referenced by used DSOs are considered used
This is needed by Gentoo's sys-cluster/ampi-0_pre20140616 package.
2021-06-24 15:54:25 +09:00
Rui Ueyama
de668b125a Refactor 2021-06-24 15:50:08 +09:00
Rui Ueyama
dd04357363 Do not set STT_GNU_IFUNC to symbols .dynsym
We should not set STT_GNU_IFUNC to symbols in .dynsym because
from the other ELF module's point of view, it doens't matter
whether a symbol is IFUNC or not.

This is needed by Gentoo's sci-mathematics/nauty-2.6.7 package.
2021-06-21 10:32:30 +09:00
Rui Ueyama
f127281d05 Allow empty input files
mmap(2) fails if you pass 0 as an argument for `length` parameter,
so this case has to be handled as a special case.

This is needed by Gentoo's media-plugins/calf-0.90.3-r1 package.
2021-06-21 09:33:35 +09:00
Rui Ueyama
d3d056d27a Do not register common symbols as lazy symbols
In other words, a linker shouldn't pull out an object file from an
archive to resolve an existing undefined or a common symbol with a
common symbol.

This is needed by Gentoo's app-arch/dump-0.4.47 package.
2021-06-21 08:36:16 +09:00
Rui Ueyama
1bac9c7b8d Add -z nodump
This is needed by Gentoo's sci-libs/indilib-1.8.9 package.
2021-06-21 06:56:07 +09:00
Rui Ueyama
7a689d8361 Handle ar header alignment correctly 2021-06-20 21:29:10 +09:00
Rui Ueyama
4f92d7f19b Add -z origin
This is needed by Gentoo's dev-ada/gnatcoll-bindings-2020-r1 package.
2021-06-20 14:42:43 +09:00
Rui Ueyama
9519e4ce20 Change how to handle --unresolved-symbols=ignore
Previously, we turned unresolved undefined symbols into dynamic
symbols. This patch changed the behavior so that such symbols
are turned into non-dynamic absolute symbols with value zero.

This change is needed by Gentoo's dev-libs/wayland-protocols-1.21
package.
2021-06-20 14:31:36 +09:00
Rui Ueyama
793136a8f0 Give common symbols in archive files higher priority
If an object file in an static archive contains a common symbol
that can be used to resolve an undefined symbol, mold now pulls
out that object file from the archive. Previously, we ignore such
common symbols.

Object files generated by a Fortran compiler often contain a lot of
common symbols, and this change makes a difference.

Fixes Gentoo's sci-astronomy/wcslib-7.3 package, which contains a
program written in Fortran.
2021-06-19 21:42:21 +09:00
Rui Ueyama
1d16374763 Fix a test 2021-06-19 12:34:20 +09:00
Rui Ueyama
a0ecd0c8dc Add --unique=PATTERN
This is needed by Gentoo's sys-fabric/infinipath-psm-3.2 package.
2021-06-19 01:09:26 +09:00
Rui Ueyama
bd858faf94 Add --unresolved-symbols
This is needed by Gentoo's dev-libs/wayland-protocols-1.21 package.
2021-06-18 15:51:57 +09:00
Rui Ueyama
725834e0b1 Do not garbage-collect C-identifer sections
This is needed for Gentoo's sys-fs/udev-245.5-r1 package.
2021-06-18 12:57:12 +09:00
Rui Ueyama
37b88e3f5a Do not set executable bit for --relocatable outputs 2021-06-18 01:45:38 +09:00
Rui Ueyama
2203644a3b Fix section addresses
This is needed for Gentoo's net-libs/nodejs-14.16.1 package.
2021-06-17 23:48:31 +09:00
Rui Ueyama
e88dddb820 Add -z {text,notext,textoff] 2021-06-17 14:18:44 +09:00