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

Add libc tests

Former-commit-id: a7a01cb1b0b00a1a5f44c5827fad319fe04f295d
parent b76ebd32
No related branches found
No related tags found
No related merge requests found
......@@ -1158,6 +1158,7 @@ tools/selective_cfi/scfi_instr.hpp -text
tools/selective_cfi/tests/dude.c -text
tools/selective_cfi/tests/fib.c -text
tools/selective_cfi/tests/foo.c -text
tools/selective_cfi/tests/libc_driver.c -text
tools/selective_cfi/tests/libdude.c -text
tools/selective_cfi/tests/libfib.c -text
tools/selective_cfi/tests/libfib2.c -text
......@@ -1166,6 +1167,7 @@ tools/selective_cfi/tests/pow.c -text
tools/selective_cfi/tests/test_dude.sh -text
tools/selective_cfi/tests/test_fib.sh -text
tools/selective_cfi/tests/test_foo.sh -text
tools/selective_cfi/tests/test_libc.sh -text
tools/selective_cfi/tests/test_pow.sh -text
tools/selective_cfi/zest_cfi_runtime/SConscript -text
tools/selective_cfi/zest_cfi_runtime/SConscript32 -text
......
#include <stdio.h>
main()
{
printf("hello world\n");
}
......@@ -72,7 +72,7 @@ main()
test foo.exe libfoo.so.cfi # shared lib only
test foo.exe.cfi libfoo.so.cfi # both protected
report
clean
# clean
}
passes=0
......
#!/bin/bash
do_cfi()
{
$PS $1 $2 --backend zipr --step move_globals=on --step selective_cfi=on --step-option selective_cfi:--multimodule --step-option move_globals:--cfi --step-option fix_calls:--fix-all --step-option zipr:"--add-sections false"
if [ ! $? -eq 0 ]; then
echo "do_cfi(): failed to protect"
fi
}
do_coloring_cfi()
{
$PS $1 $2 --backend zipr --step move_globals=on --step selective_cfi=on --step-option selective_cfi:--multimodule --step-option move_globals:--cfi --step-option fix_calls:--fix-all --step-option selective_cfi:--color --step-option zipr:"--add-sections false"
if [ ! $? -eq 0 ]; then
echo "do_coloring_cfi(): failed to protect"
fi
}
get_correct()
{
cp libfoo.so.orig libfoo.so
./foo.exe > correct
}
test()
{
cp $2 libfoo.so
./$1 > out
cmp out correct
if [ $? = 1 ]; then
fails=$(expr $fails + 1 )
echo test failed
else
passes=$(expr $passes + 1 )
echo test passed.
fi
}
build()
{
gcc -o libc_driver.exe libc_driver.c -w
libcpath=$(ldd libc_driver.exe|grep libc.so.6|sed "s/.*=>//"|sed "s/(.*//")
echo libc=$libcpath
cp $libcpath libc.so.6.orig
}
protect()
{
do_cfi libc.so.6.orig libc-2.19.so.cfi
}
clean()
{
rm out
rm correct
rm -Rf foo.exe peasoup_exe* libfoo.so libfoo.so.orig libfoo.so.cfi foo.cfi foo.exe.cfi
}
report ()
{
total=$(expr $passes + $fails)
echo "Passes: $passes / $total"
echo "Fails : $fails / $total"
}
main()
{
build
protect
# get_correct
# report
# clean
}
passes=0
fails=0
main $*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment