1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-11 05:46:58 +03:00
Commit Graph

64 Commits

Author SHA1 Message Date
Rui Ueyama
f5dbb8112c Format 2021-11-05 14:41:26 +09:00
Rui Ueyama
f90a55cec9 [ELF] Ignore invalid SHF_MERGE sections
DMD, a compiler for the D language, generates a broken .rodata.str1.1
section with sh_entsize = 0. The section also contains out-of-bound
relocations. This patch handles such broken mergeable sections as
regular sections to workaround the issues.

Fixes https://github.com/rui314/mold/issues/126
2021-11-04 22:42:33 +09:00
Rui Ueyama
06f377806b Fix formatting 2021-11-04 22:14:27 +09:00
Rui Ueyama
32f30c304e [ELF] Fix -thread-count option 2021-11-04 22:13:51 +09:00
Rui Ueyama
32cdec42cb [Mach-O] wip 2021-11-03 13:58:36 +09:00
Rui Ueyama
b1440067cc Fix indentation 2021-10-28 15:50:31 +09:00
Rui Ueyama
986516545a [ELF] Do not share OutputFile between ELF and Mach-O 2021-10-26 14:06:11 +09:00
Rui Ueyama
ffb8e03c97 [ELF] Make .rela.dyn and .rela.plt contiguous in an output file
glibc 2.22 or prior have a bug that the dynamic linker (ld-linux.so.2)
crashes on `dlopen` if .rela.dyn and .rela.plt are not contiguous in
the `dlopen`-ed file and RTLD_NOW is specified. That bug was fixed in
fa19d5c48a.

glibc 2.23 which includes the fix for the bug was released on 2016-02-18.
So, unless you are using glibc that is more than 5 years old, mold-
generated shared object files work fine with `dlopen`. But it is easy
to make the sections contiguous in file, so I'll commit this change as a
workaround for the bug.

Fixes https://github.com/rui314/mold/issues/120
2021-10-12 17:10:32 +09:00
Rui Ueyama
06c237838c [ELF] Fix --help message
Fixes https://github.com/rui314/mold/issues/119
2021-10-08 23:43:03 +09:00
Rui Ueyama
a8b2f521f7 [ELF] Create .rodata.cst and .rodata.str sections
Previously, mold created two or more ".rodata" sections if input files
contain regular .rodata sections as well as .rodata.str* or .rodata.cst*
sections. This is because .rodata.str* and .rodata.cst* contains mergeable
section contents (i.e. string constants and constant pools, respectively),
and they are handled in a special way.

In ELF, section names are not significant, so nothing is wrong with
creating multiple .rodata. However, valgrind unfortunately doesn't like
such executable.

With this change, mold keeps ".rodata.str" and ".rodata.cst" prefixes
to avoid creating multiple ".rodata" sections.

