[PATCH] [dfsan] Introduce dfsan_read_label runtime function.
Peter Collingbourne
peter at pcc.me.uk
Fri Aug 9 19:04:24 PDT 2013
Hi eugenis,
http://llvm-reviews.chandlerc.com/D1349
Files:
include/sanitizer/dfsan_interface.h
lib/dfsan/dfsan.cc
lib/dfsan/lit_tests/basic.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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1349.1.patch
Type: text/x-patch
Size: 1799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130809/f9b134d3/attachment.bin>
More information about the llvm-commits
mailing list