1#!/usr/local/bin/bash
2# Copyright (C) 2018 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# See tests/testfile-dwarf-45.source
21testfiles testfile-splitdwarf-4 testfile-splitdwarf-5
22testfiles testfile-hello4.dwo testfile-hello5.dwo
23testfiles testfile-world4.dwo testfile-world5.dwo
24
25# DWARF4 GNU DebugFission No real table header.
26# We don't really need the skeleton, but we don't want any Warnings.
27testrun_compare ${abs_top_builddir}/src/readelf --dwarf-skeleton testfile-splitdwarf-4 --debug-dump=str testfile-hello4.dwo testfile-world4.dwo<<\EOF
28
29testfile-hello4.dwo:
30
31
32DWARF section [ 5] '.debug_str_offsets.dwo' at offset 0x335:
33Table at offset 0
34 Offsets start at 0x0:
35 [ 0] [       0]  "long long int"
36 [ 1] [       e]  "frob"
37 [ 2] [      13]  "long unsigned int"
38 [ 3] [      25]  "/home/mark/src/elfutils/tests"
39 [ 4] [      43]  "wchar_t"
40 [ 5] [      4b]  "main"
41 [ 6] [      50]  "long int"
42 [ 7] [      59]  "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
43 [ 8] [      e9]  "long double"
44 [ 9] [      f5]  "hello.c"
45
46
47DWARF section [ 6] '.debug_str.dwo' at offset 0x35d:
48 Offset  String
49 [   0]  "long long int"
50 [   e]  "frob"
51 [  13]  "long unsigned int"
52 [  25]  "/home/mark/src/elfutils/tests"
53 [  43]  "wchar_t"
54 [  4b]  "main"
55 [  50]  "long int"
56 [  59]  "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
57 [  e9]  "long double"
58 [  f5]  "hello.c"
59
60testfile-world4.dwo:
61
62
63DWARF section [ 5] '.debug_str_offsets.dwo' at offset 0x2e7:
64Table at offset 0
65 Offsets start at 0x0:
66 [ 0] [       0]  "long long unsigned int"
67 [ 1] [      17]  "/home/mark/src/elfutils/tests"
68 [ 2] [      35]  "long long int"
69 [ 3] [      43]  "signed char"
70 [ 4] [      4f]  "long int"
71 [ 5] [      58]  "world.c"
72 [ 6] [      60]  "unsigned int"
73 [ 7] [      6d]  "long unsigned int"
74 [ 8] [      7f]  "short unsigned int"
75 [ 9] [      92]  "frob"
76 [10] [      97]  "calc"
77 [11] [      9c]  "unsigned char"
78 [12] [      aa]  "short int"
79 [13] [      b4]  "exit"
80 [14] [      b9]  "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
81 [15] [     149]  "char"
82 [16] [     14e]  "word"
83 [17] [     153]  "argv"
84 [18] [     158]  "argc"
85 [19] [     15d]  "main"
86
87
88DWARF section [ 6] '.debug_str.dwo' at offset 0x337:
89 Offset  String
90 [   0]  "long long unsigned int"
91 [  17]  "/home/mark/src/elfutils/tests"
92 [  35]  "long long int"
93 [  43]  "signed char"
94 [  4f]  "long int"
95 [  58]  "world.c"
96 [  60]  "unsigned int"
97 [  6d]  "long unsigned int"
98 [  7f]  "short unsigned int"
99 [  92]  "frob"
100 [  97]  "calc"
101 [  9c]  "unsigned char"
102 [  aa]  "short int"
103 [  b4]  "exit"
104 [  b9]  "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
105 [ 149]  "char"
106 [ 14e]  "word"
107 [ 153]  "argv"
108 [ 158]  "argc"
109 [ 15d]  "main"
110EOF
111
112# DWARF5 Real table header.
113# We don't really need the skeleton, but we don't want any Warnings.
114testrun_compare ${abs_top_builddir}/src/readelf --dwarf-skeleton testfile-splitdwarf-5 --debug-dump=str testfile-hello5.dwo testfile-world5.dwo<<\EOF
115
116testfile-hello5.dwo:
117
118
119DWARF section [ 5] '.debug_str_offsets.dwo' at offset 0x353:
120Table at offset 0
121
122 Length:              44
123 Offset size:          4
124 DWARF version:        5
125 Padding:              0
126
127 Offsets start at 0x8:
128 [ 0] [       0]  "long long int"
129 [ 1] [       e]  "frob"
130 [ 2] [      13]  "long unsigned int"
131 [ 3] [      25]  "/home/mark/src/elfutils/tests"
132 [ 4] [      43]  "wchar_t"
133 [ 5] [      4b]  "main"
134 [ 6] [      50]  "long int"
135 [ 7] [      59]  "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
136 [ 8] [      e9]  "long double"
137 [ 9] [      f5]  "hello.c"
138
139
140DWARF section [ 6] '.debug_str.dwo' at offset 0x383:
141 Offset  String
142 [   0]  "long long int"
143 [   e]  "frob"
144 [  13]  "long unsigned int"
145 [  25]  "/home/mark/src/elfutils/tests"
146 [  43]  "wchar_t"
147 [  4b]  "main"
148 [  50]  "long int"
149 [  59]  "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
150 [  e9]  "long double"
151 [  f5]  "hello.c"
152
153testfile-world5.dwo:
154
155
156DWARF section [ 5] '.debug_str_offsets.dwo' at offset 0x313:
157Table at offset 0
158
159 Length:              84
160 Offset size:          4
161 DWARF version:        5
162 Padding:              0
163
164 Offsets start at 0x8:
165 [ 0] [       0]  "long long unsigned int"
166 [ 1] [      17]  "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
167 [ 2] [      a7]  "/home/mark/src/elfutils/tests"
168 [ 3] [      c5]  "long long int"
169 [ 4] [      d3]  "signed char"
170 [ 5] [      df]  "long int"
171 [ 6] [      e8]  "world.c"
172 [ 7] [      f0]  "unsigned int"
173 [ 8] [      fd]  "long unsigned int"
174 [ 9] [     10f]  "short unsigned int"
175 [10] [     122]  "frob"
176 [11] [     127]  "calc"
177 [12] [     12c]  "unsigned char"
178 [13] [     13a]  "short int"
179 [14] [     144]  "exit"
180 [15] [     149]  "char"
181 [16] [     14e]  "word"
182 [17] [     153]  "argv"
183 [18] [     158]  "argc"
184 [19] [     15d]  "main"
185
186
187DWARF section [ 6] '.debug_str.dwo' at offset 0x36b:
188 Offset  String
189 [   0]  "long long unsigned int"
190 [  17]  "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
191 [  a7]  "/home/mark/src/elfutils/tests"
192 [  c5]  "long long int"
193 [  d3]  "signed char"
194 [  df]  "long int"
195 [  e8]  "world.c"
196 [  f0]  "unsigned int"
197 [  fd]  "long unsigned int"
198 [ 10f]  "short unsigned int"
199 [ 122]  "frob"
200 [ 127]  "calc"
201 [ 12c]  "unsigned char"
202 [ 13a]  "short int"
203 [ 144]  "exit"
204 [ 149]  "char"
205 [ 14e]  "word"
206 [ 153]  "argv"
207 [ 158]  "argc"
208 [ 15d]  "main"
209EOF
210
211exit 0
212