[compiler-rt] r293682 - [sanitizer] Add list of symbols exported in sanitizers' interface.

Marcos Pividori via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 12:23:22 PST 2017


Author: mpividori
Date: Tue Jan 31 14:23:21 2017
New Revision: 293682

URL: http://llvm.org/viewvc/llvm-project?rev=293682&view=rev
Log:
[sanitizer] Add list of symbols exported in sanitizers' interface.

Add a new auxiliary file to each sanitizer: sanitizer_interface.inc, listing all
the functions exported, with the macros: INTERFACE_FUNCTION() and
INTERFACE_WEAK_FUNCTION().
So, when we need to define or repeat a procedure for each function in the
sanitizer's interface, we can define the macros and include that header.
In particular, these files are needed for Windows, in the nexts commits.
Also, this files could replace the existing files: weak_symbols.txt for Apple.
Instead of reading weak_symbols.txt to get the list of weak symbols, we could
read the file sanitizer_interface.inc and consider all the symbols included with
the macro INTERFACE_WEAK_FUNCTION(Name).

In this commit, I only include these files to the sanitizers that work on
Windows. We could do the same for the rest of the sanitizers when needed.

I updated tests for: Linux, Darwin and Windows. If a new function is exported
but is not present in the interface list, the tests
"interface_symbols_[darwin|windows|linux].c" fail.

Also, I remove the comments: "/* OPTIONAL */" which are not required any more,
because we use the macro: INTERFACE_WEAK_FUNCTION() for weak functions.

Differential Revision: https://reviews.llvm.org/D29148

Added:
    compiler-rt/trunk/lib/asan/asan_interface.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface_posix.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc
    compiler-rt/trunk/lib/ubsan/ubsan_interface.inc
    compiler-rt/trunk/test/asan/TestCases/Windows/interface_symbols_windows.c
Modified:
    compiler-rt/trunk/lib/asan/asan_interface_internal.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_interface.h
    compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
    compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
    compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc

