Blame tests/run-readelf-zdebug-rel.sh

Packit 032894
#! /bin/sh
Packit 032894
# Copyright (C) 2015 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
# - testfile-zdebug-rel.c
Packit 032894
# #define UINT64_MAX 18446744073709551615UL
Packit 032894
#
Packit 032894
# int
Packit 032894
# main (int argc, char **argv)
Packit 032894
# {
Packit 032894
#   unsigned long a = UINT64_MAX - 8;
Packit 032894
#   unsigned long b = 42 + argc;
Packit 032894
#
Packit 032894
#   if ( a + b < b )
Packit 032894
#     argc = a + argc;
Packit 032894
#   else
Packit 032894
#      b--;
Packit 032894
#
Packit 032894
#   return a - b;
Packit 032894
# }
Packit 032894
#
Packit 032894
# gcc -Og -g -Xassembler --compress-debug-sections=none \
Packit 032894
#     -c -o testfile-debug-rel.o testfile-zdebug-rel.c
Packit 032894
# gcc -Og -g -Xassembler --compress-debug-sections=zlib-gnu \
Packit 032894
#     -c -o testfile-debug-rel-g.o testfile-zdebug-rel.c
Packit 032894
# gcc -Og -g -Xassembler --compress-debug-sections=zlib-gabi \
Packit 032894
#     -c -o testfile-debug-rel-z.o testfile-zdebug-rel.c
Packit 032894
Packit 032894
testfiles testfile-debug-rel.o testfile-debug-rel-g.o testfile-debug-rel-z.o
Packit 032894
tempfiles readelf.out
Packit 032894
tempfiles info.out loc.out
Packit 032894
Packit 032894
cat > info.out << \EOF
Packit 032894
Packit 032894
DWARF section [ 4] '.debug_info' at offset 0x58:
Packit 032894
 [Offset]
Packit 032894
 Compilation unit at offset 0:
Packit 032894
 Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
Packit 032894
 [     b]  compile_unit         abbrev: 1
Packit 032894
           producer             (strp) "GNU C11 5.3.1 20151207 (Red Hat 5.3.1-2) -mtune=generic -march=x86-64 -g -Og"
Packit 032894
           language             (data1) C99 (12)
Packit 032894
           name                 (strp) "testfile-zdebug-rel.c"
Packit 032894
           comp_dir             (strp) "/tmp"
Packit 032894
           low_pc               (addr) 000000000000000000
Packit 032894
           high_pc              (data8) 24 (0x0000000000000018)
Packit 032894
           stmt_list            (sec_offset) 0
Packit 032894
 [    2d]    subprogram           abbrev: 2
Packit 032894
             external             (flag_present) yes
Packit 032894
             name                 (strp) "main"
Packit 032894
             decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
             decl_line            (data1) 4
Packit 032894
             prototyped           (flag_present) yes
Packit 032894
             type                 (ref4) [    80]
Packit 032894
             low_pc               (addr) 000000000000000000
Packit 032894
             high_pc              (data8) 24 (0x0000000000000018)
Packit 032894
             frame_base           (exprloc) 
Packit 032894
              [ 0] call_frame_cfa
Packit 032894
             GNU_all_call_sites   (flag_present) yes
Packit 032894
             sibling              (ref4) [    80]
Packit 032894
 [    4e]      formal_parameter     abbrev: 3
Packit 032894
               name                 (strp) "argc"
Packit 032894
               decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
               decl_line            (data1) 4
Packit 032894
               type                 (ref4) [    80]
Packit 032894
               location             (sec_offset) location list [     0]
Packit 032894
 [    5d]      formal_parameter     abbrev: 4
Packit 032894
               name                 (strp) "argv"
Packit 032894
               decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
               decl_line            (data1) 4
Packit 032894
               type                 (ref4) [    87]
Packit 032894
               location             (exprloc) 
Packit 032894
                [ 0] reg4
Packit 032894
 [    6a]      variable             abbrev: 5
Packit 032894
               name                 (string) "a"
Packit 032894
               decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
               decl_line            (data1) 6
Packit 032894
               type                 (ref4) [    9a]
Packit 032894
               const_value          (sdata) 18446744073709551607 (-9)
