Index: base/native_library_linux.cc |
diff --git a/base/native_library_linux.cc b/base/native_library_linux.cc |
index d14941332f0fab69a5b305af9ff03b154e58a1d7..b8e51733c6c83252315bf854b75072930430e3b4 100644 |
--- a/base/native_library_linux.cc |
+++ b/base/native_library_linux.cc |
@@ -5,16 +5,37 @@ |
#include "base/native_library.h" |
#include <dlfcn.h> |
+#include <set> |
#include "base/file_path.h" |
#include "base/logging.h" |
+#include "base/singleton.h" |
#include "base/string_util.h" |
namespace base { |
+typedef std::set<FilePath> FilePathSet; |
+struct ShallowBindPathDifferentiatingType { }; |
+typedef Singleton<FilePathSet, |
+ DefaultSingletonTraits<FilePathSet>, |
+ ShallowBindPathDifferentiatingType> ShallowBindPathSingleton; |
+ |
+void AddShallowBindPath(const FilePath& library_path) { |
+ FilePathSet *file_path_set = ShallowBindPathSingleton::get(); |
+ file_path_set->insert(library_path); |
+} |
+ |
+bool IsShallowBindPath(const FilePath& library_path) { |
+ FilePathSet *file_path_set = ShallowBindPathSingleton::get(); |
+ return file_path_set->find(library_path) != file_path_set->end(); |
+} |
+ |
// static |
NativeLibrary LoadNativeLibrary(const FilePath& library_path) { |
- void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY|RTLD_DEEPBIND); |
+ int flags = RTLD_LAZY; |
+ if (!IsShallowBindPath(library_path)) |
+ flags |= RTLD_DEEPBIND; |
+ void* dl = dlopen(library_path.value().c_str(), flags); |
if (!dl) { |
LOG(ERROR) << "dlopen failed when trying to open " << library_path.value() |
<< ": " << dlerror(); |