[compiler-rt] 0b041f1 - [NFC][sanitizer] Extend `DlSymAllocator`

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 15 18:00:08 PDT 2024


Author: Vitaly Buka
Date: 2024-09-15T17:14:08-07:00
New Revision: 0b041f1da5e2f01e6d7160f22250b19ac7d6bd8c

URL: https://github.com/llvm/llvm-project/commit/0b041f1da5e2f01e6d7160f22250b19ac7d6bd8c
DIFF: https://github.com/llvm/llvm-project/commit/0b041f1da5e2f01e6d7160f22250b19ac7d6bd8c.diff

LOG: [NFC][sanitizer] Extend `DlSymAllocator`

Preparation for using in`tsan`.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h
index 92b1373ef84d1a..b360478a058a54 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h
@@ -15,6 +15,8 @@
 #define SANITIZER_ALLOCATOR_DLSYM_H
 
 #include "sanitizer_allocator_internal.h"
+#include "sanitizer_common/sanitizer_allocator_checks.h"
+#include "sanitizer_common/sanitizer_internal_defs.h"
 
 namespace __sanitizer {
 
@@ -31,15 +33,15 @@ struct DlSymAllocator {
            UNLIKELY(internal_allocator()->FromPrimary(ptr));
   }
 
-  static void *Allocate(uptr size_in_bytes) {
-    void *ptr = InternalAlloc(size_in_bytes, nullptr, kWordSize);
+  static void *Allocate(uptr size_in_bytes, uptr align = kWordSize) {
+    void *ptr = InternalAlloc(size_in_bytes, nullptr, align);
     CHECK(internal_allocator()->FromPrimary(ptr));
     Details::OnAllocate(ptr,
                         internal_allocator()->GetActuallyAllocatedSize(ptr));
     return ptr;
   }
 
-  static void *Callocate(SIZE_T nmemb, SIZE_T size) {
+  static void *Callocate(usize nmemb, usize size) {
     void *ptr = InternalCalloc(nmemb, size);
     CHECK(internal_allocator()->FromPrimary(ptr));
     Details::OnAllocate(ptr,
@@ -70,6 +72,11 @@ struct DlSymAllocator {
     return new_ptr;
   }
 
+  static void *ReallocArray(void *ptr, uptr count, uptr size) {
+    CHECK(!CheckForCallocOverflow(count, size));
+    return Realloc(ptr, count * size);
+  }
+
   static void OnAllocate(const void *ptr, uptr size) {}
   static void OnFree(const void *ptr, uptr size) {}
 };


        


More information about the llvm-commits mailing list