#! /bin/sh
# 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 .
. $srcdir/test-subr.sh
# See tests/testfile-dwarf-45.source
testfiles testfile-splitdwarf-4 testfile-splitdwarf-5
# DWARF4 GNU DebugFission No real table header.
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=addr testfile-splitdwarf-4<<\EOF
DWARF section [33] '.debug_addr' at offset 0x3671:
Table at offset 0 for CU [     b]:
 Length:              152
 DWARF version:         4
 Address size:          8
 Segment size:          0
 Addresses start at offset 0x0:
 [ 0] 0x000000000040116a 
 [ 1] 0x0000000000401189 
 [ 2] 0x000000000040118d 
 [ 3] 0x0000000000401194
 [ 4] 0x0000000000401181 
 [ 5] 0x00000000004011af 
 [ 6] 0x00000000004011b1
 [ 7] 0x00000000004011a0 
 [ 8] 0x0000000000401160 
 [ 9] 0x00000000004011a0 
 [10] 0x000000000040117b 
 [11] 0x000000000040117b 
 [12] 0x0000000000401181 
 [13] 0x0000000000401181 
 [14] 0x000000000040118d 
 [15] 0x0000000000401160 
 [16] 0x0000000000401060 
 [17] 0x000000000040117b 
 [18] 0x0000000000404038 
Table at offset 98 for CU [    3f]:
 Length:              136
 DWARF version:         4
 Address size:          8
 Segment size:          0
 Addresses start at offset 0x98:
 [ 0] 0x00000000004011df 
 [ 1] 0x00000000004011e4 
 [ 2] 0x0000000000401060 
 [ 3] 0x0000000000401071 
 [ 4] 0x0000000000401074 
 [ 5] 0x0000000000401079 
 [ 6] 0x00000000004011d3 
 [ 7] 0x0000000000401078 
 [ 8] 0x00000000004011a0 
 [ 9] 0x0000000000401040
 [10] 0x0000000000401080 <_start>
 [11] 0x00000000004011c0 
 [12] 0x0000000000401060 
 [13] 0x00000000004011c0 
 [14] 0x00000000004011c8 
 [15] 0x00000000004011d8 
 [16] 0x00000000004011da 
EOF
# DWARF5 Real table header.
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=addr testfile-splitdwarf-5<<\EOF
DWARF section [32] '.debug_addr' at offset 0x365e:
Table at offset 0 for CU [    14]:
 Length:              156
 DWARF version:         5
 Address size:          8
 Segment size:          0
 Addresses start at offset 0x8:
 [ 0] 0x000000000040116a 
 [ 1] 0x0000000000401189 
 [ 2] 0x000000000040118d 
 [ 3] 0x0000000000401194
 [ 4] 0x0000000000401181 
 [ 5] 0x00000000004011af 
 [ 6] 0x00000000004011b1
 [ 7] 0x00000000004011a0 
 [ 8] 0x0000000000401160 
 [ 9] 0x00000000004011a0 
 [10] 0x000000000040117b 
 [11] 0x000000000040117b 
 [12] 0x0000000000401181 
 [13] 0x0000000000401181 
 [14] 0x000000000040118d 
 [15] 0x0000000000401160 
 [16] 0x0000000000401060 
 [17] 0x000000000040117b 
 [18] 0x0000000000404038 
Table at offset a0 for CU [    49]:
 Length:              140
 DWARF version:         5
 Address size:          8
 Segment size:          0
 Addresses start at offset 0xa8:
 [ 0] 0x00000000004011df 
 [ 1] 0x00000000004011e4 
 [ 2] 0x0000000000401060 
 [ 3] 0x0000000000401071 
 [ 4] 0x0000000000401074 
 [ 5] 0x0000000000401079 
 [ 6] 0x00000000004011d3 
 [ 7] 0x0000000000401078 
 [ 8] 0x00000000004011a0 
 [ 9] 0x0000000000401040
 [10] 0x0000000000401080 <_start>
 [11] 0x00000000004011c0 
 [12] 0x0000000000401060 
 [13] 0x00000000004011c0 
 [14] 0x00000000004011c8 
 [15] 0x00000000004011d8 
 [16] 0x00000000004011da 
EOF
exit 0