Bug 29692 - Support binaries with empty symbol table

Some binaries can have a symbol table in which no symbol is actually
defined and exported.  That binary would thus have an empty ABI
corpus.

Interestingly, Libabigail's DWARF reader is emits an error when
it encounters such binaries.

This patch adds the support for those binaries.

	* src/abg-dwarf-reader.cc (reader::read_debug_info_into_corpus):
	Get out early also upon having an empty symbol table.
	* src/abg-elf-reader.cc (reader::read_corpus): Error out only if
	there is no symbol table for the binary.  If an empty symbol table
	is found however, that is not an error.
	* tests/data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0:
	New binary test input.
	* tests/data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi:
	New expected abixml file.
	* tests/data/Makefile.am: Add the new input test files to source
	distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Add the new test inputs
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2023-03-22 13:50:20 +01:00
parent 889f05f935
commit 6641e71a03
6 changed files with 22 additions and 4 deletions

View File

@ -2130,8 +2130,10 @@ public:
// Set symbols information to the corpus.
corpus()->set_symtab(symtab());
// Get out now if no debug info is found.
if (!dwarf_debug_info())
// Get out now if no debug info is found or if the symbol table is
// empty.
if (!dwarf_debug_info()
|| !corpus()->get_symtab()->has_symbols())
return corpus();
uint8_t address_size = 0;

View File

@ -958,10 +958,13 @@ reader::read_corpus(status& status)
corpus()->set_architecture_name(elf_architecture());
// See if we could find symbol tables.
if (!symtab() || !symtab()->has_symbols())
if (!symtab())
{
status |= STATUS_NO_SYMBOLS_FOUND;
// We found no ELF symbol, so we can't handle the binary.
// We found no ELF symbol, so we can't handle the binary. Note
// that we could have found a symbol table with no defined &
// exported ELF symbols in it. That case is handled as an empty
// corpus, which is different from this case.
return corpus_sptr();
}

View File

@ -666,6 +666,8 @@ test-read-dwarf/PR29443-missing-xx.o.abi \
test-read-dwarf/test-fallback.abi \
test-read-dwarf/test-fallback.c \
test-read-dwarf/test-fallback.o \
test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0 \
test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi \
\
test-read-ctf/test0 \
test-read-ctf/test0.abi \

View File

@ -0,0 +1,2 @@
<abi-corpus version='2.1' soname='libkjava.so.1'>
</abi-corpus>

View File

@ -550,6 +550,15 @@ static InOutSpec in_out_specs[] =
"output/test-read-dwarf/PR29443-missing-xx.o.abi",
NULL,
},
{
"data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0",
"",
"",
SEQUENCE_TYPE_ID_STYLE,
"data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi",
"output/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi",
NULL,
},
// DWARF fallback feature.
{
"data/test-read-dwarf/test-fallback.o",