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

3827 Commits

Author SHA1 Message Date
Christoph Erhardt
c6ae4234b8 Fix hanging unit test gdb-index
This affects Fedora >= 35, where debuginfod is enabled by default. On
such systems, gdb shows the following interactive prompt and then waits
forever:
```
This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.fedoraproject.org/
Enable debuginfod for this session? (y or [n])
```

Unsetting the `DEBUGINFOD_URLS` environment variable disables the prompt
as documented here: https://fedoraproject.org/wiki/Debuginfod#Disabling

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2022-04-15 19:08:15 +02:00
Rui Ueyama
1f55e40a8a Canonicalize the tar file name for ARM64 2022-04-15 20:02:37 +08:00
Rui Ueyama
f86868cb38 Bump mold version to 1.2.0 2022-04-15 17:08:14 +08:00
Rui Ueyama
421289445a Remove dist.sh's output on make clean 2022-04-15 17:08:14 +08:00
Rui Ueyama
100922b650 [ELF] Fix section file offsets
Previously, if a section has a very large alignment requirement,
that section and the following sections may get wrong file offsets.

Fixes https://github.com/rui314/mold/issues/405
2022-04-15 14:59:09 +08:00
Rui Ueyama
0daf6233fb [ELF] Fix R_RISCV_ALIGN relocations
Fixes https://github.com/rui314/mold/issues/419
2022-04-15 14:37:55 +08:00
Rui Ueyama
d0e4eee204 [ELF] Print out a warning for .note.GNU-stack
https://github.com/rui314/mold/issues/427
2022-04-14 11:47:54 +08:00
Rui Ueyama
a7475dd5e3 [ELF] Support --gdb-index
This is a tough one because .gdb_index, .debug_gnu_pubnames,
.debug_gnu_pubtypes and DWARF are underdocumented, and DWARF is
complicated even if you have a right documentation. But, I believe I
managed to create a correct .gdb_index section.

Just like ld.lld, mold's --gdb-index needs all input object files to
have been compiled with -ggnu-pubnames. We read symbol names and type
names from the sections generated by -ggnu-pubnames.

Unlike ld.gold and ld.lld, we do not use an external library to read
DWARF debug info records.

As always, this feature is implemented with speed in mind. For Clang
15 which is built with -ggnu-pubnames, mold takes ~150 ms to create a
~300 MiB .gdb_index section on a simulated 16-core machine.

Fixes https://github.com/rui314/mold/issues/396
2022-04-13 19:01:17 +08:00
Rui Ueyama
c4af13889d Refactor 2022-04-10 11:03:53 +08:00
Rui Ueyama
7aaa4afce7 Refactor 2022-04-10 10:06:41 +08:00
Rui Ueyama
2fb96ad83f Ignore tar file for mold binary distribution 2022-04-10 09:09:29 +08:00
Rui Ueyama
a2fa4e5ecc Update README 2022-04-10 09:08:05 +08:00
Rui Ueyama
68877ab6ca Use mold in our CI 2022-04-10 08:51:51 +08:00
Rui Ueyama
f62777e606
Merge pull request #424 from yurai007/fix-memory-leak
Fix memory leak caught by Memcheck
2022-04-09 19:52:07 +08:00
Dawid Jurczak
c80e316649 Fix memory leak caught by Memcheck
This patch fix memory leak reported by Memcheck while running some tests.
The problem happen even with --no-quick-exit option.
Before change there are blocks definitely and indirectly lost seen in Memcheck summary:

==1202== LEAK SUMMARY:
==1202==    definitely lost: 1,120 bytes in 14 blocks
==1202==    indirectly lost: 633 bytes in 12 blocks
==1202==      possibly lost: 56,408 bytes in 46 blocks
==1202==    still reachable: 128 bytes in 1 blocks
==1202==         suppressed: 0 bytes in 0 blocks

After change number of such blocks drops to zero:

