Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the handle from dlopen and not from debug infos #143

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/gotcha_dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static void *dlopen_wrapper(const char *filename, int flags) {
}

static void *dlsym_wrapper(void *handle, const char *symbol_name) {
typeof(&dlopen_wrapper) orig_dlopen = gotcha_get_wrappee(orig_dlopen_handle);
typeof(&dlsym_wrapper) orig_dlsym = gotcha_get_wrappee(orig_dlsym_handle);
struct internal_binding_t *binding;
debug_printf(1, "User called dlsym(%p, %s)\n", handle, symbol_name);
Expand All @@ -161,7 +162,8 @@ static void *dlsym_wrapper(void *handle, const char *symbol_name) {
struct link_map *lib = gotchas_dlsym_rtld_next_lookup(
symbol_name, __builtin_return_address(0));
if (lib) {
void *symbol = orig_dlsym(lib, symbol_name);
void *handle = orig_dlopen(lib->l_name, RTLD_NOW);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a doubt between RTLD_NOW and RTLD_LAZY

void *symbol = orig_dlsym(handle, symbol_name);
return symbol;
}
return NULL;
Expand Down
Loading