[llvm] 14cb8c5 - [lldb] add required for lldb RISCV relocations in MCJIT (#126266)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 14 05:15:36 PDT 2025
Author: dlav-sc
Date: 2025-04-14T15:15:33+03:00
New Revision: 14cb8c56b26784c684865053a6deb066f9a5e5b5
URL: https://github.com/llvm/llvm-project/commit/14cb8c56b26784c684865053a6deb066f9a5e5b5
DIFF: https://github.com/llvm/llvm-project/commit/14cb8c56b26784c684865053a6deb066f9a5e5b5.diff
LOG: [lldb] add required for lldb RISCV relocations in MCJIT (#126266)
After implementing CFI instructions in the function prologue, LLDB
testing for RISC-V started failing due to insufficient relocations
(e.g., R_RISCV_SET8, R_RISCV_SET16).
This patch adds support for the necessary RISC-V relocations in MCJIT.
Added:
Modified:
llvm/include/llvm/Support/Endian.h
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h
index f86ea8901ae46..574f9508420a0 100644
--- a/llvm/include/llvm/Support/Endian.h
+++ b/llvm/include/llvm/Support/Endian.h
@@ -277,6 +277,9 @@ struct packed_endian_specific_integral {
} // end namespace detail
+using ulittle8_t =
+ detail::packed_endian_specific_integral<uint8_t, llvm::endianness::little,
+ unaligned>;
using ulittle16_t =
detail::packed_endian_specific_integral<uint16_t, llvm::endianness::little,
unaligned>;
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index def117448ab6a..f032d5cb30f23 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -1306,6 +1306,11 @@ void RuntimeDyldELF::resolveRISCVRelocation(const SectionEntry &Section,
Ref = Value + Addend;
break;
}
+ case ELF::R_RISCV_ADD8: {
+ auto Ref = support::ulittle8_t::ref(Section.getAddressWithOffset(Offset));
+ Ref = Ref + Value + Addend;
+ break;
+ }
case ELF::R_RISCV_ADD16: {
auto Ref = support::ulittle16_t::ref(Section.getAddressWithOffset(Offset));
Ref = Ref + Value + Addend;
@@ -1321,6 +1326,11 @@ void RuntimeDyldELF::resolveRISCVRelocation(const SectionEntry &Section,
Ref = Ref + Value + Addend;
break;
}
+ case ELF::R_RISCV_SUB8: {
+ auto Ref = support::ulittle8_t::ref(Section.getAddressWithOffset(Offset));
+ Ref = Ref - Value - Addend;
+ break;
+ }
case ELF::R_RISCV_SUB16: {
auto Ref = support::ulittle16_t::ref(Section.getAddressWithOffset(Offset));
Ref = Ref - Value - Addend;
@@ -1336,6 +1346,21 @@ void RuntimeDyldELF::resolveRISCVRelocation(const SectionEntry &Section,
Ref = Ref - Value - Addend;
break;
}
+ case ELF::R_RISCV_SET8: {
+ auto Ref = support::ulittle8_t::ref(Section.getAddressWithOffset(Offset));
+ Ref = Value + Addend;
+ break;
+ }
+ case ELF::R_RISCV_SET16: {
+ auto Ref = support::ulittle16_t::ref(Section.getAddressWithOffset(Offset));
+ Ref = Value + Addend;
+ break;
+ }
+ case ELF::R_RISCV_SET32: {
+ auto Ref = support::ulittle32_t::ref(Section.getAddressWithOffset(Offset));
+ Ref = Value + Addend;
+ break;
+ }
}
}
More information about the llvm-commits
mailing list