Added: compiler-rt/trunk/lib/asan/asan_interface.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interface.inc?rev=293682&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interface.inc (added)
+++ compiler-rt/trunk/lib/asan/asan_interface.inc Tue Jan 31 14:23:21 2017
@@ -0,0 +1,167 @@
+//===-- asan_interface.inc ------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Asan interface list.
+//===----------------------------------------------------------------------===//
+INTERFACE_FUNCTION(__asan_addr_is_in_fake_stack)
+INTERFACE_FUNCTION(__asan_address_is_poisoned)
+INTERFACE_FUNCTION(__asan_after_dynamic_init)
+INTERFACE_FUNCTION(__asan_alloca_poison)
+INTERFACE_FUNCTION(__asan_allocas_unpoison)
+INTERFACE_FUNCTION(__asan_before_dynamic_init)
+INTERFACE_FUNCTION(__asan_describe_address)
+INTERFACE_FUNCTION(__asan_exp_load1)
+INTERFACE_FUNCTION(__asan_exp_load2)
+INTERFACE_FUNCTION(__asan_exp_load4)
+INTERFACE_FUNCTION(__asan_exp_load8)
+INTERFACE_FUNCTION(__asan_exp_load16)
+INTERFACE_FUNCTION(__asan_exp_loadN)
+INTERFACE_FUNCTION(__asan_exp_store1)
+INTERFACE_FUNCTION(__asan_exp_store2)
+INTERFACE_FUNCTION(__asan_exp_store4)
+INTERFACE_FUNCTION(__asan_exp_store8)
+INTERFACE_FUNCTION(__asan_exp_store16)
+INTERFACE_FUNCTION(__asan_exp_storeN)
+INTERFACE_FUNCTION(__asan_get_alloc_stack)
+INTERFACE_FUNCTION(__asan_get_current_fake_stack)
+INTERFACE_FUNCTION(__asan_get_free_stack)
+INTERFACE_FUNCTION(__asan_get_report_access_size)
+INTERFACE_FUNCTION(__asan_get_report_access_type)
+INTERFACE_FUNCTION(__asan_get_report_address)
+INTERFACE_FUNCTION(__asan_get_report_bp)
+INTERFACE_FUNCTION(__asan_get_report_description)
+INTERFACE_FUNCTION(__asan_get_report_pc)
+INTERFACE_FUNCTION(__asan_get_report_sp)
+INTERFACE_FUNCTION(__asan_get_shadow_mapping)
+INTERFACE_FUNCTION(__asan_handle_no_return)
+INTERFACE_FUNCTION(__asan_init)
+INTERFACE_FUNCTION(__asan_load_cxx_array_cookie)
+INTERFACE_FUNCTION(__asan_load1)
+INTERFACE_FUNCTION(__asan_load2)
+INTERFACE_FUNCTION(__asan_load4)
+INTERFACE_FUNCTION(__asan_load8)
+INTERFACE_FUNCTION(__asan_load16)
+INTERFACE_FUNCTION(__asan_loadN)
+INTERFACE_FUNCTION(__asan_load1_noabort)
+INTERFACE_FUNCTION(__asan_load2_noabort)
+INTERFACE_FUNCTION(__asan_load4_noabort)
+INTERFACE_FUNCTION(__asan_load8_noabort)
+INTERFACE_FUNCTION(__asan_load16_noabort)
+INTERFACE_FUNCTION(__asan_loadN_noabort)
+INTERFACE_FUNCTION(__asan_locate_address)
+INTERFACE_FUNCTION(__asan_memcpy)
+INTERFACE_FUNCTION(__asan_memmove)
+INTERFACE_FUNCTION(__asan_memset)
+INTERFACE_FUNCTION(__asan_poison_cxx_array_cookie)
+INTERFACE_FUNCTION(__asan_poison_intra_object_redzone)
+INTERFACE_FUNCTION(__asan_poison_memory_region)
+INTERFACE_FUNCTION(__asan_poison_stack_memory)
+INTERFACE_FUNCTION(__asan_print_accumulated_stats)
+INTERFACE_FUNCTION(__asan_region_is_poisoned)
+INTERFACE_FUNCTION(__asan_register_globals)
+INTERFACE_FUNCTION(__asan_register_image_globals)
+INTERFACE_FUNCTION(__asan_report_error)
+INTERFACE_FUNCTION(__asan_report_exp_load1)
+INTERFACE_FUNCTION(__asan_report_exp_load2)
+INTERFACE_FUNCTION(__asan_report_exp_load4)
+INTERFACE_FUNCTION(__asan_report_exp_load8)
+INTERFACE_FUNCTION(__asan_report_exp_load16)
+INTERFACE_FUNCTION(__asan_report_exp_load_n)
+INTERFACE_FUNCTION(__asan_report_exp_store1)
+INTERFACE_FUNCTION(__asan_report_exp_store2)
+INTERFACE_FUNCTION(__asan_report_exp_store4)
+INTERFACE_FUNCTION(__asan_report_exp_store8)
+INTERFACE_FUNCTION(__asan_report_exp_store16)
+INTERFACE_FUNCTION(__asan_report_exp_store_n)
+INTERFACE_FUNCTION(__asan_report_load1)
+INTERFACE_FUNCTION(__asan_report_load2)
+INTERFACE_FUNCTION(__asan_report_load4)
+INTERFACE_FUNCTION(__asan_report_load8)
+INTERFACE_FUNCTION(__asan_report_load16)
+INTERFACE_FUNCTION(__asan_report_load_n)
+INTERFACE_FUNCTION(__asan_report_load1_noabort)
+INTERFACE_FUNCTION(__asan_report_load2_noabort)
+INTERFACE_FUNCTION(__asan_report_load4_noabort)
+INTERFACE_FUNCTION(__asan_report_load8_noabort)
+INTERFACE_FUNCTION(__asan_report_load16_noabort)
+INTERFACE_FUNCTION(__asan_report_load_n_noabort)
+INTERFACE_FUNCTION(__asan_report_present)
+INTERFACE_FUNCTION(__asan_report_store1)
+INTERFACE_FUNCTION(__asan_report_store2)
+INTERFACE_FUNCTION(__asan_report_store4)
+INTERFACE_FUNCTION(__asan_report_store8)
+INTERFACE_FUNCTION(__asan_report_store16)
+INTERFACE_FUNCTION(__asan_report_store_n)
+INTERFACE_FUNCTION(__asan_report_store1_noabort)
+INTERFACE_FUNCTION(__asan_report_store2_noabort)
+INTERFACE_FUNCTION(__asan_report_store4_noabort)
+INTERFACE_FUNCTION(__asan_report_store8_noabort)
+INTERFACE_FUNCTION(__asan_report_store16_noabort)
+INTERFACE_FUNCTION(__asan_report_store_n_noabort)
+INTERFACE_FUNCTION(__asan_set_death_callback)
+INTERFACE_FUNCTION(__asan_set_error_report_callback)
+INTERFACE_FUNCTION(__asan_set_shadow_00)
+INTERFACE_FUNCTION(__asan_set_shadow_f1)
+INTERFACE_FUNCTION(__asan_set_shadow_f2)
+INTERFACE_FUNCTION(__asan_set_shadow_f3)
+INTERFACE_FUNCTION(__asan_set_shadow_f5)
+INTERFACE_FUNCTION(__asan_set_shadow_f8)
+INTERFACE_FUNCTION(__asan_stack_free_0)
+INTERFACE_FUNCTION(__asan_stack_free_1)
+INTERFACE_FUNCTION(__asan_stack_free_2)
+INTERFACE_FUNCTION(__asan_stack_free_3)
+INTERFACE_FUNCTION(__asan_stack_free_4)
+INTERFACE_FUNCTION(__asan_stack_free_5)
+INTERFACE_FUNCTION(__asan_stack_free_6)
+INTERFACE_FUNCTION(__asan_stack_free_7)
+INTERFACE_FUNCTION(__asan_stack_free_8)
+INTERFACE_FUNCTION(__asan_stack_free_9)
+INTERFACE_FUNCTION(__asan_stack_free_10)
+INTERFACE_FUNCTION(__asan_stack_malloc_0)
+INTERFACE_FUNCTION(__asan_stack_malloc_1)
+INTERFACE_FUNCTION(__asan_stack_malloc_2)
+INTERFACE_FUNCTION(__asan_stack_malloc_3)
+INTERFACE_FUNCTION(__asan_stack_malloc_4)
+INTERFACE_FUNCTION(__asan_stack_malloc_5)
+INTERFACE_FUNCTION(__asan_stack_malloc_6)
+INTERFACE_FUNCTION(__asan_stack_malloc_7)
+INTERFACE_FUNCTION(__asan_stack_malloc_8)
+INTERFACE_FUNCTION(__asan_stack_malloc_9)
+INTERFACE_FUNCTION(__asan_stack_malloc_10)
+INTERFACE_FUNCTION(__asan_store1)
+INTERFACE_FUNCTION(__asan_store2)
+INTERFACE_FUNCTION(__asan_store4)
+INTERFACE_FUNCTION(__asan_store8)
+INTERFACE_FUNCTION(__asan_store16)
+INTERFACE_FUNCTION(__asan_storeN)
+INTERFACE_FUNCTION(__asan_store1_noabort)
+INTERFACE_FUNCTION(__asan_store2_noabort)
+INTERFACE_FUNCTION(__asan_store4_noabort)
+INTERFACE_FUNCTION(__asan_store8_noabort)
+INTERFACE_FUNCTION(__asan_store16_noabort)
+INTERFACE_FUNCTION(__asan_storeN_noabort)
+INTERFACE_FUNCTION(__asan_unpoison_intra_object_redzone)
+INTERFACE_FUNCTION(__asan_unpoison_memory_region)
+INTERFACE_FUNCTION(__asan_unpoison_stack_memory)
+INTERFACE_FUNCTION(__asan_unregister_globals)
+INTERFACE_FUNCTION(__asan_unregister_image_globals)
+INTERFACE_FUNCTION(__asan_version_mismatch_check_v8)
+INTERFACE_FUNCTION(__sanitizer_finish_switch_fiber)
+INTERFACE_FUNCTION(__sanitizer_print_stack_trace)
+INTERFACE_FUNCTION(__sanitizer_ptr_cmp)
+INTERFACE_FUNCTION(__sanitizer_ptr_sub)
+INTERFACE_FUNCTION(__sanitizer_start_switch_fiber)
+INTERFACE_FUNCTION(__sanitizer_unaligned_load16)
+INTERFACE_FUNCTION(__sanitizer_unaligned_load32)
+INTERFACE_FUNCTION(__sanitizer_unaligned_load64)
+INTERFACE_FUNCTION(__sanitizer_unaligned_store16)
+INTERFACE_FUNCTION(__sanitizer_unaligned_store32)
+INTERFACE_FUNCTION(__sanitizer_unaligned_store64)
+INTERFACE_WEAK_FUNCTION(__asan_default_options)
+INTERFACE_WEAK_FUNCTION(__asan_default_suppressions)
+INTERFACE_WEAK_FUNCTION(__asan_on_error)

