ldso: add support for R_<arch>_NONE relocations

We discovered this relocation, which does nothing, in pre-compiled
libraries. It is easy to implement because it has the same
relocation-type number (0) for all supported ABIs.

Also adjust error message from "Unsupported PLT relocation" to
"Unsupported translation table address format" to not confuse the
relocation type with the translation table type.

Fixes #5209
This commit is contained in:
Sebastian Sumpf 2024-05-07 08:34:38 +02:00 committed by Christian Helmuth
parent a59f73f7d3
commit 6c9d3326ec

View File

@ -16,6 +16,9 @@
#include <linker.h>
/* the R_<arch>_NONE relocation is 0 for all supported architectures */
static constexpr int R_NONE = 0;
constexpr bool verbose_relocation = false;
static inline bool verbose_reloc(Linker::Dependency const &d)
@ -66,7 +69,9 @@ struct Linker::Reloc_plt_generic
Elf::Rel const *start, unsigned long size)
{
if (type != TYPE) {
error("LD: Unsupported PLT relocation type: ", (int)type);
error("LD: Unsupported translation table address format.",
" Expected ", TYPE, " got ", unsigned(type), ".",
" Type can only be DT_REL or DT_RELA not both.");
throw Incompatible();
}
@ -74,6 +79,9 @@ struct Linker::Reloc_plt_generic
REL const *end = rel + (size / sizeof(REL));
for (; rel < end; rel++) {
/* do nothing */
if (rel->type() == R_NONE) continue;
if (rel->type() != JMPSLOT) {
error("LD: Unsupported PLT relocation ", (int)rel->type());
throw Incompatible();