[cfi][test] cross-dso/stats.cpp: don't assume the order of static constructors
authorFangrui Song <maskray@google.com>
Wed, 8 Jan 2020 23:44:35 +0000 (15:44 -0800)
committerFangrui Song <maskray@google.com>
Wed, 8 Jan 2020 23:50:51 +0000 (15:50 -0800)
__sanitizer_stat_init is called for the executable first, then the
shared object. In WriterModuleReport(), the information for the shared
object will be recorded first. It'd be nice to get rid of the order
requirement of static constructors. (This should make .ctors platforms
work.)

compiler-rt/test/cfi/cross-dso/stats.cpp

index 09a7217..9d8c2ee 100644 (file)
@@ -22,24 +22,24 @@ extern "C" void nvcall(A *a);
 #ifdef SHARED_LIB
 
 extern "C" __attribute__((noinline)) void vcall(A *a) {
-  // CHECK: stats.cpp:[[@LINE+1]] vcall.cfi cfi-vcall 37
+  // CHECK-DAG: stats.cpp:[[@LINE+1]] vcall.cfi cfi-vcall 37
   a->vf();
 }
 
 extern "C" __attribute__((noinline)) void nvcall(A *a) {
-  // CHECK: stats.cpp:[[@LINE+1]] nvcall.cfi cfi-nvcall 51
+  // CHECK-DAG: stats.cpp:[[@LINE+1]] nvcall.cfi cfi-nvcall 51
   a->nvf();
 }
 
 #else
 
 extern "C" __attribute__((noinline)) A *dcast(A *a) {
-  // CHECK: stats.cpp:[[@LINE+1]] dcast.cfi cfi-derived-cast 24
+  // CHECK-DAG: stats.cpp:[[@LINE+1]] dcast.cfi cfi-derived-cast 24
   return (A *)(ABase *)a;
 }
 
 extern "C" __attribute__((noinline)) A *ucast(A *a) {
-  // CHECK: stats.cpp:[[@LINE+1]] ucast.cfi cfi-unrelated-cast 81
+  // CHECK-DAG: stats.cpp:[[@LINE+1]] ucast.cfi cfi-unrelated-cast 81
   return (A *)(char *)a;
 }