Commit
… dynamically linked against libc
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
#include "firebird.h" | ||
#include "../common/os/mod_loader.h" | ||
#include "../common/os/os_utils.h" | ||
#include "../common/os/path_utils.h" | ||
#ifdef HAVE_UNISTD_H | ||
#include <unistd.h> | ||
#endif | ||
|
@@ -40,8 +41,9 @@ | |
class DlfcnModule : public ModuleLoader::Module | ||
{ | ||
public: | ||
DlfcnModule(void* m) | ||
: module(m) | ||
DlfcnModule(MemoryPool& pool, const Firebird::PathName& aFileName, void* m) | ||
: ModuleLoader::Module(pool, aFileName), | ||
module(m) | ||
{} | ||
|
||
~DlfcnModule(); | ||
|
@@ -109,7 +111,7 @@ ModuleLoader::Module* ModuleLoader::loadModule(const Firebird::PathName& modPath | |
system(command.c_str()); | ||
#endif | ||
|
||
return FB_NEW_POOL(*getDefaultMemoryPool()) DlfcnModule(module); | ||
return FB_NEW_POOL(*getDefaultMemoryPool()) DlfcnModule(*getDefaultMemoryPool(), modPath, module); | ||
} | ||
|
||
DlfcnModule::~DlfcnModule() | ||
|
@@ -127,6 +129,18 @@ void* DlfcnModule::findSymbol(const Firebird::string& symName) | |
|
||
result = dlsym(module, newSym.c_str()); | ||
} | ||
|
||
#ifdef HAVE_DLADDR | ||
if (!PathUtils::isRelative(fileName)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hvlad
Member
|
||
{ | ||
Dl_info info; | ||
if (!dladdr(result, &info)) | ||
return NULL; | ||
if (fileName != info.dli_fname) | ||
return NULL; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
hvlad
Member
|
||
#endif | ||
|
||
return result; | ||
} | ||
|
Why not normalize the path (as database names?) and test always? I see this now as very easy way to go wrong.
What if the .so is a symbolic link, will it work?