2 # Copyright (C) 2015 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
20 # - testfile-zdebug-rel.c
21 # #define UINT64_MAX 18446744073709551615UL
24 # main (int argc, char **argv)
26 # unsigned long a = UINT64_MAX - 8;
27 # unsigned long b = 42 + argc;
37 # gcc -Og -g -Xassembler --compress-debug-sections=none \
38 # -c -o testfile-debug-rel.o testfile-zdebug-rel.c
39 # gcc -Og -g -Xassembler --compress-debug-sections=zlib-gnu \
40 # -c -o testfile-debug-rel-g.o testfile-zdebug-rel.c
41 # gcc -Og -g -Xassembler --compress-debug-sections=zlib-gabi \
42 # -c -o testfile-debug-rel-z.o testfile-zdebug-rel.c
44 testfiles testfile-debug-rel.o testfile-debug-rel-g.o testfile-debug-rel-z.o
46 tempfiles info.out loc.out
48 cat > info.out << \EOF
50 DWARF section [ 4] '.debug_info' at offset 0x58:
52 Compilation unit at offset 0:
53 Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
55 producer (strp) "GNU C11 5.3.1 20151207 (Red Hat 5.3.1-2) -mtune=generic -march=x86-64 -g -Og"
56 language (data1) C99 (12)
57 name (strp) "testfile-zdebug-rel.c"
58 comp_dir (strp) "/tmp"
59 low_pc (addr) 000000000000000000
60 high_pc (data8) 24 (0x0000000000000018)
61 stmt_list (sec_offset) 0
63 external (flag_present) yes
67 prototyped (flag_present) yes
69 low_pc (addr) 000000000000000000
70 high_pc (data8) 24 (0x0000000000000018)
73 GNU_all_call_sites (flag_present) yes
75 [ 4e] formal_parameter
80 location (sec_offset) location list [ 0]
81 [ 5d] formal_parameter
93 const_value (sdata) -9
103 encoding (data1) signed (5)
113 encoding (data1) signed_char (6)
117 encoding (data1) unsigned (7)
118 name (strp) "long unsigned int"
121 cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel.o
123 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
125 cat info.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-debug-rel-z.o
127 cat > loc.out << \EOF
129 DWARF section [ 7] '.debug_loc' at offset 0x185:
130 [ 0] 000000000000000000..0x0000000000000003 [ 0] reg5
131 0x0000000000000003..0x0000000000000010 [ 0] breg5 -42
133 0x0000000000000010..0x0000000000000018 [ 0] GNU_entry_value:
138 cat loc.out | testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc testfile-debug-rel.o
140 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
142 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