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

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