1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
#! /bin/sh
# Test for displaying DW_AT_const_types with the "correct" sign.
# Copyright (C) 2018 Red Hat, Inc.
# This file is part of elfutils.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# elfutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. $srcdir/test-subr.sh
# = s.c
#
# int s()
# {
# int i = -1;
# int j = -1;
#
# return i - j;
# }
#
# = m.c
#
# extern int s();
#
# int
# main ()
# {
# const signed char sc = -2;
# const unsigned char uc = 254;
#
# const signed short ss = -16;
# const unsigned short us = 65520;
#
# const signed int si = -3;
# const unsigned int ui = 4200000000;
#
# signed long sl = -1;
# unsigned long ul = 0xffffffffffffffffUL;
#
# return s ();
# }
#
# gcc -gdwarf-5 -O2 -c s.c
# gcc -gdwarf-4 -O2 -c m.c
# gcc -o testfile-const-values s.o m.o
# eu-strip -g -f testfile-const-values.debug testfile-const-values
testfiles testfile-const-values.debug
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info testfile-const-values.debug << EOF
DWARF section [28] '.debug_info' at offset 0x2e0:
[Offset]
Compilation unit at offset 0:
Version: 5, Abbreviation section offset: 0, Address size: 8, Offset size: 4
Unit type: compile (1)
[ c] compile_unit abbrev: 2
producer (strp) "GNU C11 7.3.1 20180303 (Red Hat 7.3.1-5) -mtune=generic -march=x86-64 -gdwarf-5 -O2"
language (data1) C11 (29)
name (string) "s.c"
comp_dir (strp) "/home/mark/build/elfutils-obj"
low_pc (addr) 0x00000000004004d0
high_pc (data8) 3 (0x00000000004004d3)
stmt_list (sec_offset) 0
[ 2e] subprogram abbrev: 3
external (flag_present) yes
name (string) "s"
decl_file (data1) s.c (1)
decl_line (data1) 1
type (ref4) [ 5e]
low_pc (addr) 0x00000000004004d0
high_pc (data8) 3 (0x00000000004004d3)
frame_base (exprloc)
[ 0] call_frame_cfa
call_all_calls (flag_present) yes
sibling (ref4) [ 5e]
[ 4d] variable abbrev: 1
name (string) "i"
decl_file (implicit_const) s.c (1)
decl_line (data1) 3
type (ref4) [ 5e]
const_value (implicit_const) -1
[ 55] variable abbrev: 1
name (string) "j"
decl_file (implicit_const) s.c (1)
decl_line (data1) 4
type (ref4) [ 5e]
const_value (implicit_const) -1
[ 5e] base_type abbrev: 4
byte_size (data1) 4
encoding (data1) signed (5)
name (string) "int"
Compilation unit at offset 102:
Version: 4, Abbreviation section offset: 73, Address size: 8, Offset size: 4
[ 71] compile_unit abbrev: 1
producer (strp) "GNU C11 7.3.1 20180303 (Red Hat 7.3.1-5) -mtune=generic -march=x86-64 -gdwarf-4 -O2"
language (data1) C99 (12)
name (string) "m.c"
comp_dir (strp) "/home/mark/build/elfutils-obj"
ranges (sec_offset) range list [ 0]
low_pc (addr) 000000000000000000
stmt_list (sec_offset) 54
[ 8f] subprogram abbrev: 2
external (flag_present) yes
name (strp) "main"
decl_file (data1) m.c (1)
decl_line (data1) 4
type (ref4) [ 119]
low_pc (addr) 0x00000000004003e0
high_pc (data8) 7 (0x00000000004003e7)
frame_base (exprloc)
[ 0] call_frame_cfa
GNU_all_call_sites (flag_present) yes
sibling (ref4) [ 119]
[ b0] variable abbrev: 3
name (string) "sc"
decl_file (data1) m.c (1)
decl_line (data1) 6
type (ref4) [ 12c]
const_value (sdata) -2
[ bb] variable abbrev: 3
name (string) "uc"
decl_file (data1) m.c (1)
decl_line (data1) 7
type (ref4) [ 138]
const_value (sdata) 254 (-2)
[ c6] variable abbrev: 3
name (string) "ss"
decl_file (data1) m.c (1)
decl_line (data1) 9
type (ref4) [ 144]
const_value (sdata) -16
[ d1] variable abbrev: 3
name (string) "us"
decl_file (data1) m.c (1)
decl_line (data1) 10
type (ref4) [ 150]
const_value (sdata) 65520 (-16)
[ dc] variable abbrev: 3
name (string) "si"
decl_file (data1) m.c (1)
decl_line (data1) 12
type (ref4) [ 120]
const_value (sdata) -3
[ e7] variable abbrev: 3
name (string) "ui"
decl_file (data1) m.c (1)
decl_line (data1) 13
type (ref4) [ 15c]
const_value (sdata) 4200000000 (-94967296)
[ f5] variable abbrev: 3
name (string) "sl"
decl_file (data1) m.c (1)
decl_line (data1) 15
type (ref4) [ 161]
const_value (sdata) -1
[ 100] variable abbrev: 3
name (string) "ul"
decl_file (data1) m.c (1)
decl_line (data1) 16
type (ref4) [ 168]
const_value (sdata) 18446744073709551615 (-1)
[ 10b] GNU_call_site abbrev: 4
low_pc (addr) 0x00000000004003e7
GNU_tail_call (flag_present) yes
abstract_origin (ref4) [ 16f]
[ 119] base_type abbrev: 5
byte_size (data1) 4
encoding (data1) signed (5)
name (string) "int"
[ 120] const_type abbrev: 6
type (ref4) [ 119]
[ 125] base_type abbrev: 7
byte_size (data1) 1
encoding (data1) signed_char (6)
name (strp) "signed char"
[ 12c] const_type abbrev: 6
type (ref4) [ 125]
[ 131] base_type abbrev: 7
byte_size (data1) 1
encoding (data1) unsigned_char (8)
name (strp) "unsigned char"
[ 138] const_type abbrev: 6
type (ref4) [ 131]
[ 13d] base_type abbrev: 7
byte_size (data1) 2
encoding (data1) signed (5)
name (strp) "short int"
[ 144] const_type abbrev: 6
type (ref4) [ 13d]
[ 149] base_type abbrev: 7
byte_size (data1) 2
encoding (data1) unsigned (7)
name (strp) "short unsigned int"
[ 150] const_type abbrev: 6
type (ref4) [ 149]
[ 155] base_type abbrev: 7
byte_size (data1) 4
encoding (data1) unsigned (7)
name (strp) "unsigned int"
[ 15c] const_type abbrev: 6
type (ref4) [ 155]
[ 161] base_type abbrev: 7
byte_size (data1) 8
encoding (data1) signed (5)
name (strp) "long int"
[ 168] base_type abbrev: 7
byte_size (data1) 8
encoding (data1) unsigned (7)
name (strp) "long unsigned int"
[ 16f] subprogram abbrev: 8
external (flag_present) yes
declaration (flag_present) yes
linkage_name (string) "s"
name (string) "s"
decl_file (data1) m.c (1)
decl_line (data1) 1
EOF
exit 0
|