blob: ccccd82dbdc1cadfae4fc289a95c8ba68ff8b9d7 [file] [log] [blame]
Mark Wielaardf5013e82015-10-21 01:30:44 +02001#! /bin/sh
2# Copyright (C) 2015 Red Hat, Inc.
3# This file is part of elfutils.
4#
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.
9#
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.
14#
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/>.
17
18. $srcdir/test-subr.sh
19
20# - testfile-zdebug-rel.c
21# #define UINT64_MAX 18446744073709551615UL
22#
23# int
24# main (int argc, char **argv)
25# {
26# unsigned long a = UINT64_MAX - 8;
27# unsigned long b = 42 + argc;
28#
29# if ( a + b < b )
30# argc = a + argc;
31# else
32# b--;
33#
34# return a - b;
35# }
36#
37# gcc -Og -g -Xassembler --compress-debug-sections=none \
38# -c -o testfile-debug-rel.o testfile-zdebug-rel.c
39# gcc -Og -g -Xassembler --compress-debug-sections=zlib-gnu \
40# -c -o testfile-debug-rel-g.o testfile-zdebug-rel.c
41# gcc -Og -g -Xassembler --compress-debug-sections=zlib-gabi \
42# -c -o testfile-debug-rel-z.o testfile-zdebug-rel.c
43
44testfiles testfile-debug-rel.o testfile-debug-rel-g.o testfile-debug-rel-z.o
45tempfiles readelf.out
46tempfiles info.out loc.out
47
48cat > info.out << \EOF
49
50DWARF section [ 4] '.debug_info' at offset 0x58:
51 [Offset]
52 Compilation unit at offset 0:
53 Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
Mark Wielaarde6f19902017-11-29 15:58:40 +010054 [ b] compile_unit abbrev: 1
Mark Wielaardf5013e82015-10-21 01:30:44 +020055 producer (strp) "GNU C11 5.3.1 20151207 (Red Hat 5.3.1-2) -mtune=generic -march=x86-64 -g -Og"
56 language (data1) C99 (12)
57 name (strp) "testfile-zdebug-rel.c"
58 comp_dir (strp) "/tmp"
59 low_pc (addr) 000000000000000000
60 high_pc (data8) 24 (0x0000000000000018)
61 stmt_list (sec_offset) 0
Mark Wielaarde6f19902017-11-29 15:58:40 +010062 [ 2d] subprogram abbrev: 2
Ulf Hermann9130b532017-04-20 15:47:49 +020063 external (flag_present) yes
Mark Wielaardf5013e82015-10-21 01:30:44 +020064 name (strp) "main"
Mark Wielaardd5b99ee2017-11-29 16:06:36 +010065 decl_file (data1) testfile-zdebug-rel.c (1)
Mark Wielaardf5013e82015-10-21 01:30:44 +020066 decl_line (data1) 4
Ulf Hermann9130b532017-04-20 15:47:49 +020067 prototyped (flag_present) yes
Mark Wielaardf5013e82015-10-21 01:30:44 +020068 type (ref4) [ 80]
69 low_pc (addr) 000000000000000000
70 high_pc (data8) 24 (0x0000000000000018)
71 frame_base (exprloc)
Mark Wielaard704f5fc2017-11-29 15:43:26 +010072 [ 0] call_frame_cfa
Ulf Hermann9130b532017-04-20 15:47:49 +020073 GNU_all_call_sites (flag_present) yes
Mark Wielaardf5013e82015-10-21 01:30:44 +020074 sibling (ref4) [ 80]
Mark Wielaarde6f19902017-11-29 15:58:40 +010075 [ 4e] formal_parameter abbrev: 3
Mark Wielaardf5013e82015-10-21 01:30:44 +020076 name (strp) "argc"
Mark Wielaardd5b99ee2017-11-29 16:06:36 +010077 decl_file (data1) testfile-zdebug-rel.c (1)
Mark Wielaardf5013e82015-10-21 01:30:44 +020078 decl_line (data1) 4
79 type (ref4) [ 80]
80 location (sec_offset) location list [ 0]
Mark Wielaarde6f19902017-11-29 15:58:40 +010081 [ 5d] formal_parameter abbrev: 4
Mark Wielaardf5013e82015-10-21 01:30:44 +020082 name (strp) "argv"
Mark Wielaardd5b99ee2017-11-29 16:06:36 +010083 decl_file (data1) testfile-zdebug-rel.c (1)
Mark Wielaardf5013e82015-10-21 01:30:44 +020084 decl_line (data1) 4
85 type (ref4) [ 87]
86 location (exprloc)
Mark Wielaard704f5fc2017-11-29 15:43:26 +010087 [ 0] reg4
Mark Wielaarde6f19902017-11-29 15:58:40 +010088 [ 6a] variable abbrev: 5
Mark Wielaardf5013e82015-10-21 01:30:44 +020089 name (string) "a"
Mark Wielaardd5b99ee2017-11-29 16:06:36 +010090 decl_file (data1) testfile-zdebug-rel.c (1)
Mark Wielaardf5013e82015-10-21 01:30:44 +020091 decl_line (data1) 6
92 type (ref4) [ 9a]
93 const_value (sdata) -9
Mark Wielaarde6f19902017-11-29 15:58:40 +010094 [ 74] variable abbrev: 6
Mark Wielaardf5013e82015-10-21 01:30:44 +020095 name (string) "b"
Mark Wielaardd5b99ee2017-11-29 16:06:36 +010096 decl_file (data1) testfile-zdebug-rel.c (1)
Mark Wielaardf5013e82015-10-21 01:30:44 +020097 decl_line (data1) 7
98 type (ref4) [ 9a]
99 location (exprloc)
Mark Wielaard704f5fc2017-11-29 15:43:26 +0100100 [ 0] reg5
Mark Wielaarde6f19902017-11-29 15:58:40 +0100101 [ 80] base_type abbrev: 7
Mark Wielaardf5013e82015-10-21 01:30:44 +0200102 byte_size (data1) 4
103 encoding (data1) signed (5)
104 name (string) "int"
Mark Wielaarde6f19902017-11-29 15:58:40 +0100105 [ 87] pointer_type abbrev: 8
Mark Wielaardf5013e82015-10-21 01:30:44 +0200106 byte_size (data1) 8
107 type (ref4) [ 8d]
Mark Wielaarde6f19902017-11-29 15:58:40 +0100108 [ 8d] pointer_type abbrev: 8
Mark Wielaardf5013e82015-10-21 01:30:44 +0200109 byte_size (data1) 8
110 type (ref4) [ 93]
Mark Wielaarde6f19902017-11-29 15:58:40 +0100111 [ 93] base_type abbrev: 9
Mark Wielaardf5013e82015-10-21 01:30:44 +0200112 byte_size (data1) 1
113 encoding (data1) signed_char (6)
114 name (strp) "char"
Mark Wielaarde6f19902017-11-29 15:58:40 +0100115 [ 9a] base_type abbrev: 9
Mark Wielaardf5013e82015-10-21 01:30:44 +0200116 byte_size (data1) 8
117 encoding (data1) unsigned (7)
118 name (strp) "long unsigned int"
119EOF
120
121cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel.o
122
123cat info.out | sed -e "s/'.debug_info'/'.zdebug_info'/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-g.o
124
125cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-z.o
126
127cat > loc.out << \EOF
128
129DWARF section [ 7] '.debug_loc' at offset 0x185:
Mark Wielaardfbb6c932017-11-29 16:37:50 +0100130
131 CU [ b] base: 000000000000000000
132 [ 0] range 0, 3
133 [ 0] reg5
134 range 3, 10
135 [ 0] breg5 -42
136 [ 2] stack_value
137 range 10, 18
138 [ 0] GNU_entry_value:
139 [ 0] reg5
140 [ 3] stack_value
Mark Wielaardf5013e82015-10-21 01:30:44 +0200141EOF
142
143cat loc.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel.o
144
145cat loc.out | sed -e "s/'.debug_loc' at offset 0x185/'.zdebug_loc' at offset 0x138/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-g.o
146
147cat loc.out | sed -e "s/at offset 0x185/at offset 0x150/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-z.o
148
149exit 0