[PATCH] [dfsan] Runtime support for ABI list functionality; can now run integration tests with args ABI.
Peter Collingbourne
peter at pcc.me.uk
Mon Aug 12 17:30:02 PDT 2013
- Add a comment to __dfsw_dfsan_get_label
Hi eugenis,
http://llvm-reviews.chandlerc.com/D1351
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1351?vs=3343&id=3402#toc
BRANCH
dfsan-up6
ARCANIST PROJECT
compiler-rt
Files:
lib/dfsan/CMakeLists.txt
lib/dfsan/dfsan.cc
lib/dfsan/done_abilist.txt
lib/dfsan/lit_tests/CMakeLists.txt
lib/dfsan/lit_tests/basic.c
lib/dfsan/lit_tests/fncall.c
lib/dfsan/lit_tests/propagate.c
Index: lib/dfsan/CMakeLists.txt
===================================================================
--- lib/dfsan/CMakeLists.txt
+++ lib/dfsan/CMakeLists.txt
@@ -26,4 +26,13 @@
list(APPEND DFSAN_RUNTIME_LIBRARIES clang_rt.dfsan-${arch})
endif()
+add_custom_target(dfsan_abilist ALL
+ SOURCES ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt)
+add_custom_command(OUTPUT ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
+ VERBATIM
+ COMMAND
+ cat ${CMAKE_CURRENT_SOURCE_DIR}/done_abilist.txt
+ > ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
+ DEPENDS done_abilist.txt)
+
add_subdirectory(lit_tests)
Index: lib/dfsan/dfsan.cc
===================================================================
--- lib/dfsan/dfsan.cc
+++ lib/dfsan/dfsan.cc
@@ -130,6 +130,12 @@
return label;
}
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE
+void __dfsan_unimplemented(char *fname) {
+ Report("WARNING: DataFlowSanitizer: call to uninstrumented function %s\n",
+ fname);
+}
+
// Like __dfsan_union, but for use from the client or custom functions. Hence
// the equality comparison is done here before calling __dfsan_union.
SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
@@ -147,7 +153,6 @@
__dfsan_label_info[label].l1 = __dfsan_label_info[label].l2 = 0;
__dfsan_label_info[label].desc = desc;
__dfsan_label_info[label].userdata = userdata;
- __dfsan_retval_tls = 0; // Ensures return value is unlabelled in the caller.
return label;
}
@@ -164,11 +169,14 @@
*labelp = __dfsan_union(*labelp, label);
}
-SANITIZER_INTERFACE_ATTRIBUTE dfsan_label dfsan_get_label(long data) {
- // The label for 'data' is implicitly passed by the instrumentation pass in
- // the first element of __dfsan_arg_tls. So we can just return it.
- __dfsan_retval_tls = 0; // Ensures return value is unlabelled in the caller.
- return __dfsan_arg_tls[0];
+// Unlike the other dfsan interface functions the behavior of this function
+// depends on the label of one of its arguments. Hence it is implemented as a
+// custom function.
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
+__dfsw_dfsan_get_label(long data, dfsan_label data_label,
+ dfsan_label *ret_label) {
+ *ret_label = 0;
+ return data_label;
}
SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
@@ -180,12 +188,10 @@
SANITIZER_INTERFACE_ATTRIBUTE
const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label) {
- __dfsan_retval_tls = 0; // Ensures return value is unlabelled in the caller.
return &__dfsan_label_info[label];
}
int dfsan_has_label(dfsan_label label, dfsan_label elem) {
- __dfsan_retval_tls = 0; // Ensures return value is unlabelled in the caller.
if (label == elem)
return true;
const dfsan_label_info *info = dfsan_get_label_info(label);
@@ -197,7 +203,6 @@
}
dfsan_label dfsan_has_label_with_desc(dfsan_label label, const char *desc) {
- __dfsan_retval_tls = 0; // Ensures return value is unlabelled in the caller.
const dfsan_label_info *info = dfsan_get_label_info(label);
if (info->l1 != 0) {
return dfsan_has_label_with_desc(info->l1, desc) ||
Index: lib/dfsan/done_abilist.txt
===================================================================
--- /dev/null
+++ lib/dfsan/done_abilist.txt
@@ -0,0 +1,30 @@
+fun:main=uninstrumented
+fun:main=discard
+
+# DFSan interface functions.
+fun:dfsan_union=uninstrumented
+fun:dfsan_union=discard
+
+fun:dfsan_create_label=uninstrumented
+fun:dfsan_create_label=discard
+
+fun:dfsan_set_label=uninstrumented
+fun:dfsan_set_label=discard
+
+fun:dfsan_add_label=uninstrumented
+fun:dfsan_add_label=discard
+
+fun:dfsan_get_label=uninstrumented
+fun:dfsan_get_label=custom
+
+fun:dfsan_read_label=uninstrumented
+fun:dfsan_read_label=discard
+
+fun:dfsan_get_label_info=uninstrumented
+fun:dfsan_get_label_info=discard
+
+fun:dfsan_has_label=uninstrumented
+fun:dfsan_has_label=discard
+
+fun:dfsan_has_label_with_desc=uninstrumented
+fun:dfsan_has_label_with_desc=discard
Index: lib/dfsan/lit_tests/CMakeLists.txt
===================================================================
--- lib/dfsan/lit_tests/CMakeLists.txt
+++ lib/dfsan/lit_tests/CMakeLists.txt
@@ -9,7 +9,8 @@
# Run DFSan tests only if we're sure we may produce working binaries.
set(DFSAN_TEST_DEPS
${SANITIZER_COMMON_LIT_TEST_DEPS}
- ${DFSAN_RUNTIME_LIBRARIES})
+ ${DFSAN_RUNTIME_LIBRARIES}
+ dfsan_abilist)
set(DFSAN_TEST_PARAMS
dfsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
add_lit_testsuite(check-dfsan "Running the DataFlowSanitizer tests"
Index: lib/dfsan/lit_tests/basic.c
===================================================================
--- lib/dfsan/lit_tests/basic.c
+++ lib/dfsan/lit_tests/basic.c
@@ -1,4 +1,5 @@
// RUN: %clang_dfsan -m64 %s -o %t && %t
+// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t && %t
// Tests that labels are propagated through loads and stores.
Index: lib/dfsan/lit_tests/fncall.c
===================================================================
--- lib/dfsan/lit_tests/fncall.c
+++ lib/dfsan/lit_tests/fncall.c
@@ -1,4 +1,5 @@
// RUN: %clang_dfsan -m64 %s -o %t && %t
+// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t && %t
// Tests that labels are propagated through function calls.
Index: lib/dfsan/lit_tests/propagate.c
===================================================================
--- lib/dfsan/lit_tests/propagate.c
+++ lib/dfsan/lit_tests/propagate.c
@@ -1,4 +1,5 @@
// RUN: %clang_dfsan -m64 %s -o %t && %t
+// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t && %t
// Tests that labels are propagated through computation and that union labels
// are properly created.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1351.2.patch
Type: text/x-patch
Size: 5797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130812/f926b941/attachment.bin>
More information about the llvm-commits
mailing list