diff options
| author | Kostya Serebryany <kcc@google.com> | 2012-12-11 09:02:36 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2012-12-11 09:02:36 +0000 |
| commit | 5e2a7acdbe522a45f927f510bda744b5e4d7fd74 (patch) | |
| tree | 4c499d5c6fd519319cbd658fb89da7a7ae9198ac | |
| parent | 3b7793797f773ee0132b38767b104ad80af75229 (diff) | |
| download | bcm5719-llvm-5e2a7acdbe522a45f927f510bda744b5e4d7fd74.tar.gz bcm5719-llvm-5e2a7acdbe522a45f927f510bda744b5e4d7fd74.zip | |
[asan] more sceleton code for asan_allocator2
llvm-svn: 169836
| -rw-r--r-- | compiler-rt/lib/asan/asan_allocator.cc | 27 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_allocator.h | 28 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_allocator2.cc | 118 | ||||
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_common.cc | 1 |
4 files changed, 143 insertions, 31 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.cc b/compiler-rt/lib/asan/asan_allocator.cc index 8a37c8d24db..e0d08501761 100644 --- a/compiler-rt/lib/asan/asan_allocator.cc +++ b/compiler-rt/lib/asan/asan_allocator.cc @@ -183,33 +183,6 @@ void AsanChunkView::GetFreeStack(StackTrace *stack) { chunk_->compressed_free_stack_size()); } -bool AsanChunkView::AddrIsInside(uptr addr, uptr access_size, uptr *offset) { - if (addr >= Beg() && (addr + access_size) <= End()) { - *offset = addr - Beg(); - return true; - } - return false; -} - -bool AsanChunkView::AddrIsAtLeft(uptr addr, uptr access_size, uptr *offset) { - if (addr < Beg()) { - *offset = Beg() - addr; - return true; - } - return false; -} - -bool AsanChunkView::AddrIsAtRight(uptr addr, uptr access_size, uptr *offset) { - if (addr + access_size >= End()) { - if (addr <= End()) - *offset = 0; - else - *offset = addr - End(); - return true; - } - return false; -} - static AsanChunk *PtrToChunk(uptr ptr) { AsanChunk *m = (AsanChunk*)(ptr - REDZONE); if (m->chunk_state == CHUNK_MEMALIGN) { diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h index 79de7fe3a24..b714d362cf2 100644 --- a/compiler-rt/lib/asan/asan_allocator.h +++ b/compiler-rt/lib/asan/asan_allocator.h @@ -40,9 +40,31 @@ class AsanChunkView { uptr FreeTid(); void GetAllocStack(StackTrace *stack); void GetFreeStack(StackTrace *stack); - bool AddrIsInside(uptr addr, uptr access_size, uptr *offset); - bool AddrIsAtLeft(uptr addr, uptr access_size, uptr *offset); - bool AddrIsAtRight(uptr addr, uptr access_size, uptr *offset); + bool AddrIsInside(uptr addr, uptr access_size, uptr *offset) { + if (addr >= Beg() && (addr + access_size) <= End()) { + *offset = addr - Beg(); + return true; + } + return false; + } + bool AddrIsAtLeft(uptr addr, uptr access_size, uptr *offset) { + if (addr < Beg()) { + *offset = Beg() - addr; + return true; + } + return false; + } + bool AddrIsAtRight(uptr addr, uptr access_size, uptr *offset) { + if (addr + access_size >= End()) { + if (addr <= End()) + *offset = 0; + else + *offset = addr - End(); + return true; + } + return false; + } + private: AsanChunk *const chunk_; }; diff --git a/compiler-rt/lib/asan/asan_allocator2.cc b/compiler-rt/lib/asan/asan_allocator2.cc index bb3a15edcdc..ad2ed3af41c 100644 --- a/compiler-rt/lib/asan/asan_allocator2.cc +++ b/compiler-rt/lib/asan/asan_allocator2.cc @@ -18,7 +18,9 @@ #include "asan_allocator.h" #if ASAN_ALLOCATOR_VERSION == 2 +#include "sanitizer/asan_interface.h" #include "sanitizer_common/sanitizer_allocator.h" +#include "sanitizer_common/sanitizer_internal_defs.h" namespace __asan { @@ -39,5 +41,121 @@ typedef CombinedAllocator<PrimaryAllocator, AllocatorCache, SecondaryAllocator> Allocator; +uptr AsanChunkView::Beg() { return 0; } +uptr AsanChunkView::End() { return Beg() + UsedSize(); } +uptr AsanChunkView::UsedSize() { return 0; } +uptr AsanChunkView::AllocTid() { return 0; } +uptr AsanChunkView::FreeTid() { return 0; } + +void AsanChunkView::GetAllocStack(StackTrace *stack) { } +void AsanChunkView::GetFreeStack(StackTrace *stack) { } +AsanChunkView FindHeapChunkByAddress(uptr address) { + UNIMPLEMENTED(); + return AsanChunkView(0); +} + +void AsanThreadLocalMallocStorage::CommitBack() { + UNIMPLEMENTED(); +} + +SANITIZER_INTERFACE_ATTRIBUTE +void *asan_memalign(uptr alignment, uptr size, StackTrace *stack) { + UNIMPLEMENTED(); + return 0; +} + +SANITIZER_INTERFACE_ATTRIBUTE +void asan_free(void *ptr, StackTrace *stack) { + UNIMPLEMENTED(); + return; +} + +SANITIZER_INTERFACE_ATTRIBUTE +void *asan_malloc(uptr size, StackTrace *stack) { + UNIMPLEMENTED(); + return 0; +} + +void *asan_calloc(uptr nmemb, uptr size, StackTrace *stack) { + UNIMPLEMENTED(); + return 0; +} + +void *asan_realloc(void *p, uptr size, StackTrace *stack) { + UNIMPLEMENTED(); + return 0; +} + +void *asan_valloc(uptr size, StackTrace *stack) { + UNIMPLEMENTED(); + return 0; +} + +void *asan_pvalloc(uptr size, StackTrace *stack) { + UNIMPLEMENTED(); + return 0; +} + +int asan_posix_memalign(void **memptr, uptr alignment, uptr size, + StackTrace *stack) { + UNIMPLEMENTED(); + return 0; +} + +uptr asan_malloc_usable_size(void *ptr, StackTrace *stack) { + UNIMPLEMENTED(); + return 0; +} + +uptr asan_mz_size(const void *ptr) { + UNIMPLEMENTED(); + return 0; +} + +void asan_mz_force_lock() { + UNIMPLEMENTED(); +} + +void asan_mz_force_unlock() { + UNIMPLEMENTED(); +} + } // namespace __asan + +// ---------------------- Interface ---------------- {{{1 +using namespace __asan; // NOLINT + +// ASan allocator doesn't reserve extra bytes, so normally we would +// just return "size". +uptr __asan_get_estimated_allocated_size(uptr size) { + UNIMPLEMENTED(); + return 0; +} + +bool __asan_get_ownership(const void *p) { + UNIMPLEMENTED(); + return false; +} + +uptr __asan_get_allocated_size(const void *p) { + UNIMPLEMENTED(); + return 0; +} + +#if !SANITIZER_SUPPORTS_WEAK_HOOKS +// Provide default (no-op) implementation of malloc hooks. +extern "C" { +SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE +void __asan_malloc_hook(void *ptr, uptr size) { + (void)ptr; + (void)size; +} +SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE +void __asan_free_hook(void *ptr) { + (void)ptr; +} +} // extern "C" +#endif + + #endif // ASAN_ALLOCATOR_VERSION diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc index ca1f6bd2ef6..a70d4406d97 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc @@ -206,5 +206,4 @@ void NOINLINE __sanitizer_sandbox_on_notify(void *reserved) { (void)reserved; PrepareForSandboxing(); } - } // extern "C" |

