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)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144178 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
NAKAMURA Takumi 2011-11-09 08:30:43 +00:00
parent 0a15035f52
commit 94d80da4a0

View File

@ -160,8 +160,21 @@ TEST(MultiJitTest, JitPool) {
EXPECT_EQ(getPointerToNamedFunction("foo2"), foo2); EXPECT_EQ(getPointerToNamedFunction("foo2"), foo2);
// Symbol search // Symbol search
EXPECT_EQ((intptr_t)getPointerToNamedFunction("getPointerToNamedFunction"), intptr_t
(intptr_t)&getPointerToNamedFunction); 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__) #endif // !defined(__arm__)