Skip to content

Fix crash on R_MIPS_HI16 relocs caused by bad cast #7144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions arch/mips/arch_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2727,10 +2727,6 @@ class MipsArchitecture: public Architecture

return registers;
}

MipsVersion GetMIPSVersion() {
return m_version;
}
};

class MipsO32CallingConvention: public CallingConvention
Expand Down Expand Up @@ -3412,8 +3408,11 @@ class MipsElfRelocationHandler: public RelocationHandler
uint32_t inst2 = *(uint32_t*)(cur->relocationDataCache);
Instruction instruction;
memset(&instruction, 0, sizeof(instruction));
MipsArchitecture& march = dynamic_cast<MipsArchitecture&>(*arch);
if (mips_decompose(&inst2, sizeof(uint32_t), &instruction, march.GetMIPSVersion(), cur->address, arch->GetEndianness(), DECOMPOSE_FLAGS_PSEUDO_OP))
auto version = arch->GetAddressSize() == 8 ? MIPS_64 : MIPS_32;
if (Architecture::GetByName("r5900l") == arch)
version = MIPS_R5900;
if (mips_decompose(&inst2, sizeof(uint32_t), &instruction,
version, cur->address, arch->GetEndianness(), DECOMPOSE_FLAGS_PSEUDO_OP))
break;

int32_t immediate = swap(inst2) & 0xffff;
Expand Down