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

936 Commits

Author SHA1 Message Date
Rui Ueyama
7aae0bf7ba [ELF][S390] Implement TLS GD -> LE relaxation 2022-10-05 20:31:38 +08:00
Rui Ueyama
2b0ab0e974 [ELF][S390] Fix linker-synthesized __tls_get_offset
__tls_get_offset is supposed to return an offset from TP. Previously,
we instead returned an offset from the beginning of the TLS block.
2022-10-05 18:08:49 +08:00
Rui Ueyama
ffac38ae9e [ELF][S390] Support more relocations, enabling tests
It seems all tests pass with this change, so I'm enabling them.
2022-10-05 13:02:47 +08:00
Rui Ueyama
6ea03e6433 [ELF] Use $ instead of @ for lihnker-synthesized symbols
gdb recognizes "@" as an operator, so it's better to use a different symbol.
2022-10-04 16:46:21 +08:00
Rui Ueyama
f19c242901 Fix CI 2022-10-03 23:16:28 +08:00
Rui Ueyama
443a9c6d2d Fix CI 2022-10-03 23:00:15 +08:00
Rui Ueyama
d414f8ff6b Attempt to fix CI 2022-10-03 22:29:14 +08:00
Rui Ueyama
1205b1c18b [ELF] Do not truncate section size to 2^32
Fixes https://github.com/rui314/mold/issues/753
2022-10-03 21:55:28 +08:00
Rui Ueyama
1b86708683 [ELF] Resurrect .plt.got
This reverts commit ef04befcba and
6c964df459.

Even though these commits are not technically wrong, they caused a
regression on ARM32 and PPC64LE. It is because glibc cannot handle
IRELATIVE relocations in .rela.plt on these targets. Compare the
following two source source files:

  https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86_64/dl-machine.h;h=005d089501fa78654e16103de9ec901af7be4ff2;hb=HEAD#l530

  https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/arm/dl-machine.h;h=b0521c15496b9967a1c00a0ca7214bad2337be14;hb=HEAD#l464

