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

3782 Commits

Author SHA1 Message Date
Rui Ueyama
94e2d7d6dc [ELF][ARM32] Fix R_ARM_THM_CALL relocation 2022-03-23 08:43:27 +00:00
Rui Ueyama
759aa95618 [ELF][ARM32] Fix R_ARM_THM_MOVT_ABS relocation 2022-03-23 03:12:29 +00:00
Rui Ueyama
575a604d5d [ELF][ARM32] Handle relocations against non-alloc sections 2022-03-23 01:44:19 +00:00
Rui Ueyama
ac9a1c4048 [ELF][ARM32] Add a link to a documentation 2022-03-23 00:50:26 +00:00
Rui Ueyama
d5cf590498 [ELF][ARM32] Support basic relocations
With this change, mold can link dynamically-linked "Hello world"
program for ARM32.
2022-03-22 12:52:07 +00:00
Rui Ueyama
18656091f6 Rename a test 2022-03-22 12:24:10 +00:00
Rui Ueyama
ead32811b3 Fix a test for AArch64
Currently, we do not support relaxations of TLS GD/LD relocations
for ARM64. This is in practice not a problem because TLSDESC is used
on ARM64 by default.

However, there's one situation in which not supporting TLS GD/LD
relaxation becomes an issue; static linking. If an executable is
statically-linked, relaxation is mandatory because we can't generate
dynamic relocations for GD/LD relocations.

In this patch, we simply report an error if an object file compiled
with TLS GD/LD is used for creating a statically-linked executable.

This commit fixes all tests on ARM64.
2022-03-21 02:49:50 +00:00
Rui Ueyama
7cdfa31e6c Refactor 2022-03-20 14:21:46 +00:00
Rui Ueyama
a6e4676a71
Merge pull request #401 from yurai007/do-not-hardcode-GCC-version-in-tests
[ELF][RISC-V] Do not hardcode GCC version in tests
2022-03-20 09:25:43 +08:00
Dawid Jurczak
0c88d323c8 [ELF][RISC-V] Do not hardcode GCC version in tests
Signed-off-by: Dawid Jurczak <dawid_jurek@vp.pl>
2022-03-19 17:22:03 +01:00
Rui Ueyama
326150a182
Merge pull request #390 from mrichtarsky/main
Improve help
2022-03-19 22:39:52 +08:00
nick-rawlings
339816702d Update cmdline.cc
use stoul for unsigned long

image-base i64 to u64 parse_unsigned_number

Signed-off-by: nick-rawlings <100548346+nick-rawlings@users.noreply.github.com>
2022-03-17 21:28:10 -05:00
Alois Wohlschlager
146ddd711c
[ELF][ARM64] Support R_AARCH64_LD_PREL_LO19 relocations
Implement support for the R_AARCH64_LD_PREL_LO19 relocation type. Since
this actually behaves the same way as R_AARCH64_CONDBR19, reuse the
relevant code.

Signed-off-by: Alois Wohlschlager <alois1@gmx-topmail.de>
2022-03-17 15:44:49 +01:00
Martin Richtarsky
32d1006e29 Improve help
Signed-off-by: Martin Richtarsky <s@martinien.de>
2022-03-10 16:06:42 +00:00
Rui Ueyama
66a057cce7 [ELF][ARM64] Add a stub for ARM32 2022-03-10 16:27:31 +09:00
Rui Ueyama
619ff869e4 [ELF][i386] Implement GD → LE and LD → LD relaxations
This commit implements TLS relocation relaxations.

Fixes https://github.com/rui314/mold/issues/388
2022-03-10 15:18:43 +09:00
Rui Ueyama
e7c071ea36 [ELF] Improve an error message 2022-03-10 13:54:16 +09:00
Rui Ueyama
3d68824dea [ELF][ARM64] Fix IFUNC relocations in -static-pie executables
For a static position-independent executable, a libc's intitialization
routine reads the dynamic relocation table and apply them. It looks like
on ARM64, they simply apply relocations from the begining of the table
to end. Therefore, if an IFUNC relocation appears before RELATIVE relocs,
the IFUNC resolver would see an unrelocated value. So, we need to place
RELATIVE relocs before IFUNCs.

