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

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