Modified: compiler-rt/trunk/lib/asan/asan_interface_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interface_internal.h?rev=293682&r1=293681&r2=293682&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interface_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interface_internal.h Tue Jan 31 14:23:21 2017
@@ -165,12 +165,12 @@ extern "C" {
   void __asan_set_error_report_callback(void (*callback)(const char*));
 
   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
-  /* OPTIONAL */ void __asan_on_error();
+  void __asan_on_error();
 
   SANITIZER_INTERFACE_ATTRIBUTE void __asan_print_accumulated_stats();
 
   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
-  /* OPTIONAL */ const char* __asan_default_options();
+  const char* __asan_default_options();
 
   SANITIZER_INTERFACE_ATTRIBUTE
   extern uptr __asan_shadow_memory_dynamic_address;
@@ -244,7 +244,7 @@ extern "C" {
   void __asan_allocas_unpoison(uptr top, uptr bottom);
 
   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
-  /* OPTIONAL */ const char* __asan_default_suppressions();
+  const char* __asan_default_suppressions();
 }  // extern "C"
 
 #endif  // ASAN_INTERFACE_INTERNAL_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_interface.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_interface.h?rev=293682&r1=293681&r2=293682&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_interface.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_interface.h Tue Jan 31 14:23:21 2017
@@ -34,9 +34,9 @@ SANITIZER_INTERFACE_ATTRIBUTE int __sani
     void (*free_hook)(const void *));
 
 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
-    /* OPTIONAL */ void __sanitizer_malloc_hook(void *ptr, uptr size);
+    void __sanitizer_malloc_hook(void *ptr, uptr size);
 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
-    /* OPTIONAL */ void __sanitizer_free_hook(void *ptr);
+    void __sanitizer_free_hook(void *ptr);
 
 
 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE

