summaryrefslogtreecommitdiff
path: root/test/cfi
diff options
context:
space:
mode:
authorVlad Tsyrklevich <vlad@tsyrklevich.net>2018-06-27 20:00:55 +0000
committerVlad Tsyrklevich <vlad@tsyrklevich.net>2018-06-27 20:00:55 +0000
commit6fa838ae17fedeee52b6b49f47510bee31062bec (patch)
treed3825e61280bf4f7d2a34806cdf0f630b7d24570 /test/cfi
parente833fe37b0abc09640c727ab55449d6e96a3e61e (diff)
downloadcompiler-rt-6fa838ae17fedeee52b6b49f47510bee31062bec.tar.gz
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/cfi')
-rw-r--r--test/cfi/cross-dso-diagnostic.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/test/cfi/cross-dso-diagnostic.cpp b/test/cfi/cross-dso-diagnostic.cpp
index e13248132..de5aa34d4 100644
--- a/test/cfi/cross-dso-diagnostic.cpp
+++ b/test/cfi/cross-dso-diagnostic.cpp
@@ -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