From d1261df41bf4963fb37cf2aeb25aa500cc4fc4d0 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Wed, 21 Apr 2021 22:35:39 -0600 Subject: [PATCH] loader: Silence wrong ELF class errors Currently the loader does not distinguish between 32 and 64 bit ELF class files. This causes `dlopen` to fail but is expected because the different ELF class libraries are located in the same directory. We can safely ignore this error. If encountered, we will report it with the INFO logging level. Change-Id: Icb8e5351208f8a413a29ea9c457bc3fdac7de292 --- loader/loader.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/loader/loader.c b/loader/loader.c index 03730945..66fcdca0 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -516,6 +516,18 @@ void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t ms fputc('\n', stderr); } +// log error from to library loading +void loader_log_load_library_error(const struct loader_instance *inst, const char *filename) { + const char *error_message = loader_platform_open_library_error(filename); + // If the error is due to incompatible ELF class, report it with INFO level + // Discussed in Github issue 262 + VkFlags err_flag = VK_DEBUG_REPORT_ERROR_BIT_EXT; + if (strstr(error_message, "wrong ELF class:") != NULL) { + err_flag = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; + } + loader_log(inst, err_flag, 0, error_message); +} + VKAPI_ATTR VkResult VKAPI_CALL vkSetInstanceDispatch(VkInstance instance, void *object) { struct loader_instance *inst = loader_get_instance(instance); if (!inst) { @@ -2299,7 +2311,7 @@ static VkResult loader_scanned_icd_add(const struct loader_instance *inst, struc handle = loader_platform_open_library(filename); #endif if (NULL == handle) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, loader_platform_open_library_error(filename)); + loader_log_load_library_error(inst, filename); goto out; } @@ -5581,7 +5593,7 @@ struct loader_instance *loader_get_instance(const VkInstance instance) { static loader_platform_dl_handle loaderOpenLayerFile(const struct loader_instance *inst, const char *chain_type, struct loader_layer_properties *prop) { if ((prop->lib_handle = loader_platform_open_library(prop->lib_name)) == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, loader_platform_open_library_error(prop->lib_name)); + loader_log_load_library_error(inst, prop->lib_name); } else { loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Loading layer library %s", prop->lib_name); }