xref: /llvm-project/compiler-rt/test/hwasan/TestCases/print-module-map.c (revision 9ea001401caa607dccbd974df0d44b13be63de20)
1 // RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=print_module_map=1 %run %t 2>&1 | FileCheck %s --check-prefixes=EXIT,NOMORE
2 // RUN: %clang_hwasan %s -DBUG -o %t && %env_hwasan_opts=print_module_map=1 not %run %t 2>&1 | FileCheck %s --check-prefixes=EXIT,NOMORE
3 // RUN: %clang_hwasan %s -DBUG -fsanitize-recover=hwaddress -o %t && %env_hwasan_opts=print_module_map=1,halt_on_error=0 not %run %t 2>&1 | FileCheck %s --check-prefixes=EXIT,NOMORE
4 // RUN: %clang_hwasan %s -DBUG -fsanitize-recover=hwaddress -o %t && %env_hwasan_opts=print_module_map=2,halt_on_error=0 not %run %t 2>&1 | FileCheck %s --check-prefixes=BUG1,BUG2,EXIT,NOMORE
5 
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <sanitizer/hwasan_interface.h>
9 
main()10 int main() {
11   __hwasan_enable_allocator_tagging();
12 #ifdef BUG
13   char * volatile x = (char*)malloc(40);
14   free(x);
15   free(x);
16   free(x);
17 #endif
18   __hwasan_disable_allocator_tagging();
19   // BUG1: Process memory map follows:
20   // BUG1: print-module-map
21   // BUG1: End of process memory map.
22 
23   // BUG2: Process memory map follows:
24   // BUG2: print-module-map
25   // BUG2: End of process memory map.
26 
27   // EXIT: Process memory map follows:
28   // EXIT: print-module-map
29   // EXIT: End of process memory map.
30 
31   // NOMORE-NOT: Process memory map follows:
32 }
33