==2137== LEAK SUMMARY:
==2137==    definitely lost: 0 bytes in 0 blocks
==2137==    indirectly lost: 0 bytes in 0 blocks
==2137==      possibly lost: 56,408 bytes in 46 blocks
==2137==    still reachable: 128 bytes in 1 blocks
==2137==         suppressed: 0 bytes in 0 blocks

Signed-off-by: Dawid Jurczak <dawid_jurek@vp.pl>
2022-04-09 13:30:21 +02:00
Rui Ueyama
d1b9549817 [ELF] Do not ignore --dynamic-linker even if --shared is given
It is very rare, but technically you can create a shared object that
can also be executed directly. You can do that by giving a dynamic
linker path to the linker.

https://github.com/rui314/mold/issues/422
2022-04-09 18:35:04 +08:00
Rui Ueyama
01d2dd8dd9 Allow to pass extra CXXFLAGS 2022-04-09 15:39:32 +08:00
Rui Ueyama
6109154a07 Refactor 2022-04-09 15:24:51 +08:00
Rui Ueyama
49d4dac7e6 Push a build environment to DockerHub 2022-04-09 14:43:16 +08:00
Rui Ueyama
87a5f238dd Fix CI 2022-04-09 13:18:22 +08:00
Rui Ueyama
e448e0eb2b [ELF] Write tombstone values to dead debug info records
This is an attempt to fix https://github.com/rui314/mold/issues/357.
2022-04-09 10:40:25 +08:00
Rui Ueyama
4df5d6497a Break down test-all into smaller targets 2022-04-09 10:21:18 +08:00
Rui Ueyama
e90ad9be16 Build OpenSSL 3 only once
dist.sh compiles OpenSSL 3 for a license reason. We don't need to
build it every time the script is run.
2022-04-08 19:04:19 +08:00
Rui Ueyama
b5788e0caa [ELF] Document new command line options 2022-04-08 18:37:29 +08:00
Rui Ueyama
9178e43681 Add comments 2022-04-08 14:36:59 +08:00
Rui Ueyama
5feab826de [ELF] Fix _TLS_MODULE_BASE_ relocations
Fixes https://github.com/rui314/mold/issues/421
2022-04-08 13:34:43 +08:00
Rui Ueyama
2fc0231348 Update comments 2022-04-07 16:22:07 +08:00
Rui Ueyama
804ae412ed [ELF][ARM64] Do not create a canonical PLT for PIE
Position-independent executable shouldn't have a canonical PLT.
2022-04-07 16:00:27 +08:00
Rui Ueyama
f0a030cbcd [ELF] Add --disable-new-dtags
Fixes https://github.com/rui314/mold/issues/420
2022-04-07 15:26:59 +08:00
Rui Ueyama
ba6347996b [ELF] Implement a workaround for libbacktrace
This commit enables mold to work with libbacktrace before 2022-04-06.

https://github.com/rui314/mold/issues/402
2022-04-07 14:35:01 +08:00
Rui Ueyama
a151f4180f Refactor 2022-04-07 14:21:49 +08:00
Rui Ueyama
2c947ce2a9 [ELF][X86_64] Allow GOTPC32_TLSDESC to take registers other than %rax 2022-04-07 11:26:06 +08:00
Rui Ueyama
63b7102a4c [ELF] Define _TLS_MODULE_BASE_
This symbol is used by some object files that use TLSDESC.

Fixes https://github.com/rui314/mold/issues/421
2022-04-07 11:25:17 +08:00
Rui Ueyama
731dd0ed25 [ELF] Support --oformat=binary
With this change, you can link a simple bootloader using mold.
To do so, compile bootloader source files to object files with
the `-fno-PIC` flag and then invoke mold on the object files with
`-Ttext=<bootloader-start-address>` and `--oformat=binary`.

The .text segment is usually at the beginning of the output file if
the file is created that way. By passing the startup code as the first
file argument to the linker, you can place that startup code at the
beginning of the file.

Fixes https://github.com/rui314/mold/issues/418
2022-04-06 19:13:43 +08:00
Rui Ueyama
3105195364 [ELF] Make -Map to output address in hex 2022-04-06 19:13:43 +08:00
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