2 # Copyright (C) 2013 Red Hat, Inc.
3 # This file is part of elfutils.
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # elfutils is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 . $srcdir/test-subr.sh
21 # int say (const char *prefix);
24 # subject (char *word, int count)
26 # return count > 0 ? word : (word + count);
30 # main (int argc, char **argv)
32 # return say (subject (argv[0], argc));
39 # return c > 0 ? c : c + 1;
43 # happy (const char *w)
49 # say (const char *prefix)
51 # const char *world = "World";
52 # return prefix ? sad (prefix[0]) : happy (world);
55 # gcc -g -O2 -c hello.c
56 # gcc -g -O2 -c world.c
57 # gcc -g -o testfileloc hello.o world.o
61 # Process values as offsets from base addresses and resolve to symbols.
62 testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=loc --debug-dump=ranges \
65 DWARF section [33] '.debug_loc' at offset 0xd2a:
66 [ 0] 0x0000000000400480 <main>..0x000000000040048d <main+0xd> [ 0] reg5
67 [ 23] 0x0000000000400485 <main+0x5>..0x000000000040048d <main+0xd> [ 0] reg5
68 [ 46] 0x00000000004004b2 <say+0x12>..0x00000000004004ba <say+0x1a> [ 0] breg5 0
70 DWARF section [34] '.debug_ranges' at offset 0xd94:
71 [ 0] 0x0000000000400480 <main>..0x0000000000400482 <main+0x2>
72 0x0000000000400485 <main+0x5>..0x000000000040048d <main+0xd>
73 [ 30] 0x00000000004004ad <say+0xd>..0x00000000004004af <say+0xf>
74 0x00000000004004b2 <say+0x12>..0x00000000004004ba <say+0x1a>
77 # Don't resolve addresses to symbols.
78 testrun_compare ${abs_top_builddir}/src/readelf -N --debug-dump=loc --debug-dump=ranges \
81 DWARF section [33] '.debug_loc' at offset 0xd2a:
82 [ 0] 0x0000000000400480..0x000000000040048d [ 0] reg5
83 [ 23] 0x0000000000400485..0x000000000040048d [ 0] reg5
84 [ 46] 0x00000000004004b2..0x00000000004004ba [ 0] breg5 0
86 DWARF section [34] '.debug_ranges' at offset 0xd94:
87 [ 0] 0x0000000000400480..0x0000000000400482
88 0x0000000000400485..0x000000000040048d
89 [ 30] 0x00000000004004ad..0x00000000004004af
90 0x00000000004004b2..0x00000000004004ba
93 # Produce "raw" unprocessed content.
94 testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc --debug-dump=ranges \
97 DWARF section [33] '.debug_loc' at offset 0xd2a:
98 [ 0] 000000000000000000..0x000000000000000d [ 0] reg5
99 [ 23] 0x0000000000000005..0x000000000000000d [ 0] reg5
100 [ 46] 0x0000000000000012..0x000000000000001a [ 0] breg5 0
102 DWARF section [34] '.debug_ranges' at offset 0xd94:
103 [ 0] 000000000000000000..0x0000000000000002
104 0x0000000000000005..0x000000000000000d
105 [ 30] 0x000000000000000d..0x000000000000000f
106 0x0000000000000012..0x000000000000001a