Filter invalid jumps.

This commit is contained in:
Bartosz Taudul 2020-04-19 15:45:19 +02:00
parent ea00efa857
commit 421f0895b7

View File

@ -223,18 +223,26 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
}
if( jumpAddr >= symAddr && jumpAddr < symAddr + len )
{
const auto min = std::min( jumpAddr, op.address );
const auto max = std::max( jumpAddr, op.address );
auto it = m_jumpTable.find( jumpAddr );
if( it == m_jumpTable.end() )
auto fit = std::lower_bound( insn, insn+cnt, jumpAddr, []( const auto& l, const auto& r ) { return l.address < r; } );
if( fit != insn+cnt && fit->address == jumpAddr )
{
m_jumpTable.emplace( jumpAddr, JumpData { min, max, 0, { op.address } } );
const auto min = std::min( jumpAddr, op.address );
const auto max = std::max( jumpAddr, op.address );
auto it = m_jumpTable.find( jumpAddr );
if( it == m_jumpTable.end() )
{
m_jumpTable.emplace( jumpAddr, JumpData { min, max, 0, { op.address } } );
}
else
{
if( it->second.min > min ) it->second.min = min;
else if( it->second.max < max ) it->second.max = max;
it->second.source.emplace_back( op.address );
}
}
else
{
if( it->second.min > min ) it->second.min = min;
else if( it->second.max < max ) it->second.max = max;
it->second.source.emplace_back( op.address );
jumpAddr = 0;
}
}
else