mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-16 16:16:45 +00:00
Alternative fix to make sure that the extern declarations used by
DynamicLibrary::SearchForAddressOfSymbol refer to declarations in the global namespace. llvm-svn: 92023
This commit is contained in:
parent
44f2fe915f
commit
0f306eba2f
@ -69,29 +69,7 @@ bool DynamicLibrary::LoadLibraryPermanently(const char *Filename,
|
||||
return false;
|
||||
}
|
||||
|
||||
void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
|
||||
// First check symbols added via AddSymbol().
|
||||
if (ExplicitSymbols) {
|
||||
std::map<std::string, void *>::iterator I =
|
||||
ExplicitSymbols->find(symbolName);
|
||||
std::map<std::string, void *>::iterator E = ExplicitSymbols->end();
|
||||
|
||||
if (I != E)
|
||||
return I->second;
|
||||
}
|
||||
|
||||
// Now search the libraries.
|
||||
if (OpenedHandles) {
|
||||
for (std::vector<void *>::iterator I = OpenedHandles->begin(),
|
||||
E = OpenedHandles->end(); I != E; ++I) {
|
||||
//lt_ptr ptr = lt_dlsym(*I, symbolName);
|
||||
void *ptr = dlsym(*I, symbolName);
|
||||
if (ptr) {
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void *SearchForAddressOfSpecialSymbol(const char* symbolName) {
|
||||
#define EXPLICIT_SYMBOL(SYM) \
|
||||
extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM
|
||||
|
||||
@ -128,6 +106,34 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
|
||||
#endif
|
||||
|
||||
#undef EXPLICIT_SYMBOL
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
|
||||
// First check symbols added via AddSymbol().
|
||||
if (ExplicitSymbols) {
|
||||
std::map<std::string, void *>::iterator I =
|
||||
ExplicitSymbols->find(symbolName);
|
||||
std::map<std::string, void *>::iterator E = ExplicitSymbols->end();
|
||||
|
||||
if (I != E)
|
||||
return I->second;
|
||||
}
|
||||
|
||||
// Now search the libraries.
|
||||
if (OpenedHandles) {
|
||||
for (std::vector<void *>::iterator I = OpenedHandles->begin(),
|
||||
E = OpenedHandles->end(); I != E; ++I) {
|
||||
//lt_ptr ptr = lt_dlsym(*I, symbolName);
|
||||
void *ptr = dlsym(*I, symbolName);
|
||||
if (ptr) {
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (void *Result = SearchForAddressOfSpecialSymbol(symbolName))
|
||||
return Result;
|
||||
|
||||
// This macro returns the address of a well-known, explicit symbol
|
||||
#define EXPLICIT_SYMBOL(SYM) \
|
||||
|
Loading…
Reference in New Issue
Block a user