Skip to content

Commit 52bec2b

Browse files
committed
Add an assert to ensure behavior consistency with ld.bfd.
1 parent 03645ef commit 52bec2b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lld/ELF/Arch/LoongArch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,10 @@ static void relaxCall36(Ctx &ctx, const InputSection &sec, size_t i,
850850
return;
851851

852852
const uint32_t nextInsn = read32le(sec.content().data() + r.offset + 4);
853+
// To ensure behavior consistency with ld.bfd, we add an assert here.
854+
// https://github.com/llvm/llvm-project/pull/123576#discussion_r1974854075
855+
assert(isJirl(nextInsn) &&
856+
"The second instruction related to R_LARCH_CALL36 must be JIRL");
853857
if (getD5(nextInsn) == R_RA) {
854858
// convert jirl to bl
855859
sec.relaxAux->relocTypes[i] = R_LARCH_B26;

0 commit comments

Comments
 (0)