public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdwfl: Find and handle compressed vmlinuz image.
@ 2019-12-05 14:21 Mark Wielaard
  2019-12-09 19:24 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2019-12-05 14:21 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Aaron Merey, Frank Ch . Eigler, Mark Wielaard

Both the dwfl_linux_kernel_find_elf callback and the
dwfl_linux_kernel_report_offline reporting function only handled
vmlinix images possibly compressed with .gz, .bz2 or .xz extension.
They did not find or handle the much more common vmlinuz compressed
images.

It is not completely clear why we didn't up to now. Support for
compressed ELF files was added in 2009 and the code was updated to
to try to find the .gz, .bz2 or .xz extension variants in 2011.
But not the vmlinuz named variant.

Reported-by: Aaron Merey <amerey@redhat.com>
Tested-by: Frank Ch. Eigler <fche@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdwfl/ChangeLog              |  5 +++++
 libdwfl/linux-kernel-modules.c | 23 +++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index b8222189..b6b427d4 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-05  Mark Wielaard  <mark@klomp.org>
+
+	* linux-kernel-modules.c (find_kernel_elf): Also try to find
+	vmlinux image.
+
 2019-10-28  Aaron Merey  <amerey@redhat.com>
 
 	* dwfl_build_id_find_elf.c (dwfl_build_id_find_elf): Call debuginfod
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index d46ab5aa..48fb1ff0 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -174,6 +174,8 @@ kernel_release (void)
 static int
 find_kernel_elf (Dwfl *dwfl, const char *release, char **fname)
 {
+  /* First try to find an uncompressed vmlinux image.  Possibly
+     including debuginfo.  */
   if ((release[0] == '/'
        ? asprintf (fname, "%s/vmlinux", release)
        : asprintf (fname, "/boot/vmlinux-%s", release)) < 0)
@@ -188,6 +190,27 @@ find_kernel_elf (Dwfl *dwfl, const char *release, char **fname)
       fd = try_kernel_name (dwfl, fname, true);
     }
 
+  /* There might be a compressed vmlinuz image.  Probably without
+     debuginfo, but try to find it under the debug path also, just in
+     case.  */
+  if (fd < 0)
+    {
+      free (*fname);
+      if ((release[0] == '/'
+           ? asprintf (fname, "%s/vmlinuz", release)
+           : asprintf (fname, "/boot/vmlinuz-%s", release)) < 0)
+        return -1;
+
+      fd = try_kernel_name (dwfl, fname, true);
+      if (fd < 0 && release[0] != '/')
+	{
+	  free (*fname);
+	  if (asprintf (fname, MODULEDIRFMT "/vmlinuz", release) < 0)
+	    return -1;
+	  fd = try_kernel_name (dwfl, fname, true);
+	}
+    }
+
   return fd;
 }
 
-- 
2.18.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libdwfl: Find and handle compressed vmlinuz image.
  2019-12-05 14:21 [PATCH] libdwfl: Find and handle compressed vmlinuz image Mark Wielaard
@ 2019-12-09 19:24 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2019-12-09 19:24 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Aaron Merey, Frank Ch . Eigler

On Thu, 2019-12-05 at 15:21 +0100, Mark Wielaard wrote:
> Both the dwfl_linux_kernel_find_elf callback and the
> dwfl_linux_kernel_report_offline reporting function only handled
> vmlinix images possibly compressed with .gz, .bz2 or .xz extension.
> They did not find or handle the much more common vmlinuz compressed
> images.
> 
> It is not completely clear why we didn't up to now. Support for
> compressed ELF files was added in 2009 and the code was updated to
> to try to find the .gz, .bz2 or .xz extension variants in 2011.
> But not the vmlinuz named variant.

Testing (against systemtap) looks good. Pushed to master.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-09 19:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05 14:21 [PATCH] libdwfl: Find and handle compressed vmlinuz image Mark Wielaard
2019-12-09 19:24 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).