Skip to content

Commit 3ad2555

Browse files
committed
Fix crash on R_MIPS_HI16 relocs caused by bad cast
1 parent c9f1802 commit 3ad2555

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

arch/mips/arch_mips.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,10 +2727,6 @@ class MipsArchitecture: public Architecture
27272727

27282728
return registers;
27292729
}
2730-
2731-
MipsVersion GetMIPSVersion() {
2732-
return m_version;
2733-
}
27342730
};
27352731

27362732
class MipsO32CallingConvention: public CallingConvention
@@ -3412,8 +3408,11 @@ class MipsElfRelocationHandler: public RelocationHandler
34123408
uint32_t inst2 = *(uint32_t*)(cur->relocationDataCache);
34133409
Instruction instruction;
34143410
memset(&instruction, 0, sizeof(instruction));
3415-
MipsArchitecture& march = dynamic_cast<MipsArchitecture&>(*arch);
3416-
if (mips_decompose(&inst2, sizeof(uint32_t), &instruction, march.GetMIPSVersion(), cur->address, arch->GetEndianness(), DECOMPOSE_FLAGS_PSEUDO_OP))
3411+
auto version = arch->GetAddressSize() == 8 ? MIPS_64 : MIPS_32;
3412+
if (Architecture::GetByName("r5900l") == arch)
3413+
version = MIPS_R5900;
3414+
if (mips_decompose(&inst2, sizeof(uint32_t), &instruction,
3415+
version, cur->address, arch->GetEndianness(), DECOMPOSE_FLAGS_PSEUDO_OP))
34173416
break;
34183417

34193418
int32_t immediate = swap(inst2) & 0xffff;

0 commit comments

Comments
 (0)