libdwfl: Initialize notes early in intuit_kernel_bounds.
authorMark Wielaard <mark@klomp.org>
Sun, 3 Feb 2019 18:03:26 +0000 (19:03 +0100)
committerMark Wielaard <mark@klomp.org>
Thu, 28 Feb 2019 21:19:03 +0000 (22:19 +0100)
We fake initialization of notes with an empty asm statement.  But
it is simpler and less confusing to just initialize notes just
before the fopen.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdwfl/ChangeLog
libdwfl/linux-kernel-modules.c

index 04cadb4..95dc426 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-24  Mark Wielaard  <mark@klomp.org>
+
+       * linux-kernel-modules.c (intuit_kernel_bounds): Init *notes before
+       fopen.
+       (dwfl_linux_kernel_report_kernel): Remove fake note init empty asm.
+
 2019-01-25  Yonghong Song  <yhs@fb.com>
 
        * linux-proc-maps.c (proc_maps_report): Use PRIu64, not PRIi64, to
index 360e4ee..d46ab5a 100644 (file)
@@ -493,14 +493,14 @@ intuit_kernel_bounds (Dwarf_Addr *start, Dwarf_Addr *end, Dwarf_Addr *notes)
 {
   struct read_address_state state = { NULL, NULL, 0, 0, NULL, NULL };
 
+  *notes = 0;
+
   state.f = fopen (KSYMSFILE, "r");
   if (state.f == NULL)
     return errno;
 
   (void) __fsetlocking (state.f, FSETLOCKING_BYCALLER);
 
-  *notes = 0;
-
   int result;
   do
     result = read_address (&state, start) ? 0 : -1;
@@ -695,9 +695,6 @@ dwfl_linux_kernel_report_kernel (Dwfl *dwfl)
   /* Try to figure out the bounds of the kernel image without
      looking for any vmlinux file.  */
   Dwarf_Addr notes;
-  /* The compiler cannot deduce that if intuit_kernel_bounds returns
-     zero NOTES will be initialized.  Fake the initialization.  */
-  asm ("" : "=m" (notes));
   int result = intuit_kernel_bounds (&start, &end, &notes);
   if (result == 0)
     {