summaryrefslogtreecommitdiff
path: root/lib/asan/asan_mapping.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2012-03-15 01:18:06 +0000
committerKostya Serebryany <kcc@google.com>2012-03-15 01:18:06 +0000
commit8599762021935ccfce4db9b054f092af8ef001ab (patch)
tree1635128116a5e7893b6870c5da37fcc7fa1b5e1d /lib/asan/asan_mapping.h
parentf0977db20608fa61fe6dd14d96cdd94c35c85b4e (diff)
[asan] performance optimization: make sure the check for poisoned shadow inside inteceptors is inlined
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@152767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_mapping.h')
-rw-r--r--lib/asan/asan_mapping.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/asan/asan_mapping.h b/lib/asan/asan_mapping.h
index 63aba10a2..4824bf109 100644
--- a/lib/asan/asan_mapping.h
+++ b/lib/asan/asan_mapping.h
@@ -95,6 +95,18 @@ static inline bool AddrIsAlignedByGranularity(uintptr_t a) {
return (a & (SHADOW_GRANULARITY - 1)) == 0;
}
+static inline bool AddressIsPoisoned(uintptr_t a) {
+ const size_t kAccessSize = 1;
+ uint8_t *shadow_address = (uint8_t*)MemToShadow(a);
+ int8_t shadow_value = *shadow_address;
+ if (shadow_value) {
+ uint8_t last_accessed_byte = (a & (SHADOW_GRANULARITY - 1))
+ + kAccessSize - 1;
+ return (last_accessed_byte >= shadow_value);
+ }
+ return false;
+}
+
} // namespace __asan
#endif // ASAN_MAPPING_H