Skip to content
Snippets Groups Projects
Commit aea1136e authored by an7s's avatar an7s
Browse files

more tests, bug fixes

Former-commit-id: 9ae7d72249536af43379c2753617774fa41edf35
parent 33a2f4fc
No related branches found
No related tags found
No related merge requests found
...@@ -307,6 +307,8 @@ libtransform/tests/int16overflow.c -text ...@@ -307,6 +307,8 @@ libtransform/tests/int16overflow.c -text
libtransform/tests/int32overflow.c -text libtransform/tests/int32overflow.c -text
libtransform/tests/mul.c -text libtransform/tests/mul.c -text
libtransform/tests/sample_meds_int.annot -text libtransform/tests/sample_meds_int.annot -text
libtransform/tests/simpletest.c -text
libtransform/tests/unsigned_add.c -text
tests/coreutils/Makefile -text tests/coreutils/Makefile -text
tests/coreutils/bzip2_manual_tests.sh -text tests/coreutils/bzip2_manual_tests.sh -text
tests/coreutils/cat_manual_tests.sh -text tests/coreutils/cat_manual_tests.sh -text
......
...@@ -82,7 +82,17 @@ void IntegerTransform::handleOverflowCheck(Instruction_t *p_instruction, const M ...@@ -82,7 +82,17 @@ void IntegerTransform::handleOverflowCheck(Instruction_t *p_instruction, const M
addOverflowCheck(p_instruction, p_annotation); addOverflowCheck(p_instruction, p_annotation);
else if (p_annotation.getBitWidth() == 32) else if (p_annotation.getBitWidth() == 32)
{ {
addOverflowCheck(p_instruction, p_annotation); if (p_annotation.isUnderflow() || p_annotation.isOverflow())
{
if (p_annotation.isSigned() || p_annotation.isUnsigned())
{
addOverflowCheck(p_instruction, p_annotation);
}
else
{
cerr << "integertransform: unknown sign: do not instrument" << endl;
}
}
} }
} }
...@@ -216,7 +226,7 @@ void IntegerTransform::addOverflowCheck(Instruction_t *p_instruction, const MEDS ...@@ -216,7 +226,7 @@ void IntegerTransform::addOverflowCheck(Instruction_t *p_instruction, const MEDS
cerr << "void IntegerTransform::addOverflowCheck(): enter: " << p_instruction->GetComment() << endl; cerr << "void IntegerTransform::addOverflowCheck(): enter: " << p_instruction->GetComment() << endl;
assert(getVariantIR() && p_instruction); assert(getVariantIR() && p_instruction);
string detector(TRUNCATION_DETECTOR); string detector(INTEGER_OVERFLOW_DETECTOR);
string dataBits; string dataBits;
AddressID_t *jncond_a =new AddressID_t; AddressID_t *jncond_a =new AddressID_t;
...@@ -298,6 +308,12 @@ cerr << "void IntegerTransform::addOverflowCheck(): enter: " << p_instruction->G ...@@ -298,6 +308,12 @@ cerr << "void IntegerTransform::addOverflowCheck(): enter: " << p_instruction->G
detector = string(ADDSUB_OVERFLOW_DETECTOR_UNSIGNED_32); detector = string(ADDSUB_OVERFLOW_DETECTOR_UNSIGNED_32);
cerr << "integertransform: ADD/SUB OVERFLOW UNSIGNED 32" << endl; cerr << "integertransform: ADD/SUB OVERFLOW UNSIGNED 32" << endl;
}
else
{
cerr << "integertransform: ADD/SUB OVERFLOW UNKONWN 32: do nothing for now" << endl;
return;
} }
jncond_i->SetDataBits(dataBits); jncond_i->SetDataBits(dataBits);
......
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
unsigned int x; unsigned int x;
x = 0xFFFFFFFF; x = 0xFFFFFFFF;
x++; x++;
printf("Value of unsigned int (add): %u\n", x); printf("Value of unsigned int (add): %u\n", x);
unsigned int s; unsigned int s;
...@@ -14,9 +12,16 @@ int main(int argc, char **argv) ...@@ -14,9 +12,16 @@ int main(int argc, char **argv)
s--; s--;
printf("Value of unsigned int (sub): %u\n", s); printf("Value of unsigned int (sub): %u\n", s);
/*
overflow flag not set in this example!
unsigned int m1 = 5; unsigned int m1 = 5;
unsigned int m2 = 0xFFFFFFFF; unsigned int m2 = 0xFFFFFFFF;
m1 = m1 * m2; m1 = m1 * m2;
printf("Value of unsigned int (mul): %u\n", m1); printf("Value of unsigned int (mul): %u\n", m1);
*/
int m1 = 0x0FFFFFFF;
int m2 = 0x0FFFFFFF;
m1 = m1 * m2;
printf("Value of int (mul): %d\n", m1);
} }
...@@ -4,8 +4,8 @@ int main(int argc, char **argv) ...@@ -4,8 +4,8 @@ int main(int argc, char **argv)
unsigned a = (unsigned) atoi(argv[1]); unsigned a = (unsigned) atoi(argv[1]);
unsigned b = (unsigned) atoi(argv[2]); unsigned b = (unsigned) atoi(argv[2]);
unsigned d = a * b; unsigned d = a * b;
printf("%u * %u = %u\n", a, b, d);
printf("hello, how are you?"); printf("%u\n", d);
// printf("%u * %u = %u\n", a, b, d);
} }
// from smartfuzz paper
// ./simpletest.exe -2147483659 will trigger the Surprise
int main (int argc, char** argv)
{
int i = atol(argv[1]);
unsigned int j = 0;
if (i < 10)
{
j = i;
if ( j > 50)
{
printf("Surprise! \n");
return 1;
}
}
return 0;
}
int main(int argc, char **argv)
{
unsigned delta = 0xFFFFFFF0;
unsigned base = 0xFFFFFFF0;
unsigned result = delta;
if (delta > 0)
delta++;
result = base + delta;
printf("%u + %u = %u\n", base, delta, result);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment