[PATCH] [dfsan] Introduce dfsan_read_label runtime function.
Peter Collingbourne
peter at pcc.me.uk
Mon Aug 12 17:12:43 PDT 2013
- Add a test for dfsan_read_label unioning
Hi eugenis,
http://llvm-reviews.chandlerc.com/D1349
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1349?vs=3341&id=3399#toc
Files:
include/sanitizer/dfsan_interface.h
lib/dfsan/dfsan.cc
lib/dfsan/lit_tests/basic.c
lib/dfsan/lit_tests/propagate.c
Index: include/sanitizer/dfsan_interface.h
===================================================================
--- include/sanitizer/dfsan_interface.h
+++ include/sanitizer/dfsan_interface.h
@@ -61,6 +61,9 @@
/// value.
dfsan_label dfsan_get_label(long data);
+/// Retrieves the label associated with the data at the given address.
+dfsan_label dfsan_read_label(const void *addr, size_t size);
+
/// Retrieves a pointer to the dfsan_label_info struct for the given label.
const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label);
Index: lib/dfsan/dfsan.cc
===================================================================
--- lib/dfsan/dfsan.cc
+++ lib/dfsan/dfsan.cc
@@ -120,7 +120,7 @@
}
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
-dfsan_label __dfsan_union_load(dfsan_label *ls, size_t n) {
+dfsan_label __dfsan_union_load(const dfsan_label *ls, size_t n) {
dfsan_label label = ls[0];
for (size_t i = 1; i != n; ++i) {
dfsan_label next_label = ls[i];
@@ -178,6 +178,13 @@
return __dfsan_arg_tls[0];
}
+SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
+dfsan_read_label(const void *addr, size_t size) {
+ if (size == 0)
+ return 0;
+ return __dfsan_union_load(shadow_for(addr), 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.
Index: lib/dfsan/lit_tests/basic.c
===================================================================
--- lib/dfsan/lit_tests/basic.c
+++ lib/dfsan/lit_tests/basic.c
@@ -13,5 +13,8 @@
dfsan_label new_label = dfsan_get_label(i);
assert(i_label == new_label);
+ dfsan_label read_label = dfsan_read_label(&i, sizeof(i));
+ assert(i_label == read_label);
+
return 0;
}
Index: lib/dfsan/lit_tests/propagate.c
===================================================================
--- lib/dfsan/lit_tests/propagate.c
+++ lib/dfsan/lit_tests/propagate.c
@@ -34,5 +34,8 @@
assert(dfsan_has_label(ijk_label, j_label));
assert(dfsan_has_label(ijk_label, k_label));
+ struct { int i, j; } s = { i, j };
+ assert(dfsan_read_label(&s, sizeof(s)) == ij_label);
+
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1349.2.patch
Type: text/x-patch
Size: 2206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130812/de0889e9/attachment.bin>
More information about the llvm-commits
mailing list