Add a test checking that all the "__asan_" interface functions are present in a binar...
authorAlexander Potapenko <glider@google.com>
Thu, 9 Aug 2012 16:05:17 +0000 (16:05 +0000)
committerAlexander Potapenko <glider@google.com>
Thu, 9 Aug 2012 16:05:17 +0000 (16:05 +0000)
Fix force_interface_symbols() so that none of the interface symbols is stripped.

llvm-svn: 161582

compiler-rt/lib/asan/asan_rtl.cc
compiler-rt/lib/asan/output_tests/test_output.sh

index 39d9ef1..786e312 100644 (file)
@@ -228,6 +228,19 @@ static NOINLINE void force_interface_symbols() {
     case 14: __asan_set_death_callback(0); break;
     case 15: __asan_set_error_report_callback(0); break;
     case 16: __asan_handle_no_return(); break;
+    case 17: __asan_address_is_poisoned(0); break;
+    case 18: __asan_get_allocated_size(0); break;
+    case 19: __asan_get_current_allocated_bytes(); break;
+    case 20: __asan_get_estimated_allocated_size(0); break;
+    case 21: __asan_get_free_bytes(); break;
+    case 22: __asan_get_heap_size(); break;
+    case 23: __asan_get_ownership(0); break;
+    case 24: __asan_get_unmapped_bytes(); break;
+    case 25: __asan_poison_memory_region(0, 0); break;
+    case 26: __asan_unpoison_memory_region(0, 0); break;
+    case 27: __asan_set_error_exit_code(0); break;
+    case 28: __asan_stack_free(0, 0, 0); break;
+    case 29: __asan_stack_malloc(0, 0); break;
   }
 }
 
@@ -241,7 +254,7 @@ static void asan_atexit() {
 // ---------------------- Interface ---------------- {{{1
 using namespace __asan;  // NOLINT
 
-int __asan_set_error_exit_code(int exit_code) {
+int NOINLINE __asan_set_error_exit_code(int exit_code) {
   int old = flags()->exitcode;
   flags()->exitcode = exit_code;
   return old;
index 8dc93eb..fccdb0d 100755 (executable)
@@ -8,6 +8,7 @@ CC=$2
 FILE_CHECK=$3
 CXXFLAGS="-mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -g"
 SYMBOLIZER=../scripts/asan_symbolize.py
+ASAN_INTERFACE_H=../asan_interface.h
 TMP_ASAN_REPORT=asan_report.tmp
 
 run_program() {
@@ -46,6 +47,18 @@ export ASAN_OPTIONS="strip_path_prefix='/'"
 export ASAN_OPTIONS=""
 rm ./a.out
 
+echo "Checking the presense of interface symbols in compiled file"
+$CC -g -faddress-sanitizer -dead_strip -O2 $C_TEST.c
+nm ./a.out | grep " T " | sed "s/.* T //" | grep "__asan_" | sed "s/___asan_/__asan_/" > symbols.txt
+cat $ASAN_INTERFACE_H | sed "s/\/\/.*//" | grep "__asan_.*("  | sed "s/.* __asan_/__asan_/;s/(.*//" > interface.txt
+for i in __asan_report_{load,store}{1,2,4,8,16}
+do
+  echo $i >> interface.txt
+done
+cat interface.txt | sort | uniq | diff symbols.txt - || exit 1
+rm ./a.out interface.txt symbols.txt
+
+
 # FIXME: some tests do not need to be ran for all the combinations of arch
 # and optimization mode.
 for t in  *.cc; do