summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2019-11-20 14:12:46 +0100
committerMark Wielaard <mark@klomp.org>2019-11-21 14:56:55 +0100
commit68a322ca7fd96e993293125203854db5e0dc2691 (patch)
tree56c4aad29ffed3bd9cdff2dd70e9c10538e28ce1
parent8739082b47adf51b32ea6c4f3744ba1595785980 (diff)
downloadelfutils-debuginfod-submit-presquash.tar.gz
Try to dlopen lddebuginfod.so early during libdw.so library load.debuginfod-submit-presquash
This hopefully makes sure that the code (and the libcurl.so dependency) is loaded before the program goes into multi-threaded mode. Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r--libdwfl/debuginfod-client.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/libdwfl/debuginfod-client.c b/libdwfl/debuginfod-client.c
index 37a4c71f..ee604ad9 100644
--- a/libdwfl/debuginfod-client.c
+++ b/libdwfl/debuginfod-client.c
@@ -46,32 +46,7 @@ get_client (Dwfl *dwfl)
if (dwfl->debuginfod != NULL)
return dwfl->debuginfod;
- if (fp_debuginfod_begin == NULL)
- {
- void *debuginfod_so = dlopen("libdebuginfod-" VERSION ".so", RTLD_LAZY);
-
- if (debuginfod_so == NULL)
- debuginfod_so = dlopen("libdebuginfod.so", RTLD_LAZY);
-
- if (debuginfod_so != NULL)
- {
- fp_debuginfod_begin = dlsym (debuginfod_so, "debuginfod_begin");
- fp_debuginfod_find_executable = dlsym (debuginfod_so,
- "debuginfod_find_executable");
- fp_debuginfod_find_debuginfo = dlsym (debuginfod_so,
- "debuginfod_find_debuginfo");
- fp_debuginfod_end = dlsym (debuginfod_so, "debuginfod_end");
- }
-
- if (fp_debuginfod_begin == NULL
- || fp_debuginfod_find_executable == NULL
- || fp_debuginfod_find_debuginfo == NULL
- || fp_debuginfod_end == NULL)
- fp_debuginfod_begin = (void *) -1; /* never try again */
- }
-
- if (fp_debuginfod_begin != NULL
- && fp_debuginfod_begin != (void *) -1)
+ if (fp_debuginfod_begin != NULL)
{
dwfl->debuginfod = (*fp_debuginfod_begin) ();
return dwfl->debuginfod;
@@ -120,3 +95,37 @@ __libdwfl_debuginfod_end (debuginfod_client *c)
if (c != NULL)
(*fp_debuginfod_end) (c);
}
+
+/* Try to get the libdebuginfod library functions to make sure
+ everything is initialized early. */
+void __attribute__ ((constructor))
+__libdwfl_debuginfod_init (void)
+{
+ void *debuginfod_so = dlopen("libdebuginfod-" VERSION ".so", RTLD_LAZY);
+
+ if (debuginfod_so == NULL)
+ debuginfod_so = dlopen("libdebuginfod.so", RTLD_LAZY);
+
+ if (debuginfod_so != NULL)
+ {
+ fp_debuginfod_begin = dlsym (debuginfod_so, "debuginfod_begin");
+ fp_debuginfod_find_executable = dlsym (debuginfod_so,
+ "debuginfod_find_executable");
+ fp_debuginfod_find_debuginfo = dlsym (debuginfod_so,
+ "debuginfod_find_debuginfo");
+ fp_debuginfod_end = dlsym (debuginfod_so, "debuginfod_end");
+
+ /* We either get them all, or we get none. */
+ if (fp_debuginfod_begin == NULL
+ || fp_debuginfod_find_executable == NULL
+ || fp_debuginfod_find_debuginfo == NULL
+ || fp_debuginfod_end == NULL)
+ {
+ fp_debuginfod_begin = NULL;
+ fp_debuginfod_find_executable = NULL;
+ fp_debuginfod_find_debuginfo = NULL;
+ fp_debuginfod_end = NULL;
+ dlclose (debuginfod_so);
+ }
+ }
+}