Blame tests/run-readelf-gdb_index.sh

Packit 032894
#! /bin/sh
Packit 032894
# Copyright (C) 2012 Red Hat, Inc.
Packit 032894
# This file is part of elfutils.
Packit 032894
#
Packit 032894
# This file is free software; you can redistribute it and/or modify
Packit 032894
# it under the terms of the GNU General Public License as published by
Packit 032894
# the Free Software Foundation; either version 3 of the License, or
Packit 032894
# (at your option) any later version.
Packit 032894
#
Packit 032894
# elfutils is distributed in the hope that it will be useful, but
Packit 032894
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 032894
# GNU General Public License for more details.
Packit 032894
#
Packit 032894
# You should have received a copy of the GNU General Public License
Packit 032894
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 032894
Packit 032894
. $srcdir/test-subr.sh
Packit 032894
Packit 032894
# common.h
Packit 032894
# struct foo
Packit 032894
# {
Packit 032894
#   const char *bar;
Packit 032894
# };
Packit 032894
#
Packit 032894
# extern char *global;
Packit 032894
# int say (struct foo *prefix);
Packit 032894
Packit 032894
# hello.c
Packit 032894
# #include "common.h"
Packit 032894
#
Packit 032894
# static char *hello = "Hello";
Packit 032894
#
Packit 032894
# int
Packit 032894
# main (int argc, char **argv)
Packit 032894
# {
Packit 032894
#   struct foo baz;
Packit 032894
#   global = hello;
Packit 032894
#   baz.bar = global;
Packit 032894
#   return say(&baz;;
Packit 032894
# }
Packit 032894
Packit 032894
# world.c
Packit 032894
# #include "common.h"
Packit 032894
#
Packit 032894
# char *global;
Packit 032894
#
Packit 032894
# static int hello (const char *bar)
Packit 032894
# {
Packit 032894
#   return bar == global;
Packit 032894
# }
Packit 032894
#
Packit 032894
# int
Packit 032894
# say (struct foo *prefix)
Packit 032894
# {
Packit 032894
#   return hello (prefix->bar);
Packit 032894
# }
Packit 032894
Packit 032894
# gcc -g -fdebug-types-section -c hello.c
Packit 032894
# gcc -g -fdebug-types-section -c world.c
Packit 032894
# gcc -g -fdebug-types-section -o testfilegdbindex7 hello.o world.o
Packit 032894
# gdb testfilegdbindex7
Packit 032894
# (gdb) save gdb-index .
Packit 032894
# objcopy --add-section .gdb_index=testfilegdbindex7.gdb-index --set-section-flags .gdb_index=readonly testfilegdbindex7 testfilegdbindex7
Packit 032894
Packit 032894
testfiles testfilegdbindex5 testfilegdbindex7
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=gdb_index testfilegdbindex5 <<\EOF
Packit 032894
Packit 032894
GDB section [33] '.gdb_index' at offset 0xe76 contains 8383 bytes :
Packit 032894
 Version:         5
Packit 032894
 CU offset:       0x18
Packit 032894
 TU offset:       0x38
Packit 032894
 address offset:  0x50
Packit 032894
 symbol offset:   0x78
Packit 032894
 constant offset: 0x2078
Packit 032894
Packit 032894
 CU list at offset 0x18 contains 2 entries:
Packit 032894
 [   0] start: 00000000, length:   184
Packit 032894
 [   1] start: 0x0000b8, length:   204
Packit 032894
Packit 032894
 TU list at offset 0x38 contains 1 entries:
Packit 032894
 [   0] CU offset:     0, type offset:    29, signature: 0x87e03f92cc37cdf0
Packit 032894
Packit 032894
 Address list at offset 0x50 contains 2 entries:
Packit 032894
 [   0] 0x000000000040049c <main>..0x00000000004004d1 <main+0x35>, CU index:     0
Packit 032894
 [   1] 0x00000000004004d4 <hello>..0x000000000040050b <say+0x1c>, CU index:     1
Packit 032894
Packit 032894
 Symbol table at offset 0x50 contains 1024 slots:
Packit 032894
 [ 123] symbol: global, CUs: 1
Packit 032894
 [ 489] symbol: main, CUs: 0
Packit 032894
 [ 518] symbol: char, CUs: 0
Packit 032894
 [ 661] symbol: foo, CUs: 0T
Packit 032894
 [ 741] symbol: hello, CUs: 0, 1
Packit 032894
 [ 746] symbol: say, CUs: 1
Packit 032894
 [ 754] symbol: int, CUs: 0
Packit 032894
EOF
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=gdb_index testfilegdbindex7 <<\EOF
Packit 032894
Packit 032894
GDB section [33] '.gdb_index' at offset 0xe76 contains 8399 bytes :
Packit 032894
 Version:         7
Packit 032894
 CU offset:       0x18
Packit 032894
 TU offset:       0x38
Packit 032894
 address offset:  0x50
Packit 032894
 symbol offset:   0x78
Packit 032894
 constant offset: 0x2078
Packit 032894
Packit 032894
 CU list at offset 0x18 contains 2 entries:
Packit 032894
 [   0] start: 00000000, length:   184
Packit 032894
 [   1] start: 0x0000b8, length:   204
Packit 032894
Packit 032894
 TU list at offset 0x38 contains 1 entries:
Packit 032894
 [   0] CU offset:     0, type offset:    29, signature: 0x87e03f92cc37cdf0
Packit 032894
Packit 032894
 Address list at offset 0x50 contains 2 entries:
Packit 032894
 [   0] 0x000000000040049c <main>..0x00000000004004d1 <main+0x35>, CU index:     0
Packit 032894
 [   1] 0x00000000004004d4 <hello>..0x000000000040050b <say+0x1c>, CU index:     1
Packit 032894
Packit 032894
 Symbol table at offset 0x50 contains 1024 slots:
Packit 032894
 [ 123] symbol: global, CUs: 1 (var:G)
Packit 032894
 [ 489] symbol: main, CUs: 0 (func:G)
Packit 032894
 [ 518] symbol: char, CUs: 0 (type:S)
Packit 032894
 [ 661] symbol: foo, CUs: 0T (type:S)
Packit 032894
 [ 741] symbol: hello, CUs: 0 (var:S), 1 (func:S)
Packit 032894
 [ 746] symbol: say, CUs: 1 (func:G)
Packit 032894
 [ 754] symbol: int, CUs: 0 (type:S)
Packit 032894
EOF
Packit 032894
Packit 032894
exit 0