Skip to content

Commit 929527a

Browse files
committed
[Support][Cygwin] Fix handling of Process symbol lookup.
In Unix/DynamicLibrary.inc, it was already known that Cygwin required use of RTLD_DEFAULT as the "Handle" parameter to DLSym to search all modules for a symbol. Unfortunately RTLD_DEFAULT is defined as NULL, so the existing checks of the "Process" handle meant DLSym would never be called on Cygwin. Add a bool to indicate whether the Process handle was set instead.
1 parent cd58586 commit 929527a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Support/DynamicLibrary.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class DynamicLibrary::HandleSet {
2626
typedef std::vector<void *> HandleList;
2727
HandleList Handles;
2828
void *Process = nullptr;
29+
bool ProcessAdded = false;
2930

3031
public:
3132
static void *DLOpen(const char *Filename, std::string *Err);
@@ -66,6 +67,7 @@ class DynamicLibrary::HandleSet {
6667
}
6768
#endif
6869
Process = Handle;
70+
ProcessAdded = true;
6971
}
7072
return true;
7173
}
@@ -97,11 +99,11 @@ class DynamicLibrary::HandleSet {
9799
assert(!((Order & SO_LoadedFirst) && (Order & SO_LoadedLast)) &&
98100
"Invalid Ordering");
99101

100-
if (!Process || (Order & SO_LoadedFirst)) {
102+
if (!ProcessAdded || (Order & SO_LoadedFirst)) {
101103
if (void *Ptr = LibLookup(Symbol, Order))
102104
return Ptr;
103105
}
104-
if (Process) {
106+
if (ProcessAdded) {
105107
// Use OS facilities to search the current binary and all loaded libs.
106108
if (void *Ptr = DLSym(Process, Symbol))
107109
return Ptr;

0 commit comments

Comments
 (0)