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

3792 Commits

Author SHA1 Message Date
Rui Ueyama
23045c6f95 [ELF] Do not create synthetic sections if not necessary 2022-04-06 18:04:42 +08:00
Rui Ueyama
2d29f234e2 [ELF] Change output section layout 2022-04-06 16:35:38 +08:00
Rui Ueyama
4edaf82691 Fix CI 2022-04-06 15:03:37 +08:00
Rui Ueyama
49aa10318c [ELF] Add --section-start 2022-04-06 14:45:31 +08:00
Rui Ueyama
2c03ed5673 Add comments 2022-04-06 11:08:29 +08:00
Rui Ueyama
e0bc74ad8a [ELF] Create canonical PLTs only when needed
Previously, we make all PLT entries canonical if we are creating
a position dependent executable, because I was thinking that promoting
usual PLT entries to canonical ones is harmless; symbol equality still
holds.

However, it looks like Qt depends on the usual linker's behavior not
to make PLT canonical if not necessary. I believe they are maintaining
some hidden symbol as aliases for exported symbols and compare their
addresses at runtime.

Of course this doesn't work if your program is not compiled with -fPIC,
but qt5/QtCore/qglobal.h has a macro to abort compilation if PIC is
disabled. (They check for __PIC__ and __PIE__ macros.) So, all object
files are guaranteed to be compiled with -fPIC if they are using QT
functions, and they assume that the linker doesn't create a canonical
PLT for Qt functions.

This commit makes mold to create canonical PLTs only when needed.
That is, if an address of a function is directly taken (i.e. not via
GOT), then mold makes its PLT canonical.

Fixes https://github.com/rui314/mold/issues/352
2022-04-05 21:02:42 +08:00
Rui Ueyama
3768ca612e [ELF] Deprecate --preload
It looks like no one is using --preload, so there's no point to
maintain this feature.

https://github.com/rui314/mold/issues/414
2022-04-05 12:41:50 +08:00
Rui Ueyama
86d59c29eb [ELF][ARM32] Handle TLS_LDO32 relocations in non-alloc sections
Fixes https://github.com/rui314/mold/issues/417
2022-04-05 04:22:16 +00:00
Rui Ueyama
96a4a1b635 [ELF][ARM64] Support non-NC variant of MOVW_UABS relocations
We need to implement an overflow check for non-NC relocations,
but for now they are just aliases for NC variants.

Fixes https://github.com/rui314/mold/issues/416
2022-04-05 02:50:43 +00:00
Rui Ueyama
006b13aec1 Refactor 2022-04-04 17:26:11 +08:00
Rui Ueyama
91947405fe Attempt to silence CI 2022-04-04 17:06:47 +08:00
Rui Ueyama
b7123bded5 [ELF] Fix tests for non-x86-64 targets 2022-04-04 16:36:43 +08:00
Rui Ueyama
0884f279e0 [ELF][x86] Always create .got.plt
glibc's -static-pie implementation expect that _GLOBAL_OFFSET_TABLE_
is at the beginning of .got.plt, as it uses the address of _DYNAMIC
which is stored at _GLOBAL_OFFSET_TABLE_[0].

In this patch, we always create .got.plt for x86-64 and i386.
2022-04-04 16:35:22 +08:00
Rui Ueyama
615a24d1dd Add comments 2022-04-03 19:12:10 +08:00
Rui Ueyama
e1e4e9fd9e Fix data races found by ThreadSanitizer 2022-04-03 15:08:57 +08:00
Rui Ueyama
ceed69ff49 [ELF] Fix crash bug in ICF
Fixes https://github.com/rui314/mold/issues/398
2022-04-03 13:41:13 +08:00
Rui Ueyama
d90f7e162b [ELF] Improve error message
Fixes https://github.com/rui314/mold/issues/412
2022-04-03 12:31:31 +08:00
Rui Ueyama
340528bdc3 Update mimalloc to v2.0.5
Fixes https://github.com/rui314/mold/issues/281
2022-04-03 12:00:23 +08:00
Rui Ueyama
392781a0e2 [ELF][i386] Sort .ctors and .dtors sections 2022-04-03 10:43:22 +08:00
Rui Ueyama
4e10ee7e50 [ELF] Run tests for all targets on CI 2022-04-02 21:27:45 +08:00
Rui Ueyama
8d94fd6ca3 [ELF][ARM64] Fix a test 2022-04-02 18:05:05 +08:00
Rui Ueyama
358f244247 [ELF][RISCV64] Fix a test 2022-04-02 18:00:23 +08:00
Rui Ueyama
7a1cbb9b34 [ELF][ARM32] Support R_ARM_THM_JUMP11 2022-04-02 17:35:55 +08:00
Rui Ueyama
e6d4154688 [ELF] Generalize tests
With this change, you can now cross compile test cases and run
them on qemu-user. Here is an example to run our test suits in
an emulated ARM32 environment.

