libabigail/tests/data/test-alt-dwarf-file
Dodji Seketeli ce5e4889b1 Plug leak of debug info handles
On recent elfutils where the libdw's function dwarf_getalt exists, we
don't need to try and find the alternate debug info file ourselves by
using the function dwfl_standard_find_debuginfo.  Furthermore, when we
use that function on those recent elfutils versions, we leak the elf
resources allocated in the debug info resources; we also leak the file
descriptor to access the alternate debug info sections.

More generally, we also leak debug info handles used to access debug
info when using get_soname_of_elf_file and get_type_of_elf_file.

This patch plugs those leaks.

In the first case, if the function dwarf_getalt exists, the patch just
uses it to get the alternate debug info.  Otherwise, the patch uses
the dwfl_standard_find_debuginfo function like we used to, but then it
tries hard to free the file descriptor and debuginfo memory of the
alternate debug info.

	* configure.ac: Check the presence of dwarf_getalt in libdw.  If
	it's present, define the preprocessor macro
	LIBDW_HAS_DWARF_GETALT.  Update the autoconf configuration
	summary.
	* src/abg-dwarf-reader.cc: Add config.h.
	(find_alt_debug_info_location): Factorize this out of ...
	(find_alt_debug_info): ... this function.  Use dwarf_getalt if
	present, otherwise, keep using dwfl_standard_find_debuginfo.  In
	the later case, return the file descriptor opened to access the
	alternate debug info, by parameter, so that the caller can fclose
	it.
	(read_context::alt_fd_): New data member.
	(read_context::read_context): Initialize the new alt_fd_ data
	member.
	(read_context::load_debug_info): Store the file descriptor used to
	access the alternate debug info into the new alt_fd_ data member.
	(read_context::~read_context): New desctructor.
	(get_soname_of_elf_file, get_type_of_elf_file): Free the elf
	handle.
	(read_context::load_debug_info): Be paranoid in making sure we
	never override alt_dwarf_.
	* tests/data/test-alt-dwarf-file/test0-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-22 23:20:13 +02:00
..
test0-debug-dir Make the alt dwarf debug file *not* be a symlink 2014-11-19 16:50:48 +01:00
test1-libgromacs-debug-dir Bug 19336 - Better handle redundantly qualified reference types 2015-12-08 14:11:22 +01:00
libtest0-common.so Support alternate debug info sections 2014-08-15 18:27:04 +02:00
libtest0.so Support alternate debug info sections 2014-08-15 18:27:04 +02:00
test0-common-dwz.debug Support alternate debug info sections 2014-08-15 18:27:04 +02:00
test0-common.cc Support alternate debug info sections 2014-08-15 18:27:04 +02:00
test0-report.txt Plug leak of debug info handles 2016-05-22 23:20:13 +02:00
test0.cc Support alternate debug info sections 2014-08-15 18:27:04 +02:00
test0.h Support alternate debug info sections 2014-08-15 18:27:04 +02:00
test1-libgromacs_d.so.0.0.0 Bug 19336 - Better handle redundantly qualified reference types 2015-12-08 14:11:22 +01:00
test1-report-0.txt Bug 19336 - Better handle redundantly qualified reference types 2015-12-08 14:11:22 +01:00