[llvm-commits] [llvm] r144178 - /llvm/trunk/unittests/ExecutionEngine/JIT/MultiJITTest.cpp

NAKAMURA Takumi geek4civic at gmail.com
Wed Nov 9 00:30:43 PST 2011


Author: chapuni
Date: Wed Nov  9 02:30:43 2011
New Revision: 144178

URL: http://llvm.org/viewvc/llvm-project?rev=144178&view=rev
Log:
unittests/MultiJITTest.cpp: Tweak how to check symbol value for Win32 --enable-shared.

getPointerToNamedFunction might be indirect jump on Win32 --enable-shared.
FF 25 <disp32>: jmp *(pointer to IAT)

Modified:
    llvm/trunk/unittests/ExecutionEngine/JIT/MultiJITTest.cpp

Modified: llvm/trunk/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/MultiJITTest.cpp?rev=144178&r1=144177&r2=144178&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/MultiJITTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/MultiJITTest.cpp Wed Nov  9 02:30:43 2011
@@ -160,8 +160,21 @@
   EXPECT_EQ(getPointerToNamedFunction("foo2"), foo2);
 
   // Symbol search
-  EXPECT_EQ((intptr_t)getPointerToNamedFunction("getPointerToNamedFunction"),
-            (intptr_t)&getPointerToNamedFunction);
+  intptr_t
+    sa = (intptr_t)getPointerToNamedFunction("getPointerToNamedFunction");
+  EXPECT_TRUE(sa != 0);
+  intptr_t fa = (intptr_t)&getPointerToNamedFunction;
+  EXPECT_TRUE(fa != 0);
+#ifdef __i386__
+  // getPointerToNamedFunction might be indirect jump on Win32 --enable-shared.
+  // FF 25 <disp32>: jmp *(pointer to IAT)
+  if (sa != fa && memcmp((char *)fa, "\xFF\x25", 2) == 0) {
+    fa = *(intptr_t *)(fa + 2); // Address to IAT
+    EXPECT_TRUE(fa != 0);
+    fa = *(intptr_t *)fa;       // Bound value of IAT
+  }
+#endif
+  EXPECT_TRUE(sa == fa);
 }
 #endif  // !defined(__arm__)
 





More information about the llvm-commits mailing list