Packit 032894
 [    74]      variable             abbrev: 6
Packit 032894
               name                 (string) "b"
Packit 032894
               decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
               decl_line            (data1) 7
Packit 032894
               type                 (ref4) [    9a]
Packit 032894
               location             (exprloc) 
Packit 032894
                [ 0] reg5
Packit 032894
 [    80]    base_type            abbrev: 7
Packit 032894
             byte_size            (data1) 4
Packit 032894
             encoding             (data1) signed (5)
Packit 032894
             name                 (string) "int"
Packit 032894
 [    87]    pointer_type         abbrev: 8
Packit 032894
             byte_size            (data1) 8
Packit 032894
             type                 (ref4) [    8d]
Packit 032894
 [    8d]    pointer_type         abbrev: 8
Packit 032894
             byte_size            (data1) 8
Packit 032894
             type                 (ref4) [    93]
Packit 032894
 [    93]    base_type            abbrev: 9
Packit 032894
             byte_size            (data1) 1
Packit 032894
             encoding             (data1) signed_char (6)
Packit 032894
             name                 (strp) "char"
Packit 032894
 [    9a]    base_type            abbrev: 9
Packit 032894
             byte_size            (data1) 8
Packit 032894
             encoding             (data1) unsigned (7)
Packit 032894
             name                 (strp) "long unsigned int"
Packit 032894
EOF
Packit 032894
Packit 032894
cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel.o
Packit 032894
Packit 032894
cat info.out | sed -e "s/'.debug_info'/'.zdebug_info'/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-g.o
Packit 032894
Packit 032894
cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-z.o
Packit 032894
Packit 032894
cat > loc.out << \EOF
Packit 032894
Packit 032894
DWARF section [ 7] '.debug_loc' at offset 0x185:
Packit 032894
Packit 032894
 CU [     b] base: 000000000000000000
Packit 032894
 [     0] range 0, 3
Packit 032894
           [ 0] reg5
Packit 032894
          range 3, 10
Packit 032894
           [ 0] breg5 -42
Packit 032894
           [ 2] stack_value
Packit 032894
          range 10, 18
Packit 032894
           [ 0] GNU_entry_value:
Packit 032894
                [ 0] reg5
Packit 032894
           [ 3] stack_value
Packit 032894
EOF
Packit 032894
Packit 032894
cat loc.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel.o
Packit 032894
Packit 032894
cat loc.out | sed -e "s/'.debug_loc' at offset 0x185/'.zdebug_loc' at offset 0x138/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-g.o
Packit 032894
Packit 032894
cat loc.out | sed -e "s/at offset 0x185/at offset 0x150/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-z.o
Packit 032894
Packit 032894
# Same as above, but on ppc64
Packit 032894
testfiles testfile-debug-rel-ppc64.o
Packit 032894
testfiles testfile-debug-rel-ppc64-g.o testfile-debug-rel-ppc64-z.o
Packit 032894
Packit 032894
cat > info.out << \EOF
Packit 032894
Packit 032894
DWARF section [ 6] '.debug_info' at offset 0x80:
Packit 032894
 [Offset]
Packit 032894
 Compilation unit at offset 0:
Packit 032894
 Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
Packit 032894
 [     b]  compile_unit         abbrev: 1
Packit 032894
           producer             (strp) "GNU C11 7.3.1 20180712 (Red Hat 7.3.1-6) -Asystem=linux -Asystem=unix -Asystem=posix -msecure-plt -g -Og"
Packit 032894
           language             (data1) C99 (12)
Packit 032894
           name                 (strp) "testfile-zdebug-rel.c"
Packit 032894
           comp_dir             (strp) "/home/mjw"
Packit 032894
           low_pc               (addr) 000000000000000000
Packit 032894
           high_pc              (data8) 44 (0x000000000000002c)
Packit 032894
           stmt_list            (sec_offset) 0
Packit 032894
 [    2d]    subprogram           abbrev: 2
Packit 032894
             external             (flag_present) yes
Packit 032894
             name                 (strp) "main"
Packit 032894
             decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
             decl_line            (data1) 4
Packit 032894
             prototyped           (flag_present) yes
Packit 032894
             type                 (ref4) [    82]
