1da0c48c4Sopenharmony_ci#! /bin/sh
2da0c48c4Sopenharmony_ci# Copyright (C) 2015 Red Hat, Inc.
3da0c48c4Sopenharmony_ci# This file is part of elfutils.
4da0c48c4Sopenharmony_ci#
5da0c48c4Sopenharmony_ci# This file is free software; you can redistribute it and/or modify
6da0c48c4Sopenharmony_ci# it under the terms of the GNU General Public License as published by
7da0c48c4Sopenharmony_ci# the Free Software Foundation; either version 3 of the License, or
8da0c48c4Sopenharmony_ci# (at your option) any later version.
9da0c48c4Sopenharmony_ci#
10da0c48c4Sopenharmony_ci# elfutils is distributed in the hope that it will be useful, but
11da0c48c4Sopenharmony_ci# WITHOUT ANY WARRANTY; without even the implied warranty of
12da0c48c4Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13da0c48c4Sopenharmony_ci# GNU General Public License for more details.
14da0c48c4Sopenharmony_ci#
15da0c48c4Sopenharmony_ci# You should have received a copy of the GNU General Public License
16da0c48c4Sopenharmony_ci# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17da0c48c4Sopenharmony_ci
18da0c48c4Sopenharmony_ci. $srcdir/test-subr.sh
19da0c48c4Sopenharmony_ci
20da0c48c4Sopenharmony_ci# See run-elfgetchdr.sh for testfiles.
21da0c48c4Sopenharmony_ci
22da0c48c4Sopenharmony_citestfiles testfile-zgnu64
23da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgnu64 <<\EOF
24da0c48c4Sopenharmony_ciThere are 9 section headers, starting at offset 0x3e0:
25da0c48c4Sopenharmony_ci
26da0c48c4Sopenharmony_ciSection Headers:
27da0c48c4Sopenharmony_ci[Nr] Name                 Type         Addr             Off      Size     ES Flags Lk Inf Al
28da0c48c4Sopenharmony_ci     [Compression  Size     Al]
29da0c48c4Sopenharmony_ci[ 0]                      NULL         0000000000000000 00000000 00000000  0        0   0  0
30da0c48c4Sopenharmony_ci[ 1] .text                PROGBITS     0000000000400078 00000078 0000002a  0 AX     0   0  1
31da0c48c4Sopenharmony_ci[ 2] .zdebug_aranges      PROGBITS     0000000000000000 00000260 00000032  0        0   0 16
32da0c48c4Sopenharmony_ci     [GNU ZLIB     00000060   ]
33da0c48c4Sopenharmony_ci[ 3] .zdebug_info         PROGBITS     0000000000000000 00000292 0000006f  0        0   0  1
34da0c48c4Sopenharmony_ci     [GNU ZLIB     000000aa   ]
35da0c48c4Sopenharmony_ci[ 4] .debug_abbrev        PROGBITS     0000000000000000 00000301 00000028  0        0   0  1
36da0c48c4Sopenharmony_ci[ 5] .zdebug_line         PROGBITS     0000000000000000 00000329 0000005b  0        0   0  1
37da0c48c4Sopenharmony_ci     [GNU ZLIB     0000008d   ]
38da0c48c4Sopenharmony_ci[ 6] .shstrtab            STRTAB       0000000000000000 00000384 00000059  0        0   0  1
39da0c48c4Sopenharmony_ci[ 7] .symtab              SYMTAB       0000000000000000 000000a8 00000168 24        8   8  8
40da0c48c4Sopenharmony_ci[ 8] .strtab              STRTAB       0000000000000000 00000210 0000004b  0        0   0  1
41da0c48c4Sopenharmony_ci
42da0c48c4Sopenharmony_ciEOF
43da0c48c4Sopenharmony_ci
44da0c48c4Sopenharmony_citestfiles testfile-zgnu64be
45da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgnu64be <<\EOF
46da0c48c4Sopenharmony_ciThere are 10 section headers, starting at offset 0x438:
47da0c48c4Sopenharmony_ci
48da0c48c4Sopenharmony_ciSection Headers:
49da0c48c4Sopenharmony_ci[Nr] Name                 Type         Addr             Off      Size     ES Flags Lk Inf Al
50da0c48c4Sopenharmony_ci     [Compression  Size     Al]
51da0c48c4Sopenharmony_ci[ 0]                      NULL         0000000000000000 00000000 00000000  0        0   0  0
52da0c48c4Sopenharmony_ci[ 1] .text                PROGBITS     0000000010000078 00000078 00000074  0 AX     0   0  8
53da0c48c4Sopenharmony_ci[ 2] .eh_frame            PROGBITS     00000000100000ec 000000ec 00000000  0 A      0   0  4
54da0c48c4Sopenharmony_ci[ 3] .zdebug_aranges      PROGBITS     0000000000000000 000002c0 00000034  0        0   0 16
55da0c48c4Sopenharmony_ci     [GNU ZLIB     00000060   ]
56da0c48c4Sopenharmony_ci[ 4] .zdebug_info         PROGBITS     0000000000000000 000002f4 00000059  0        0   0  1
57da0c48c4Sopenharmony_ci     [GNU ZLIB     0000007e   ]
58da0c48c4Sopenharmony_ci[ 5] .debug_abbrev        PROGBITS     0000000000000000 0000034d 00000028  0        0   0  1
59da0c48c4Sopenharmony_ci[ 6] .zdebug_line         PROGBITS     0000000000000000 00000375 0000005b  0        0   0  1
60da0c48c4Sopenharmony_ci     [GNU ZLIB     0000008d   ]
61da0c48c4Sopenharmony_ci[ 7] .shstrtab            STRTAB       0000000000000000 000003d0 00000063  0        0   0  1
62da0c48c4Sopenharmony_ci[ 8] .symtab              SYMTAB       0000000000000000 000000f0 00000180 24        9   9  8
63da0c48c4Sopenharmony_ci[ 9] .strtab              STRTAB       0000000000000000 00000270 00000044  0        0   0  1
64da0c48c4Sopenharmony_ci
65da0c48c4Sopenharmony_ciEOF
66da0c48c4Sopenharmony_ci
67da0c48c4Sopenharmony_citestfiles testfile-zgabi64
68da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgabi64 <<\EOF
69da0c48c4Sopenharmony_ciThere are 9 section headers, starting at offset 0x400:
70da0c48c4Sopenharmony_ci
71da0c48c4Sopenharmony_ciSection Headers:
72da0c48c4Sopenharmony_ci[Nr] Name                 Type         Addr             Off      Size     ES Flags Lk Inf Al
73da0c48c4Sopenharmony_ci     [Compression  Size     Al]
74da0c48c4Sopenharmony_ci[ 0]                      NULL         0000000000000000 00000000 00000000  0        0   0  0
75da0c48c4Sopenharmony_ci[ 1] .text                PROGBITS     0000000000400078 00000078 0000002a  0 AX     0   0  1
76da0c48c4Sopenharmony_ci[ 2] .debug_aranges       PROGBITS     0000000000000000 00000260 0000003e  0 C      0   0 16
77da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 00000060 16]
78da0c48c4Sopenharmony_ci[ 3] .debug_info          PROGBITS     0000000000000000 0000029e 0000007b  0 C      0   0  1
79da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 000000aa  1]
80da0c48c4Sopenharmony_ci[ 4] .debug_abbrev        PROGBITS     0000000000000000 00000319 00000028  0        0   0  1
81da0c48c4Sopenharmony_ci[ 5] .debug_line          PROGBITS     0000000000000000 00000341 00000067  0 C      0   0  1
82da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 0000008d  1]
83da0c48c4Sopenharmony_ci[ 6] .shstrtab            STRTAB       0000000000000000 000003a8 00000056  0        0   0  1
84da0c48c4Sopenharmony_ci[ 7] .symtab              SYMTAB       0000000000000000 000000a8 00000168 24        8   8  8
85da0c48c4Sopenharmony_ci[ 8] .strtab              STRTAB       0000000000000000 00000210 0000004b  0        0   0  1
86da0c48c4Sopenharmony_ci
87da0c48c4Sopenharmony_ciEOF
88da0c48c4Sopenharmony_ci
89da0c48c4Sopenharmony_citestfiles testfile-zgabi64be
90da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgabi64be <<\EOF
91da0c48c4Sopenharmony_ciThere are 10 section headers, starting at offset 0x458:
92da0c48c4Sopenharmony_ci
93da0c48c4Sopenharmony_ciSection Headers:
94da0c48c4Sopenharmony_ci[Nr] Name                 Type         Addr             Off      Size     ES Flags Lk Inf Al
95da0c48c4Sopenharmony_ci     [Compression  Size     Al]
96da0c48c4Sopenharmony_ci[ 0]                      NULL         0000000000000000 00000000 00000000  0        0   0  0
97da0c48c4Sopenharmony_ci[ 1] .text                PROGBITS     0000000010000078 00000078 00000074  0 AX     0   0  8
98da0c48c4Sopenharmony_ci[ 2] .eh_frame            PROGBITS     00000000100000ec 000000ec 00000000  0 A      0   0  4
99da0c48c4Sopenharmony_ci[ 3] .debug_aranges       PROGBITS     0000000000000000 000002c0 00000040  0 C      0   0 16
100da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 00000060 16]
101da0c48c4Sopenharmony_ci[ 4] .debug_info          PROGBITS     0000000000000000 00000300 00000065  0 C      0   0  1
102da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 0000007e  1]
103da0c48c4Sopenharmony_ci[ 5] .debug_abbrev        PROGBITS     0000000000000000 00000365 00000028  0        0   0  1
104da0c48c4Sopenharmony_ci[ 6] .debug_line          PROGBITS     0000000000000000 0000038d 00000067  0 C      0   0  1
105da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 0000008d  1]
106da0c48c4Sopenharmony_ci[ 7] .shstrtab            STRTAB       0000000000000000 000003f4 00000060  0        0   0  1
107da0c48c4Sopenharmony_ci[ 8] .symtab              SYMTAB       0000000000000000 000000f0 00000180 24        9   9  8
108da0c48c4Sopenharmony_ci[ 9] .strtab              STRTAB       0000000000000000 00000270 00000044  0        0   0  1
109da0c48c4Sopenharmony_ci
110da0c48c4Sopenharmony_ciEOF
111da0c48c4Sopenharmony_ci
112da0c48c4Sopenharmony_citestfiles testfile-zgnu32
113da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgnu32 <<\EOF
114da0c48c4Sopenharmony_ciThere are 9 section headers, starting at offset 0x33c:
115da0c48c4Sopenharmony_ci
116da0c48c4Sopenharmony_ciSection Headers:
117da0c48c4Sopenharmony_ci[Nr] Name                 Type         Addr     Off    Size   ES Flags Lk Inf Al
118da0c48c4Sopenharmony_ci     [Compression  Size   Al]
119da0c48c4Sopenharmony_ci[ 0]                      NULL         00000000 000000 000000  0        0   0  0
120da0c48c4Sopenharmony_ci[ 1] .text                PROGBITS     08048054 000054 00002a  0 AX     0   0  1
121da0c48c4Sopenharmony_ci[ 2] .zdebug_aranges      PROGBITS     00000000 0001c0 000031  0        0   0  8
122da0c48c4Sopenharmony_ci     [GNU ZLIB     000040   ]
123da0c48c4Sopenharmony_ci[ 3] .zdebug_info         PROGBITS     00000000 0001f1 00006f  0        0   0  1
124da0c48c4Sopenharmony_ci     [GNU ZLIB     00009a   ]
125da0c48c4Sopenharmony_ci[ 4] .debug_abbrev        PROGBITS     00000000 000260 000028  0        0   0  1
126da0c48c4Sopenharmony_ci[ 5] .zdebug_line         PROGBITS     00000000 000288 00005a  0        0   0  1
127da0c48c4Sopenharmony_ci     [GNU ZLIB     000085   ]
128da0c48c4Sopenharmony_ci[ 6] .shstrtab            STRTAB       00000000 0002e2 000059  0        0   0  1
129da0c48c4Sopenharmony_ci[ 7] .symtab              SYMTAB       00000000 000080 0000f0 16        8   8  4
130da0c48c4Sopenharmony_ci[ 8] .strtab              STRTAB       00000000 000170 00004b  0        0   0  1
131da0c48c4Sopenharmony_ci
132da0c48c4Sopenharmony_ciEOF
133da0c48c4Sopenharmony_ci
134da0c48c4Sopenharmony_citestfiles testfile-zgnu32be
135da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgnu32be <<\EOF
136da0c48c4Sopenharmony_ciThere are 10 section headers, starting at offset 0x390:
137da0c48c4Sopenharmony_ci
138da0c48c4Sopenharmony_ciSection Headers:
139da0c48c4Sopenharmony_ci[Nr] Name                 Type         Addr     Off    Size   ES Flags Lk Inf Al
140da0c48c4Sopenharmony_ci     [Compression  Size   Al]
141da0c48c4Sopenharmony_ci[ 0]                      NULL         00000000 000000 000000  0        0   0  0
142da0c48c4Sopenharmony_ci[ 1] .text                PROGBITS     01800054 000054 000074  0 AX     0   0  1
143da0c48c4Sopenharmony_ci[ 2] .eh_frame            PROGBITS     018000c8 0000c8 000000  0 A      0   0  4
144da0c48c4Sopenharmony_ci[ 3] .zdebug_aranges      PROGBITS     00000000 000220 000033  0        0   0  8
145da0c48c4Sopenharmony_ci     [GNU ZLIB     000040   ]
146da0c48c4Sopenharmony_ci[ 4] .zdebug_info         PROGBITS     00000000 000253 000058  0        0   0  1
147da0c48c4Sopenharmony_ci     [GNU ZLIB     00006e   ]
148da0c48c4Sopenharmony_ci[ 5] .debug_abbrev        PROGBITS     00000000 0002ab 000028  0        0   0  1
149da0c48c4Sopenharmony_ci[ 6] .zdebug_line         PROGBITS     00000000 0002d3 000059  0        0   0  1
150da0c48c4Sopenharmony_ci     [GNU ZLIB     000085   ]
151da0c48c4Sopenharmony_ci[ 7] .shstrtab            STRTAB       00000000 00032c 000063  0        0   0  1
152da0c48c4Sopenharmony_ci[ 8] .symtab              SYMTAB       00000000 0000c8 000110 16        9   9  4
153da0c48c4Sopenharmony_ci[ 9] .strtab              STRTAB       00000000 0001d8 000045  0        0   0  1
154da0c48c4Sopenharmony_ci
155da0c48c4Sopenharmony_ciEOF
156da0c48c4Sopenharmony_ci
157da0c48c4Sopenharmony_citestfiles testfile-zgabi32
158da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgabi32 <<\EOF
159da0c48c4Sopenharmony_ciThere are 9 section headers, starting at offset 0x338:
160da0c48c4Sopenharmony_ci
161da0c48c4Sopenharmony_ciSection Headers:
162da0c48c4Sopenharmony_ci[Nr] Name                 Type         Addr     Off    Size   ES Flags Lk Inf Al
163da0c48c4Sopenharmony_ci     [Compression  Size   Al]
164da0c48c4Sopenharmony_ci[ 0]                      NULL         00000000 000000 000000  0        0   0  0
165da0c48c4Sopenharmony_ci[ 1] .text                PROGBITS     08048054 000054 00002a  0 AX     0   0  1
166da0c48c4Sopenharmony_ci[ 2] .debug_aranges       PROGBITS     00000000 0001c0 000031  0 C      0   0  8
167da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 000040  8]
168da0c48c4Sopenharmony_ci[ 3] .debug_info          PROGBITS     00000000 0001f1 00006f  0 C      0   0  1
169da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 00009a  1]
170da0c48c4Sopenharmony_ci[ 4] .debug_abbrev        PROGBITS     00000000 000260 000028  0        0   0  1
171da0c48c4Sopenharmony_ci[ 5] .debug_line          PROGBITS     00000000 000288 00005a  0 C      0   0  1
172da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 000085  1]
173da0c48c4Sopenharmony_ci[ 6] .shstrtab            STRTAB       00000000 0002e2 000056  0        0   0  1
174da0c48c4Sopenharmony_ci[ 7] .symtab              SYMTAB       00000000 000080 0000f0 16        8   8  4
175da0c48c4Sopenharmony_ci[ 8] .strtab              STRTAB       00000000 000170 00004b  0        0   0  1
176da0c48c4Sopenharmony_ci
177da0c48c4Sopenharmony_ciEOF
178da0c48c4Sopenharmony_ci
179da0c48c4Sopenharmony_citestfiles testfile-zgabi32be
180da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/readelf -z -S testfile-zgabi32be <<\EOF
181da0c48c4Sopenharmony_ciThere are 10 section headers, starting at offset 0x38c:
182da0c48c4Sopenharmony_ci
183da0c48c4Sopenharmony_ciSection Headers:
184da0c48c4Sopenharmony_ci[Nr] Name                 Type         Addr     Off    Size   ES Flags Lk Inf Al
185da0c48c4Sopenharmony_ci     [Compression  Size   Al]
186da0c48c4Sopenharmony_ci[ 0]                      NULL         00000000 000000 000000  0        0   0  0
187da0c48c4Sopenharmony_ci[ 1] .text                PROGBITS     01800054 000054 000074  0 AX     0   0  1
188da0c48c4Sopenharmony_ci[ 2] .eh_frame            PROGBITS     018000c8 0000c8 000000  0 A      0   0  4
189da0c48c4Sopenharmony_ci[ 3] .debug_aranges       PROGBITS     00000000 000220 000033  0 C      0   0  8
190da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 000040  8]
191da0c48c4Sopenharmony_ci[ 4] .debug_info          PROGBITS     00000000 000253 000058  0 C      0   0  1
192da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 00006e  1]
193da0c48c4Sopenharmony_ci[ 5] .debug_abbrev        PROGBITS     00000000 0002ab 000028  0        0   0  1
194da0c48c4Sopenharmony_ci[ 6] .debug_line          PROGBITS     00000000 0002d3 000059  0 C      0   0  1
195da0c48c4Sopenharmony_ci     [ELF ZLIB (1) 000085  1]
196da0c48c4Sopenharmony_ci[ 7] .shstrtab            STRTAB       00000000 00032c 000060  0        0   0  1
197da0c48c4Sopenharmony_ci[ 8] .symtab              SYMTAB       00000000 0000c8 000110 16        9   9  4
198da0c48c4Sopenharmony_ci[ 9] .strtab              STRTAB       00000000 0001d8 000045  0        0   0  1
199da0c48c4Sopenharmony_ci
200da0c48c4Sopenharmony_ciEOF
201da0c48c4Sopenharmony_ci
202da0c48c4Sopenharmony_ciexit 0
203