1673dc3d4SNico Weber // Check the presence of interface symbols in compiled file.
2*fcfcc64cSEmily Shi // If you're changing this file, please also change
3*fcfcc64cSEmily Shi // ../Darwin/interface_symbols_darwin.cpp
4673dc3d4SNico Weber 
5c1352485SKirill Stoimenov // RUN: %clangxx -x c++-header -o - -E %p/../../../../lib/asan/asan_interface.inc  \
6c1352485SKirill Stoimenov // RUN:  | sed "s/INTERFACE_FUNCTION/\nINTERFACE_FUNCTION/g" >  %t.asan_interface.inc
7673dc3d4SNico Weber // RUN: %clangxx_asan -O2 %s -o %t.exe
8673dc3d4SNico Weber // RUN: nm -D %t.exe | grep " [TWw] "                                          \
9673dc3d4SNico Weber // RUN:  | grep -o "\(__asan_\|__ubsan_\|__sancov_\|__sanitizer_\)[^ ]*"       \
10673dc3d4SNico Weber // RUN:  | grep -v "__sanitizer_syscall"                                       \
11673dc3d4SNico Weber // RUN:  | grep -v "__sanitizer_weak_hook"                                     \
12673dc3d4SNico Weber // RUN:  | grep -v "__sancov_lowest_stack"                                     \
13673dc3d4SNico Weber // RUN:  | sed -e "s/__asan_version_mismatch_check_v[0-9]+/__asan_version_mismatch_check/" \
14673dc3d4SNico Weber // RUN:  > %t.exports
15673dc3d4SNico Weber //
16673dc3d4SNico Weber // RUN: grep -e "INTERFACE_\(WEAK_\)\?FUNCTION"                                \
17c1352485SKirill Stoimenov // RUN:  %t.asan_interface.inc                                                 \
18673dc3d4SNico Weber // RUN:  %p/../../../../lib/ubsan/ubsan_interface.inc                          \
19673dc3d4SNico Weber // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc    \
20673dc3d4SNico Weber // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface_posix.inc \
21673dc3d4SNico Weber // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc  \
22673dc3d4SNico Weber // RUN:  | grep -v "__sanitizer_weak_hook"                                     \
23673dc3d4SNico Weber // RUN:  | sed -e "s/.*(//" -e "s/).*//" > %t.imports
24673dc3d4SNico Weber //
25673dc3d4SNico Weber // RUN: cat %t.imports | sort | uniq > %t.imports-sorted
26673dc3d4SNico Weber // RUN: cat %t.exports | sort | uniq > %t.exports-sorted
27673dc3d4SNico Weber //
28673dc3d4SNico Weber // RUN: echo
29673dc3d4SNico Weber // RUN: echo "=== NOTE === If you see a mismatch below, please update sanitizer_interface.inc files."
30673dc3d4SNico Weber // RUN: diff %t.imports-sorted %t.exports-sorted
31673dc3d4SNico Weber //
32673dc3d4SNico Weber // FIXME: nm -D on powerpc somewhy shows ASan interface symbols residing
33673dc3d4SNico Weber // in "initialized data section".
34673dc3d4SNico Weber // REQUIRES: x86-target-arch,asan-static-runtime
35673dc3d4SNico Weber 
main()36673dc3d4SNico Weber int main() { return 0; }
37