@@ -1128,7 +1128,7 @@ bool ElfView::Init()
11281128 }
11291129 if (!relocationExists)
11301130 {
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 */ ;
11321132 relocs.push_back (ELFRelocEntry (gotEntry, i, relocType, 0 , 0 , false ));
11331133 }
11341134 if (entry.section != ELF_SHN_UNDEF)
@@ -1154,7 +1154,7 @@ bool ElfView::Init()
11541154 }
11551155 if (!relocationExists)
11561156 {
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 */ ;
11581158 relocs.push_back (ELFRelocEntry (gotEntry, i, relocType, 0 , 0 , false ));
11591159 }
11601160 if (entry.section != ELF_SHN_UNDEF)
@@ -1703,6 +1703,29 @@ bool ElfView::Init()
17031703 AddAutoSection (ss.str (), s.first , s.second , ReadOnlyDataSectionSemantics);
17041704 }
17051705 }
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+ }
17061729 }
17071730
17081731 // Sometimes ELF will specify Thumb entry points w/o the bottom bit set
@@ -2398,8 +2421,8 @@ bool ElfView::Init()
23982421 memset (&relocInfo, 0 , sizeof (BNRelocationInfo));
23992422 relocInfo.base = gotStart;
24002423 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 */ ;
24032426
24042427 DefineRelocation (m_arch, relocInfo, symbol, relocInfo.address );
24052428 }
0 commit comments