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