[compiler-rt] r194955 - [DFSan] Don't include public headers in dfsan runtime code
Alexey Samsonov
samsonov at google.com
Sun Nov 17 01:41:47 PST 2013
Author: samsonov
Date: Sun Nov 17 03:41:47 2013
New Revision: 194955
URL: http://llvm.org/viewvc/llvm-project?rev=194955&view=rev
Log:
[DFSan] Don't include public headers in dfsan runtime code
Summary:
Definitions we use in public sanitizer headers may
slightly conflict with the ones we use in private sanitizer runtimes.
Moreover, we generally forbid to include any system headers (like <stdint.h>)
in sanitizer runtime headers. This leads to inevitable duplication of selected
interface function declarations, but we decided to live with it.
Reviewers: pcc
Reviewed By: pcc
CC: kcc, llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2179
Modified:
compiler-rt/trunk/CMakeLists.txt
compiler-rt/trunk/lib/dfsan/dfsan.cc
compiler-rt/trunk/lib/dfsan/dfsan.h
compiler-rt/trunk/lib/dfsan/dfsan_custom.cc
compiler-rt/trunk/lib/dfsan/dfsan_interceptors.cc
Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=194955&r1=194954&r2=194955&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Sun Nov 17 03:41:47 2013
@@ -212,8 +212,6 @@ endif()
filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
x86_64 i386 powerpc64)
-# Add the public header's directory to the includes for all of compiler-rt.
-include_directories(include)
add_subdirectory(include)
set(SANITIZER_COMMON_LIT_TEST_DEPS
Modified: compiler-rt/trunk/lib/dfsan/dfsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan.cc?rev=194955&r1=194954&r2=194955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan.cc (original)
+++ compiler-rt/trunk/lib/dfsan/dfsan.cc Sun Nov 17 03:41:47 2013
@@ -19,7 +19,6 @@
// prefixed __dfsan_.
//===----------------------------------------------------------------------===//
-#include "sanitizer/dfsan_interface.h"
#include "sanitizer_common/sanitizer_atomic.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_flags.h"
@@ -123,9 +122,9 @@ dfsan_label __dfsan_union(dfsan_label l1
}
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
-dfsan_label __dfsan_union_load(const dfsan_label *ls, size_t n) {
+dfsan_label __dfsan_union_load(const dfsan_label *ls, uptr n) {
dfsan_label label = ls[0];
- for (size_t i = 1; i != n; ++i) {
+ for (uptr i = 1; i != n; ++i) {
dfsan_label next_label = ls[i];
if (label != next_label)
label = __dfsan_union(label, next_label);
@@ -157,7 +156,7 @@ dfsan_union(dfsan_label l1, dfsan_label
return __dfsan_union(l1, l2);
}
-SANITIZER_INTERFACE_ATTRIBUTE
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE
dfsan_label dfsan_create_label(const char *desc, void *userdata) {
dfsan_label label =
atomic_fetch_add(&__dfsan_last_label, 1, memory_order_relaxed) + 1;
@@ -169,18 +168,18 @@ dfsan_label dfsan_create_label(const cha
}
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
-void __dfsan_set_label(dfsan_label label, void *addr, size_t size) {
+void __dfsan_set_label(dfsan_label label, void *addr, uptr size) {
for (dfsan_label *labelp = shadow_for(addr); size != 0; --size, ++labelp)
*labelp = label;
}
SANITIZER_INTERFACE_ATTRIBUTE
-void dfsan_set_label(dfsan_label label, void *addr, size_t size) {
+void dfsan_set_label(dfsan_label label, void *addr, uptr size) {
__dfsan_set_label(label, addr, size);
}
SANITIZER_INTERFACE_ATTRIBUTE
-void dfsan_add_label(dfsan_label label, void *addr, size_t size) {
+void dfsan_add_label(dfsan_label label, void *addr, uptr size) {
for (dfsan_label *labelp = shadow_for(addr); size != 0; --size, ++labelp)
if (*labelp != label)
*labelp = __dfsan_union(*labelp, label);
@@ -197,7 +196,7 @@ __dfsw_dfsan_get_label(long data, dfsan_
}
SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
-dfsan_read_label(const void *addr, size_t size) {
+dfsan_read_label(const void *addr, uptr size) {
if (size == 0)
return 0;
return __dfsan_union_load(shadow_for(addr), size);
@@ -208,7 +207,8 @@ const struct dfsan_label_info *dfsan_get
return &__dfsan_label_info[label];
}
-int dfsan_has_label(dfsan_label label, dfsan_label elem) {
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE int
+dfsan_has_label(dfsan_label label, dfsan_label elem) {
if (label == elem)
return true;
const dfsan_label_info *info = dfsan_get_label_info(label);
@@ -219,7 +219,8 @@ int dfsan_has_label(dfsan_label label, d
}
}
-dfsan_label dfsan_has_label_with_desc(dfsan_label label, const char *desc) {
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
+dfsan_has_label_with_desc(dfsan_label label, const char *desc) {
const dfsan_label_info *info = dfsan_get_label_info(label);
if (info->l1 != 0) {
return dfsan_has_label_with_desc(info->l1, desc) ||
Modified: compiler-rt/trunk/lib/dfsan/dfsan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan.h?rev=194955&r1=194954&r2=194955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan.h (original)
+++ compiler-rt/trunk/lib/dfsan/dfsan.h Sun Nov 17 03:41:47 2013
@@ -15,14 +15,35 @@
#ifndef DFSAN_H
#define DFSAN_H
-#include "sanitizer/dfsan_interface.h"
+#include "sanitizer_common/sanitizer_internal_defs.h"
+
+// Copy declarations from public sanitizer/dfsan_interface.h header here.
+typedef u16 dfsan_label;
+
+struct dfsan_label_info {
+ dfsan_label l1;
+ dfsan_label l2;
+ const char *desc;
+ void *userdata;
+};
+
+extern "C" {
+void dfsan_set_label(dfsan_label label, void *addr, uptr size);
+dfsan_label dfsan_read_label(const void *addr, uptr size);
+dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2);
+} // extern "C"
+
+template <typename T>
+void dfsan_set_label(dfsan_label label, T &data) { // NOLINT
+ dfsan_set_label(label, (void *)&data, sizeof(T));
+}
namespace __dfsan {
void InitializeInterceptors();
inline dfsan_label *shadow_for(void *ptr) {
- return (dfsan_label *) ((((uintptr_t) ptr) & ~0x700000000000) << 1);
+ return (dfsan_label *) ((((uptr) ptr) & ~0x700000000000) << 1);
}
inline const dfsan_label *shadow_for(const void *ptr) {
Modified: compiler-rt/trunk/lib/dfsan/dfsan_custom.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan_custom.cc?rev=194955&r1=194954&r2=194955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan_custom.cc (original)
+++ compiler-rt/trunk/lib/dfsan/dfsan_custom.cc Sun Nov 17 03:41:47 2013
@@ -11,7 +11,6 @@
//
// This file defines the custom functions listed in done_abilist.txt.
//===----------------------------------------------------------------------===//
-#include "sanitizer/dfsan_interface.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_linux.h"
Modified: compiler-rt/trunk/lib/dfsan/dfsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan_interceptors.cc?rev=194955&r1=194954&r2=194955&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/dfsan/dfsan_interceptors.cc Sun Nov 17 03:41:47 2013
@@ -12,7 +12,7 @@
// Interceptors for standard library functions.
//===----------------------------------------------------------------------===//
-#include "sanitizer/dfsan_interface.h"
+#include "dfsan/dfsan.h"
#include "interception/interception.h"
#include "sanitizer_common/sanitizer_common.h"
More information about the llvm-commits
mailing list