Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/elfix:master commit in: /, tests/gnustack/
Date: Fri, 27 Jul 2012 21:07:55
Message-Id: 1343423248.f8a6f9f2f822e7d1c9b5abc32f409af3d82c99ef.blueness@gentoo
1 commit: f8a6f9f2f822e7d1c9b5abc32f409af3d82c99ef
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jul 27 21:07:28 2012 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 27 21:07:28 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=f8a6f9f2
7
8 tests/gnustack: switch from yasm to gcc for assembler
9
10 ---
11 configure.ac | 2 +
12 tests/gnustack/Makefile.am | 18 ++++++----------
13 tests/gnustack/bad32.asm | 26 -------------------------
14 tests/gnustack/{bad-gnustack.c => bad32.s} | 21 ++++++++++++-------
15 tests/gnustack/bad64.asm | 25 ------------------------
16 tests/gnustack/{bad-gnustack.c => bad64.s} | 29 ++++++++++++++++++++-------
17 6 files changed, 43 insertions(+), 78 deletions(-)
18
19 diff --git a/configure.ac b/configure.ac
20 index 9cf4143..f97c3d7 100644
21 --- a/configure.ac
22 +++ b/configure.ac
23 @@ -6,6 +6,7 @@ AC_INIT([elfix], [0.5], [http://bugs.gentoo.org/])
24 AC_CONFIG_SRCDIR([src/fix-gnustack.c])
25 AC_CONFIG_HEADERS([config.h])
26 AM_INIT_AUTOMAKE([1.11 foreign])
27 +AM_SILENT_RULES([yes])
28
29 AC_ARG_ENABLE(
30 [tests],
31 @@ -61,6 +62,7 @@ AC_ARG_ENABLE(
32 # Checks for programs.
33 AC_PROG_AWK
34 AC_PROG_CC
35 +AM_PROG_AS
36
37 # Checks for libraries.
38 AC_CHECK_LIB([elf], [elf_begin],[],[AC_MSG_ERROR(["Missing necessary function elf_begin in libelf"])])
39
40 diff --git a/tests/gnustack/Makefile.am b/tests/gnustack/Makefile.am
41 index af11d60..7a19c18 100644
42 --- a/tests/gnustack/Makefile.am
43 +++ b/tests/gnustack/Makefile.am
44 @@ -1,15 +1,11 @@
45 noinst_PROGRAMS = bad-gnustack
46 -bad_gnustack_SOURCES = bad-gnustack.c
47 -bad_gnustack_DEPENDENCIES = bad-asm.o
48 -bad_gnustack_LDADD = bad-asm.o
49 -
50 -EXTRA_DIST = bad64.asm bad32.asm
51 +bad_gnustack_SOURCES = bad64.s bad32.s
52
53 ARCH = $(shell uname -m | sed -e 's/i./x/')
54
55 -bad-asm.o: bad64.asm bad32.asm
56 - [[ "$(ARCH)" == "x86" ]] && yasm -f elf -m x86 bad32.asm && mv bad32.o bad-asm.o || true
57 - [[ "$(ARCH)" == "x86_64" ]] && yasm -f elf -m amd64 bad64.asm && mv bad64.o bad-asm.o || true
58 +bad-gnustack: bad64.s bad32.s
59 + [[ "$(ARCH)" == "x86" ]] && $(CCAS) -m32 -o bad-gnustack bad32.s || true
60 + [[ "$(ARCH)" == "x86_64" ]] && $(CCAS) -m64 -o bad-gnustack bad64.s || true
61
62 check_SCRIPTS = test.sh
63 TEST = $(check_SCRIPTS)
64 @@ -17,12 +13,12 @@ TEST = $(check_SCRIPTS)
65 test.sh:
66 @echo "================================================================================"
67 @echo
68 - @echo "Fixing Bad GNU_STACK Elf"
69 + @echo "Before GNU_STACK Elf: "
70 @../../src/fix-gnustack -f bad-gnustack
71 @echo
72 - @echo "Fixed Bad GNU_STACK Elf"
73 + @echo "After GNU_STACK Elf: "
74 @../../src/fix-gnustack bad-gnustack
75 @echo
76 @echo "================================================================================"
77
78 -CLEANFILES = bad-asm.o test.sh
79 +CLEANFILES = *.o test.sh
80
81 diff --git a/tests/gnustack/bad32.asm b/tests/gnustack/bad32.asm
82 deleted file mode 100644
83 index 8020ac7..0000000
84 --- a/tests/gnustack/bad32.asm
85 +++ /dev/null
86 @@ -1,26 +0,0 @@
87 -;bad32.asm: 32-bit asm source for sample elf with X on GNU_STACK
88 -;Copyright (C) 2011 Anthony G. Basile
89 -;
90 -;This program is free software: you can redistribute it and/or modify
91 -;it under the terms of the GNU General Public License as published by
92 -;the Free Software Foundation, either version 3 of the License, or
93 -;(at your option) any later version.
94 -;
95 -;This program is distributed in the hope that it will be useful,
96 -;but WITHOUT ANY WARRANTY; without even the implied warranty of
97 -;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98 -;GNU General Public License for more details.
99 -;
100 -;You should have received a copy of the GNU General Public License
101 -;along with this program. If not, see <http://www.gnu.org/licenses/>.
102 -
103 -global badness
104 -
105 -SECTION .text
106 -
107 -badness:
108 - push ebp
109 - mov ebp,esp
110 - mov esp,ebp
111 - pop ebp
112 - ret
113
114 diff --git a/tests/gnustack/bad-gnustack.c b/tests/gnustack/bad32.s
115 similarity index 69%
116 copy from tests/gnustack/bad-gnustack.c
117 copy to tests/gnustack/bad32.s
118 index fa7bcf5..95441d8 100644
119 --- a/tests/gnustack/bad-gnustack.c
120 +++ b/tests/gnustack/bad32.s
121 @@ -1,6 +1,6 @@
122 /*
123 - bad-gnustack.c: C source for sample elf with X on GNU_STACK
124 - Copyright (C) 2011 Anthony G. Basile
125 + bad32.s: 32-bit asm source for sample elf with X on GNU_STACK
126 + Copyright (C) 2012 Anthony G. Basile
127
128 This program is free software: you can redistribute it and/or modify
129 it under the terms of the GNU General Public License as published by
130 @@ -15,10 +15,15 @@
131 You should have received a copy of the GNU General Public License
132 along with this program. If not, see <http://www.gnu.org/licenses/>.
133 */
134 -#include <stdlib.h>
135
136 -int main()
137 -{
138 - badness();
139 - return 0;
140 -}
141 + .file "main.c"
142 + .text
143 + .globl main
144 + .type main, @function
145 +main:
146 + pushl %ebp
147 + movl %esp, %ebp
148 + popl %ebp
149 + ret
150 + .size main, .-main
151 + .section .note.GNU-stack,"x",@progbits
152
153 diff --git a/tests/gnustack/bad64.asm b/tests/gnustack/bad64.asm
154 deleted file mode 100644
155 index 1164095..0000000
156 --- a/tests/gnustack/bad64.asm
157 +++ /dev/null
158 @@ -1,25 +0,0 @@
159 -;bad64.asm: 64-bit asm source for sample elf with X on GNU_STACK
160 -;Copyright (C) 2011 Anthony G. Basile
161 -;
162 -;This program is free software: you can redistribute it and/or modify
163 -;it under the terms of the GNU General Public License as published by
164 -;the Free Software Foundation, either version 3 of the License, or
165 -;(at your option) any later version.
166 -;
167 -;This program is distributed in the hope that it will be useful,
168 -;but WITHOUT ANY WARRANTY; without even the implied warranty of
169 -;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170 -;GNU General Public License for more details.
171 -;
172 -;You should have received a copy of the GNU General Public License
173 -;along with this program. If not, see <http://www.gnu.org/licenses/>.
174 -
175 -global badness
176 -
177 -SECTION .text
178 -badness:
179 - push rbp
180 - mov rbp,rsp
181 - mov rsp,rbp
182 - pop rbp
183 - ret
184
185 diff --git a/tests/gnustack/bad-gnustack.c b/tests/gnustack/bad64.s
186 similarity index 61%
187 rename from tests/gnustack/bad-gnustack.c
188 rename to tests/gnustack/bad64.s
189 index fa7bcf5..0168921 100644
190 --- a/tests/gnustack/bad-gnustack.c
191 +++ b/tests/gnustack/bad64.s
192 @@ -1,6 +1,6 @@
193 /*
194 - bad-gnustack.c: C source for sample elf with X on GNU_STACK
195 - Copyright (C) 2011 Anthony G. Basile
196 + bad32.s: 32-bit asm source for sample elf with X on GNU_STACK
197 + Copyright (C) 2012 Anthony G. Basile
198
199 This program is free software: you can redistribute it and/or modify
200 it under the terms of the GNU General Public License as published by
201 @@ -15,10 +15,23 @@
202 You should have received a copy of the GNU General Public License
203 along with this program. If not, see <http://www.gnu.org/licenses/>.
204 */
205 -#include <stdlib.h>
206
207 -int main()
208 -{
209 - badness();
210 - return 0;
211 -}
212 + .file "main.c"
213 + .text
214 + .globl main
215 + .type main, @function
216 +main:
217 +.LFB0:
218 + .cfi_startproc
219 + pushq %rbp
220 + .cfi_def_cfa_offset 16
221 + movq %rsp, %rbp
222 + .cfi_offset 6, -16
223 + .cfi_def_cfa_register 6
224 + leave
225 + .cfi_def_cfa 7, 8
226 + ret
227 + .cfi_endproc
228 +.LFE0:
229 + .size main, .-main
230 + .section .note.GNU-stack,"x",@progbits