ARM doesn't handle IRELATIVE for some reason, though x86-64 does.
I guess this is glibc's bug, but apparently we can't create IRELATIVE
relocations in .rela.plt. So we need to create it in .rela.dyn.
2022-10-03 21:45:15 +08:00
Rui Ueyama
6c964df459 [ELF] Do not always create a GOT entry for IFUNC 2022-10-03 17:07:43 +08:00
Rui Ueyama
a7f1e20594 [ELF] Emit local symbols for .got, .plt and .plt.got
These symbols are purely informational. They are not used for symbol
resolution. But they are useful for making disassembly readable.
2022-10-02 16:51:45 +08:00
Rui Ueyama
ae91e487df Do not include .sh in test name 2022-10-02 14:44:07 +08:00
Rui Ueyama
1709ad5996 [ELF] Do not create a PLT entry for IFUNC if -fno-plt 2022-10-02 14:26:33 +08:00
Rui Ueyama
0fa4cff086 [ELF] Fix thread-pointer calculation
TLS segments were always page-aligned before 9c7b95f108,
so we didn't notice, but our expressions to compute TP and TLS offset
were wrong.
2022-10-02 11:41:04 +08:00
Rui Ueyama
2f5366f764 Refactor 2022-10-01 16:16:28 +08:00
Rui Ueyama
92c2c9bc8f Refactor 2022-10-01 16:13:52 +08:00
Rui Ueyama
19db4bbe13 [ELF] Create symbols for range extension thunks 2022-10-01 15:52:59 +08:00
Rui Ueyama
fb4c21a65a Raise the support level of SPARC64 to match other targets 2022-10-01 11:22:40 +08:00
Rui Ueyama
b36562fc94 Show skipped tests
https://github.com/rui314/mold/pull/745
2022-10-01 10:57:43 +08:00
Rui Ueyama
5cf3ad6fe7 Handle MOLD_ENABLE_QEMU_TESTS 2022-10-01 10:57:04 +08:00
Rui Ueyama
930964ab38 [ELF] Do not run target-specific tests on unintended targets
This commit reduces the number of tests that are invoked only to
print out the "skipped" message.
2022-10-01 10:29:40 +08:00
Rui Ueyama
56de92f65f Fix CI 2022-10-01 10:25:25 +08:00
Rui Ueyama
7d8bf817e9 [ELF] Reorganize test files 2022-09-30 15:59:53 +08:00
Rui Ueyama
438d67bcf5 Refactor 2022-09-30 12:30:32 +08:00
Rui Ueyama
57f2099a36 Revert "Detect skipped tests"
This reverts commit 313629e1af because
it made `ctest` to print out too many lines after the test summary
report for skipped test names.
2022-09-30 10:20:50 +08:00
Rui Ueyama
2fcfb9b470 [ELF] Do not allocate disk space for .relro_padding
With this change, there should be no file size penalty on specifying
a large value to `-z max-page-size`.
2022-09-30 10:18:55 +08:00
Rui Ueyama
8ef01f87b1
Merge pull request #743 from sicherha/detect_skipped_tests 2022-09-29 18:23:39 -07:00
Rui Ueyama
5eed32bcf2 [ELF] Do not discard .gnu.warning sections
.gnu.warning* section may contain strings referenced by other sections,
so we can't discard them unconditionally. In this commit, we simply
keep all .gnu.warning* sections.
2022-09-30 08:57:23 +08:00
Christoph Erhardt
313629e1af Detect skipped tests
This allows CTest to differentiate between tests that were executed
successfully and tests that were skipped.

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2022-09-29 16:43:17 +02:00
Rui Ueyama
260182d439 Fix CI 2022-09-29 21:52:32 +08:00
Rui Ueyama
34ee49f3de [ELF] Add a padding at end of a PT_GNU_RELRO segment
We used to extend just a load segment containing RELRO sections.
strip command shrinks such segment so that it fits its contents.
So we need a dummy section for padding.

https://github.com/rui314/mold/issues/732
2022-09-29 20:02:49 +08:00
Rui Ueyama
5746060cde Refactor 2022-09-29 20:02:33 +08:00
Rui Ueyama
d504b24419 [ELF] Fix test for PPC64LE
`readelf --symbols` print out auxiliary information after a symbol name
for PPC64, so something like `foo$` didn't match.

     7: 0000000000000000    80 FUNC    GLOBAL DEFAULT    3 main [<localentry>: 8]
     8: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND .TOC.
     9: 0000000000000000    72 FUNC    GLOBAL DEFAULT   11 foo  [<localentry>: 8]
    10: 0000000000000000    40 FUNC    GLOBAL DEFAULT   19 bar

Fixes https://github.com/rui314/mold/issues/739
2022-09-29 15:43:18 +08:00
Rui Ueyama
33de554f41 Revert "Revert recent memory layout changes"
This reverts commit e62de0b31f so that
we can try this for 1.5.2.
2022-09-29 13:22:03 +08:00
Rui Ueyama
6abf26ef38 [ELF] Sort loadable segments on p_vaddr 2022-09-29 11:47:04 +08:00
Rui Ueyama
e62de0b31f Revert recent memory layout changes
This commit reverts the following commits:

- 3d33349691 [ELF] Fix -max-page-size
- 14b2ba3b74 Refactor
- 41c762b6c5 Update comments
- d22e85f345 [ELF] Save one memory page for RELRO
- 2941d75c71 [ELF] Do not page-align loadable segments
- a2552b6fd1 Refactor
- 919f58dc5d Fix CI
- ef6e6ecdf4 Refactor
- 9c7b95f108 [ELF] Do not page-align RELRO and TLS segments

