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
// 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); }