[llvm-commits] [compiler-rt] r169836 - in /compiler-rt/trunk/lib: asan/asan_allocator.cc asan/asan_allocator.h asan/asan_allocator2.cc sanitizer_common/sanitizer_common.cc
Kostya Serebryany
kcc at google.com
Tue Dec 11 01:02:36 PST 2012
Author: kcc
Date: Tue Dec 11 03:02:36 2012
New Revision: 169836
URL: http://llvm.org/viewvc/llvm-project?rev=169836&view=rev
Log:
[asan] more sceleton code for asan_allocator2
Modified:
compiler-rt/trunk/lib/asan/asan_allocator.cc
compiler-rt/trunk/lib/asan/asan_allocator.h
compiler-rt/trunk/lib/asan/asan_allocator2.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=169836&r1=169835&r2=169836&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Tue Dec 11 03:02:36 2012
@@ -183,33 +183,6 @@
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) {
Modified: compiler-rt/trunk/lib/asan/asan_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.h?rev=169836&r1=169835&r2=169836&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.h (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.h Tue Dec 11 03:02:36 2012
@@ -40,9 +40,31 @@
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_;
};
Modified: compiler-rt/trunk/lib/asan/asan_allocator2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator2.cc?rev=169836&r1=169835&r2=169836&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator2.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator2.cc Tue Dec 11 03:02:36 2012
@@ -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 @@
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
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=169836&r1=169835&r2=169836&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc Tue Dec 11 03:02:36 2012
@@ -206,5 +206,4 @@
(void)reserved;
PrepareForSandboxing();
}
-
} // extern "C"
More information about the llvm-commits
mailing list