diff options
author | 2011-04-13 22:27:40 -0400 | |
---|---|---|
committer | 2011-04-13 22:27:40 -0400 | |
commit | ceb19bb70a081eb281dca22c87d62a8915f3eed3 (patch) | |
tree | b7d9d4c2837427449e0cb377aa67552288ebf05f | |
parent | fix-gnustack.c: removed unnecessary and harmful elf_update() (diff) | |
download | elfix-ceb19bb70a081eb281dca22c87d62a8915f3eed3.tar.gz elfix-ceb19bb70a081eb281dca22c87d62a8915f3eed3.tar.bz2 elfix-ceb19bb70a081eb281dca22c87d62a8915f3eed3.zip |
tests/Makefile.am: improved build of bad elf
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | tests/Makefile.am | 26 | ||||
-rw-r--r-- | tests/test-bad32.asm | 10 | ||||
-rw-r--r-- | tests/test-bad64.asm (renamed from tests/test-bad.asm) | 4 |
6 files changed, 35 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am index 3ecf7c5..e44deab 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,9 @@ SUBDIRS = tests bin_PROGRAMS = get-gnustack fix-gnustack parse-elf get_gnustack_SOURCES = get-gnustack.c get_gnustack_LDADD = -lelf + parse_elf_SOURCES = parse-elf.c parse_elf_LDADD = -lelf + fix_gnustack_SOURCES = fix-gnustack.c fix_gnustack_LDADD = -lelf @@ -1,9 +1,5 @@ -1. Addec check for yasm to configure.ac - -2. Fix for 32-bit make check. This entails editing the yasm line in the chec and asm itself - -3. Fix the following print format errors that arrise on 32-bit: +Fix the following print format errors that arrise on 32-bit: parse-elf.c:112: warning: format '%lu' expects type 'long unsigned int', but argument 6 has type 'Elf64_Addr' parse-elf.c:112: warning: format '%lu' expects type 'long unsigned int', but argument 7 has type 'Elf64_Off' diff --git a/configure.ac b/configure.ac index 6afc2e0..aac51c5 100644 --- a/configure.ac +++ b/configure.ac @@ -2,15 +2,18 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([parse-elf], [0.1], [blueness@gentoo.org]) -AC_CONFIG_SRCDIR([parse-elf.c]) +AC_INIT([elf-misc], [0.1], [blueness@gentoo.org]) +AC_CONFIG_SRCDIR([fix-gnustack.c]) #AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([1.11 foreign]) # Checks for programs. AC_PROG_CC +AC_CHECK_PROG([has_yasm],[yasm],["yes"],["no"]) +AS_IF([test "x$has_yasm" = "xno"],AC_MSG_ERROR(["Missing yasm assembler"])) # Checks for libraries. +AC_CHECK_LIB([elf], [elf_begin]) # Checks for header files. AC_CHECK_HEADERS([fcntl.h stdlib.h unistd.h]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 6a997c8..1ac6e14 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,25 +1,31 @@ +noinst_PROGRAMS = good bad +good_SOURCES = good.c +bad_SOURCES = bad.c +bad_DEPENDENCIES = test-bad.o +bad_LDADD = test-bad.o + +ARCH = $(shell uname -m) + +test-bad.o: test-bad64.asm test-bad32.asm + [[ "$(ARCH)" == "x86" ]] && yasm -f elf -m x86 test-bad32.asm && mv test-bad32.o test-bad.o || true + [[ "$(ARCH)" == "x86_64" ]] && yasm -f elf -m amd64 test-bad64.asm && mv test-bad64.o test-bad.o || true + check_SCRIPTS = test.sh TEST = $(check_SCRIPTS) test.sh: @echo "================================================================================" @echo -# @[[ -x ../get-gnustack ]] || echo "Run 'make' first" && exit -# @[[ -x ../fix-gnustack ]] || echo "Run 'make' first" && exit - @gcc -o good good.c - @echo "Good result" + @echo "Good Elf" @../get-gnustack good @echo - @yasm -f elf -m amd64 test-bad.asm - @gcc -c bad.c - @gcc -o bad bad.o test-bad.o - @echo "Bad result" + @echo "Bad Elf" @../get-gnustack bad @echo - @echo "Fixed results" + @echo "Fixing Bad Elf" @../fix-gnustack bad @../get-gnustack bad @echo @echo "================================================================================" -CLEANFILES = good good.o bad bad.o test-bad.o test.sh +CLEANFILES = test-bad.o test.sh diff --git a/tests/test-bad32.asm b/tests/test-bad32.asm new file mode 100644 index 0000000..3d23244 --- /dev/null +++ b/tests/test-bad32.asm @@ -0,0 +1,10 @@ +global badness
+
+SECTION .text
+badness:
+ push ebp
+ mov ebp,esp
+
+ mov esp,ebp
+ pop ebp
+ ret
diff --git a/tests/test-bad.asm b/tests/test-bad64.asm index 8468062..ac31c04 100644 --- a/tests/test-bad.asm +++ b/tests/test-bad64.asm @@ -1,8 +1,6 @@ -global badness:function
+global badness
SECTION .text
-
-align 16
badness:
push rbp
mov rbp,rsp
|