Packit 032894
             low_pc               (addr) 000000000000000000
Packit 032894
             high_pc              (data8) 44 (0x000000000000002c)
Packit 032894
             frame_base           (exprloc) 
Packit 032894
              [ 0] call_frame_cfa
Packit 032894
             GNU_all_call_sites   (flag_present) yes
Packit 032894
             sibling              (ref4) [    82]
Packit 032894
 [    4e]      formal_parameter     abbrev: 3
Packit 032894
               name                 (strp) "argc"
Packit 032894
               decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
               decl_line            (data1) 4
Packit 032894
               type                 (ref4) [    82]
Packit 032894
               location             (sec_offset) location list [     0]
Packit 032894
 [    5d]      formal_parameter     abbrev: 4
Packit 032894
               name                 (strp) "argv"
Packit 032894
               decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
               decl_line            (data1) 4
Packit 032894
               type                 (ref4) [    89]
Packit 032894
               location             (exprloc) 
Packit 032894
                [ 0] reg4
Packit 032894
 [    6a]      variable             abbrev: 5
Packit 032894
               name                 (string) "a"
Packit 032894
               decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
               decl_line            (data1) 6
Packit 032894
               type                 (ref4) [    9c]
Packit 032894
               const_value          (sdata) 18446744073709551607 (-9)
Packit 032894
 [    74]      variable             abbrev: 6
Packit 032894
               name                 (string) "b"
Packit 032894
               decl_file            (data1) testfile-zdebug-rel.c (1)
Packit 032894
               decl_line            (data1) 7
Packit 032894
               type                 (ref4) [    9c]
Packit 032894
               location             (sec_offset) location list [    4e]
Packit 032894
 [    82]    base_type            abbrev: 7
Packit 032894
             byte_size            (data1) 4
Packit 032894
             encoding             (data1) signed (5)
Packit 032894
             name                 (string) "int"
Packit 032894
 [    89]    pointer_type         abbrev: 8
Packit 032894
             byte_size            (data1) 8
Packit 032894
             type                 (ref4) [    8f]
Packit 032894
 [    8f]    pointer_type         abbrev: 8
Packit 032894
             byte_size            (data1) 8
Packit 032894
             type                 (ref4) [    95]
Packit 032894
 [    95]    base_type            abbrev: 9
Packit 032894
             byte_size            (data1) 1
Packit 032894
             encoding             (data1) unsigned_char (8)
Packit 032894
             name                 (strp) "char"
Packit 032894
 [    9c]    base_type            abbrev: 9
Packit 032894
             byte_size            (data1) 8
Packit 032894
             encoding             (data1) unsigned (7)
Packit 032894
             name                 (strp) "long unsigned int"
Packit 032894
EOF
Packit 032894
Packit 032894
cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-ppc64.o
Packit 032894
Packit 032894
cat info.out | sed -e "s/'.debug_info'/'.zdebug_info'/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-ppc64-g.o
Packit 032894
Packit 032894
cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-ppc64-z.o
Packit 032894
Packit 032894
cat > loc.out << \EOF
Packit 032894
Packit 032894
DWARF section [ 9] '.debug_loc' at offset 0x1af:
Packit 032894
Packit 032894
 CU [     b] base: 000000000000000000
Packit 032894
 [     0] range 0, 4
Packit 032894
           [ 0] reg3
Packit 032894
          range 4, 14
Packit 032894
           [ 0] breg3 -42
Packit 032894
           [ 2] stack_value
Packit 032894
          range 14, 2c
Packit 032894
           [ 0] GNU_entry_value:
Packit 032894
                [ 0] reg3
Packit 032894
           [ 3] stack_value
Packit 032894
 [    4e] range 8, 18
Packit 032894
           [ 0] reg3
Packit 032894
EOF
Packit 032894
Packit 032894
cat loc.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-ppc64.o
Packit 032894
Packit 032894
cat loc.out | sed -e "s/'.debug_loc' at offset 0x1af/'.zdebug_loc' at offset 0x15f/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-ppc64-g.o
Packit 032894
Packit 032894
cat loc.out | sed -e "s/at offset 0x1af/at offset 0x177/" | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel-ppc64-z.o
Packit 032894
Packit 032894
exit 0