[llvm-commits] [Patch Proposal] add to unittests/JIT, capability of looking up an indirect symbol
NAKAMURA Takumi
geek4civic at gmail.com
Sun Aug 15 04:34:46 PDT 2010
Good evening!
Win32.DLL resolves function entries with IAT(indirect pointer call/jmp).
In opposite, llvm::getPointerToNamedFunction() gets the address of
function entries directly in DLL.
At comparing pointers, this patch enables trying fetching indirect pointer value
when the function entry is indirect "jmp *XXX".
TODO: it should be enhanced for Win x64.
...Takumi
-------------- next part --------------
diff --git a/unittests/ExecutionEngine/JIT/MultiJITTest.cpp b/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
index 8997d39..374ecdc 100644
--- a/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
+++ b/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
@@ -157,8 +157,20 @@ TEST(MultiJitTest, JitPool) {
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);
+ static intptr_t fa = (intptr_t)&getPointerToNamedFunction;
+ EXPECT_TRUE(fa != 0);
+#ifdef __i386__
+ // FF 25 xxxxxxxx: jmp *xxxxxxxx
+ if (sa != fa && memcmp((char *)fa, "\xFF\x25", 2) == 0) {
+ fa = *(intptr_t *)(fa + 2);
+ EXPECT_TRUE(fa != 0);
+ fa = *(intptr_t *)fa;
+ }
+#endif
+ EXPECT_TRUE(sa == fa);
}
} // anonymous namespace
More information about the llvm-commits
mailing list