]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Test cases for libdwfl vs prelink.
authorJosh Stone <jistone@redhat.com>
Tue, 11 Jan 2011 05:28:46 +0000 (21:28 -0800)
committerRoland McGrath <roland@redhat.com>
Tue, 11 Jan 2011 05:28:46 +0000 (21:28 -0800)
tests/ChangeLog
tests/Makefile.am
tests/run-prelink-addr-test.sh [new file with mode: 0755]
tests/testfile52.prelink.so.bz2 [new file with mode: 0755]
tests/testfile52.so.bz2 [new file with mode: 0755]
tests/testfile52.so.debug.bz2 [new file with mode: 0755]
tests/testfile53.bz2 [new file with mode: 0755]
tests/testfile53.debug.bz2 [new file with mode: 0755]
tests/testfile53.prelink.bz2 [new file with mode: 0755]

index 0176fb4951bd1de47b6039eca2d7336a6c3e4cf9..f6aee50b0479b826ece37a906ed3a0c9bda52612 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-10  Josh Stone  <jistone@redhat.com>
+
+       * run-prelink-addr-test.sh: New test for prelinked addrs.
+       * Makefile.am (TESTS, EXTRA_DIST): Add it.
+       * testfile52.so.bz2, testfile52.so.debug.bz2: New data files.
+       * testfile52.prelink.so.bz2: New data file, shows REL->RELA.
+       * testfile53.bz2, testfile53.debug.bz2: New data files.
+       * testfile53.prelink.bz2: New data file, shows ET_EXEC remap.
+       * Makefile.am (EXTRA_DIST): Add them.
+
 2010-06-04  Roland McGrath  <roland@redhat.com>
 
        * run-unstrip-test.sh: Also test modifying the file in place.
index 008008acc47287593ff235c7566405e86119dbe9..4650a59e7b1f97492e74389ce77906a129c51357 100644 (file)
@@ -83,7 +83,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
        run-dwfl-bug-offline-rel.sh run-dwfl-addr-sect.sh \
        run-disasm-x86.sh run-disasm-x86-64.sh \
        run-early-offscn.sh run-dwarf-getmacros.sh \
-       run-test-flag-nobits.sh
+       run-test-flag-nobits.sh run-prelink-addr-test.sh
 # run-show-ciefde.sh
 
 if !STANDALONE
@@ -139,7 +139,10 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
             testfile44.S.bz2 testfile44.expect.bz2 run-disasm-x86.sh \
             testfile45.S.bz2 testfile45.expect.bz2 run-disasm-x86-64.sh \
             testfile46.bz2 testfile47.bz2 testfile48.bz2 testfile48.debug.bz2 \
-            testfile49.bz2 testfile50.bz2 testfile51.bz2
+            testfile49.bz2 testfile50.bz2 testfile51.bz2 \
+            run-prelink-addr-test.sh testfile52.so.bz2 testfile52.so.debug.bz2 \
+            testfile52.prelink.so.bz2 testfile53.bz2 testfile53.debug.bz2 \
+            testfile53.prelink.bz2
 
 installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
                              bindir=$(DESTDIR)$(bindir) \