Added: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc?rev=293682&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc (added)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc Tue Jan 31 14:23:21 2017
@@ -0,0 +1,34 @@
+//===-- sanitizer_common_interface.inc ------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Sanitizer Common interface list.
+//===----------------------------------------------------------------------===//
+INTERFACE_FUNCTION(__sanitizer_annotate_contiguous_container)
+INTERFACE_FUNCTION(__sanitizer_contiguous_container_find_bad_address)
+INTERFACE_FUNCTION(__sanitizer_set_death_callback)
+INTERFACE_FUNCTION(__sanitizer_set_report_path)
+INTERFACE_FUNCTION(__sanitizer_set_report_fd)
+INTERFACE_FUNCTION(__sanitizer_verify_contiguous_container)
+INTERFACE_WEAK_FUNCTION(__sanitizer_report_error_summary)
+INTERFACE_WEAK_FUNCTION(__sanitizer_sandbox_on_notify)
+// Stacktrace interface.
+INTERFACE_FUNCTION(__sanitizer_get_module_and_offset_for_pc)
+INTERFACE_FUNCTION(__sanitizer_symbolize_global)
+INTERFACE_FUNCTION(__sanitizer_symbolize_pc)
+// Allocator interface.
+INTERFACE_FUNCTION(__sanitizer_get_allocated_size)
+INTERFACE_FUNCTION(__sanitizer_get_current_allocated_bytes)
+INTERFACE_FUNCTION(__sanitizer_get_estimated_allocated_size)
+INTERFACE_FUNCTION(__sanitizer_get_free_bytes)
+INTERFACE_FUNCTION(__sanitizer_get_heap_size)
+INTERFACE_FUNCTION(__sanitizer_get_ownership)
+INTERFACE_FUNCTION(__sanitizer_get_unmapped_bytes)
+INTERFACE_FUNCTION(__sanitizer_install_malloc_and_free_hooks)
+INTERFACE_WEAK_FUNCTION(__sanitizer_free_hook)
+INTERFACE_WEAK_FUNCTION(__sanitizer_malloc_hook)
+INTERFACE_WEAK_FUNCTION(__sanitizer_print_memory_profile)

Added: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface_posix.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface_posix.inc?rev=293682&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface_posix.inc (added)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface_posix.inc Tue Jan 31 14:23:21 2017
@@ -0,0 +1,14 @@
+//===-- sanitizer_common_interface_posix.inc ------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Sanitizer Common interface list only available for Posix systems.
+//===----------------------------------------------------------------------===//
+INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_code)
+INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_data)
+INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_demangle)
+INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_flush)

Added: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc?rev=293682&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc (added)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc Tue Jan 31 14:23:21 2017
@@ -0,0 +1,40 @@
+//===-- sanitizer_coverage_interface.inc ----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Sanitizer Coverage interface list.
+//===----------------------------------------------------------------------===//
+INTERFACE_FUNCTION(__sanitizer_cov)
+INTERFACE_FUNCTION(__sanitizer_cov_dump)
+INTERFACE_FUNCTION(__sanitizer_cov_indir_call16)
+INTERFACE_FUNCTION(__sanitizer_cov_init)
+INTERFACE_FUNCTION(__sanitizer_cov_module_init)
+INTERFACE_FUNCTION(__sanitizer_cov_trace_basic_block)
+INTERFACE_FUNCTION(__sanitizer_cov_trace_func_enter)
+INTERFACE_FUNCTION(__sanitizer_cov_with_check)
+INTERFACE_FUNCTION(__sanitizer_dump_coverage)
+INTERFACE_FUNCTION(__sanitizer_dump_trace_pc_guard_coverage)
+INTERFACE_FUNCTION(__sanitizer_get_coverage_guards)
+INTERFACE_FUNCTION(__sanitizer_get_number_of_counters)
+INTERFACE_FUNCTION(__sanitizer_get_total_unique_caller_callee_pairs)
+INTERFACE_FUNCTION(__sanitizer_get_total_unique_coverage)
+INTERFACE_FUNCTION(__sanitizer_maybe_open_cov_file)
+INTERFACE_FUNCTION(__sanitizer_reset_coverage)
+INTERFACE_FUNCTION(__sanitizer_update_counter_bitset_and_clear_counters)
+INTERFACE_WEAK_FUNCTION(__sancov_default_options)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_cmp)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_cmp1)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_cmp2)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_cmp4)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_cmp8)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_div4)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_div8)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_gep)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_pc_guard)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_pc_guard_init)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_pc_indir)
+INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_switch)

