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

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 17:22:35 PDT 2016


Author: lhames
Date: Wed Aug 17 19:22:34 2016
New Revision: 279016

URL: http://llvm.org/viewvc/llvm-project?rev=279016&view=rev
Log:
[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!


Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
    llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp?rev=279016&r1=279015&r2=279016&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp Wed Aug 17 19:22:34 2016
@@ -265,8 +265,8 @@ RTDyldMemoryManager::getSymbolAddressInP
   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

Modified: llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp?rev=279016&r1=279015&r2=279016&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp Wed Aug 17 19:22:34 2016
@@ -139,8 +139,8 @@ TEST_F(ExecutionEngineTest, LookupWithMa
   // 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




More information about the llvm-commits mailing list