loader: Modify ICD dlopen to use RTLD_NOW
authorMark Young <marky@lunarg.com>
Tue, 16 May 2017 03:35:47 +0000 (21:35 -0600)
committerMark Young <marky@lunarg.com>
Tue, 16 May 2017 13:54:56 +0000 (07:54 -0600)
Pierre-Loup at Valve caught this.  By using RTLD_NOW on dlopen
it fails if symbols are not resolved at dlopen time.  This resolves
an error where an ICD is missing a symbol on a system causing
the loader to fail later at an unrecoverable time.

Change-Id: Icf43fd36aebfbcb4b08e7e3891570161234118f7

loader/vk_loader_platform.h

index 436f3b4..0f71d9a 100644 (file)
@@ -98,7 +98,10 @@ static inline char *loader_platform_dirname(char *path) { return dirname(path);
 // Dynamic Loading of libraries:
 typedef void *loader_platform_dl_handle;
 static inline loader_platform_dl_handle loader_platform_open_library(const char *libPath) {
-    return dlopen(libPath, RTLD_LAZY | RTLD_LOCAL);
+    // When loading the library, we need to make sure we load it with RTLD_NOW to force
+    // symbol resolution at the time of load.  This way, we make sure that all appropriate
+    // symbols are there.
+    return dlopen(libPath, RTLD_NOW | RTLD_LOCAL);
 }
 static inline const char *loader_platform_open_library_error(const char *libPath) { return dlerror(); }
 static inline void loader_platform_close_library(loader_platform_dl_handle library) { dlclose(library); }