[compiler-rt] r335777 - Another shot at fixing android r335644 failure

Vlad Tsyrklevich via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 27 13:00:55 PDT 2018


Author: vlad.tsyrklevich
Date: Wed Jun 27 13:00:55 2018
New Revision: 335777

URL: http://llvm.org/viewvc/llvm-project?rev=335777&view=rev
Log:
Another shot at fixing android r335644 failure

The android buildbot moves the build outputs to a different directory
and rewrites the executable path, the DSO passed as an argument does not
get re-written. Use rpaths to load the DSO the same way the
test/cfi/cross-dso/ tests do and test the DSO name differently.

Modified:
    compiler-rt/trunk/test/cfi/cross-dso-diagnostic.cpp

Modified: compiler-rt/trunk/test/cfi/cross-dso-diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/cross-dso-diagnostic.cpp?rev=335777&r1=335776&r2=335777&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/cross-dso-diagnostic.cpp (original)
+++ compiler-rt/trunk/test/cfi/cross-dso-diagnostic.cpp Wed Jun 27 13:00:55 2018
@@ -1,8 +1,8 @@
 // Check that cross-DSO diagnostics print the names of both modules
 
-// RUN: %clangxx_cfi_diag -g -DSHARED_LIB -fPIC -shared -o %t_dso_suffix %s
-// RUN: %clangxx_cfi_diag -g -o %t_exe_suffix %s -ldl
-// RUN: %t_exe_suffix %t_dso_suffix 2>&1 | FileCheck %s
+// RUN: %clangxx_cfi_diag -g -DSHARED_LIB -fPIC -shared -o %dynamiclib %s %ld_flags_rpath_so
+// RUN: %clangxx_cfi_diag -g -o %t_exe_suffix %s %ld_flags_rpath_exe
+// RUN: %t_exe_suffix 2>&1 | FileCheck -DDSONAME=%xdynamiclib_filename %s
 
 // UNSUPPORTED: win32
 // REQUIRES: cxxabi
@@ -23,20 +23,25 @@ void* dso_symbol() { return new S1(); }
 
 #else
 
-int main(int argc, char *argv[]) {
-  void *handle = dlopen(argv[1], RTLD_NOW);
+int main() {
+  void* (*fp)(void) =
+      reinterpret_cast<void*(*)(void)>(dlsym(RTLD_DEFAULT, "dso_symbol"));
+  if (!fp) {
+    perror("failed to resolve dso_symbol");
+    return 1;
+  }
 
   // CHECK: runtime error: control flow integrity check for type 'void *()' failed during indirect function call
-  // CHECK: {{.*}} defined here
-  // CHECK: check failed in {{.*}}_exe_suffix, destination function located in {{.*}}_dso_suffix
-  void* (*fp)(void) =
-      reinterpret_cast<void*(*)(void)>(dlsym(handle, "dso_symbol"));
+  // CHECK: dso_symbol defined here
+  // CHECK: check failed in {{.*}}_exe_suffix, destination function located in {{.*}}[[DSONAME]]
   void *S = fp(); // trigger cfi-icall failure
 
   // CHECK: runtime error: control flow integrity check for type 'S1' failed during cast to unrelated type
   // CHECK: invalid vtable
-  // CHECK: check failed in {{.*}}_exe_suffix, vtable located in {{.*}}_dso_suffix
+  // CHECK: check failed in {{.*}}_exe_suffix, vtable located in {{.*}}[[DSONAME]]
   S1 *Scast = reinterpret_cast<S1*>(S); // trigger cfi-unrelated-cast failure
+
+  return 0;
 }
 
 #endif // SHARED_LIB




More information about the llvm-commits mailing list