Added: compiler-rt/trunk/lib/ubsan/ubsan_interface.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_interface.inc?rev=293682&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_interface.inc (added)
+++ compiler-rt/trunk/lib/ubsan/ubsan_interface.inc Tue Jan 31 14:23:21 2017
@@ -0,0 +1,43 @@
+//===-- ubsan_interface.inc -----------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Ubsan interface list.
+//===----------------------------------------------------------------------===//
+INTERFACE_FUNCTION(__ubsan_handle_add_overflow)
+INTERFACE_FUNCTION(__ubsan_handle_add_overflow_abort)
+INTERFACE_FUNCTION(__ubsan_handle_builtin_unreachable)
+INTERFACE_FUNCTION(__ubsan_handle_cfi_check_fail)
+INTERFACE_FUNCTION(__ubsan_handle_cfi_check_fail_abort)
+INTERFACE_FUNCTION(__ubsan_handle_divrem_overflow)
+INTERFACE_FUNCTION(__ubsan_handle_divrem_overflow_abort)
+INTERFACE_FUNCTION(__ubsan_handle_float_cast_overflow)
+INTERFACE_FUNCTION(__ubsan_handle_float_cast_overflow_abort)
+INTERFACE_FUNCTION(__ubsan_handle_function_type_mismatch)
+INTERFACE_FUNCTION(__ubsan_handle_function_type_mismatch_abort)
+INTERFACE_FUNCTION(__ubsan_handle_load_invalid_value)
+INTERFACE_FUNCTION(__ubsan_handle_load_invalid_value_abort)
+INTERFACE_FUNCTION(__ubsan_handle_missing_return)
+INTERFACE_FUNCTION(__ubsan_handle_mul_overflow)
+INTERFACE_FUNCTION(__ubsan_handle_mul_overflow_abort)
+INTERFACE_FUNCTION(__ubsan_handle_negate_overflow)
+INTERFACE_FUNCTION(__ubsan_handle_negate_overflow_abort)
+INTERFACE_FUNCTION(__ubsan_handle_nonnull_arg)
+INTERFACE_FUNCTION(__ubsan_handle_nonnull_arg_abort)
+INTERFACE_FUNCTION(__ubsan_handle_nonnull_return)
+INTERFACE_FUNCTION(__ubsan_handle_nonnull_return_abort)
+INTERFACE_FUNCTION(__ubsan_handle_out_of_bounds)
+INTERFACE_FUNCTION(__ubsan_handle_out_of_bounds_abort)
+INTERFACE_FUNCTION(__ubsan_handle_shift_out_of_bounds)
+INTERFACE_FUNCTION(__ubsan_handle_shift_out_of_bounds_abort)
+INTERFACE_FUNCTION(__ubsan_handle_sub_overflow)
+INTERFACE_FUNCTION(__ubsan_handle_sub_overflow_abort)
+INTERFACE_FUNCTION(__ubsan_handle_type_mismatch_v1)
+INTERFACE_FUNCTION(__ubsan_handle_type_mismatch_v1_abort)
+INTERFACE_FUNCTION(__ubsan_handle_vla_bound_not_positive)
+INTERFACE_FUNCTION(__ubsan_handle_vla_bound_not_positive_abort)
+INTERFACE_WEAK_FUNCTION(__ubsan_default_options)

Modified: compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c?rev=293682&r1=293681&r2=293682&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c Tue Jan 31 14:23:21 2017
@@ -3,63 +3,27 @@
 // ../Linux/interface_symbols.c
 
 // RUN: %clang_asan -dead_strip -O2 %s -o %t.exe
-// RUN: rm -f %t.symbols %t.interface
-
+//
 // RUN: nm -g `%clang_asan %s -fsanitize=address -### 2>&1 | grep "libclang_rt.asan_osx_dynamic.dylib" | sed -e 's/.*"\(.*libclang_rt.asan_osx_dynamic.dylib\)".*/\1/'` \
