summaryrefslogtreecommitdiff
path: root/lib/dfsan
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-08-14 18:54:06 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-08-14 18:54:06 +0000
commite8d20340700e0253a2b08c03391409f397eac3e3 (patch)
tree27df64b13f1451003433a5dfd23eb9573be12605 /lib/dfsan
parente6e564d232f95719277476308937856328c63682 (diff)
[dfsan] Runtime support for ABI list functionality; can now run integration tests with args ABI.
Differential Revision: http://llvm-reviews.chandlerc.com/D1351 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188401 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/dfsan')
-rw-r--r--lib/dfsan/CMakeLists.txt11
-rw-r--r--lib/dfsan/dfsan.cc23
-rw-r--r--lib/dfsan/done_abilist.txt30
-rw-r--r--lib/dfsan/lit_tests/CMakeLists.txt3
-rw-r--r--lib/dfsan/lit_tests/basic.c1
-rw-r--r--lib/dfsan/lit_tests/fncall.c1
-rw-r--r--lib/dfsan/lit_tests/propagate.c1
7 files changed, 60 insertions, 10 deletions
diff --git a/lib/dfsan/CMakeLists.txt b/lib/dfsan/CMakeLists.txt
index 3d96c080c..869797f72 100644
--- a/lib/dfsan/CMakeLists.txt
+++ b/lib/dfsan/CMakeLists.txt
@@ -26,4 +26,15 @@ if(CAN_TARGET_${arch})
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)
+install(FILES ${CLANG_RESOURCE_DIR}/dfsan_abilist.txt
+ DESTINATION ${LIBCLANG_INSTALL_PATH})
+
add_subdirectory(lit_tests)
diff --git a/lib/dfsan/dfsan.cc b/lib/dfsan/dfsan.cc
index ba8e8b511..71f83d8c1 100644
--- a/lib/dfsan/dfsan.cc
+++ b/lib/dfsan/dfsan.cc
@@ -130,6 +130,12 @@ dfsan_label __dfsan_union_load(const dfsan_label *ls, size_t n) {
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 dfsan_create_label(const char *desc, void *userdata) {
__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 @@ void dfsan_add_label(dfsan_label label, void *addr, size_t size) {
*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 @@ dfsan_read_label(const void *addr, size_t size) {
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 @@ int dfsan_has_label(dfsan_label label, dfsan_label elem) {
}
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) ||
diff --git a/lib/dfsan/done_abilist.txt b/lib/dfsan/done_abilist.txt
new file mode 100644
index 000000000..c156b3334
--- /dev/null
+++ b/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
diff --git a/lib/dfsan/lit_tests/CMakeLists.txt b/lib/dfsan/lit_tests/CMakeLists.txt
index 67888dfb9..d7c5c82ac 100644
--- a/lib/dfsan/lit_tests/CMakeLists.txt
+++ b/lib/dfsan/lit_tests/CMakeLists.txt
@@ -9,7 +9,8 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
# 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"
diff --git a/lib/dfsan/lit_tests/basic.c b/lib/dfsan/lit_tests/basic.c
index de11bd186..b566c9271 100644
--- a/lib/dfsan/lit_tests/basic.c
+++ b/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.
diff --git a/lib/dfsan/lit_tests/fncall.c b/lib/dfsan/lit_tests/fncall.c
index 7d4706f70..15b77bd67 100644
--- a/lib/dfsan/lit_tests/fncall.c
+++ b/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.
diff --git a/lib/dfsan/lit_tests/propagate.c b/lib/dfsan/lit_tests/propagate.c
index 31b65ee72..d1e971d41 100644
--- a/lib/dfsan/lit_tests/propagate.c
+++ b/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.