diff --git a/VTIL-Architecture/routine/basic_block.cpp b/VTIL-Architecture/routine/basic_block.cpp index 2dc43df..48061ef 100644 --- a/VTIL-Architecture/routine/basic_block.cpp +++ b/VTIL-Architecture/routine/basic_block.cpp @@ -140,6 +140,8 @@ namespace vtil // basic_block::iterator basic_block::insert( const const_iterator& it_const, instruction&& ins ) { + fassert( ins.is_valid() ); + // Drop const qualifier of the iterator, since we are in a non-const // qualified member function, this qualifier is unnecessary. // diff --git a/VTIL-Architecture/symex/translation.cpp b/VTIL-Architecture/symex/translation.cpp index 8fcd124..471dfcf 100644 --- a/VTIL-Architecture/symex/translation.cpp +++ b/VTIL-Architecture/symex/translation.cpp @@ -114,8 +114,16 @@ namespace vtil } else { + operand base = cvt( var.mem().decay() ); + if ( base.is_immediate() ) + { + operand tmp2 = block->tmp( 64 ); + block->mov( tmp2, base ); + base = tmp2; + } + operand tmp = block->tmp( exp.size() ); - block->ldd( tmp, cvt( var.mem().decay() ), 0 ); + block->ldd( tmp, base, 0 ); return tmp; } } diff --git a/VTIL-Common/io/asserts.hpp b/VTIL-Common/io/asserts.hpp index 841dae6..e7f9019 100644 --- a/VTIL-Common/io/asserts.hpp +++ b/VTIL-Common/io/asserts.hpp @@ -41,14 +41,10 @@ namespace vtil::assert line_number, condition_str ); + logger::impl::noreturn_helper(); } }; -#ifdef _DEBUG - #define fassert__stringify(x) #x - #define fassert(x) vtil::assert::or_die( bool(x), __FILE__, __LINE__, fassert__stringify(x) ) - #define unreachable() vtil::logger::error( "Illegal control flow. %s:%d", __FILE__, __LINE__ ) -#else - #define fassert(...) - #define unreachable() vtil::logger::impl::noreturn_helper() -#endif \ No newline at end of file +#define fassert__stringify(x) #x +#define fassert(x) vtil::assert::or_die( bool(x), __FILE__, __LINE__, fassert__stringify(x) ) +#define unreachable() vtil::logger::error( "Illegal control flow. %s:%d", __FILE__, __LINE__ ) \ No newline at end of file diff --git a/VTIL-Common/io/logger.hpp b/VTIL-Common/io/logger.hpp index f5518f9..06c2944 100644 --- a/VTIL-Common/io/logger.hpp +++ b/VTIL-Common/io/logger.hpp @@ -255,10 +255,7 @@ namespace vtil::logger log( "\n%s\n", message.data() ); // Break the program. - // -#ifndef _DEBUG - exit( EXIT_FAILURE ); -#endif + // impl::noreturn_helper(); } }; \ No newline at end of file diff --git a/VTIL-Optimizer/passes/mov_propagation_pass.cpp b/VTIL-Optimizer/passes/mov_propagation_pass.cpp index 89fda2b..fa3b2b9 100644 --- a/VTIL-Optimizer/passes/mov_propagation_pass.cpp +++ b/VTIL-Optimizer/passes/mov_propagation_pass.cpp @@ -125,6 +125,11 @@ namespace vtil::optimizer // if ( res.is_constant() ) { + // If operand does not accept immediates, skip. + // + if ( type != operand_type::read_any ) + continue; + // Replace the operand with a constant. // operand_swap_buffer.emplace_back( &op, operand{ *res.get(), ( bitcnt_t ) op.size() * 8 } ); diff --git a/VTIL-Optimizer/passes/register_renaming_pass.cpp b/VTIL-Optimizer/passes/register_renaming_pass.cpp index e2c2a2d..18d40ed 100644 --- a/VTIL-Optimizer/passes/register_renaming_pass.cpp +++ b/VTIL-Optimizer/passes/register_renaming_pass.cpp @@ -175,6 +175,7 @@ namespace vtil::optimizer reg.flags = dst.reg().flags; reg.bit_offset += dst.reg().bit_offset - src.reg().bit_offset; } + fassert( ins.is_valid() ); } ); // Nop the origin instruction. diff --git a/VTIL-Optimizer/passes/symbolic_rewrite_pass.cpp b/VTIL-Optimizer/passes/symbolic_rewrite_pass.cpp index adcdaab..eadd67a 100644 --- a/VTIL-Optimizer/passes/symbolic_rewrite_pass.cpp +++ b/VTIL-Optimizer/passes/symbolic_rewrite_pass.cpp @@ -118,7 +118,7 @@ namespace vtil::optimizer // Buffer a mov instruction. // - instruction_buffer.push_back( { &ins::mov,{ k, op } } ); + instruction_buffer.push_back( { &ins::mov, { k, op } } ); } // For each memory state: @@ -145,12 +145,20 @@ namespace vtil::optimizer } else { + operand base = translator << k.base; + if ( base.is_immediate() ) + { + operand tmp = temporary_block.tmp( bitcnt_t( base.size() * 8 ) ); + instruction_buffer.push_back( { &ins::mov, { tmp, base } } ); + base = tmp; + } + // Buffer a str , 0, value. // instruction_buffer.push_back( { &ins::str, - { translator << k.base, make_imm( 0 ), translator << v.simplify( true ) } + { base, make_imm( 0 ), translator << v.simplify( true ) } } ); } }