I'll revert these changes because they caused a regression on systems
with large page size. Even though I believe most users are not
affected, it's a critical bug as mold creates completely unusable
output files for certain systems. In order to release 1.5.1, I'll
revert all of them.
2022-09-28 17:24:19 +08:00
Christoph Erhardt
7aa87220c4 Disable PIE in run-clang.sh unit test
This fixes the following error when Clang 15 is installed on the system:
> mold: error: out/test/elf/x86_64/run-clang/a.o:(.text):
> R_X86_64_32 relocation at offset 0x5 against symbol `.rodata' can not
> be used; recompile with -fPIC

The error occurs because Clang 15 assumes PIE to be enabled by default:
https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#build-system-changes

Attempting to produce a position-independent executable from an object
file that was created by `cc` without `-fPIE` caused the linker to bail
out.

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2022-09-27 15:16:44 +02:00
Rui Ueyama
3d33349691 [ELF] Fix -max-page-size
Fixes https://github.com/rui314/mold/issues/732
2022-09-27 11:19:31 +08:00
Rui Ueyama
2941d75c71 [ELF] Do not page-align loadable segments
Previously, we align each loadable segment and the beginning of
readable-writable non-RELRO segment to page boundaries. That's one
posible layout, but it made too many holes in files that resulted
in output file bloat.

That bloat is most visible on targets supporting large pages.
We conservatively link output files for the largest possible page
size so that the output will run both on large pages and usual small
pages. As an example, we use 64 KiB as a page size for ARM64.
So we wasted up to 64 KiB for each loadable segment. A "hello world"
program for exapmle became almost 200 KiB on ARM64 because of that
reason.

This commit changes the file layout. Loadable segments are no longer
aligned to page boundaries. Loadable segments are still placed into
different memory pages. A page at a boundary of two loadable segments
are doubly mapped to memory.

This change reduces output file size. It is most noticeable when an
output is small -- a "hello world" on ARM64 is now smaller than 10
KiB now.
2022-09-26 13:48:03 +08:00
Rui Ueyama
9c7b95f108 [ELF] Do not page-align RELRO and TLS segments
Previously, we always aligned RELRO and TLS segments to page boundaries.
Paddings for doing that bloated up resulting output files.
2022-09-25 17:42:59 +08:00
Martin Liska
b5f9d936da Enable compress-debug-sections-zstd for GCC
The compression option is directly passed to linker,
so GCC can handle it as well.

Signed-off-by: Martin Liska <mliska@suse.cz>
2022-09-22 16:06:16 +02:00
Martin Liska
d315ff2eff fix i686 ld warning
ld: warning: out/test/elf/i686/tls-module-base-i386/a.o:
missing .note.GNU-stack section implies executable stack

Signed-off-by: Martin Liska <mliska@suse.cz>
2022-09-21 10:17:48 +02:00
Rui Ueyama
3625c40f04 [ELF][SPARC] Disable gdb-index tests
These tests don't pass even with GNU ld on SPARC64. gdb doesn't seem
to be able to set a breakpoint to a function in an DSO for some resaon.
2022-09-21 08:06:01 +08:00
Rui Ueyama
99d6478b35 Disable on SPARC64 2022-09-20 21:00:51 +08:00
Rui Ueyama
c0cd1f5d58 Revert "[ELF][SPARC] Enable SPARC64 tests" to unbreak CI
This reverts commit 8c4d65179f.
2022-09-20 14:09:56 +08:00
Rui Ueyama
8c4d65179f [ELF][SPARC] Enable SPARC64 tests 2022-09-20 13:50:45 +08:00
Rui Ueyama
546c552644 Fix tests 2022-09-20 11:21:21 +08:00
Rui Ueyama
9dcc70f6ee [ELF][SPARC] Fix more test failures 2022-09-19 21:03:37 +08:00
Martin Liska
459cdcb6f1 fix a test warning
Fixes:
./test/elf/tls-gd2.sh: line 15: [: missing `]'

Signed-off-by: Martin Liska <mliska@suse.cz>
2022-09-18 19:22:46 +02:00
Rui Ueyama
b87398be69
Merge pull request #712 from wangp/which
Don't use which(1) or perl
2022-09-18 06:10:54 -07:00