Skip to content

Commit fa08100

Browse files
committed
add logging in utils_get_symbol_addr
1 parent 77ef32a commit fa08100

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/utils/utils_load_library.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616
#include <libloaderapi.h>
1717
// clang-format on
1818

19-
#else
19+
#else // _WIN32
2020

2121
#define _GNU_SOURCE 1
2222

2323
#include <dlfcn.h> // forces linking with libdl on Linux
2424

25-
#endif
25+
#endif // !_WIN32
26+
27+
#include <stddef.h>
2628

2729
#include "utils_load_library.h"
30+
#include "utils_log.h"
2831

2932
#ifdef _WIN32
3033

@@ -47,7 +50,13 @@ void *utils_get_symbol_addr(void *handle, const char *symbol,
4750
}
4851
handle = GetModuleHandle(libname);
4952
}
50-
return (void *)GetProcAddress((HMODULE)handle, symbol);
53+
54+
void *addr = (void *)GetProcAddress((HMODULE)handle, symbol);
55+
if (addr == NULL) {
56+
LOG_ERR("Required symbol not found: %s", symbol);
57+
}
58+
59+
return addr;
5160
}
5261

5362
#else /* Linux */
@@ -68,7 +77,13 @@ void *utils_get_symbol_addr(void *handle, const char *symbol,
6877
if (!handle) {
6978
handle = RTLD_DEFAULT;
7079
}
71-
return dlsym(handle, symbol);
80+
81+
void *addr = dlsym(handle, symbol);
82+
if (addr == NULL) {
83+
LOG_ERR("Required symbol not found: %s", symbol);
84+
}
85+
86+
return addr;
7287
}
7388

7489
#endif

0 commit comments

Comments
 (0)