-// RUN:   | grep " T " | sed "s/.* T //" \
-// RUN:   | grep "__asan_" | sed "s/___asan_/__asan_/" \
-// RUN:   | sed -E "s/__asan_version_mismatch_check_v[0-9]+/__asan_version_mismatch_check/" \
-// RUN:   | grep -v "__asan_default_options" \
-// RUN:   | grep -v "__asan_default_suppressions" \
-// RUN:   | grep -v "__asan_on_error" > %t.symbols
-
-// RUN: cat %p/../../../../lib/asan/asan_interface_internal.h \
-// RUN:    | sed "s/\/\/.*//" | sed "s/typedef.*//" \
-// RUN:    | grep -v "OPTIONAL" \
-// RUN:    | grep "__asan_.*(" | sed "s/.* __asan_/__asan_/;s/(.*//" \
-// RUN:    > %t.interface
-// RUN: echo __asan_report_load1 >> %t.interface
-// RUN: echo __asan_report_load2 >> %t.interface
-// RUN: echo __asan_report_load4 >> %t.interface
-// RUN: echo __asan_report_load8 >> %t.interface
-// RUN: echo __asan_report_load16 >> %t.interface
-// RUN: echo __asan_report_store1 >> %t.interface
-// RUN: echo __asan_report_store2 >> %t.interface
-// RUN: echo __asan_report_store4 >> %t.interface
-// RUN: echo __asan_report_store8 >> %t.interface
-// RUN: echo __asan_report_store16 >> %t.interface
-// RUN: echo __asan_report_load_n >> %t.interface
-// RUN: echo __asan_report_store_n >> %t.interface
-// RUN: echo __asan_report_load1_noabort >> %t.interface
-// RUN: echo __asan_report_load2_noabort >> %t.interface
-// RUN: echo __asan_report_load4_noabort >> %t.interface
-// RUN: echo __asan_report_load8_noabort >> %t.interface
-// RUN: echo __asan_report_load16_noabort >> %t.interface
-// RUN: echo __asan_report_store1_noabort >> %t.interface
-// RUN: echo __asan_report_store2_noabort >> %t.interface
-// RUN: echo __asan_report_store4_noabort >> %t.interface
-// RUN: echo __asan_report_store8_noabort >> %t.interface
-// RUN: echo __asan_report_store16_noabort >> %t.interface
-// RUN: echo __asan_report_load_n_noabort >> %t.interface
-// RUN: echo __asan_report_store_n_noabort >> %t.interface
-// RUN: echo __asan_report_exp_load1 >> %t.interface
-// RUN: echo __asan_report_exp_load2 >> %t.interface
-// RUN: echo __asan_report_exp_load4 >> %t.interface
-// RUN: echo __asan_report_exp_load8 >> %t.interface
-// RUN: echo __asan_report_exp_load16 >> %t.interface
-// RUN: echo __asan_report_exp_store1 >> %t.interface
-// RUN: echo __asan_report_exp_store2 >> %t.interface
-// RUN: echo __asan_report_exp_store4 >> %t.interface
-// RUN: echo __asan_report_exp_store8 >> %t.interface
-// RUN: echo __asan_report_exp_store16 >> %t.interface
-// RUN: echo __asan_report_exp_load_n >> %t.interface
-// RUN: echo __asan_report_exp_store_n >> %t.interface
-// RUN: echo __asan_get_current_fake_stack >> %t.interface
-// RUN: echo __asan_addr_is_in_fake_stack >> %t.interface
-
-// RUN: for i in `jot - 0 10`; do echo __asan_stack_malloc_$i >> %t.interface; done
-// RUN: for i in `jot - 0 10`; do echo __asan_stack_free_$i >> %t.interface; done
-
-// RUN: cat %t.interface | sort -u | diff %t.symbols -
+// RUN:  | grep -o "\(__asan_\|__ubsan_\|__sancov_\|__sanitizer_\)[^ ]*"       \
+// RUN:  | grep -v "__sanitizer_syscall"                                       \
+// RUN:  | grep -v "__sanitizer_weak_hook"                                     \
+// RUN:  | sed -e "s/__asan_version_mismatch_check_v[0-9]+/__asan_version_mismatch_check/" \
+// RUN:  > %t.exports
+//
+// RUN: grep -e "INTERFACE_\(WEAK_\)\?FUNCTION"                                \
+// RUN:  %p/../../../../lib/asan/asan_interface.inc                            \
+// RUN:  %p/../../../../lib/ubsan/ubsan_interface.inc                          \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc    \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface_posix.inc \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc  \
+// RUN:  | sed -e "s/.*(//" -e "s/).*//" > %t.imports
+//
+// RUN: cat %t.imports | sort | uniq > %t.imports-sorted
+// RUN: cat %t.exports | sort | uniq > %t.exports-sorted
+//
+// RUN: echo
+// RUN: echo "=== NOTE === If you see a mismatch below, please update sanitizer_interface.inc files."
+// RUN: diff %t.imports-sorted %t.exports-sorted
 
 int main() { return 0; }

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c?rev=293682&r1=293681&r2=293682&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c Tue Jan 31 14:23:21 2017
@@ -1,60 +1,28 @@
 // Check the presence of interface symbols in compiled file.
 
 // RUN: %clang_asan -O2 %s -o %t.exe
