OSDN Git Service

dlopen() has no NO_LOAD option before Android L.
authorPing-Hao Wu <pinghao@google.com>
Fri, 20 Mar 2015 20:15:56 +0000 (13:15 -0700)
committerGreg Hartman <ghartman@google.com>
Wed, 25 Mar 2015 16:52:50 +0000 (16:52 +0000)
This change could result in multiple instances of the shared library being
loaded when using alternate paths. This will be addressed by b/18752589.

Change-Id: Icf26a0c6f76edfd4f1c710e14f1005138d97e77a
Reviewed-on: https://swiftshader-review.googlesource.com/2664
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
src/Common/SharedLibrary.hpp

index b9d5a51..adaa7fc 100644 (file)
@@ -74,14 +74,19 @@ void *loadLibrary(const char *(&names)[n])
 \r
        inline void *getLibraryHandle(const char *path)\r
        {\r
-               void *resident = dlopen(path, RTLD_LAZY | RTLD_NOLOAD);\r
-\r
-               if(resident)\r
-               {\r
-                       return dlopen(path, RTLD_LAZY);   // Increment reference count\r
-               }\r
-\r
-               return 0;\r
+               #ifdef __ANDROID__\r
+                       // bionic doesn't support RTLD_NOLOAD before L\r
+                       return dlopen(path, RTLD_NOW);\r
+               #else\r
+                       void *resident = dlopen(path, RTLD_LAZY | RTLD_NOLOAD);\r
+\r
+                       if(resident)\r
+                       {\r
+                               return dlopen(path, RTLD_LAZY);   // Increment reference count\r
+                       }\r
+\r
+                       return 0;\r
+               #endif\r
        }\r
 \r
     inline void freeLibrary(void *library)\r