[PATCH] D142188: [ORC] Fix in-process lookup of symbols without GlobalPrefix

Jonas Hahnfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 01:05:26 PST 2023


Hahnfeld created this revision.
Hahnfeld added reviewers: lhames, sunho.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

On Windows, C++ symbols are prefixed not with the "global" prefix, but with a question mark. Their symbol names must be processed without stripping the first character.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142188

Files:
  llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp


Index: llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
+++ llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
@@ -241,8 +241,6 @@
     JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) {
   orc::SymbolMap NewSymbols;
 
-  bool HasGlobalPrefix = (GlobalPrefix != '\0');
-
   for (auto &KV : Symbols) {
     auto &Name = KV.first;
 
@@ -252,11 +250,10 @@
     if (Allow && !Allow(Name))
       continue;
 
-    if (HasGlobalPrefix && (*Name).front() != GlobalPrefix)
-      continue;
+    bool StripGlobalPrefix = (GlobalPrefix != '\0' && (*Name).front() == GlobalPrefix);
 
-    std::string Tmp((*Name).data() + HasGlobalPrefix,
-                    (*Name).size() - HasGlobalPrefix);
+    std::string Tmp((*Name).data() + StripGlobalPrefix,
+                    (*Name).size() - StripGlobalPrefix);
     if (void *Addr = Dylib.getAddressOfSymbol(Tmp.c_str())) {
       NewSymbols[Name] = JITEvaluatedSymbol(
           static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(Addr)),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142188.490745.patch
Type: text/x-patch
Size: 1119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230120/c593ab09/attachment.bin>


More information about the llvm-commits mailing list