From: Mark Young Date: Tue, 16 May 2017 03:35:47 +0000 (-0600) Subject: loader: Modify ICD dlopen to use RTLD_NOW X-Git-Tag: sdk-1.0.51.0~202 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a480e11deebf69a1b1dfebccd5314492409db601;p=platform%2Fupstream%2FVulkan-LoaderAndValidationLayers.git loader: Modify ICD dlopen to use RTLD_NOW 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 --- diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h index 436f3b4..0f71d9a 100644 --- a/loader/vk_loader_platform.h +++ b/loader/vk_loader_platform.h @@ -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); }