mold does not have to be built with clang/clang++, so don't use
these compiler frontends.
mold also doesn't have be built with g++ (GNU C++ compiler).
We use `c++` command instead.
Fixes https://github.com/rui314/mold/issues/261
The .ctors section contains a list of pointers that have to be run
before `main`. It usually contains pointers to global constructors.
The .dtors are for global destructors.
The .init_array and .fini_array serve the same purpose as .ctors and
.dtors. The former sections are newer than the latter sections, and
most programs have already migrated to .{init,fini}_array.
.ctors/.dtors are very similar to .{init,fini}_array, but the order
in which pointers are executed is different. .ctors/.dtors are executed
from the end to the beginning, while .{init,fini}_array are executed
from the beginning to the end.
Previously, we converted .ctors/.dtors sections into .{init,fini}_array
sections. In order to do that, we not only merge .ctors/.dtors to
.{init,fini}_array but also reverse their section contents, so that
the initialization order remains the same.
However, there was a bug in that logic. We forgot to reverse the
locations of dynamic relocations for the converted sections.
So, .ctors/.dtors sections converted to .{init,fini}_array were executed
in a wrong order.
We have two choices to "fix" the issue: (1) reverse not only section
contents but also dynamic relocations, or (2) stop converting .ctors/.dtors.
In this patch, I chose (2).
Since LLVM lld doesn't convert .ctors/.dtors, it shouldn't cause an
issue for most programs.
Previously, mold crashes due to an invalid regex pattern exception
when `[...]` is given as a version script pattern.
Fixes https://github.com/rui314/mold/issues/258
This reverts commit 4d78510cb0.
If the SHF_MERGE bit is set, sh_entsize must have the size of the unit
for that section. In the previous commit, we changed the behavior of
mold so that it sets SHF_MERGE bits in the output file. However, we
didn't set sh_entsize. So, the resulting section is technically invalid.
We merge sections with different sh_entsize into a single output
section, so there's no easy way to "keep" the original value.
In this commit, we simply revert the previous change so that mold won't
set SHF_MERGE in the output file.
https://github.com/rui314/mold/issues/155
Previously, mold put all global symbols into .gnu.hash. Although I
believe it was not an error, it bloated the size of .gnu.hash because
.gnu.hash needs only exported symbols.
https://github.com/rui314/mold/issues/255
Let Makefile know how to locate openssl header files in a directory other than
the default directories by using pkg-config. If you don't have pkg-config, then
$(shell) returns empty.
Signed-off-by: Hiroshi Takekawa <sian.ht@gmail.com>
This is very hacky but highly practical, so I couldn't resist to not
implement this. We should support LTO natively in the future. In the
meantime, this feature should work as a poor-man's replacement.
Fixes https://github.com/rui314/mold/issues/242
Let Makefile know how to link libcrypto in a directory other than the default
directories by using pkg-config. If you don't have pkg-config, then $(shell)
returns empty.
Signed-off-by: Hiroshi Takekawa <sian.ht@gmail.com>
Looks like some CUDA object files contains FDEs whose relocation has
r_sym with value 0. Such FDEs are dead and should be ignored.
Unfortunately, there's no easy way to produce an object file containing
such relocation, so this change lacks a testcase.
Fixes https://github.com/rui314/mold/issues/235