[compiler-rt] [hwasan] Add fixed_shadow_base flag (PR #73980)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 14:28:43 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff f8a21dff70cc5d20db731b3af1858c5a2ae96d30 0896aa86ba9de0f1b681c3e4565cfe597294a0a7 -- compiler-rt/test/hwasan/TestCases/Linux/fixed-shadow.c compiler-rt/lib/hwasan/hwasan_flags.inc compiler-rt/lib/hwasan/hwasan_linux.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/compiler-rt/test/hwasan/TestCases/Linux/fixed-shadow.c b/compiler-rt/test/hwasan/TestCases/Linux/fixed-shadow.c
index 9ff57f27de..154ef5cd44 100644
--- a/compiler-rt/test/hwasan/TestCases/Linux/fixed-shadow.c
+++ b/compiler-rt/test/hwasan/TestCases/Linux/fixed-shadow.c
@@ -13,41 +13,41 @@
 //
 // Note: if fixed_shadow_base is not set, compiler-rt will dynamically choose a
 // shadow base, which has a tiny but non-zero probability of matching the
-// compiler instrumentation. To avoid test flake, we do not test this case. 
+// compiler instrumentation. To avoid test flake, we do not test this case.
 //
 // Assume 48-bit VMA
 // REQUIRES: aarch64-target-arch
 //
 // UNSUPPORTED: android
 
-#include <stdio.h> 
-#include <stdlib.h>
-#include <assert.h>  
-#include <sys/mman.h>   
-#include <sanitizer/hwasan_interface.h>   
+#include <assert.h>
 #include <sanitizer/allocator_interface.h>
+#include <sanitizer/hwasan_interface.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
 
-int main() { 
+int main() {
   __hwasan_enable_allocator_tagging();
 
-  void** mmaps [256];
+  void **mmaps[256];
   // 48-bit VMA
-  for (int i = 0; i < 256; i++) {  
-      unsigned long long addr = (i * (1ULL << 40));
+  for (int i = 0; i < 256; i++) {
+    unsigned long long addr = (i * (1ULL << 40));
 
-      void *p = mmap ((void*)addr, 4096, PROT_READ | PROT_WRITE,
-                      MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
-      mmaps [i] = p;    
+    void *p = mmap((void *)addr, 4096, PROT_READ | PROT_WRITE,
+                   MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+    mmaps[i] = p;
   }
 
   int failures = 0;
-  for (int i = 0; i < 256; i++) {   
-      if (mmaps [i] == MAP_FAILED) {
-          failures++;
-      } else {    
-          printf ("%d %p\n", i, mmaps [i]);
-          munmap (mmaps [i], 4096);
-      }
+  for (int i = 0; i < 256; i++) {
+    if (mmaps[i] == MAP_FAILED) {
+      failures++;
+    } else {
+      printf("%d %p\n", i, mmaps[i]);
+      munmap(mmaps[i], 4096);
+    }
   }
 
   // We expect roughly 17 failures:
@@ -56,7 +56,7 @@ int main() {
   // We could also get unlucky e.g., if libraries or binaries are loaded into the
   // exact addresses where we tried to map.
   // To avoid test flake, we allow some margin of error.
-  printf ("Failed: %d\n", failures);
-  assert (failures < 32);
+  printf("Failed: %d\n", failures);
+  assert(failures < 32);
   return 0;
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/73980


More information about the llvm-commits mailing list