Blame SOURCES/elfutils-0.178-compressed-vmlinuz.patch

73e148
commit 4a90cb11140a6bb3712228861a32e4035013ad85
73e148
Author: Mark Wielaard <mark@klomp.org>
73e148
Date:   Thu Dec 5 15:03:54 2019 +0100
73e148
73e148
    libdwfl: Find and handle compressed vmlinuz image.
73e148
    
73e148
    Both the dwfl_linux_kernel_find_elf callback and the
73e148
    dwfl_linux_kernel_report_offline reporting function only handled
73e148
    vmlinix images possibly compressed with .gz, .bz2 or .xz extension.
73e148
    They did not find or handle the much more common vmlinuz compressed
73e148
    images.
73e148
    
73e148
    It is not completely clear why we didn't up to now. Support for
73e148
    compressed ELF files was added in 2009 and the code was updated to
73e148
    to try to find the .gz, .bz2 or .xz extension variants in 2011.
73e148
    But not the vmlinuz named variant.
73e148
    
73e148
    Reported-by: Aaron Merey <amerey@redhat.com>
73e148
    Tested-by: Frank Ch. Eigler <fche@redhat.com>
73e148
    Signed-off-by: Mark Wielaard <mark@klomp.org>
73e148
73e148
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
73e148
index d46ab5aa..48fb1ff0 100644
73e148
--- a/libdwfl/linux-kernel-modules.c
73e148
+++ b/libdwfl/linux-kernel-modules.c
73e148
@@ -174,6 +174,8 @@ kernel_release (void)
73e148
 static int
73e148
 find_kernel_elf (Dwfl *dwfl, const char *release, char **fname)
73e148
 {
73e148
+  /* First try to find an uncompressed vmlinux image.  Possibly
73e148
+     including debuginfo.  */
73e148
   if ((release[0] == '/'
73e148
        ? asprintf (fname, "%s/vmlinux", release)
73e148
        : asprintf (fname, "/boot/vmlinux-%s", release)) < 0)
73e148
@@ -188,6 +190,27 @@ find_kernel_elf (Dwfl *dwfl, const char *release, char **fname)
73e148
       fd = try_kernel_name (dwfl, fname, true);
73e148
     }
73e148
 
73e148
+  /* There might be a compressed vmlinuz image.  Probably without
73e148
+     debuginfo, but try to find it under the debug path also, just in
73e148
+     case.  */
73e148
+  if (fd < 0)
73e148
+    {
73e148
+      free (*fname);
73e148
+      if ((release[0] == '/'
73e148
+           ? asprintf (fname, "%s/vmlinuz", release)
73e148
+           : asprintf (fname, "/boot/vmlinuz-%s", release)) < 0)
73e148
+        return -1;
73e148
+
73e148
+      fd = try_kernel_name (dwfl, fname, true);
73e148
+      if (fd < 0 && release[0] != '/')
73e148
+	{
73e148
+	  free (*fname);
73e148
+	  if (asprintf (fname, MODULEDIRFMT "/vmlinuz", release) < 0)
73e148
+	    return -1;
73e148
+	  fd = try_kernel_name (dwfl, fname, true);
73e148
+	}
73e148
+    }
73e148
+
73e148
   return fd;
73e148
 }
73e148