Skip to content

Commit 14cb8c5

Browse files
authored
[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.
1 parent 1c04ebb commit 14cb8c5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

llvm/include/llvm/Support/Endian.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ struct packed_endian_specific_integral {
277277

278278
} // end namespace detail
279279

280+
using ulittle8_t =
281+
detail::packed_endian_specific_integral<uint8_t, llvm::endianness::little,
282+
unaligned>;
280283
using ulittle16_t =
281284
detail::packed_endian_specific_integral<uint16_t, llvm::endianness::little,
282285
unaligned>;

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,11 @@ void RuntimeDyldELF::resolveRISCVRelocation(const SectionEntry &Section,
13061306
Ref = Value + Addend;
13071307
break;
13081308
}
1309+
case ELF::R_RISCV_ADD8: {
1310+
auto Ref = support::ulittle8_t::ref(Section.getAddressWithOffset(Offset));
1311+
Ref = Ref + Value + Addend;
1312+
break;
1313+
}
13091314
case ELF::R_RISCV_ADD16: {
13101315
auto Ref = support::ulittle16_t::ref(Section.getAddressWithOffset(Offset));
13111316
Ref = Ref + Value + Addend;
@@ -1321,6 +1326,11 @@ void RuntimeDyldELF::resolveRISCVRelocation(const SectionEntry &Section,
13211326
Ref = Ref + Value + Addend;
13221327
break;
13231328
}
1329+
case ELF::R_RISCV_SUB8: {
1330+
auto Ref = support::ulittle8_t::ref(Section.getAddressWithOffset(Offset));
1331+
Ref = Ref - Value - Addend;
1332+
break;
1333+
}
13241334
case ELF::R_RISCV_SUB16: {
13251335
auto Ref = support::ulittle16_t::ref(Section.getAddressWithOffset(Offset));
13261336
Ref = Ref - Value - Addend;
@@ -1336,6 +1346,21 @@ void RuntimeDyldELF::resolveRISCVRelocation(const SectionEntry &Section,
13361346
Ref = Ref - Value - Addend;
13371347
break;
13381348
}
1349+
case ELF::R_RISCV_SET8: {
1350+
auto Ref = support::ulittle8_t::ref(Section.getAddressWithOffset(Offset));
1351+
Ref = Value + Addend;
1352+
break;
1353+
}
1354+
case ELF::R_RISCV_SET16: {
1355+
auto Ref = support::ulittle16_t::ref(Section.getAddressWithOffset(Offset));
1356+
Ref = Value + Addend;
1357+
break;
1358+
}
1359+
case ELF::R_RISCV_SET32: {
1360+
auto Ref = support::ulittle32_t::ref(Section.getAddressWithOffset(Offset));
1361+
Ref = Value + Addend;
1362+
break;
1363+
}
13391364
}
13401365
}
13411366

0 commit comments

Comments
 (0)