[RuntimeDyld] Strip leading '_' from symbols on 32-bit windows in

RTDyldMemoryManager::getSymbolAddressInProcess()

This should allow JIT'd code for win32 to find in-process symbols. See
http://llvm.org/PR28699 .

Patch by James Holderness. Thanks James!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279016 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames 2016-08-18 00:22:34 +00:00
parent a53e50c418
commit 5bc5c47fda
2 changed files with 4 additions and 4 deletions

View File

@ -265,8 +265,8 @@ RTDyldMemoryManager::getSymbolAddressInProcess(const std::string &Name) {
const char *NameStr = Name.c_str();
// DynamicLibrary::SearchForAddresOfSymbol expects an unmangled 'C' symbol
// name so ff we're on Darwin, strip the leading '_' off.
#ifdef __APPLE__
// name so if we're on Darwin or 32-bit Windows, strip the leading '_' off.
#if defined(__APPLE__) || (defined(_WIN32) && !defined(_WIN64))
if (NameStr[0] == '_')
++NameStr;
#endif

View File

@ -139,8 +139,8 @@ TEST_F(ExecutionEngineTest, LookupWithMangledAndDemangledSymbol) {
// RTDyldMemoryManager::getSymbolAddressInProcess expects a mangled symbol,
// but DynamicLibrary is a wrapper for dlsym, which expects the unmangled C
// symbol name. This test verifies that getSymbolAddressInProcess strips the
// leading '_' on Darwin, but not on other platforms.
#ifdef __APPLE__
// leading '_' on Darwin and 32-bit Windows, but not on other platforms.
#if defined(__APPLE__) || (defined(_WIN32) && !defined(_WIN64))
EXPECT_EQ(reinterpret_cast<uint64_t>(&x),
RTDyldMemoryManager::getSymbolAddressInProcess("_x"));
#else