[compiler-rt] e487713 - [Sanitizers] UUID/Build ID is 16 bytes on Darwin.

usama hameed via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 7 14:33:14 PDT 2023


Author: usama hameed
Date: 2023-06-07T14:32:41-07:00
New Revision: e487713a21f780bf7150f86f42718be4d0342beb

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

LOG: [Sanitizers] UUID/Build ID is 16 bytes on Darwin.

https://reviews.llvm.org/D114294 changed the kModuleUUIDSize from 16 to 32 for
all platforms. This is not true for Darwin where the UUID is 16 bytes.

Differential Revision: https://reviews.llvm.org/D152309
rdar://110346025

Added: 
    compiler-rt/lib/sanitizer_common/tests/sanitizer_module_uuid_size.cpp

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_common.h
    compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 302b4437d64bd..b2755833263dd 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -796,7 +796,11 @@ inline const char *ModuleArchToString(ModuleArch arch) {
   return "";
 }
 
+#if SANITIZER_APPLE
+const uptr kModuleUUIDSize = 16;
+#else
 const uptr kModuleUUIDSize = 32;
+#endif
 const uptr kMaxSegName = 16;
 
 // Represents a binary loaded into virtual memory (e.g. this can be an

diff  --git a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt
index dad90cddefbc3..ec0f1d2608458 100644
--- a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt
@@ -31,6 +31,7 @@ set(SANITIZER_UNITTESTS
   sanitizer_list_test.cpp
   sanitizer_lzw_test.cpp
   sanitizer_mac_test.cpp
+  sanitizer_module_uuid_size.cpp
   sanitizer_mutex_test.cpp
   sanitizer_nolibc_test.cpp
   sanitizer_posix_test.cpp

diff  --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_module_uuid_size.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_module_uuid_size.cpp
new file mode 100644
index 0000000000000..feb17dc3d77e2
--- /dev/null
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_module_uuid_size.cpp
@@ -0,0 +1,10 @@
+#include "sanitizer_common/sanitizer_common.h"
+#include "gtest/gtest.h"
+
+TEST(ModuleUUID, kModuleUUIDSize) {
+#if SANITIZER_APPLE
+    EXPECT_EQ(__sanitizer::kModuleUUIDSize, 16ULL);
+#else
+    EXPECT_EQ(__sanitizer::kModuleUUIDSize, 32ULL);
+#endif
+}


        


More information about the llvm-commits mailing list