From 6c9d3326ec36dc73b2333dd5f84cbf2d75cfc5a2 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Tue, 7 May 2024 08:34:38 +0200 Subject: [PATCH] ldso: add support for R__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 --- repos/base/src/lib/ldso/include/relocation_generic.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/repos/base/src/lib/ldso/include/relocation_generic.h b/repos/base/src/lib/ldso/include/relocation_generic.h index 4ba6a707bf..f19cd4e840 100644 --- a/repos/base/src/lib/ldso/include/relocation_generic.h +++ b/repos/base/src/lib/ldso/include/relocation_generic.h @@ -16,6 +16,9 @@ #include +/* the R__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();