[compiler-rt] r182461 - [asan] fix dlclose-test to work with non-4K pages. Properly disable interface_symbols_linux on non-x86

Kostya Serebryany kcc at google.com
Wed May 22 03:20:10 PDT 2013


Author: kcc
Date: Wed May 22 05:20:10 2013
New Revision: 182461

URL: http://llvm.org/viewvc/llvm-project?rev=182461&view=rev
Log:
[asan] fix dlclose-test to work with non-4K pages. Properly disable interface_symbols_linux on non-x86

Modified:
    compiler-rt/trunk/lib/asan/lit_tests/Linux/interface_symbols_linux.c
    compiler-rt/trunk/lib/asan/lit_tests/dlclose-test.cc

Modified: compiler-rt/trunk/lib/asan/lit_tests/Linux/interface_symbols_linux.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/Linux/interface_symbols_linux.c?rev=182461&r1=182460&r2=182461&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/Linux/interface_symbols_linux.c (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/Linux/interface_symbols_linux.c Wed May 22 05:20:10 2013
@@ -29,6 +29,6 @@
 
 // FIXME: nm -D on powerpc somewhy shows ASan interface symbols residing
 // in "initialized data section".
-// XFAIL: powerpc-supported-arch
+// REQUIRES: x86_64-supported-target,i386-supported-target
 
 int main() { return 0; }

Modified: compiler-rt/trunk/lib/asan/lit_tests/dlclose-test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/dlclose-test.cc?rev=182461&r1=182460&r2=182461&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/dlclose-test.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/dlclose-test.cc Wed May 22 05:20:10 2013
@@ -9,6 +9,11 @@
 // are globals.
 // 6. BOOM
 
+// This sublte test assumes that after a foo.so is dlclose-d
+// we can mmap the region of memory that has been occupied by the library.
+// It works on i368/x86_64 Linux, but not necessary anywhere else.
+// REQUIRES: x86_64-supported-target,i386-supported-target
+
 // RUN: %clangxx_asan -m64 -O0 %p/SharedLibs/dlclose-test-so.cc \
 // RUN:     -fPIC -shared -o %t-so.so
 // RUN: %clangxx_asan -m64 -O0 %s -o %t && %t 2>&1 | FileCheck %s
@@ -44,12 +49,11 @@
 
 using std::string;
 
-static const int kPageSize = 4096;
-
 typedef int *(fun_t)();
 
 int main(int argc, char *argv[]) {
   string path = string(argv[0]) + "-so.so";
+  size_t PageSize = sysconf(_SC_PAGESIZE);
   printf("opening %s ... \n", path.c_str());
   void *lib = dlopen(path.c_str(), RTLD_NOW);
   if (!lib) {
@@ -73,8 +77,8 @@ int main(int argc, char *argv[]) {
     return 1;
   }
   // Now, the page where 'addr' is unmapped. Map it.
-  size_t page_beg = ((size_t)addr) & ~(kPageSize - 1);
-  void *res = mmap((void*)(page_beg), kPageSize,
+  size_t page_beg = ((size_t)addr) & ~(PageSize - 1);
+  void *res = mmap((void*)(page_beg), PageSize,
                    PROT_READ | PROT_WRITE,
                    MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE, 0, 0);
   if (res == (char*)-1L) {





More information about the llvm-commits mailing list