@@ -1128,7 +1128,7 @@ bool ElfView::Init()
1128
1128
}
1129
1129
if (!relocationExists)
1130
1130
{
1131
- int relocType = m_arch-> GetAddressSize () == 4 ? 126 /* R_MIPS_COPY */ : 125 /* R_MIPS64_COPY */ ;
1131
+ int relocType = m_addressSize == 4 ? 126 /* R_MIPS_COPY */ : 125 /* R_MIPS64_COPY */ ;
1132
1132
relocs.push_back (ELFRelocEntry (gotEntry, i, relocType, 0 , 0 , false ));
1133
1133
}
1134
1134
if (entry.section != ELF_SHN_UNDEF)
@@ -1154,7 +1154,7 @@ bool ElfView::Init()
1154
1154
}
1155
1155
if (!relocationExists)
1156
1156
{
1157
- int relocType = m_arch-> GetAddressSize () == 4 ? 127 /* R_MIPS_JUMP_SLOT*/ : 125 /* R_MIPS64_COPY */ ;
1157
+ int relocType = m_addressSize == 4 ? 127 /* R_MIPS_JUMP_SLOT*/ : 125 /* R_MIPS64_COPY */ ;
1158
1158
relocs.push_back (ELFRelocEntry (gotEntry, i, relocType, 0 , 0 , false ));
1159
1159
}
1160
1160
if (entry.section != ELF_SHN_UNDEF)
@@ -1703,6 +1703,29 @@ bool ElfView::Init()
1703
1703
AddAutoSection (ss.str (), s.first , s.second , ReadOnlyDataSectionSemantics);
1704
1704
}
1705
1705
}
1706
+
1707
+ // Perform fixup processing on the local GOT entries if the view is relocatable.
1708
+ if (m_relocatable)
1709
+ {
1710
+ uint64_t lastLocalGotEntry = gotStart + (localMipsSyms - 1 ) * (m_elf32 ? 4 : 8 );
1711
+ for (auto gotEntry : m_gotEntryLocations)
1712
+ {
1713
+ if (gotEntry > lastLocalGotEntry)
1714
+ break ;
1715
+
1716
+ virtualReader.Seek (gotEntry);
1717
+ auto target = virtualReader.ReadPointer ();
1718
+ if (!target)
1719
+ continue ;
1720
+
1721
+ BNRelocationInfo relocInfo;
1722
+ memset (&relocInfo, 0 , sizeof (BNRelocationInfo));
1723
+ relocInfo.address = gotEntry;
1724
+ relocInfo.size = m_addressSize;
1725
+ relocInfo.nativeType = m_addressSize == 4 ? 127 /* R_MIPS_JUMP_SLOT*/ : 125 /* R_MIPS64_COPY */ ;
1726
+ DefineRelocation (m_arch, relocInfo, target + baseAddress, relocInfo.address );
1727
+ }
1728
+ }
1706
1729
}
1707
1730
1708
1731
// Sometimes ELF will specify Thumb entry points w/o the bottom bit set
@@ -2398,8 +2421,8 @@ bool ElfView::Init()
2398
2421
memset (&relocInfo, 0 , sizeof (BNRelocationInfo));
2399
2422
relocInfo.base = gotStart;
2400
2423
relocInfo.address = gotStart;
2401
- relocInfo.size = m_arch-> GetAddressSize () ;
2402
- relocInfo.nativeType = m_arch-> GetAddressSize () == 4 ? 2 /* R_MIPS_32 */ : 18 /* R_MIPS_64 */ ;
2424
+ relocInfo.size = m_addressSize ;
2425
+ relocInfo.nativeType = m_addressSize == 4 ? 2 /* R_MIPS_32 */ : 18 /* R_MIPS_64 */ ;
2403
2426
2404
2427
DefineRelocation (m_arch, relocInfo, symbol, relocInfo.address );
2405
2428
}
0 commit comments