2 # Copyright (C) 2012 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
26 # extern char *global;
27 # int say (struct foo *prefix);
32 # static char *hello = "Hello";
35 # main (int argc, char **argv)
48 # static int hello (const char *bar)
50 # return bar == global;
54 # say (struct foo *prefix)
56 # return hello (prefix->bar);
59 # gcc -g -fdebug-types-section -c hello.c
60 # gcc -g -fdebug-types-section -c world.c
61 # gcc -g -fdebug-types-section -o testfilegdbindex7 hello.o world.o
62 # gdb testfilegdbindex7
63 # (gdb) save gdb-index .
64 # objcopy --add-section .gdb_index=testfilegdbindex7.gdb-index --set-section-flags .gdb_index=readonly testfilegdbindex7 testfilegdbindex7
66 testfiles testfilegdbindex5 testfilegdbindex7
68 testrun_compare ../src/readelf --debug-dump=gdb_index testfilegdbindex5 <<\EOF
70 GDB section [33] '.gdb_index' at offset 0xe76 contains 8383 bytes :
76 constant offset: 0x2078
78 CU list at offset 0x18 contains 2 entries:
79 [ 0] start: 00000000, length: 184
80 [ 1] start: 0x0000b8, length: 204
82 TU list at offset 0x38 contains 1 entries:
83 [ 0] CU offset: 0, type offset: 29, signature: 0x87e03f92cc37cdf0
85 Address list at offset 0x50 contains 2 entries:
86 [ 0] 0x000000000040049c <main>..0x00000000004004d1 <main+0x35>, CU index: 0
87 [ 1] 0x00000000004004d4 <hello>..0x000000000040050b <say+0x1c>, CU index: 1
89 Symbol table at offset 0x50 contains 1024 slots:
90 [ 123] symbol: global, CUs: 1
91 [ 489] symbol: main, CUs: 0
92 [ 518] symbol: char, CUs: 0
93 [ 661] symbol: foo, CUs: 0T
94 [ 741] symbol: hello, CUs: 0, 1
95 [ 746] symbol: say, CUs: 1
96 [ 754] symbol: int, CUs: 0
99 testrun_compare ../src/readelf --debug-dump=gdb_index testfilegdbindex7 <<\EOF
101 GDB section [33] '.gdb_index' at offset 0xe76 contains 8399 bytes :
107 constant offset: 0x2078
109 CU list at offset 0x18 contains 2 entries:
110 [ 0] start: 00000000, length: 184
111 [ 1] start: 0x0000b8, length: 204
113 TU list at offset 0x38 contains 1 entries:
114 [ 0] CU offset: 0, type offset: 29, signature: 0x87e03f92cc37cdf0
116 Address list at offset 0x50 contains 2 entries:
117 [ 0] 0x000000000040049c <main>..0x00000000004004d1 <main+0x35>, CU index: 0
118 [ 1] 0x00000000004004d4 <hello>..0x000000000040050b <say+0x1c>, CU index: 1
120 Symbol table at offset 0x50 contains 1024 slots:
121 [ 123] symbol: global, CUs: 1 (var:G)
122 [ 489] symbol: main, CUs: 0 (func:G)
123 [ 518] symbol: char, CUs: 0 (type:S)
124 [ 661] symbol: foo, CUs: 0T (type:S)
125 [ 741] symbol: hello, CUs: 0 (var:S), 1 (func:S)
126 [ 746] symbol: say, CUs: 1 (func:G)
127 [ 754] symbol: int, CUs: 0 (type:S)