Imported Upstream version 0.155
[platform/upstream/elfutils.git] / tests / run-readelf-dwz-multi.sh
1 #! /bin/sh
2 # Copyright (C) 2012 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 # common.h
21 #
22 # #include <stdio.h>
23 #
24 # struct foobar
25 # {
26 #   int foo;
27 #   struct foobar *bar;
28 # };
29 #
30 # extern int call_foo(struct foobar *foobar_struct_ptr);
31
32 # main.c
33 #
34 # #include "common.h"
35 #
36 # int main(int argc, char ** argv)
37 # {
38 #   struct foobar b;
39 #   b.foo = 42;
40 #   b.bar = &b;
41 #
42 #   return call_foo(b.bar);
43 # }
44
45 # shared.c
46 #
47 # #include "common.h"
48 #
49 # int call_foo(struct foobar *fb)
50 # {
51 #   return fb->bar->foo - 42;
52 # }
53
54 # gcc -fPIC -g -c -Wall shared.c
55 # gcc -shared -o libtestfile_multi_shared.so shared.o
56 # gcc -g -o testfile_multi_main -L. -ltestfile_multi_shared main.c -Wl,-rpath,.
57 # dwz -m testfile_multi.dwz testfile_multi_main libtestfile_multi_shared.so
58
59 testfiles libtestfile_multi_shared.so testfile_multi_main testfile_multi.dwz
60
61 testrun_compare ../src/readelf --debug-dump=info testfile_multi_main <<\EOF
62
63 DWARF section [28] '.debug_info' at offset 0x1078:
64  [Offset]
65  Compilation unit at offset 0:
66  Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
67  [     b]  compile_unit
68            producer             (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -mtune=generic -march=x86-64 -g"
69            language             (data1) C89 (1)
70            name                 (strp) "main.c"
71            comp_dir             (GNU_strp_alt) "/home/mark/src/tests/dwz"
72            low_pc               (addr) 0x00000000004006ac <main>
73            high_pc              (udata) 44
74            stmt_list            (sec_offset) 0
75  [    26]    imported_unit
76              import               (GNU_ref_alt) [     b]
77  [    2b]    pointer_type
78              byte_size            (data1) 8
79              type                 (GNU_ref_alt) [    53]
80  [    31]    subprogram
81              external             (flag_present) 
82              name                 (strp) "main"
83              decl_file            (data1) 1
84              decl_line            (data1) 3
85              prototyped           (flag_present) 
86              type                 (GNU_ref_alt) [    3e]
87              low_pc               (addr) 0x00000000004006ac <main>
88              high_pc              (udata) 44
89              frame_base           (exprloc) 
90               [   0] call_frame_cfa
91              GNU_all_tail_call_sites (flag_present) 
92              sibling              (ref_udata) [    6e]
93  [    48]      formal_parameter
94                name                 (strp) "argc"
95                decl_file            (data1) 1
96                decl_line            (data1) 3
97                type                 (GNU_ref_alt) [    3e]
98                location             (exprloc) 
99                 [   0] fbreg -36
100  [    56]      formal_parameter
101                name                 (strp) "argv"
102                decl_file            (data1) 1
103                decl_line            (data1) 3
104                type                 (ref_udata) [    6e]
105                location             (exprloc) 
106                 [   0] fbreg -48
107  [    61]      variable
108                name                 (string) "b"
109                decl_file            (data1) 1
110                decl_line            (data1) 5
111                type                 (GNU_ref_alt) [    5a]
112                location             (exprloc) 
113                 [   0] fbreg -32
114  [    6e]    pointer_type
115              byte_size            (data1) 8
116              type                 (ref_udata) [    2b]
117 EOF
118
119 testrun_compare ../src/readelf --debug-dump=info libtestfile_multi_shared.so <<\EOF
120
121 DWARF section [25] '.debug_info' at offset 0x106c:
122  [Offset]
123  Compilation unit at offset 0:
124  Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
125  [     b]  compile_unit
126            producer             (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -fpreprocessed -mtune=generic -march=x86-64 -g -fPIC"
127            language             (data1) C89 (1)
128            name                 (strp) "shared.c"
129            comp_dir             (GNU_strp_alt) "/home/mark/src/tests/dwz"
130            low_pc               (addr) +0x0000000000000670 <call_foo>
131            high_pc              (udata) 23
132            stmt_list            (sec_offset) 0
133  [    26]    imported_unit
134              import               (GNU_ref_alt) [     b]
135  [    2b]    subprogram
136              external             (flag_present) 
137              name                 (strp) "call_foo"
138              decl_file            (data1) 1
139              decl_line            (data1) 3
140              prototyped           (flag_present) 
141              type                 (GNU_ref_alt) [    3e]
142              low_pc               (addr) +0x0000000000000670 <call_foo>
143              high_pc              (udata) 23
144              frame_base           (exprloc) 
145               [   0] call_frame_cfa
146              GNU_all_call_sites   (flag_present) 
147  [    41]      formal_parameter
148                name                 (string) "fb"
149                decl_file            (data1) 1
150                decl_line            (data1) 3
151                type                 (GNU_ref_alt) [    76]
152                location             (exprloc) 
153                 [   0] fbreg -24
154 EOF
155
156 exit 0