[BOLT] Restrict creation of jump tables

Summary:
Heuristic that creates a jump table for every memory access,
including those we do not match against a pattern in an indirect jump,
is too permissive and has false positives. Guard this logic under
strict mode until we figure out a better strategy.

(cherry picked from FBD16192205)
This commit is contained in:
Rafael Auler
2019-07-10 15:41:34 -07:00
committed by Maksim Panchenko
parent 3cfc76cdbf
commit 8880969ced

View File

@@ -283,7 +283,12 @@ BinaryContext::handleAddressRef(uint64_t Address, BinaryFunction &BF,
}
const auto MemType = analyzeMemoryAt(Address, BF);
if (MemType == MemoryContentsType::POSSIBLE_PIC_JUMP_TABLE && IsPCRel) {
// FIXME: this is too permissive in creating jump tables. This is a random
// memory access we did not necessarily match against an indirect jump. Only
// do this for strict mode, for now. We should revisit this and come up with a
// better heuristic.
if (opts::StrictMode &&
MemType == MemoryContentsType::POSSIBLE_PIC_JUMP_TABLE && IsPCRel) {
JumpTable *JT;
const MCSymbol *Symbol;
std::tie(JT, Symbol) =