1#! /bin/sh
2# Copyright (C) 2015 Red Hat, Inc.
3# This file is part of elfutils.
4#
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.
9#
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.
14#
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/>.
17
18. $srcdir/test-subr.sh
19
20# = funcs.s =
21# .globl testfunc
22# testfunc:
23# 	nop
24# 	ret
25# .type testfunc, @function
26# .size testfunc, .-testfunc
27#
28# .globl testfunc2
29# testfunc2:
30# 	call testfunc
31# 	nop
32# 	nop
33# 	ret
34# .type testfunc2, @function
35# .size testfunc2, .-testfunc2
36#
37# .globl functest3
38# functest3:
39# 	jmp local
40# 	nop
41# 	nop
42# local:
43# 	call testfunc2
44# 	ret
45# .type functest3, @function
46# .size functest3, .-functest3
47
48# = start.s =
49# .global _start
50# _start:
51# 	call functest3
52# 	nop
53# 	nop
54# 	nop
55# 	nop
56# 	nop
57# 	nop
58# 	nop
59# 	nop
60# 	nop
61# 	nop
62# 	nop
63# 	nop
64# 	nop
65# 	nop
66# 	nop
67# 	nop
68# 	ret
69# .type _start, @function
70# .size _start, .-_start
71
72# gas --compress-debug-sections=zlib-gnu -32 -g -o start.o start.s
73# gas --compress-debug-sections=zlib-gnu -32 -g -o funcs.o funcs.s
74# ld --compress-debug-sections=zlib-gnu -melf_i386 -g -o zgnu32 funcs.o start.o
75
76# gas --compress-debug-sections=zlib-gnu -64 -g -o start.o start.s
77# gas --compress-debug-sections=zlib-gnu -64 -g -o funcs.o funcs.s
78# ld --compress-debug-sections=zlib-gnu -g -o zgnu64 funcs.o start.o
79
80# gas --compress-debug-sections=zlib-gabi -32 -g -o start.o start.s
81# gas --compress-debug-sections=zlib-gabi -32 -g -o funcs.o funcs.s
82# ld --compress-debug-sections=zlib-gabi -melf_i386 -g -o zgabi32 funcs.o start.o
83
84# gas --compress-debug-sections=zlib-gabi -64 -g -o start.o start.s
85# gas --compress-debug-sections=zlib-gabi -64 -g -o funcs.o funcs.s
86# ld --compress-debug-sections=zlib-gabi -g -o zgabi64 funcs.o start.o
87
88testfiles testfile-zgnu64
89testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgnu64 <<\EOF
90section 1: NOT Compressed
91section 2: GNU Compressed size: 60
92section 3: GNU Compressed size: aa
93section 4: NOT Compressed
94section 5: GNU Compressed size: 8d
95section 6: NOT Compressed
96section 7: NOT Compressed
97section 8: NOT Compressed
98EOF
99
100testfiles testfile-zgabi64
101testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgabi64 <<\EOF
102section 1: NOT Compressed
103section 2: ELF Compressed ch_type: 1, ch_size: 60, ch_addralign: 10
104section 3: ELF Compressed ch_type: 1, ch_size: aa, ch_addralign: 1
105section 4: NOT Compressed
106section 5: ELF Compressed ch_type: 1, ch_size: 8d, ch_addralign: 1
107section 6: NOT Compressed
108section 7: NOT Compressed
109section 8: NOT Compressed
110EOF
111
112testfiles testfile-zgnu32
113testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgnu32 <<\EOF
114section 1: NOT Compressed
115section 2: GNU Compressed size: 40
116section 3: GNU Compressed size: 9a
117section 4: NOT Compressed
118section 5: GNU Compressed size: 85
119section 6: NOT Compressed
120section 7: NOT Compressed
121section 8: NOT Compressed
122EOF
123
124testfiles testfile-zgabi32
125testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgabi32 <<\EOF
126section 1: NOT Compressed
127section 2: ELF Compressed ch_type: 1, ch_size: 40, ch_addralign: 8
128section 3: ELF Compressed ch_type: 1, ch_size: 9a, ch_addralign: 1
129section 4: NOT Compressed
130section 5: ELF Compressed ch_type: 1, ch_size: 85, ch_addralign: 1
131section 6: NOT Compressed
132section 7: NOT Compressed
133section 8: NOT Compressed
134EOF
135
136testfiles testfile-zgnu64be
137testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgnu64be <<\EOF
138section 1: NOT Compressed
139section 2: NOT Compressed
140section 3: GNU Compressed size: 60
141section 4: GNU Compressed size: 7e
142section 5: NOT Compressed
143section 6: GNU Compressed size: 8d
144section 7: NOT Compressed
145section 8: NOT Compressed
146section 9: NOT Compressed
147EOF
148
149testfiles testfile-zgabi64be
150testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgabi64be <<\EOF
151section 1: NOT Compressed
152section 2: NOT Compressed
153section 3: ELF Compressed ch_type: 1, ch_size: 60, ch_addralign: 10
154section 4: ELF Compressed ch_type: 1, ch_size: 7e, ch_addralign: 1
155section 5: NOT Compressed
156section 6: ELF Compressed ch_type: 1, ch_size: 8d, ch_addralign: 1
157section 7: NOT Compressed
158section 8: NOT Compressed
159section 9: NOT Compressed
160EOF
161
162testfiles testfile-zgnu32be
163testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgnu32be <<\EOF
164section 1: NOT Compressed
165section 2: NOT Compressed
166section 3: GNU Compressed size: 40
167section 4: GNU Compressed size: 6e
168section 5: NOT Compressed
169section 6: GNU Compressed size: 85
170section 7: NOT Compressed
171section 8: NOT Compressed
172section 9: NOT Compressed
173EOF
174
175testfiles testfile-zgabi32be
176testrun_compare ${abs_top_builddir}/tests/elfgetchdr testfile-zgabi32be <<\EOF
177section 1: NOT Compressed
178section 2: NOT Compressed
179section 3: ELF Compressed ch_type: 1, ch_size: 40, ch_addralign: 8
180section 4: ELF Compressed ch_type: 1, ch_size: 6e, ch_addralign: 1
181section 5: NOT Compressed
182section 6: ELF Compressed ch_type: 1, ch_size: 85, ch_addralign: 1
183section 7: NOT Compressed
184section 8: NOT Compressed
185section 9: NOT Compressed
186EOF
187
188exit 0
189