[compiler-rt] r335943 - [cfi] Reset i-cache after copying code in test.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 28 17:38:26 PDT 2018


Author: eugenis
Date: Thu Jun 28 17:38:26 2018
New Revision: 335943

URL: http://llvm.org/viewvc/llvm-project?rev=335943&view=rev
Log:
[cfi] Reset i-cache after copying code in test.

Fixes intermittent crashes on Android.
Also add PROT_READ to the code mapping for no real reason.

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

Modified: compiler-rt/trunk/test/cfi/cross-dso/icall/dlopen.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/cross-dso/icall/dlopen.cpp?rev=335943&r1=335942&r2=335943&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/cross-dso/icall/dlopen.cpp (original)
+++ compiler-rt/trunk/test/cfi/cross-dso/icall/dlopen.cpp Thu Jun 28 17:38:26 2018
@@ -83,10 +83,12 @@ static void save_code(char *p) {
 }
 
 static void restore_code() {
-  char *code = (char *)mmap(real_start, kCodeSize, PROT_WRITE | PROT_EXEC,
-                            MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, 0, 0);
+  char *code =
+      (char *)mmap(real_start, kCodeSize, PROT_READ | PROT_WRITE | PROT_EXEC,
+                   MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, 0, 0);
   assert(code == real_start);
   memcpy(code, saved_code, kCodeSize);
+  __clear_cache(code, code + kCodeSize);
 }
 
 int main(int argc, char *argv[]) {




More information about the llvm-commits mailing list