Fixes https://github.com/rui314/mold/issues/382
2022-03-09 18:04:34 +09:00
Rui Ueyama
c98d276916 [ELF][ARM64] Fix a test
For some reason, readelf doesn't like a build-id if it's very short.
2022-03-09 17:00:53 +09:00
Rui Ueyama
446c461201 [ELF][ARM64] Fix debug info section
This fixes a regression introduced in 92876820cb.
Until now, mold set bogus addresses to non-alloc sections and
as a result emitted corrupted debug info.

Fixes https://github.com/rui314/mold/issues/387
2022-03-09 16:04:03 +09:00
Rui Ueyama
98edd441ce [ELF] Do not print out an error of ldd --version
Some `ldd` impls don't support the --version option. We do not
want to show the error message but instead just skip the test
entirely.

https://github.com/rui314/mold/pull/385
2022-03-09 14:53:10 +09:00
Rui Ueyama
37f6ef2081 [ELF] Fix a crash bug for -noinhibit-exec
After a certain point, it is not expected that there's a remaining
undefined symbol. -noinhibit-exec did not respect that invariant,
which caused a crash bug on ARM64.

This change forces all symbols to be resolved if --noinhibit-exec
is given.

Fixes https://github.com/rui314/mold/issues/383
2022-03-09 11:38:46 +09:00
Rui Ueyama
41cf6d7814 [ELF][ARM64] Avoid -mcmodel=large and -no-PIC
Such combination is not supported by GCC.

Fixes https://github.com/rui314/mold/issues/384
2022-03-09 11:36:44 +09:00
Rui Ueyama
bb5a596bc5 Set LC_ALL=C to get consistent output from shell comands
We unset `LANG`, but it looks like `LC_ALL` takes precedence over `LANG`,
so we should set `LC_ALL` to `C`.

Reported at https://github.com/rui314/mold/pull/385
2022-03-09 09:03:22 +09:00
Rui Ueyama
1b6f301644
Merge pull request #381 from Scrumplex/ignore-dy
[ELF] Add --dy and --dn aliases
2022-03-08 20:43:08 +09:00
Sefa Eyeoglu
8a089fee45
[ELF] Move --static option in helpmsg
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2022-03-08 10:53:32 +01:00
Sefa Eyeoglu
82e80721ac
[ELF] Add --dy and --dn aliases
GNU ld aliases these to -Bdynamic and -Bstatic respectively.

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2022-03-08 10:53:27 +01:00
Rui Ueyama
d3dea2f435
Merge pull request #380 from sicherha/static-pie-glibc-version-requirement
Increase required glibc version for `-static-pie` tests
2022-03-08 18:37:21 +09:00
Christoph Erhardt
a20e3b8004 Increase required glibc version for -static-pie tests
mold 1.1.1 generates `-static-pie` code that works with glibc 2.35 but
segfaults with glibc 2.34 or older.

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2022-03-08 10:13:49 +01:00
Rui Ueyama
c1af9c97e7 Bump mold version to 1.1.1 2022-03-07 19:38:14 +09:00
Rui Ueyama
3999aa8b18 [ELF] Fix -static-pie
Previously, mold did not work with the -static-pie compiler flag.
In order to support static PIE, we need the following:

1. Create a .dynamic section even if it is not a dynamic executable, and
2. do not define __rel_iplt_start/end symbols.

The second part is required to workaround a glibc issue.

