diff options
| author | Brandon Miller <brandon@vector35.com> | 2024-12-02 11:18:21 -0500 |
|---|---|---|
| committer | Brandon Miller <brandon@vector35.com> | 2024-12-03 10:35:07 -0500 |
| commit | d14513b4abcd436082a768b73de9932fe67646e6 (patch) | |
| tree | 78179c67f83c66ad8e1c747e44120c26c8aa5afd /arch/mips/arch_mips.cpp | |
| parent | d21ae80e4062367ebde153c18c324fd370365fff (diff) | |
Multiple fixes for HI16/LO16 relocs for MIPS64
Some binaries consist of LO16 entires that are BEFORE associated HI16
entries. Also, prior to this commit we don't appear to be applying
HI16 relocations at all for MIPS64. mips_decompose was being called
with MIPS_32 and failing prior to fixing up the relocation
Diffstat (limited to 'arch/mips/arch_mips.cpp')
| -rw-r--r-- | arch/mips/arch_mips.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/mips/arch_mips.cpp b/arch/mips/arch_mips.cpp index 83f3177c..4079519a 100644 --- a/arch/mips/arch_mips.cpp +++ b/arch/mips/arch_mips.cpp @@ -3011,7 +3011,7 @@ public: uint32_t inst2 = *(uint32_t*)(cur->relocationDataCache); Instruction instruction; memset(&instruction, 0, sizeof(instruction)); - if (mips_decompose(&inst2, sizeof(uint32_t), &instruction, MIPS_32, cur->address, arch->GetEndianness(), DECOMPOSE_FLAGS_PSEUDO_OP)) + if (mips_decompose(&inst2, sizeof(uint32_t), &instruction, arch->GetAddressSize() == 8 ? MIPS_64 : MIPS_32, cur->address, arch->GetEndianness(), DECOMPOSE_FLAGS_PSEUDO_OP)) break; int32_t immediate = swap(inst2) & 0xffff; @@ -3115,8 +3115,9 @@ public: case R_MIPS_HI16: result[i].dataRelocation = false; result[i].pcRelative = false; - // MIPS_HI16 relocations can have multiple MIPS_LO16 relocations following them - for (size_t j = i + 1; j < result.size(); j++) + // MIPS_HI16 relocations usually come before multiple MIPS_LO16 relocations. But, this is not always + // the case. Some binaries have MIPS_HI16 relocations after an associated MIPS_LO16 relocation. + for (size_t j = 0; j < result.size(); j++) { if (result[j].nativeType == R_MIPS_LO16 && result[j].symbolIndex == result[i].symbolIndex) { @@ -3128,6 +3129,7 @@ public: break; } } + break; case R_MIPS_LO16: result[i].pcRelative = false; |
