Add a test checking that all the "__asan_" interface functions are present in a binary built with -dead_strip.
Fix force_interface_symbols() so that none of the interface symbols is stripped.



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161582 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc
index 39d9ef1..786e312 100644
--- a/lib/asan/asan_rtl.cc
+++ b/lib/asan/asan_rtl.cc
@@ -228,6 +228,19 @@
     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 @@
 // ---------------------- 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;
diff --git a/lib/asan/output_tests/test_output.sh b/lib/asan/output_tests/test_output.sh
index 8dc93eb..fccdb0d 100755
--- a/lib/asan/output_tests/test_output.sh
+++ b/lib/asan/output_tests/test_output.sh
@@ -8,6 +8,7 @@
 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=""
 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