summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-05-20 21:57:39 +0200
committerMark Wielaard <[email protected]>2018-05-30 14:56:28 +0200
commite9e64f6748499d458b951e0dcd46d6cc9d850886 (patch)
treec2b0538445c6eae69f1b2de46463415feb4f9d06 /tests
parent4ac4a42376428248f7174c7bb713fff27bb4d4b0 (diff)
libdw: Fix memory corruption in libdw_find_split_unit.
Found by valgrind when trying to match a split unit from a .dwo file that doesn't contain the split unit (as first) match. We would close the split Dwarf too early, before we had inspected all units in it. Add a testcase that simulates this. Which failed (at least under valgrind as run by make distcheck) before the fix. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am5
-rwxr-xr-xtests/run-readelf-info-plus.sh31
3 files changed, 40 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 7ac6bd3c..4d69515b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-28 Mark Wielaard <[email protected]>
+
+ * run-readelf-info-plus.sh: New test.
+ * Makefile.am (TESTS): Add run-readelf-info-plus.sh.
+ (EXTRA_DIST): Likewise.
+
2018-04-29 Mark Wielaard <[email protected]>
* run-readelf-addr.sh: New test.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4cd06656..e935410a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -93,7 +93,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
run-find-prologues.sh run-allregs.sh run-addrcfi.sh \
- run-nm-self.sh run-readelf-self.sh \
+ run-nm-self.sh run-readelf-self.sh run-readelf-info-plus.sh \
run-varlocs-self.sh run-exprlocs-self.sh \
run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \
run-readelf-test4.sh run-readelf-twofiles.sh \
@@ -197,7 +197,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \
run-ranlib-test3.sh run-ranlib-test4.sh \
run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
- run-nm-self.sh run-readelf-self.sh run-addrcfi.sh \
+ run-nm-self.sh run-readelf-self.sh run-readelf-info-plus.sh \
+ run-addrcfi.sh \
run-varlocs-self.sh run-exprlocs-self.sh \
run-find-prologues.sh run-allregs.sh run-native-test.sh \
run-addrname-test.sh run-dwfl-bug-offline-rel.sh \
diff --git a/tests/run-readelf-info-plus.sh b/tests/run-readelf-info-plus.sh
new file mode 100755
index 00000000..ee1db021
--- /dev/null
+++ b/tests/run-readelf-info-plus.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Test for --debug-dump=info+ and finding split unit (in wrong file).
+# Copyright (C) 2018 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 tests/testfile-dwarf-45.source
+testfiles testfile-splitdwarf-5
+testfiles testfile-world5.dwo
+
+# note, wrong file, renamed as if this contains the correct dwo...
+tempfiles testfile-hello5.dwo
+cp testfile-world5.dwo testfile-hello5.dwo
+
+testrun ${abs_top_builddir}/src/readelf --debug-dump=info+ testfile-splitdwarf-5
+
+exit 0