From: Matthias Maennich Date: Sun, 15 Mar 2020 12:55:12 +0000 (+0100) Subject: dwarf-reader: remove superfluous ABG_ASSERT X-Git-Tag: libabigail-1.8~194 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=34e867e7;p=libabigail.git dwarf-reader: remove superfluous ABG_ASSERT maybe_adjust_et_rel_sym_addr_to_abs_addr contained an ABG_ASSERT to ensure symbol_section is not used on an invalid value. Since maybe_adjust_et_rel_sym_addr_to_abs_addr handles this case, this assert can be removed. * src/abg-dwarf-reader.cc (maybe_adjust_et_rel_sym_addr_to_abs_addr): improve NULL check, remove superfluous ABG_ASSERT * tests/data/Makefile.am: Add new test case to the distribution. * tests/test-read-dwarf.cc: Likewise. * tests/data/test-read-dwarf/test27-bogus-binary.elf: New test case. Signed-off-by: Matthias Maennich --- diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 3454fcf5..ff532cfd 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -8585,7 +8585,7 @@ public: GElf_Addr maybe_adjust_et_rel_sym_addr_to_abs_addr(GElf_Addr addr, Elf_Scn *section) { - if (section == 0) + if (!section) return addr; Elf* elf = elf_handle(); @@ -8623,7 +8623,6 @@ public: maybe_adjust_et_rel_sym_addr_to_abs_addr(GElf_Sym *sym) { Elf_Scn *symbol_section = elf_getscn(elf_handle(), sym->st_shndx); - ABG_ASSERT(symbol_section); GElf_Addr result = sym->st_value; result = maybe_adjust_et_rel_sym_addr_to_abs_addr(result, symbol_section); return result; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 21ae846b..e9fdad1e 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -442,6 +442,7 @@ test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0 \ test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi \ test-read-dwarf/test25-bogus-binary.elf \ test-read-dwarf/test26-bogus-binary.elf \ +test-read-dwarf/test27-bogus-binary.elf \ \ test-annotate/test0.abi \ test-annotate/test1.abi \ diff --git a/tests/data/test-read-dwarf/test27-bogus-binary.elf b/tests/data/test-read-dwarf/test27-bogus-binary.elf new file mode 100644 index 00000000..3240f539 Binary files /dev/null and b/tests/data/test-read-dwarf/test27-bogus-binary.elf differ diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc index a8ea0619..7c99d218 100644 --- a/tests/test-read-dwarf.cc +++ b/tests/test-read-dwarf.cc @@ -265,6 +265,12 @@ InOutSpec in_out_specs[] = "", "", }, + { + "data/test-read-dwarf/test27-bogus-binary.elf", + "", + "", + "", + }, // This should be the last entry. {NULL, NULL, NULL, NULL} };