diff --git a/tests/run-prelink-addr-test.sh b/tests/run-prelink-addr-test.sh
new file mode 100755 (executable)
index 0000000..9c19988
--- /dev/null
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2011 Red Hat, Inc.
+# This file is part of Red Hat elfutils.
+#
+# Red Hat elfutils 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; version 2 of the License.
+#
+# Red Hat 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 Red Hat elfutils; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+#
+# Red Hat elfutils is an included package of the Open Invention Network.
+# An included package of the Open Invention Network is a package for which
+# Open Invention Network licensees cross-license their patents.  No patent
+# license is granted, either expressly or impliedly, by designation as an
+# included package.  Should you wish to participate in the Open Invention
+# Network licensing program, please visit www.openinventionnetwork.com
+# <http://www.openinventionnetwork.com>.
+
+. $srcdir/test-subr.sh
+
+
+# testfile52.c:
+#   #include <stdlib.h>
+#   int foo() { exit(0); }
+#
+# gcc -m32 -g -shared testfile52.c -o testfile52.so
+# eu-strip -f testfile52.so.debug testfile52.so
+# cp testfile52.so testfile52.prelink.so
+# prelink -N testfile52.prelink.so
+
+testfiles testfile52.so testfile52.prelink.so testfile52.so.debug
+tempfiles testmaps52
+
+cat > testmaps52 <<EOF
+00110000-00111000 r-xp 00000000 00:00 0 [vdso]
+00111000-00112000 r-xp 00000000 fd:01 1 `pwd`/testfile52.so
+00112000-00113000 rw-p 00000000 fd:01 1 `pwd`/testfile52.so
+41000000-41001000 r-xp 00000000 fd:01 2 `pwd`/testfile52.prelink.so
+41001000-41002000 rw-p 00000000 fd:01 2 `pwd`/testfile52.prelink.so
+4718e000-47191000 rw-p 00000000 00:00 0
+f7fda000-f7fdb000 rw-p 00000000 00:00 0
+f7ffd000-f7ffe000 rw-p 00000000 00:00 0
+fffdd000-ffffe000 rw-p 00000000 00:00 0 [stack]
+EOF
+
+# Prior to commit 1743d7f, libdwfl would fail on the second address,
+# because it didn't notice that prelink added a 0x20-byte offset from
+# what the .debug file reports.
+testrun_compare ../src/addr2line -S -M testmaps52 0x11140c 0x4100042d <<\EOF
+foo
+/home/jistone/src/elfutils/tests/testfile52.c:2
+foo+0x1
+/home/jistone/src/elfutils/tests/testfile52.c:2
+EOF
+
+
+# testfile53.c:
+#   char foo[2000];
+#   int main() { return 0; }
+#
+# gcc -g testfile53.c -o testfile53
+# eu-strip -f testfile53.debug testfile53
+# cp testfile53 testfile53.prelinked
+# prelink -N testfile53.prelinked
+testfiles testfile53 testfile53.prelink testfile53.debug
+
+testrun_compare ../src/addr2line -S -e testfile53 0x400474 0x400475 <<\EOF
+main
+/home/jistone/src/elfutils/tests/testfile53.c:2
+main+0x1
+/home/jistone/src/elfutils/tests/testfile53.c:2
+EOF
+
+# prelink shuffled some of the sections, but .text is in the same place.
+testrun_compare ../src/addr2line -S -e testfile53.prelink 0x400476 0x400477 <<\EOF
+main+0x2
+/home/jistone/src/elfutils/tests/testfile53.c:2
+main+0x3
+/home/jistone/src/elfutils/tests/testfile53.c:2
+EOF
diff --git a/tests/testfile52.prelink.so.bz2 b/tests/testfile52.prelink.so.bz2
new file mode 100755 (executable)
index 0000000..b0e3d3f
Binary files /dev/null and b/tests/testfile52.prelink.so.bz2 differ
diff --git a/tests/testfile52.so.bz2 b/tests/testfile52.so.bz2
new file mode 100755 (executable)
index 0000000..453759c
Binary files /dev/null and b/tests/testfile52.so.bz2 differ
diff --git a/tests/testfile52.so.debug.bz2 b/tests/testfile52.so.debug.bz2
new file mode 100755 (executable)
index 0000000..38088a6
Binary files /dev/null and b/tests/testfile52.so.debug.bz2 differ
diff --git a/tests/testfile53.bz2 b/tests/testfile53.bz2
new file mode 100755 (executable)
index 0000000..2e0e74c
Binary files /dev/null and b/tests/testfile53.bz2 differ
diff --git a/tests/testfile53.debug.bz2 b/tests/testfile53.debug.bz2
new file mode 100755 (executable)
index 0000000..ec36e98
Binary files /dev/null and b/tests/testfile53.debug.bz2 differ
diff --git a/tests/testfile53.prelink.bz2 b/tests/testfile53.prelink.bz2
new file mode 100755 (executable)
index 0000000..b2f4dea
Binary files /dev/null and b/tests/testfile53.prelink.bz2 differ