[PATCH] libdwfl: do not dlopen libdebuginfod.so in --disable-libdebuginfod mode

Dmitry V. Levin ldv@altlinux.org
Thu Aug 20 20:27:24 GMT 2020


debuginfod-client.c used to try to dlopen libdebuginfod.so even if
libdebuginfod was completely disabled using --disable-libdebuginfod.

Fix this by disabling build of debuginfod-client.c and disabling all
__libdwfl_debuginfod_* invocations in --disable-libdebuginfod mode.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 ChangeLog                        |  4 ++++
 configure.ac                     |  5 ++++-
 libdwfl/ChangeLog                | 13 +++++++++++++
 libdwfl/Makefile.am              |  5 ++++-
 libdwfl/dwfl_build_id_find_elf.c |  2 ++
 libdwfl/dwfl_end.c               |  2 ++
 libdwfl/find-debuginfo.c         |  2 ++
 7 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c6b526fe..0f00fade 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-08-20  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* configure.ac (--enable-libdebuginfod): AC_DEFINE ENABLE_LIBDEBUGINFOD.
+
 2020-07-17  Mark Wielaard  <mark@klomp.org>
 
 	* configure.ac: Set -DBAD_FTS=1 also for CXXFLAGS.
diff --git a/configure.ac b/configure.ac
index e2f213ab..f3f1597b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -693,7 +693,10 @@ AS_IF([test "x$enable_libdebuginfod" != "xno"], [
     fi
 ])
 
-AS_IF([test "x$enable_libdebuginfod" = "xdummy"],AC_DEFINE([DUMMY_LIBDEBUGINFOD],[1],[Build dummy libdebuginfod]))
+AS_IF([test "x$enable_libdebuginfod" = "xyes" || test "x$enable_libdebuginfod" = "xdummy"],
+      [AC_DEFINE([ENABLE_LIBDEBUGINFOD], [1], [Enable libdebuginfod])])
+AS_IF([test "x$enable_libdebuginfod" = "xdummy"],
+      [AC_DEFINE([DUMMY_LIBDEBUGINFOD], [1], [Build dummy libdebuginfod])])
 AM_CONDITIONAL([LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xyes" || test "x$enable_libdebuginfod" = "xdummy"])
 AM_CONDITIONAL([DUMMY_LIBDEBUGINFOD],[test "x$enable_libdebuginfod" = "xdummy"])
 
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index e59efd77..bf6b3ff6 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,16 @@
+2020-08-20  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* Makefile.am (libdwfl_a_SOURCES): Conditionalize
+	debuginfod-client.c on LIBDEBUGINFOD.
+	* dwfl_build_id_find_elf.c (dwfl_build_id_find_elf): Conditionalize
+	__libdwfl_debuginfod_find_executable invocation on
+	ENABLE_LIBDEBUGINFOD.
+	* dwfl_end.c (dwfl_end): Conditionalize __libdwfl_debuginfod_end
+	invocation on ENABLE_LIBDEBUGINFOD.
+	* find-debuginfo.c (dwfl_standard_find_debuginfo): Conditionalize
+	__libdwfl_debuginfod_find_debuginfo invocation on
+	ENABLE_LIBDEBUGINFOD.
+
 2020-07-05  Mark Wielaard  <mark@klomp.org>
 
 	* argp-std.c (parse_opt): Don't assert, but call fail when
diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
index 47bd62a5..1de05492 100644
--- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am
@@ -70,7 +70,7 @@ libdwfl_a_SOURCES = dwfl_begin.c dwfl_end.c dwfl_error.c dwfl_version.c \
 		    link_map.c core-file.c open.c image-header.c \
 		    dwfl_frame.c frame_unwind.c dwfl_frame_pc.c \
 		    linux-pid-attach.c linux-core-attach.c dwfl_frame_regs.c \
-		    gzip.c debuginfod-client.c
+		    gzip.c
 
 if BZLIB
 libdwfl_a_SOURCES += bzip2.c
@@ -78,6 +78,9 @@ endif
 if LZMA
 libdwfl_a_SOURCES += lzma.c
 endif
+if LIBDEBUGINFOD
+libdwfl_a_SOURCES += debuginfod-client.c
+endif
 
 libdwfl = $(libdw)
 libdw = ../libdw/libdw.so
diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
index f685c979..7b604d47 100644
--- a/libdwfl/dwfl_build_id_find_elf.c
+++ b/libdwfl/dwfl_build_id_find_elf.c
@@ -192,12 +192,14 @@ dwfl_build_id_find_elf (Dwfl_Module *mod,
     }
   else
     {
+#ifdef ENABLE_LIBDEBUGINFOD
       /* If all else fails and a build-id is available, query the
 	 debuginfo-server if enabled.  */
       if (fd < 0 && mod->build_id_len > 0)
 	fd = __libdwfl_debuginfod_find_executable (mod->dwfl,
 						   mod->build_id_bits,
 						   mod->build_id_len);
+#endif
     }
 
   if (fd < 0 && errno == 0 && mod->build_id_len > 0)
diff --git a/libdwfl/dwfl_end.c b/libdwfl/dwfl_end.c
index 4f6c722a..b1840191 100644
--- a/libdwfl/dwfl_end.c
+++ b/libdwfl/dwfl_end.c
@@ -39,7 +39,9 @@ dwfl_end (Dwfl *dwfl)
   if (dwfl == NULL)
     return;
 
+#ifdef ENABLE_LIBDEBUGINFOD
   __libdwfl_debuginfod_end (dwfl->debuginfod);
+#endif
 
   if (dwfl->process)
     __libdwfl_process_free (dwfl->process);
diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c
index eb68d549..449df5a1 100644
--- a/libdwfl/find-debuginfo.c
+++ b/libdwfl/find-debuginfo.c
@@ -401,6 +401,7 @@ dwfl_standard_find_debuginfo (Dwfl_Module *mod,
       free (canon);
     }
 
+#ifdef ENABLE_LIBDEBUGINFOD
   /* Still nothing? Try if we can use the debuginfod client.
      But note that we might be looking for the alt file.
      We use the same trick as dwfl_build_id_find_debuginfo.
@@ -422,6 +423,7 @@ dwfl_standard_find_debuginfo (Dwfl_Module *mod,
       if (bits_len > 0)
 	fd = __libdwfl_debuginfod_find_debuginfo (mod->dwfl, bits, bits_len);
     }
+#endif
 
   return fd;
 }

-- 
ldv


More information about the Elfutils-devel mailing list