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 <maennich@google.com>
This commit is contained in:
Matthias Maennich 2020-03-15 13:55:12 +01:00 committed by Dodji Seketeli
parent 247b4a1815
commit 34e867e74f
4 changed files with 8 additions and 2 deletions

View File

@ -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;

View File

@ -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 \

Binary file not shown.

View File

@ -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}
};