$ CC=arm-linux-gnueabihf-gcc \
  CXX=arm-linux-gnueabihf-g++ \
  GCC=arm-linux-gnueabihf-gcc \
  GXX=arm-linux-gnueabihf-g++ \
  OBJDUMP=arm-linux-gnueabihf-objdump \
  MACHINE=arm \
  QEMU='qemu-arm -L /usr/arm-linux-gnueabihf' \
  make -j16 test
2022-04-02 16:53:41 +08:00
Rui Ueyama
60eae9ed20 [ELF][ARM32] Support R_ARM_GOT_PREL 2022-04-02 01:46:48 +00:00
Rui Ueyama
7fb1b1b9ec
Merge pull request #399 from alois31/r_aarch64_ld_prel_lo19
[ELF][ARM64] Support R_AARCH64_LD_PREL_LO19 relocations
2022-04-01 13:44:39 +08:00
Rui Ueyama
0ecd72900e Attempt to fix CI 2022-04-01 13:32:01 +08:00
Rui Ueyama
9eb4e76daf Attempt to fix CI 2022-04-01 13:20:17 +08:00
Rui Ueyama
b6876b5640 Update comment 2022-04-01 13:12:27 +08:00
Rui Ueyama
f4753b34bf [ELF] Fix use-after-free found by ASAN 2022-04-01 13:12:10 +08:00
Rui Ueyama
8196199cac Refactor 2022-04-01 12:52:21 +08:00
Rui Ueyama
2a3ee11b7d
Merge pull request #400 from nick-rawlings/parse_unsigned_number
image-base i64 to u64 parse_unsigned_number
2022-04-01 12:36:44 +08:00
Rui Ueyama
68f2a26987 Refactor 2022-04-01 02:49:57 +00:00
Rui Ueyama
227a6c8a88 [ELF][ARM32] Fix TLSDESC relocations 2022-04-01 02:47:29 +00:00
Rui Ueyama
fe617c3618 [ELF][ARM32] Support R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS 2022-04-01 02:47:29 +00:00
Rui Ueyama
e3a7c9e017 [ELF][RISCV] Disable a test that doesn't work with RISCV64 2022-03-31 13:24:34 +00:00
Rui Ueyama
5ee6f89544 Revert "Attempt to fix a build issue with libc++14"
This reverts commit 8e3cee958b
because it broke the RISC-V target.
2022-03-31 13:24:19 +00:00
Rui Ueyama
40c2ad7839 [ELF][RISCV64] Fix tests 2022-03-31 08:16:07 +00:00
Rui Ueyama
5edd07efd9 Refactor 2022-03-31 01:47:56 +00:00
Rui Ueyama
8e5def28ce Refactor 2022-03-31 00:46:33 +00:00
Rui Ueyama
b534d5af27 Add comments 2022-03-30 14:11:34 +00:00
Rui Ueyama
673f531adb Add comments 2022-03-30 13:57:17 +00:00
Rui Ueyama
66d3de438c Attempt to fix CI 2022-03-30 09:36:38 +00:00
Rui Ueyama
d9ea875677 [ELF][ARM32] Implement many relocations
With this change, most tests in test/elf/ directory pass on ARM32.
2022-03-30 09:26:32 +00:00
Rui Ueyama
577361478a Fix CI
This reverts commit 408e2bfee8.
2022-03-29 11:23:30 +00:00
Rui Ueyama
408e2bfee8 Improve tests 2022-03-29 06:47:17 +00:00
Rui Ueyama
9ac23730b7
Merge pull request #408 from yurai007/fix-some-ubsan-errors
[ELF] Fix issues caught by UBSan
2022-03-28 16:39:24 +08:00
Dawid Jurczak
bf26753bbd [ELF] Fix issues caught by UBSan
While running tests on UBSan instrumented mold binary 2 separated problems are reported:

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior elf/main.cc:592:15 in
elf/output-chunks.cc:1866:24: runtime error: member call on null pointer of type 'mold:🧝:VerdefSection<mold:🧝:X86_64> *'

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior elf/output-chunks.cc:1866:24 in
elf/input-files.cc:1000:8: runtime error: load of value 190, which is not a valid value for type 'bool'

This change fixes both of them.

Signed-off-by: Dawid Jurczak <dawid_jurek@vp.pl>
2022-03-28 09:43:28 +02:00
Rui Ueyama
8e3cee958b Attempt to fix a build issue with libc++14
https://github.com/rui314/mold/issues/407
2022-03-27 08:15:25 +00:00
Rui Ueyama
05f4a43c8f [ELF][ARM64] Allow TLSGD relocations in statically-linked executables 2022-03-27 07:48:42 +00:00