-// RUN: nm -D %t.exe | grep " T " | sed "s/.* T //" \
-// RUN:    | grep "__asan_" | sed "s/___asan_/__asan_/" \
-// RUN:    | sed -E "s/__asan_version_mismatch_check_v[0-9]+/__asan_version_mismatch_check/" \
-// RUN:    | grep -v "__asan_default_options" \
-// RUN:    | grep -v "__asan_default_suppressions" \
-// RUN:    | grep -v "__asan_stack_" \
-// RUN:    | grep -v "__asan_on_error" > %t.symbols
-// RUN: cat %p/../../../../lib/asan/asan_interface_internal.h \
-// RUN:    | sed "s/\/\/.*//" | sed "s/typedef.*//" \
-// RUN:    | grep -v "OPTIONAL" \
-// RUN:    | grep "__asan_.*(" | sed "s/.* __asan_/__asan_/;s/(.*//" \
-// RUN:    > %t.interface
-// RUN: echo __asan_report_load1 >> %t.interface
-// RUN: echo __asan_report_load2 >> %t.interface
-// RUN: echo __asan_report_load4 >> %t.interface
-// RUN: echo __asan_report_load8 >> %t.interface
-// RUN: echo __asan_report_load16 >> %t.interface
-// RUN: echo __asan_report_store1 >> %t.interface
-// RUN: echo __asan_report_store2 >> %t.interface
-// RUN: echo __asan_report_store4 >> %t.interface
-// RUN: echo __asan_report_store8 >> %t.interface
-// RUN: echo __asan_report_store16 >> %t.interface
-// RUN: echo __asan_report_load_n >> %t.interface
-// RUN: echo __asan_report_store_n >> %t.interface
-// RUN: echo __asan_report_load1_noabort >> %t.interface
-// RUN: echo __asan_report_load2_noabort >> %t.interface
-// RUN: echo __asan_report_load4_noabort >> %t.interface
-// RUN: echo __asan_report_load8_noabort >> %t.interface
-// RUN: echo __asan_report_load16_noabort >> %t.interface
-// RUN: echo __asan_report_store1_noabort >> %t.interface
-// RUN: echo __asan_report_store2_noabort >> %t.interface
-// RUN: echo __asan_report_store4_noabort >> %t.interface
-// RUN: echo __asan_report_store8_noabort >> %t.interface
-// RUN: echo __asan_report_store16_noabort >> %t.interface
-// RUN: echo __asan_report_load_n_noabort >> %t.interface
-// RUN: echo __asan_report_store_n_noabort >> %t.interface
-// RUN: echo __asan_report_exp_load1 >> %t.interface
-// RUN: echo __asan_report_exp_load2 >> %t.interface
-// RUN: echo __asan_report_exp_load4 >> %t.interface
-// RUN: echo __asan_report_exp_load8 >> %t.interface
-// RUN: echo __asan_report_exp_load16 >> %t.interface
-// RUN: echo __asan_report_exp_store1 >> %t.interface
-// RUN: echo __asan_report_exp_store2 >> %t.interface
-// RUN: echo __asan_report_exp_store4 >> %t.interface
-// RUN: echo __asan_report_exp_store8 >> %t.interface
-// RUN: echo __asan_report_exp_store16 >> %t.interface
-// RUN: echo __asan_report_exp_load_n >> %t.interface
-// RUN: echo __asan_report_exp_store_n >> %t.interface
-// RUN: echo __asan_get_current_fake_stack >> %t.interface
-// RUN: echo __asan_addr_is_in_fake_stack >> %t.interface
-// RUN: echo __asan_alloca_poison >> %t.interface
-// RUN: echo __asan_allocas_unpoison >> %t.interface
-// RUN: cat %t.interface | sort -u | diff %t.symbols -
-
+// RUN: nm -D %t.exe | grep " [TWw] "                                          \
+// RUN:  | grep -o "\(__asan_\|__ubsan_\|__sancov_\|__sanitizer_\)[^ ]*"       \
+// RUN:  | grep -v "__sanitizer_syscall"                                       \
+// RUN:  | grep -v "__sanitizer_weak_hook"                                     \
+// RUN:  | sed -e "s/__asan_version_mismatch_check_v[0-9]+/__asan_version_mismatch_check/" \
+// RUN:  > %t.exports
+//
+// RUN: grep -e "INTERFACE_\(WEAK_\)\?FUNCTION"                                \
+// RUN:  %p/../../../../lib/asan/asan_interface.inc                            \
+// RUN:  %p/../../../../lib/ubsan/ubsan_interface.inc                          \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc    \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface_posix.inc \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc  \
+// RUN:  | sed -e "s/.*(//" -e "s/).*//" > %t.imports
+//
+// RUN: cat %t.imports | sort | uniq > %t.imports-sorted
+// RUN: cat %t.exports | sort | uniq > %t.exports-sorted
+//
+// RUN: echo
+// RUN: echo "=== NOTE === If you see a mismatch below, please update sanitizer_interface.inc files."
+// RUN: diff %t.imports-sorted %t.exports-sorted
+//
 // FIXME: nm -D on powerpc somewhy shows ASan interface symbols residing
 // in "initialized data section".
 // REQUIRES: x86-target-arch,asan-static-runtime

Modified: compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc?rev=293682&r1=293681&r2=293682&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_host.cc Tue Jan 31 14:23:21 2017
@@ -7,18 +7,23 @@
 // Get the list of ASan wrappers exported by the main module RTL:
 // note: The mangling decoration (i.e. @4 )is removed because calling convention
 //       differ from 32-bit and 64-bit.
-// RUN: dumpbin /EXPORTS %t | grep -o "__asan_wrap[^ ]*" | sed -e s/@.*// > %t.exported_wrappers1
-// FIXME: we should really check the other __asan exports too.
-// RUN: dumpbin /EXPORTS %t | grep -o "__sanitizer_[^ ]*" | sed -e s/@.*// > %t.exported_wrappers2
+// RUN: dumpbin /EXPORTS %t | grep -o "__asan_wrap[^ ]*" | sed -e s/@.*// > %t.exports1
+//
+// The exception handlers differ in 32-bit and 64-bit, so we ignore them:
+// RUN: grep '[E]XPORT:' %s | sed -e 's/.*[E]XPORT: //' > %t.exports2
+// EXPORT: __asan_wrap__except_handler3
+// EXPORT: __asan_wrap__except_handler4
+// EXPORT: __asan_wrap___C_specific_handler
 //
 // Get the list of ASan wrappers imported by the DLL RTL:
 // [BEWARE: be really careful with the sed commands, as this test can be run
 //  from different environemnts with different shells and seds]
-// RUN: grep INTERCEPT_LIBRARY_FUNCTION %p/../../../../lib/asan/asan_win_dll_thunk.cc | grep -v define | sed -e s/.*(/__asan_wrap_/ | sed -e s/).*// > %t.dll_imports1
-// RUN: grep "^INTERFACE_FUNCTION.*sanitizer" %p/../../../../lib/asan/asan_win_dll_thunk.cc | grep -v define | sed -e s/.*(// | sed -e s/).*// > %t.dll_imports2
+// RUN: grep INTERCEPT_LIBRARY_FUNCTION %p/../../../../lib/asan/asan_win_dll_thunk.cc \
+// RUN:  | grep -v define | sed -e s/.*(/__asan_wrap_/ -e s/).*//              \
+// RUN:  > %t.imports1
 //
 // Add functions interecepted in asan_malloc.win.cc and asan_win.cc.
-// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.dll_imports3
+// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.imports2
 // IMPORT: __asan_wrap_HeapAlloc
 // IMPORT: __asan_wrap_HeapFree
 // IMPORT: __asan_wrap_HeapReAlloc
@@ -27,21 +32,14 @@
 // IMPORT: __asan_wrap_RaiseException
 // IMPORT: __asan_wrap_RtlRaiseException
 //
-// The exception handlers differ in 32-bit and 64-bit, so we ignore them:
-// RUN: grep '[E]XPORT:' %s | sed -e 's/.*[E]XPORT: //' > %t.exported_wrappers3
-// EXPORT: __asan_wrap__except_handler3
-// EXPORT: __asan_wrap__except_handler4
-// EXPORT: __asan_wrap___C_specific_handler
-//
-// RUN: cat %t.dll_imports1 %t.dll_imports2 %t.dll_imports3 | sort | uniq > %t.dll_imports-sorted
-// RUN: cat %t.exported_wrappers1 %t.exported_wrappers2 %t.exported_wrappers3 | sort | uniq > %t.exported_wrappers-sorted
+// RUN: cat %t.imports1 %t.imports2 | sort | uniq > %t.imports-sorted
+// RUN: cat %t.exports1 %t.exports2 | sort | uniq > %t.exports-sorted
 //
 // Now make sure the DLL thunk imports everything:
 // RUN: echo
 // RUN: echo "=== NOTE === If you see a mismatch below, please update asan_win_dll_thunk.cc"
-// RUN: diff %t.dll_imports-sorted %t.exported_wrappers-sorted
+// RUN: diff %t.imports-sorted %t.exports-sorted
 // REQUIRES: asan-static-runtime
-// XFAIL: win
 
 #include <stdio.h>
 #include <windows.h>

Added: compiler-rt/trunk/test/asan/TestCases/Windows/interface_symbols_windows.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/interface_symbols_windows.c?rev=293682&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/interface_symbols_windows.c (added)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/interface_symbols_windows.c Tue Jan 31 14:23:21 2017
@@ -0,0 +1,51 @@
+// Check that the interface exported by asan static lib matches the list of
+// functions mentioned in sanitizer_interface.inc.
+//
+// Just make sure we can compile this.
+// RUN: %clang_cl_asan -O0 %s -Fe%t
+//
+// note: The mangling decoration (i.e. @4 )is removed because calling convention
+//       differ from 32-bit and 64-bit.
+//
+// RUN: dumpbin /EXPORTS %t | sed "s/=.*//"                                    \
+// RUN:   | grep -o "\(__asan_\|__ubsan_\|__sanitizer_\|__sancov_\)[^ ]*"      \
+// RUN:   | grep -v "__asan_wrap"                                              \
+// RUN:   | sed -e s/@.*// > %t.exports
+//
+// [BEWARE: be really careful with the sed commands, as this test can be run
+//  from different environemnts with different shells and seds]
+//
+// RUN: grep -e "INTERFACE_FUNCTION"                                           \
+// RUN:  %p/../../../../lib/asan/asan_interface.inc                            \
+// RUN:  %p/../../../../lib/ubsan/ubsan_interface.inc                          \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc    \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc  \
+// RUN:  | sed -e "s/.*(//" -e "s/).*//" > %t.imports1
+//
+// RUN: grep -e "INTERFACE_WEAK_FUNCTION"                                      \
+// RUN:  %p/../../../../lib/asan/asan_interface.inc                            \
+// RUN:  %p/../../../../lib/ubsan/ubsan_interface.inc                          \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc    \
+// RUN:  %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc  \
+// RUN:  | sed -e "s/.*(//" -e "s/).*/__dll/" > %t.imports2
+//
+// Add functions not included in the interface lists:
+// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.imports3
+// IMPORT: __asan_shadow_memory_dynamic_address
+// IMPORT: __asan_get_shadow_memory_dynamic_address
+// IMPORT: __asan_option_detect_stack_use_after_return
+// IMPORT: __asan_should_detect_stack_use_after_return
+// IMPORT: __asan_set_seh_filter
+// IMPORT: __asan_unhandled_exception_filter
+// IMPORT: __asan_test_only_reported_buggy_pointer
+//
+// RUN: cat %t.imports1 %t.imports2 %t.imports3 | sort | uniq > %t.imports-sorted
+// RUN: cat %t.exports | sort | uniq > %t.exports-sorted
+//
+// Now make sure the DLL thunk imports everything:
+// RUN: echo
+// RUN: echo "=== NOTE === If you see a mismatch below, please update interface.inc files."
+// RUN: diff %t.imports-sorted %t.exports-sorted
+// REQUIRES: asan-static-runtime
+
+int main() { return 0; }




More information about the llvm-commits mailing list