Skip to content

Commit

Permalink
Try to find dlopen/dlsym from libc.so too (musl libc, glibc 2.34+)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackun committed Sep 27, 2021
1 parent cd43374 commit ced84ec
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/real_dlsym.cpp
Expand Up @@ -18,19 +18,26 @@ static bool print_dlsym = getenv("MANGOHUD_DEBUG_DLSYM") != nullptr;
void get_real_functions()
{
eh_obj_t libdl;
int ret;

if (eh_find_obj(&libdl, "*libdl.so*")) {
fprintf(stderr, "can't get libdl.so\n");
#if defined(__GLIBC__)
ret = eh_find_obj(&libdl, "*libdl.so*");
if (ret)
#endif
ret = eh_find_obj(&libdl, "*libc.so*"); // musl, glibc 2.34+

if (ret) {
fprintf(stderr, "MANGOHUD: Cannot find libdl.so and libc.so\n");
exit(1);
}

if (eh_find_sym(&libdl, "dlopen", (void **) &__dlopen)) {
fprintf(stderr, "can't get dlopen()\n");
fprintf(stderr, "MANGOHUD: Can't get dlopen()\n");
exit(1);
}

if (eh_find_sym(&libdl, "dlsym", (void **) &__dlsym)) {
fprintf(stderr, "can't get dlsym()\n");
fprintf(stderr, "MANGOHUD: Can't get dlsym()\n");
exit(1);
}

Expand Down

0 comments on commit ced84ec

Please sign in to comment.