Skip to content

Commit 7b7cea7

Browse files
committed
Print dlerror in utils_open_library() and utils_get_symbol_addr()
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent dffe4e6 commit 7b7cea7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/utils/utils_load_library.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ void *utils_open_library(const char *filename, int userFlags) {
6666
if (userFlags & UMF_UTIL_OPEN_LIBRARY_GLOBAL) {
6767
dlopenFlags |= RTLD_GLOBAL;
6868
}
69-
return dlopen(filename, dlopenFlags);
69+
70+
void *handle = dlopen(filename, dlopenFlags);
71+
if (handle == NULL) {
72+
LOG_FATAL("dlopen(%s) failed with error: %s", filename, dlerror());
73+
}
74+
75+
return handle;
7076
}
7177

7278
int utils_close_library(void *handle) { return dlclose(handle); }
@@ -80,7 +86,7 @@ void *utils_get_symbol_addr(void *handle, const char *symbol,
8086

8187
void *addr = dlsym(handle, symbol);
8288
if (addr == NULL) {
83-
LOG_ERR("Required symbol not found: %s", symbol);
89+
LOG_ERR("required symbol not found: %s (error: %s)", symbol, dlerror());
8490
}
8591

8692
return addr;

0 commit comments

Comments
 (0)