abg-dwarf-reader: detect kernel modules without exports as such
authorMatthias Maennich <maennich@google.com>
Wed, 24 Jul 2019 21:32:55 +0000 (22:32 +0100)
committerDodji Seketeli <dodji@redhat.com>
Thu, 25 Jul 2019 08:36:44 +0000 (10:36 +0200)
Kernel modules without exported symbols (no use of EXPORT_SYMBOL*()),
will not have a __ksymtab_strings section. Libabigail will therefore
assume they are usual ELF binaries. That leads to wrong results as
now all ELF symbols are considered part of the ABI. That is obviously
wrong. Instead consider binaries having a .modinfo section to be kernel
binaries. We keep the __ksymtab_strings condition as vmlinux has no
.modinfo section but a __ksymtab_strings if symbols are exported.

One case is still open (and requires maybe some documentation): if a
kernel does not export symbols (no module support), none of the
conditions apply. But, who would be interested in the ABI of a kernel
that does not expose any?

* src/abg-dwarf-reader.cc(is_linux_kernel_binary): consider
  binaries only having a .modinfo section to be kernel binaries

Co-developed-by: Alessio Balsini <balsini@android.com>
Signed-off-by: Alessio Balsini <balsini@android.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
src/abg-dwarf-reader.cc

index 47af7e3516d33ead549d0a6fb7f024e1ec534242..ab3f8e3b25252219cb0e925fe2751201580b09c7 100644 (file)
@@ -8350,7 +8350,10 @@ public:
   ///
   bool
   is_linux_kernel_binary() const
-  {return find_section(elf_handle(), "__ksymtab_strings", SHT_PROGBITS);}
+  {
+    return find_section(elf_handle(), "__ksymtab_strings", SHT_PROGBITS)
+          || find_section(elf_handle(), ".modinfo", SHT_PROGBITS);
+  }
 
   /// Getter of the "show_stats" flag.
   ///