From 9344c0d9373dcd323c9709033bfd97f17407ad55 Mon Sep 17 00:00:00 2001 From: Alexander Aksenov Date: Tue, 17 Jan 2017 15:48:27 +0300 Subject: [PATCH] Change dlsym flags RTLD_NEXT -> RTLD_DEFAULT. Library loading time is unpredictable, so target symbol can be anywhere in linker list and this lead to real func searching fails somethimes. Our probes have not the same name as target functions so, it is good and safety to use RTLD_DEFAULT instead of RTLD_NEXT. Change-Id: I7900631e2edefc5e5e6f5bfd922e3974a7a37ac8 Signed-off-by: Alexander Aksenov --- include/binproto.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/binproto.h b/include/binproto.h index c190781..77e1dd4 100644 --- a/include/binproto.h +++ b/include/binproto.h @@ -540,7 +540,7 @@ DEF_WKC(_ret, _name, __VA_ARGS__) \ struct probe_data_t pd; \ void *func; \ \ - func = dlsym(RTLD_NEXT, #_name); \ + func = dlsym(RTLD_DEFAULT, #_name); \ if (func == NULL || dlerror() != NULL) { \ PRINTERR("Cannot find function <%s>, terminate!", #_name); \ exit(1); \ @@ -604,7 +604,7 @@ DEF_WKC(_ret, _name, __VA_ARGS__) \ struct probe_data_t pd; \ void *func; \ \ - func = dlsym(RTLD_NEXT, #_name); \ + func = dlsym(RTLD_DEFAULT, #_name); \ if (func == NULL || dlerror() != NULL) { \ PRINTERR("Cannot find function <%s>, terminate!", #_name); \ exit(1); \ @@ -683,7 +683,7 @@ DEF_WKCV(_ret, _name, __VA_ARGS__) \ struct probe_data_t pd; \ void *exec; \ \ - exec = dlsym(RTLD_NEXT, #_name); \ + exec = dlsym(RTLD_DEFAULT, #_name); \ if (exec == NULL || dlerror() != NULL) { \ PRINTERR("Cannot find function <%s>, terminate!", #_name); \ exit(1); \ @@ -751,7 +751,7 @@ DEF_WKC(_ret, _name, __VA_ARGS__) throw _throw \ struct probe_data_t pd; \ void *func; \ \ - func = dlsym(RTLD_NEXT, #_name); \ + func = dlsym(RTLD_DEFAULT, #_name); \ if (func == NULL || dlerror() != NULL) { \ PRINTERR("Cannot find function <%s>, terminate!", #_name); \ exit(1); \ -- 2.7.4