/* If a pointer lies within an allocation, it will return the start address
of the allocation. Otherwise, it returns nullptr. */
- void *__sanitizer_get_allocated_begin(const void *p);
+ const void *__sanitizer_get_allocated_begin(const void *p);
/* Returns the number of bytes reserved for the pointer p.
Requires (get_ownership(p) == true) or (p == 0). */
// ---------------------- Interface ---------------- {{{1
using namespace __asan;
-void *AllocationBegin(const void *p) {
+const void *AllocationBegin(const void *p) {
AsanChunk *m = __asan::instance.GetAsanChunkByAddr((uptr)p);
if (!m)
return nullptr;
return nullptr;
if (m->UsedSize() == 0)
return nullptr;
- return (void *)(m->Beg());
+ return (const void *)(m->Beg());
}
// ASan allocator doesn't reserve extra bytes, so normally we would
return allocated_size;
}
-void *__sanitizer_get_allocated_begin(const void *p) {
+const void *__sanitizer_get_allocated_begin(const void *p) {
return AllocationBegin(p);
}
return DFsanAllocate(nmemb * size, sizeof(u64), true /*zeroise*/);
}
-void *AllocationBegin(const void *p) {
+const void *AllocationBegin(const void *p) {
if (!p)
return nullptr;
void *beg = allocator.GetBlockBegin(p);
return nullptr;
if (b->requested_size == 0)
return nullptr;
- return (void *)beg;
+ return (const void *)beg;
}
static uptr AllocationSize(const void *p) {
int __sanitizer_get_ownership(const void *p) { return AllocationSize(p) != 0; }
-void *__sanitizer_get_allocated_begin(const void *p) {
+const void *__sanitizer_get_allocated_begin(const void *p) {
return AllocationBegin(p);
}
return HwasanChunkView(reinterpret_cast<uptr>(block), metadata);
}
-void *AllocationBegin(const void *p) {
+const void *AllocationBegin(const void *p) {
const void *untagged_ptr = UntagPtr(p);
if (!untagged_ptr)
return nullptr;
return nullptr;
tag_t tag = GetTagFromPointer((uptr)p);
- return (void *)AddTagToPointer((uptr)beg, tag);
+ return (const void *)AddTagToPointer((uptr)beg, tag);
}
static uptr AllocationSize(const void *tagged_ptr) {
int __sanitizer_get_ownership(const void *p) { return AllocationSize(p) != 0; }
-void *__sanitizer_get_allocated_begin(const void *p) {
+const void *__sanitizer_get_allocated_begin(const void *p) {
return AllocationBegin(p);
}
*end = *begin + sizeof(AllocatorCache);
}
-void *GetMallocBegin(const void *p) {
+const void *GetMallocBegin(const void *p) {
if (!p)
return nullptr;
void *beg = allocator.GetBlockBegin(p);
return nullptr;
if (m->requested_size == 0)
return nullptr;
- return (void *)beg;
+ return (const void *)beg;
}
uptr GetMallocUsableSize(const void *p) {
int __sanitizer_get_ownership(const void *p) { return Metadata(p) != nullptr; }
SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_get_allocated_begin(const void *p) {
+const void * __sanitizer_get_allocated_begin(const void *p) {
return GetMallocBegin(p);
}
return 0;
}
-void *memprof_malloc_begin(const void *p) {
+const void *memprof_malloc_begin(const void *p) {
u64 user_requested_size;
MemprofChunk *m =
instance.GetMemprofChunkByAddr((uptr)p, user_requested_size);
if (user_requested_size == 0)
return nullptr;
- return (void *)m->Beg();
+ return (const void *)m->Beg();
}
uptr memprof_malloc_usable_size(const void *ptr, uptr pc, uptr bp) {
return memprof_malloc_usable_size(p, 0, 0) != 0;
}
-void *__sanitizer_get_allocated_begin(const void *p) {
+const void *__sanitizer_get_allocated_begin(const void *p) {
return memprof_malloc_begin(p);
}
return MsanAllocate(stack, nmemb * size, sizeof(u64), true);
}
-void *AllocationBegin(const void *p) {
+const void *AllocationBegin(const void *p) {
if (!p)
return nullptr;
void *beg = allocator.GetBlockBegin(p);
if (b->requested_size == 0)
return nullptr;
- return (void *)beg;
+ return (const void *)beg;
}
static uptr AllocationSize(const void *p) {
int __sanitizer_get_ownership(const void *p) { return AllocationSize(p) != 0; }
-void *__sanitizer_get_allocated_begin(const void *p) {
+const void *__sanitizer_get_allocated_begin(const void *p) {
return AllocationBegin(p);
}
SANITIZER_INTERFACE_ATTRIBUTE
uptr __sanitizer_get_estimated_allocated_size(uptr size);
SANITIZER_INTERFACE_ATTRIBUTE int __sanitizer_get_ownership(const void *p);
-SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void *
+SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const void *
__sanitizer_get_allocated_begin(const void *p);
SANITIZER_INTERFACE_ATTRIBUTE uptr
__sanitizer_get_allocated_size(const void *p);
return SetErrnoOnNull(user_alloc_internal(thr, pc, sz, PageSize));
}
-void *user_alloc_begin(const void *p) {
+const void *user_alloc_begin(const void *p) {
if (p == nullptr || !IsAppMem((uptr)p))
return nullptr;
void *beg = allocator()->GetBlockBegin(p);
if (!b)
return nullptr; // Not a valid pointer.
- return (void *)beg;
+ return (const void *)beg;
}
uptr user_alloc_usable_size(const void *p) {
return allocator()->GetBlockBegin(p) != 0;
}
-void *__sanitizer_get_allocated_begin(const void *p) {
+const void *__sanitizer_get_allocated_begin(const void *p) {
return user_alloc_begin(p);
}
// Bogus value to unpoison start. Calling __sanitizer_get_allocated_begin
// does not unpoison it.
- void *start = NULL;
+ const void *start = NULL;
for (int j = 0; j < sizes[i]; j++) {
printf("j: %d\n", j);