From 413381ee7f99c0a2bef1c6d76c1c06fb17160a1b Mon Sep 17 00:00:00 2001 From: Matthias Maennich Date: Wed, 24 Jul 2019 22:32:55 +0100 Subject: [PATCH] abg-dwarf-reader: detect kernel modules without exports as such 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 Signed-off-by: Alessio Balsini Signed-off-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 47af7e3..ab3f8e3 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -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. /// -- 2.7.4