1#! /bin/sh
2# Copyright (C) 2007, 2008 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
20testfiles testfile34 testfile38 testfile41 testfile49
21
22testrun_compare ${abs_top_builddir}/src/addr2line -f -e testfile34 \
23				 0x08048074 0x08048075 0x08048076 \
24				 0x08049078 0x08048080 0x08049080 <<\EOF
25foo
26??:0
27bar
28??:0
29_etext
30??:0
31data1
32??:0
33??
34??:0
35_end
36??:0
37EOF
38
39testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile38 0x02 0x10a 0x211 0x31a <<\EOF
40t1_global_outer+0x2
41??:0
42t2_global_symbol+0x2
43??:0
44t3_global_after_0+0x1
45??:0
46(.text)+0x31a
47??:0
48EOF
49
50testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile41 0x1 0x104 <<\EOF
51small_global_at_large_global+0x1
52??:0
53small_global_first_at_large_global+0x1
54??:0
55EOF
56
57testfiles testfile12 testfile14
58tempfiles testmaps
59
60cat > testmaps <<EOF
6100400000-00401000 r-xp 00000000 fd:01 4006812                            `pwd`/testfile14
6200500000-00501000 rw-p 00000000 fd:01 4006812                            `pwd`/testfile14
6301000000-01001000 r-xp 00000000 fd:01 1234567				 `pwd`/testfile12
6401100000-01011000 rw-p 00000000 fd:01 1234567				 `pwd`/testfile12
652aaaaaaab000-2aaaaaaad000 rw-p 2aaaaaaab000 00:00 0 
662aaaaaae2000-2aaaaaae3000 rw-p 2aaaaaae2000 00:00 0 
677fff61068000-7fff6107d000 rw-p 7ffffffea000 00:00 0                      [stack]
687fff611fe000-7fff61200000 r-xp 7fff611fe000 00:00 0                      [vdso]
69ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
70EOF
71
72testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps 0x40047c 0x10009db <<\EOF
73caller+0x14
74/home/drepper/local/elfutils-build/20050425/v.c:11
75foo+0xb
76/home/drepper/local/elfutils-build/20030710/u.c:5
77EOF
78
79#	.section .text
80#	nop #0
81#sizeless_foo:
82#	nop #1
83#	nop #2
84#sized_bar:
85#	nop #3
86#	nop #4
87#sizeless_baz:
88#	nop #5
89#	nop #6
90#	.size sized_bar, . - sized_bar
91#	nop #7
92#	nop #8
93#sizeless_x:
94#	nop #9
95#	.org 0x100
96#	nop #0
97#	.globl global_outer
98#global_outer:
99#	nop #1
100#	nop #2
101#	.globl global_in_global
102#global_in_global:
103#	nop #3
104#	nop #4
105#	.size global_in_global, . - global_in_global
106#local_in_global:
107#	nop #5
108#	nop #6
109#	.size local_in_global, . - local_in_global
110#	nop #7
111#	nop #8
112#.Lsizeless1:
113#	nop #9
114#	nop #10
115#	.size global_outer, . - global_outer
116#	nop #11
117#	.org 0x200
118#	nop #0
119#local_outer:
120#	nop #1
121#	nop #2
122#	.globl global_in_local
123#global_in_local:
124#	nop #3
125#	nop #4
126#	.size global_in_local, . - global_in_local
127#local_in_local:
128#	nop #5
129#	nop #6
130#	.size local_in_local, . - local_in_local
131#	nop #7
132#	nop #8
133#.Lsizeless2:
134#	nop #9
135#	nop #10
136#	.size local_outer, . - local_outer
137#	nop #11
138testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile49 \
139    		0 1 2 3 4 5 6 7 8 9 \
140		0x100 0x101 0x102 0x103 0x104 0x105 \
141		0x106 0x107 0x108 0x109 0x10a 0x10b \
142		0x200 0x201 0x202 0x203 0x204 0x205 \
143		0x206 0x207 0x208 0x209 0x20a 0x20b <<\EOF
144(.text)+0
145??:0
146sizeless_foo
147??:0
148sizeless_foo+0x1
149??:0
150sized_bar
151??:0
152sized_bar+0x1
153??:0
154sized_bar+0x2
155??:0
156sized_bar+0x3
157??:0
158(.text)+0x7
159??:0
160(.text)+0x8
161??:0
162sizeless_x
163??:0
164sizeless_x+0xf7
165??:0
166global_outer
167??:0
168global_outer+0x1
169??:0
170global_in_global
171??:0
172global_in_global+0x1
173??:0
174global_outer+0x4
175??:0
176global_outer+0x5
177??:0
178global_outer+0x6
179??:0
180global_outer+0x7
181??:0
182global_outer+0x8
183??:0
184global_outer+0x9
185??:0
186(.text)+0x10b
187??:0
188(.text)+0x200
189??:0
190local_outer
191??:0
192local_outer+0x1
193??:0
194global_in_local
195??:0
196global_in_local+0x1
197??:0
198local_in_local
199??:0
200local_in_local+0x1
201??:0
202local_outer+0x6
203??:0
204local_outer+0x7
205??:0
206local_outer+0x8
207??:0
208local_outer+0x9
209??:0
210(.text)+0x20b
211??:0
212EOF
213
214#	.macro global label size
215#\label:	.globl \label
216#	.size \label, \size
217#	.endm
218#	.macro weak label size
219#\label:	.weak \label
220#	.size \label, \size
221#	.endm
222#	.macro local label size
223#\label:	.size \label, \size
224#	.endm
225#	.macro offset val
226#	.ifne (. - _start) - \val
227#	.err
228#	.endif
229#	.byte \val
230#	.endm
231#
232#_start:
233#	offset 0
234#
235#	local glocal, 1
236#	weak gweak, 1
237#	global gglobal1, 2
238#	global gglobal2, 1
239#	global gglobal3, 1
240#	offset 1
241#	/* Symbols end here.  */
242#	offset 2
243#	/* gglobal1 ends here.  */
244#	offset 3
245#
246#	local g0local, 0
247#	weak g0weak, 0
248#	global g0global1, 0
249#	global g0global2, 0
250#	offset 4
251#
252#	local wlocal, 1
253#	weak wweak1, 2
254#	weak wweak2, 1
255#	weak wweak3, 1
256#	offset 5
257#	/* Symbols end here.  */
258#	offset 6
259#	/* wweak1 ends here.  */
260#	offset 7
261#
262#	local w0local, 0
263#	weak w0weak1, 0
264#	weak w0weak2, 0
265#	offset 8
266#
267#	local llocal1, 2
268#	local llocal2, 1
269#	local llocal3, 1
270#	offset 9
271#	/* Symbols end here.  */
272#	offset 10
273#	/* llocal1 ends here.  */
274#	offset 11
275#
276#	local l0local1, 0
277#	local l0local2, 0
278#	offset 12
279testfiles testfile64
280testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile64 1 4 5 8 9 c <<\EOF
281gglobal2
282??:0
283g0global2
284??:0
285wweak2
286??:0
287w0weak2
288??:0
289llocal2
290??:0
291l0local2
292??:0
293EOF
294
295testfiles testfile65
296testrun_compare ${abs_top_builddir}/src/addr2line -S --core=testfile65 0x7fff94bffa30 <<\EOF
297__vdso_time
298??:0
299EOF
300
301#	.section	".text"
302#	.globl _start
303#	.section	".opd","aw"
304#_start:	.quad	.L._start,.TOC.@tocbase
305#	.previous
306#	.type	_start, @function
307#.L._start:
308#	.byte	0x7d, 0x82, 0x10, 0x08
309#	.size	_start,.-.L._start
310testfiles testfile66 testfile66.core
311testrun_compare ${abs_top_builddir}/src/addr2line -x -e testfile66 _start 0x2d8 0x2db 0x2dc 0x103d0 0x103d3 0x103d4<<EOF
312_start (.text)
313??:0
314_start (.text)
315??:0
316_start+0x3 (.text)
317??:0
318()+0x2dc
319??:0
320_start (.opd)
321??:0
322_start+0x3 (.opd)
323??:0
324()+0x103d4
325??:0
326EOF
327testrun_compare ${abs_top_builddir}/src/addr2line -x -e testfile66 --core=testfile66.core _start 0x461b02d8 0x461c03d0<<\EOF
328_start (.text)
329??:0
330_start (.text)
331??:0
332_start (.opd)
333??:0
334EOF
335
336testfiles testfile69.core testfile69.so
337testrun_compare ${abs_top_builddir}/src/addr2line --core=./testfile69.core -S 0x7f0bc6a33535 0x7f0bc6a33546 <<\EOF
338libstatic+0x9
339??:0
340libglobal+0x9
341??:0
342EOF
343
344testfiles testfile70.exec testfile70.core
345testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile70.exec --core=testfile70.core 0x7ff2cfe9b6b5 <<\EOF
346main+0x9
347??:0
348EOF
349testrun_compare ${abs_top_builddir}/src/addr2line -S --core=testfile70.core -e testfile70.exec 0x7ff2cfe9b6b5 <<\EOF
350main+0x9
351??:0
352EOF
353
354testfiles test-core-lib.so test-core.core test-core.exec
355testrun_compare ${abs_top_builddir}/src/addr2line -S -e test-core.exec --core=test-core.core 0x7f67f2aaf619 <<\EOF
356libfunc+0x9
357??:0
358EOF
359
360exit 0
361