From: Mark Wielaard Date: Wed, 30 Jan 2013 10:04:38 +0000 (+0100) Subject: Add readelf test for --debug-dump=loc --debug-dump=ranges, -N and -U. X-Git-Tag: elfutils-0.156~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c4b2078c51c687a1a192b001f0b331a0ccac629;p=thirdparty%2Felfutils.git Add readelf test for --debug-dump=loc --debug-dump=ranges, -N and -U. Signed-off-by: Mark Wielaard --- diff --git a/tests/ChangeLog b/tests/ChangeLog index e363a176f..0a26e7ed9 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,10 @@ +2013-01-30 Mark Wielaard + + * testfileloc.bz2: New testfile. + * run-readelf-loc.sh: New test. + * Makefile.am (TESTS): Add run-readelf-loc.sh. + (EXTRA_DIST): Add run-readelf-loc.sh and testfileloc.bz2. + 2013-01-29 Jan Kratochvil * run-readelf-mixed-corenote.sh: New testcase for readelf -n of s390 diff --git a/tests/Makefile.am b/tests/Makefile.am index e8efcd058..a26e5c262 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -73,7 +73,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-nm-self.sh run-readelf-self.sh \ run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \ run-readelf-test4.sh run-readelf-twofiles.sh \ - run-readelf-macro.sh \ + run-readelf-macro.sh run-readelf-loc.sh \ run-native-test.sh run-bug1-test.sh \ dwfl-bug-addr-overflow run-addrname-test.sh \ dwfl-bug-fd-leak dwfl-bug-report \ @@ -151,6 +151,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ testfile46.bz2 testfile47.bz2 testfile48.bz2 testfile48.debug.bz2 \ testfile49.bz2 testfile50.bz2 testfile51.bz2 \ run-readelf-macro.sh testfilemacro.bz2 \ + run-readelf-loc.sh testfileloc.bz2 \ run-readelf-dwz-multi.sh libtestfile_multi_shared.so.bz2 \ testfile_multi.dwz.bz2 testfile_multi_main.bz2 \ run-prelink-addr-test.sh \ diff --git a/tests/run-readelf-loc.sh b/tests/run-readelf-loc.sh new file mode 100755 index 000000000..6612e7dfc --- /dev/null +++ b/tests/run-readelf-loc.sh @@ -0,0 +1,109 @@ +#! /bin/sh +# Copyright (C) 2013 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 . + +. $srcdir/test-subr.sh + +# - hello.c +# int say (const char *prefix); +# +# static char * +# subject (char *word, int count) +# { +# return count > 0 ? word : (word + count); +# } +# +# int +# main (int argc, char **argv) +# { +# return say (subject (argv[0], argc)); +# } +# +# - world.c +# static int +# sad (char c) +# { +# return c > 0 ? c : c + 1; +# } +# +# static int +# happy (const char *w) +# { +# return sad (w[1]); +# } +# +# int +# say (const char *prefix) +# { +# const char *world = "World"; +# return prefix ? sad (prefix[0]) : happy (world); +# } +# +# gcc -g -O2 -c hello.c +# gcc -g -O2 -c world.c +# gcc -g -o testfileloc hello.o world.o + +testfiles testfileloc + +# Process values as offsets from base addresses and resolve to symbols. +testrun_compare ../src/readelf --debug-dump=loc --debug-dump=ranges \ + testfileloc<<\EOF + +DWARF section [33] '.debug_loc' at offset 0xd2a: + [ 0] 0x0000000000400480
..0x000000000040048d [ 0] reg5 + [ 23] 0x0000000000400485 ..0x000000000040048d [ 0] reg5 + [ 46] 0x00000000004004b2 ..0x00000000004004ba [ 0] breg5 0 + +DWARF section [34] '.debug_ranges' at offset 0xd94: + [ 0] 0x0000000000400480
..0x0000000000400482 + 0x0000000000400485 ..0x000000000040048d + [ 30] 0x00000000004004ad ..0x00000000004004af + 0x00000000004004b2 ..0x00000000004004ba +EOF + +# Don't resolve addresses to symbols. +testrun_compare ../src/readelf -N --debug-dump=loc --debug-dump=ranges \ + testfileloc<<\EOF + +DWARF section [33] '.debug_loc' at offset 0xd2a: + [ 0] 0x0000000000400480..0x000000000040048d [ 0] reg5 + [ 23] 0x0000000000400485..0x000000000040048d [ 0] reg5 + [ 46] 0x00000000004004b2..0x00000000004004ba [ 0] breg5 0 + +DWARF section [34] '.debug_ranges' at offset 0xd94: + [ 0] 0x0000000000400480..0x0000000000400482 + 0x0000000000400485..0x000000000040048d + [ 30] 0x00000000004004ad..0x00000000004004af + 0x00000000004004b2..0x00000000004004ba +EOF + +# Produce "raw" unprocessed content. +testrun_compare ../src/readelf -U --debug-dump=loc --debug-dump=ranges \ + testfileloc<<\EOF + +DWARF section [33] '.debug_loc' at offset 0xd2a: + [ 0] 000000000000000000..0x000000000000000d [ 0] reg5 + [ 23] 0x0000000000000005..0x000000000000000d [ 0] reg5 + [ 46] 0x0000000000000012..0x000000000000001a [ 0] breg5 0 + +DWARF section [34] '.debug_ranges' at offset 0xd94: + [ 0] 000000000000000000..0x0000000000000002 + 0x0000000000000005..0x000000000000000d + [ 30] 0x000000000000000d..0x000000000000000f + 0x0000000000000012..0x000000000000001a +EOF + +exit 0 diff --git a/tests/testfileloc.bz2 b/tests/testfileloc.bz2 new file mode 100755 index 000000000..a436965be Binary files /dev/null and b/tests/testfileloc.bz2 differ