Fixes https://github.com/rui314/mold/issues/118
2021-10-07 13:55:46 +09:00
Rui Ueyama
d71c33b3e8 [ELF] Refactor 2021-10-07 12:40:55 +09:00
Rui Ueyama
46c20da35e [Mach-O] wip 2021-10-05 20:02:41 +09:00
Rui Ueyama
ca9a6d0843 Move code from elf/output-file.cc to output-file.h 2021-10-05 11:37:30 +09:00
Rui Ueyama
de1db98cde Split mold.h into multiple headers 2021-10-05 11:24:48 +09:00
Rui Ueyama
7b251e3d7b [ELF] Improve .init and .fini detection logic 2021-10-05 11:05:36 +09:00
Rui Ueyama
30b45d2263 [ELF] Rename Symbol<E>::intern -> intern 2021-10-05 08:31:28 +09:00
Rui Ueyama
3fc9c6c3ed [ELF] Rename section piece -> subsection 2021-10-05 08:22:38 +09:00
Rui Ueyama
97ff050396 Use s suffix 2021-10-04 15:41:49 +09:00
Rui Ueyama
e89af3ee94 Use sv suffix 2021-10-04 15:28:02 +09:00
Rui Ueyama
77069156cb [ELF] Rename OutputChunk Chunk 2021-10-04 10:16:24 +09:00
Rui Ueyama
928c39937a Refactor 2021-10-03 16:26:31 +09:00
Rui Ueyama
001cf042d9 Refactor 2021-10-03 16:01:59 +09:00
Rui Ueyama
fcd10254b7 Rename variables 2021-10-03 16:01:59 +09:00
Rui Ueyama
bc3f556055 Make get_file_type() to recognize Mach-O file types 2021-10-03 13:44:45 +09:00
Rui Ueyama
ebc8a68cb3 [ELF] Rename variables 2021-10-02 14:12:42 +09:00
Rui Ueyama
56b7c42fae Refactor 2021-10-01 00:35:42 +09:00
Rui Ueyama
52c7793326 Move archive-file.cc out of elf directory 2021-09-30 23:13:27 +09:00
Rui Ueyama
7c9205f68d Move memory-mapped-file.cc out of elf directory
So that we can use the class from mold/mach-o.
2021-09-30 23:13:22 +09:00
Rui Ueyama
ffd34678e0 [ELF] Fix "mold-wrapper.so is not found" error 2021-09-30 15:01:55 +09:00
Rui Ueyama
a2c9d0ad4d [ELF] Reduce the size of Subsection struct 2021-09-29 16:30:04 +09:00
Rui Ueyama
aa46df7735 [ELF] s/SectionFragment/Subsection/g 2021-09-29 16:18:41 +09:00
Rui Ueyama
5e3f526bc1 Refactor 2021-09-28 16:40:07 +09:00
Rui Ueyama
2844f1f573 [ELF] Refactor 2021-09-28 13:23:58 +09:00
Rui Ueyama
bc2bd0e26a [ELF] Refactor 2021-09-27 23:01:51 +09:00
Rui Ueyama
3d95b0e1d4 [ELF] Refactor 2021-09-27 21:44:39 +09:00
Rui Ueyama
c40b9aea5f [Mach-O] Generalize perf.cc so that we can use the feature in mold/mach-o 2021-09-27 18:14:56 +09:00
Rui Ueyama
541399911d [ELF] Refactor 2021-09-26 19:55:46 +09:00
Rui Ueyama
67990f775b [ELF] Refactor 2021-09-26 18:50:03 +09:00
Rui Ueyama
58f1fbadc3 [ELF] Refactor 2021-09-26 12:43:51 +09:00
Rui Ueyama
6536663130 [ELF] Fix comment 2021-09-26 12:43:39 +09:00
Rui Ueyama
774fc0f340 [ELF] Remove an extra space in an error message 2021-09-26 12:43:39 +09:00
Rui Ueyama
a5d02b18c7 Refactor 2021-09-25 21:47:09 +09:00
Rui Ueyama
e4861bb3e1 [ELF] Fix "recompile with -fPIC" error
mold used to emit a spurious "recompile with -fPIC" error when creating
a position-dependent executable. This is because we alwyas create
dynamic relocations for importe symbols. If the relocated place is
read-only, we can't apply a dynamic relocation, and we printed out the
error message.

This patch fixes the issue by creating copy relocations and PLTs for
such symbols.

Fixes https://github.com/rui314/mold/issues/116
2021-09-25 18:13:26 +09:00
Rui Ueyama
7232178513 [Mach-O] wip 2021-09-16 14:20:38 +09:00
Rui Ueyama
150565601b Move error handlers from mold::elf to mold 2021-09-15 15:32:42 +09:00
Rui Ueyama
6ab3ddaf8e Move cleanup handlers from mold::elf to mold 2021-09-15 15:25:14 +09:00
Rui Ueyama
7ffc3a4545 [Mach-O] Add a feature to dump an executable
This is not a linker feature, but in order to learn how Mach-O
executables are constructed, I'll implement a dump feature.
I'll remove the feature once I understand the structure of Mach-O
binaries.
2021-09-13 18:16:13 +09:00
Rui Ueyama
e051ad2a9a Do not define _GNU_SOURCE
We should not depend on glibc-specific features.
2021-09-13 17:29:49 +09:00
Rui Ueyama
08b61f29d2 [ELF] Add --require-defined 2021-09-12 18:34:42 +09:00
Rui Ueyama
1cb750a649 [ELF] Add -Bno-symbolic 2021-09-11 21:41:17 +09:00