]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Fix dwarf_peel_type infinite loop.
authorMark Wielaard <mark@klomp.org>
Thu, 30 Mar 2017 10:19:53 +0000 (12:19 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 5 Apr 2017 14:41:00 +0000 (16:41 +0200)
We were calling dwarf_attr_integrate () in the die in the loop instead of
on the result. Which would cause an infinite loop when die != result.
Add a testcase that explicitly checks this case.

https://sourceware.org/bugzilla/show_bug.cgi?id=21330

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_peel_type.c
tests/ChangeLog
tests/Makefile.am
tests/run-peel-type.sh [new file with mode: 0755]

index 978b9913a95010ee9c5558333b3c752aa81a6a06..3f63a174a1238812795cc51186490a609a65302d 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-30  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_peel_type.c (dwarf_peel_type): Call dwarf_attr_integrate on
+       result.
+
 2016-10-22  Mark Wielaard  <mjw@redhat.com>
 
        * dwarf.h: Correct spelling of DW_LANG_PLI. Add compatibility define.
index 5dca8f88ce9766ca6e966877b5435ce67c74acd1..97356944676023647b5cacf9610a4fe9ffa6bc9c 100644 (file)
@@ -53,7 +53,7 @@ dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result)
         || tag == DW_TAG_atomic_type)
     {
       Dwarf_Attribute attr_mem;
-      Dwarf_Attribute *attr = INTUSE (dwarf_attr_integrate) (die, DW_AT_type,
+      Dwarf_Attribute *attr = INTUSE (dwarf_attr_integrate) (result, DW_AT_type,
                                                             &attr_mem);
       if (attr == NULL)
        return 1;
index 0df0bae4048abebfb30302615f2f802da5311abc..3479cf0724abccb082fa7bdd2fc234ef8eb47993 100644 (file)
@@ -1,3 +1,12 @@
+2017-03-30  Mark Wielaard  <mark@klomp.org>
+
+       * peel_type.c: New file.
+       * run-peel-type.sh: New test.
+       * Makefile.am (check_PROGRAMS): Add peel_type.c.
+       (TESTS): Add run-peel-type.sh.
+       (EXTRA_DIST): Likewise.
+       (peel_type_LDADD): New variable.
+
 2017-03-27  Mark Wielaard  <mark@klomp.org>
 
        * fillfile.c: New file.
index f287d92b84d6582c34be85c16c92820d28c7973c..f6d8b0d885a8b500cb5742d8b956979d81e88ebf 100644 (file)
@@ -50,7 +50,8 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
                  test-elf_cntl_gelf_getshdr dwflsyms dwfllines \
                  dwfl-report-elf-align varlocs backtrace backtrace-child \
                  backtrace-data backtrace-dwarf debuglink debugaltlink \
-                 buildid deleted deleted-lib.so aggregate_size vdsosyms \
+                 buildid deleted deleted-lib.so aggregate_size peel_type \
+                 vdsosyms \
                  getsrc_die strptr newdata elfstrtab dwfl-proc-attach \
                  elfshphehdr elfstrmerge dwelfgnucompressed elfgetchdr \
                  elfgetzdata elfputzdata zstrptr emptyfile vendorelf \
@@ -121,7 +122,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
        run-backtrace-demangle.sh run-stack-d-test.sh run-stack-i-test.sh \
        run-stack-demangled-test.sh run-readelf-zx.sh run-readelf-zp.sh \
        run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \
-       run-linkmap-cut.sh run-aggregate-size.sh vdsosyms run-readelf-A.sh \
+       run-linkmap-cut.sh run-aggregate-size.sh run-peel-type.sh \
+       vdsosyms run-readelf-A.sh \
        run-getsrc-die.sh run-strptr.sh newdata elfstrtab dwfl-proc-attach \
        elfshphehdr run-lfs-symbols.sh run-dwelfgnucompressed.sh \
        run-elfgetchdr.sh \
@@ -316,7 +318,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
             run-deleted.sh run-linkmap-cut.sh linkmap-cut-lib.so.bz2 \
             linkmap-cut.bz2 linkmap-cut.core.bz2 \
             run-aggregate-size.sh testfile-sizes1.o.bz2 testfile-sizes2.o.bz2 \
-            testfile-sizes3.o.bz2 \
+            testfile-sizes3.o.bz2 run-peel-type.sh \
             run-readelf-A.sh testfileppc32attrs.o.bz2 \
             testfilesparc64attrs.o.bz2 testfileppc64attrs.o.bz2 \
             testfile-debug-types.bz2 \
@@ -474,6 +476,7 @@ deleted_LDADD = ./deleted-lib.so
 deleted_lib_so_LDFLAGS = -shared -rdynamic
 deleted_lib_so_CFLAGS = -fPIC -fasynchronous-unwind-tables
 aggregate_size_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+peel_type_LDADD = $(libdw) $(libelf) $(argp_LDADD)
 vdsosyms_LDADD = $(libdw) $(libelf)
 getsrc_die_LDADD = $(libdw) $(libelf)
 strptr_LDADD = $(libelf)
diff --git a/tests/run-peel-type.sh b/tests/run-peel-type.sh
new file mode 100755 (executable)
index 0000000..7fd96e8
--- /dev/null
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2017 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# See run-aggregate-size.sh for how to generate testfiles.
+
+testfiles testfile-sizes1.o testfile-sizes2.o testfile-sizes3.o
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes1.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+EOF
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes2.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+EOF
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes3.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+f raw type base_type
+b raw type base_type
+EOF
+
+exit 0