Even with these changes, mold-generated executable doesn't work with
old glibc versions. But I think it's OK because -static-pie is relatively
new option and you need a newer toolchain anyway.
2022-03-06 17:14:13 +09:00
Rui Ueyama
b4d9db9db8 [ELF] Do not emit DT_RELCOUNT
It looks like the glibc loader does not use this field in the dynamic
section. GNU ld, gold and LLVM lld don't create this. So I think we
can just follow suit.
2022-03-06 14:43:24 +09:00
Rui Ueyama
95c7871c6e Fix documentation 2022-03-06 14:23:22 +09:00
Rui Ueyama
3f7bffe93c Add a comment 2022-03-06 13:48:31 +09:00
Rui Ueyama
ec473c74d7 Refactor 2022-03-06 13:24:01 +09:00
Rui Ueyama
9e11b40a99 [ELF] Do not allocate a byte for an empty class
In C++, the size of an empty class is 1 rather than 0 because every
object is guaranteed to have a unique address. But if we do not need
the unique address guarantee, we can add `[[no_unique_address]]` to
a class member to save 1 byte. This is a new C++20 feature.
2022-03-06 12:20:31 +09:00
Rui Ueyama
a4fd7e3819 [ELF] Remove redundant foo/.. from library paths 2022-03-05 21:28:43 +09:00
Rui Ueyama
aae3dc3c1e Refactor 2022-03-05 20:27:10 +09:00
Rui Ueyama
ba7967152d Refactor 2022-03-05 20:14:43 +09:00
Rui Ueyama
d6dae3be6d [ELF] Report errors more strictly for unrepresentable relocations 2022-03-05 14:59:31 +09:00
Rui Ueyama
83aaa63a49 [ELF][i386] Make GOT-relative relocs relative to .got instead of .got.plt
We used to compute offsets from .got.plt for GOT-relative relocations,
but according to the i386 psABI, they should be relative to .got.
2022-03-05 12:13:04 +09:00
Rui Ueyama
b0d91b9967 [ELF] Add -warn-shared-textrel
Fixes https://github.com/rui314/mold/issues/377
2022-03-05 10:59:04 +09:00
Rui Ueyama
4ea052591a
Merge pull request #378 from gruenich/main
input-files: Remove unused variable size
2022-03-05 09:49:57 +09:00
Christoph Grüninger
2f03e46bb3 input-files: Remove unused variable size
Removed code has no effect.
Left-over from code removal in 4dae896726.

Signed-off-by: Christoph Grüninger <foss@grueninger.de>
2022-03-05 00:30:30 +01:00
Rui Ueyama
6205a1edc3 Update the man page 2022-03-04 14:54:10 +09:00
Rui Ueyama
4dea134949 [ELF] Do not compute the contents of .eh_frame twice 2022-03-03 20:07:45 +09:00
Rui Ueyama
eb79859ea2 [ELF] Always set _GLOBAL_OFFSET_TABLE_ to the beginning of .got
Previously, we set the address of `_GLOBAL_OFFSET_TABLE_` to `.got.plt`
on i386 and x86-64 and to `.got` on other targets. But it looks like
this special treament of x86 isn't necessary. The x86-64 psABI said
that the symbol can even be in the middle of `.got` (*1). If `.got.plt`
is missing, GNU linker set it to `.got`.

This commit unconditionally set the symbol value to `.got`.

(*1) x86-64 psABI 1.0 p.77: "The symbol _GLOBAL_OFFSET_TABLE_ may
reside in the middle of the .got section, allowing both negative and
non-negative offsets into the array of addresses."
2022-03-03 12:10:26 +09:00
Rui Ueyama
8714b78d48 [ELF] Reduce memory usage a bit 2022-03-03 10:28:27 +09:00
Rui Ueyama
86b142e555 [ELF] Do not create DT_INIT/DT_FINI if _init/_fini are in a .so
Fixes https://github.com/rui314/mold/issues/372
2022-03-02 21:12:41 +09:00
Rui Ueyama
e5549c73f0 Remove an unused class 2022-03-02 17:37:38 +09:00