Bug 24378 - DW_TAG_subroutine_type as a DIE scope causes infinite loop

GCC 4.3.2 wrongly emits some type definition DIEs in the scope of a
DW_TAG_subroutine_type.  Whenever the DWARF reader tries to get the
scope of a DIE during the computation of the pretty name of a type DIE
which scope is (wrongly) emitted as being a DW_TAG_subroutine_type
things end-up in an infinite loop.

This patch makes get_scope_die to look through the
DW_TAG_subroutine_type to return the proper scope instead, just like
what we already do for DW_TAG_subprogram and DW_TAG_array_type.

	* src/abg-dwarf-reader.cc (get_scope_die): Look through
	DW_TAG_subroutine_type to get the scope of a given DIE.
	* tests/data/Makefile.am: Add the two new files below to source
	distribution.
	* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi: New
	reference test output.
	* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.o: New binary
	test input.
	* tests/test-read-dwarf.cc (in_out_specs): Add the new test input
	to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2019-03-25 14:46:31 +01:00
parent 8d60c4a2a1
commit 5bb7194b0a
5 changed files with 27 additions and 0 deletions

View File

@ -12363,6 +12363,7 @@ get_scope_die(const read_context& ctxt,
return false;
if (dwarf_tag(&scope_die) == DW_TAG_subprogram
|| dwarf_tag(&scope_die) == DW_TAG_subroutine_type
|| dwarf_tag(&scope_die) == DW_TAG_array_type)
return get_scope_die(ctxt, &scope_die, where_offset, scope_die);
return true;

View File

@ -397,6 +397,8 @@ test-read-dwarf/PR22015-libboost_iostreams.so \
test-read-dwarf/PR22015-libboost_iostreams.so.abi \
test-read-dwarf/PR22122-libftdc.so \
test-read-dwarf/PR22122-libftdc.so.abi \
test-read-dwarf/PR24378-fn-is-not-scope.abi \
test-read-dwarf/PR24378-fn-is-not-scope.o \
\
test-annotate/test0.abi \
test-annotate/test1.abi \

View File

@ -0,0 +1,18 @@
<abi-corpus path='data/test-read-dwarf/PR24378-fn-is-not-scope.o'>
<elf-function-symbols>
<elf-symbol name='_ZN4stac14buggy_functionEPFvPFfiiEE' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
</elf-function-symbols>
<abi-instr version='1.0' address-size='64' path='dwarf_bug.cpp' comp-dir-path='/remote/users/lstacul' language='LANG_C_plus_plus'>
<namespace-decl name='stac'>
<function-decl name='buggy_function' mangled-name='_ZN4stac14buggy_functionEPFvPFfiiEE' filepath='/remote/users/lstacul/dwarf_bug.cpp' line='10' column='1' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='_ZN4stac14buggy_functionEPFvPFfiiEE'>
<parameter type-id='type-id-1'/>
<return type-id='type-id-2'/>
</function-decl>
</namespace-decl>
<type-decl name='void' id='type-id-2'/>
<pointer-type-def type-id='type-id-3' size-in-bits='64' id='type-id-1'/>
<function-type size-in-bits='64' id='type-id-3'>
<return type-id='type-id-2'/>
</function-type>
</abi-instr>
</abi-corpus>

Binary file not shown.

View File

@ -228,6 +228,12 @@ InOutSpec in_out_specs[] =
"data/test-read-dwarf/PR22122-libftdc.so.abi",
"output/test-read-dwarf/PR22122-libftdc.so.abi",
},
{
"data/test-read-dwarf/PR24378-fn-is-not-scope.o",
"",
"data/test-read-dwarf/PR24378-fn-is-not-scope.abi",
"output/test-read-dwarf/PR24378-fn-is-not-scope.abi",
},
// This should be the last entry.
{NULL, NULL, NULL, NULL}
};