Skip to content

Commit c2ea84a

Browse files
committed
[BOLT] Skip special handling on non virtual function pointer relocation in relative vtable
Besides virtual function pointers vtable could also contain other kinds of entries like the one for RTTI data that requires relocation too. We need to skip the special handling on the relocations for non virtual function pointers in relative vtable.
1 parent 6957699 commit c2ea84a

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,20 +2697,19 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
26972697
BD->nameStartsWith("_ZTCN"))) { // construction vtable
26982698
BinaryFunction *BF = BC->getBinaryFunctionContainingAddress(
26992699
SymbolAddress, /*CheckPastEnd*/ false, /*UseMaxSize*/ true);
2700-
if (!BF || BF->getAddress() != SymbolAddress) {
2701-
BC->errs()
2702-
<< "BOLT-ERROR: the virtual function table entry at offset 0x"
2703-
<< Twine::utohexstr(Rel.getOffset());
2704-
if (BF)
2705-
BC->errs() << " points to the middle of a function @ 0x"
2706-
<< Twine::utohexstr(BF->getAddress()) << "\n";
2707-
else
2708-
BC->errs() << " does not point to any function\n";
2709-
exit(1);
2700+
if (BF) {
2701+
if (BF->getAddress() != SymbolAddress) {
2702+
BC->errs()
2703+
<< "BOLT-ERROR: the virtual function table entry at offset 0x"
2704+
<< Twine::utohexstr(Rel.getOffset())
2705+
<< " points to the middle of a function @ 0x"
2706+
<< Twine::utohexstr(BF->getAddress()) << "\n";
2707+
exit(1);
2708+
}
2709+
BC->addRelocation(Rel.getOffset(), BF->getSymbol(), RType, Addend,
2710+
ExtractedValue);
2711+
return;
27102712
}
2711-
BC->addRelocation(Rel.getOffset(), BF->getSymbol(), RType, Addend,
2712-
ExtractedValue);
2713-
return;
27142713
}
27152714
}
27162715

0 commit comments

Comments
 (0)