aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--tests/gnustack/Makefile.am18
-rw-r--r--tests/gnustack/bad32.asm26
-rw-r--r--tests/gnustack/bad32.s (renamed from tests/gnustack/bad-gnustack.c)21
-rw-r--r--tests/gnustack/bad64.asm25
-rw-r--r--tests/gnustack/bad64.s37
6 files changed, 59 insertions, 70 deletions
diff --git a/configure.ac b/configure.ac
index 9cf4143..f97c3d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,6 +6,7 @@ AC_INIT([elfix], [0.5], [http://bugs.gentoo.org/])
AC_CONFIG_SRCDIR([src/fix-gnustack.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.11 foreign])
+AM_SILENT_RULES([yes])
AC_ARG_ENABLE(
[tests],
@@ -61,6 +62,7 @@ AC_ARG_ENABLE(
# Checks for programs.
AC_PROG_AWK
AC_PROG_CC
+AM_PROG_AS
# Checks for libraries.
AC_CHECK_LIB([elf], [elf_begin],[],[AC_MSG_ERROR(["Missing necessary function elf_begin in libelf"])])
diff --git a/tests/gnustack/Makefile.am b/tests/gnustack/Makefile.am
index af11d60..7a19c18 100644
--- a/tests/gnustack/Makefile.am
+++ b/tests/gnustack/Makefile.am
@@ -1,15 +1,11 @@
noinst_PROGRAMS = bad-gnustack
-bad_gnustack_SOURCES = bad-gnustack.c
-bad_gnustack_DEPENDENCIES = bad-asm.o
-bad_gnustack_LDADD = bad-asm.o
-
-EXTRA_DIST = bad64.asm bad32.asm
+bad_gnustack_SOURCES = bad64.s bad32.s
ARCH = $(shell uname -m | sed -e 's/i./x/')
-bad-asm.o: bad64.asm bad32.asm
- [[ "$(ARCH)" == "x86" ]] && yasm -f elf -m x86 bad32.asm && mv bad32.o bad-asm.o || true
- [[ "$(ARCH)" == "x86_64" ]] && yasm -f elf -m amd64 bad64.asm && mv bad64.o bad-asm.o || true
+bad-gnustack: bad64.s bad32.s
+ [[ "$(ARCH)" == "x86" ]] && $(CCAS) -m32 -o bad-gnustack bad32.s || true
+ [[ "$(ARCH)" == "x86_64" ]] && $(CCAS) -m64 -o bad-gnustack bad64.s || true
check_SCRIPTS = test.sh
TEST = $(check_SCRIPTS)
@@ -17,12 +13,12 @@ TEST = $(check_SCRIPTS)
test.sh:
@echo "================================================================================"
@echo
- @echo "Fixing Bad GNU_STACK Elf"
+ @echo "Before GNU_STACK Elf: "
@../../src/fix-gnustack -f bad-gnustack
@echo
- @echo "Fixed Bad GNU_STACK Elf"
+ @echo "After GNU_STACK Elf: "
@../../src/fix-gnustack bad-gnustack
@echo
@echo "================================================================================"
-CLEANFILES = bad-asm.o test.sh
+CLEANFILES = *.o test.sh
diff --git a/tests/gnustack/bad32.asm b/tests/gnustack/bad32.asm
deleted file mode 100644
index 8020ac7..0000000
--- a/tests/gnustack/bad32.asm
+++ /dev/null
@@ -1,26 +0,0 @@
-;bad32.asm: 32-bit asm source for sample elf with X on GNU_STACK
-;Copyright (C) 2011 Anthony G. Basile
-;
-;This program 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.
-;
-;This program 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 <http://www.gnu.org/licenses/>.
-
-global badness
-
-SECTION .text
-
-badness:
- push ebp
- mov ebp,esp
- mov esp,ebp
- pop ebp
- ret
diff --git a/tests/gnustack/bad-gnustack.c b/tests/gnustack/bad32.s
index fa7bcf5..95441d8 100644
--- a/tests/gnustack/bad-gnustack.c
+++ b/tests/gnustack/bad32.s
@@ -1,6 +1,6 @@
/*
- bad-gnustack.c: C source for sample elf with X on GNU_STACK
- Copyright (C) 2011 Anthony G. Basile
+ bad32.s: 32-bit asm source for sample elf with X on GNU_STACK
+ Copyright (C) 2012 Anthony G. Basile
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,10 +15,15 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-int main()
-{
- badness();
- return 0;
-}
+ .file "main.c"
+ .text
+ .globl main
+ .type main, @function
+main:
+ pushl %ebp
+ movl %esp, %ebp
+ popl %ebp
+ ret
+ .size main, .-main
+ .section .note.GNU-stack,"x",@progbits
diff --git a/tests/gnustack/bad64.asm b/tests/gnustack/bad64.asm
deleted file mode 100644
index 1164095..0000000
--- a/tests/gnustack/bad64.asm
+++ /dev/null
@@ -1,25 +0,0 @@
-;bad64.asm: 64-bit asm source for sample elf with X on GNU_STACK
-;Copyright (C) 2011 Anthony G. Basile
-;
-;This program 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.
-;
-;This program 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 <http://www.gnu.org/licenses/>.
-
-global badness
-
-SECTION .text
-badness:
- push rbp
- mov rbp,rsp
- mov rsp,rbp
- pop rbp
- ret
diff --git a/tests/gnustack/bad64.s b/tests/gnustack/bad64.s
new file mode 100644
index 0000000..0168921
--- /dev/null
+++ b/tests/gnustack/bad64.s
@@ -0,0 +1,37 @@
+/*
+ bad32.s: 32-bit asm source for sample elf with X on GNU_STACK
+ Copyright (C) 2012 Anthony G. Basile
+
+ This program 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.
+
+ This program 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 <http://www.gnu.org/licenses/>.
+*/
+
+ .file "main.c"
+ .text
+ .globl main
+ .type main, @function
+main:
+.LFB0:
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ movq %rsp, %rbp
+ .cfi_offset 6, -16
+ .cfi_def_cfa_register 6
+ leave
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE0:
+ .size main, .-main
+ .section .note.GNU-stack,"x",@progbits