diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-08-30 17:05:48 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-08-30 17:05:48 +0200 |
commit | 3112ed67f92d65863d736fafb7d62b0428acb11a (patch) | |
tree | b4139d19c859e6bc925f32a7c925c53ea51f60d0 | |
parent | 60aa83189e70d22e1056ec5dd3657c0a6ac1bcd0 (diff) | |
download | compilertests-3112ed67f92d65863d736fafb7d62b0428acb11a.tar.gz compilertests-3112ed67f92d65863d736fafb7d62b0428acb11a.tar.bz2 |
emul: find illegal address references to opcodes (avoid endless loops)
-rw-r--r-- | ecomp-c/emul.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ecomp-c/emul.c b/ecomp-c/emul.c index c67ca49..e4234f9 100644 --- a/ecomp-c/emul.c +++ b/ecomp-c/emul.c @@ -304,6 +304,7 @@ int main( int argc, char *argv[] ) uint64_t address = CODE_START; bool terminate = false; + bool notfound = false; int iteration = 1; printf( "Single step execution:\n" ); @@ -316,7 +317,15 @@ int main( int argc, char *argv[] ) while( instrs_map[n+1] != address ) { n += 2; if( n >= 2 * N ) { - n = 0; + if( !notfound ) { + n = 0; + notfound = true; + } else { + fprintf( stderr, "ERROR: address %X not found in hashmap\n", (unsigned int)address ); + cs_close( &cs ); + uc_close( uc ); + exit( EXIT_FAILURE ); + } } } n = instrs_map[n]; |