aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <basile@opensource.dyc.edu>2011-04-12 16:22:45 -0400
committerAnthony G. Basile <basile@opensource.dyc.edu>2011-04-12 16:22:45 -0400
commit76aa9f15d582bd5b37891d8b73abf80896a8c057 (patch)
tree1b9d062fd992c7ac148d3a08caef71dc60478eee
parentget_gnu_stack.c: code cleanup (diff)
downloadelfix-76aa9f15d582bd5b37891d8b73abf80896a8c057.tar.gz
elfix-76aa9f15d582bd5b37891d8b73abf80896a8c057.tar.bz2
elfix-76aa9f15d582bd5b37891d8b73abf80896a8c057.zip
Added: test_asm.c test_bad.asm to test RWX in asm
-rw-r--r--Makefile27
-rw-r--r--test_asm.c12
-rw-r--r--test_bad.asm96
-rw-r--r--test_good.c (renamed from test.c)0
4 files changed, 130 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 8fb7984..c8cd20b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,29 @@
-SRCS = parse_elf get_gnu_stack test
+CC = gcc
+LIBS += -lelf
+
+SRCS = $(wildcard *.c)
+OBJS = $(patsubst %.c,%.o,$(SRCS))
+BINS = $(patsubst %.c,%,$(SRCS))
+
.PHONY: all
-all: $(SRCS)
+#all: $(BINS)
+all: $(OBJS) $(BINS)
.PHONY: clean
clean:
- rm -f $(SRCS)
+ rm -f $(BINS) *.o
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $<
+
+%.o: %.asm
+ yasm -f elf -m amd64 $<
+
+test_asm: test_asm.o test_bad.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+%: %.o
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)
-%: %.c
- gcc -o $@ $^ -lelf
diff --git a/test_asm.c b/test_asm.c
new file mode 100644
index 0000000..4e47d3b
--- /dev/null
+++ b/test_asm.c
@@ -0,0 +1,12 @@
+
+#include <stdlib.h>
+
+int CrcUpdateT8(int, const void *, size_t, int *);
+
+void doit(){;return;}
+
+int main()
+{
+ int i = 5 ;
+ CrcUpdateT8(3,doit,(size_t)5,&i);
+}
diff --git a/test_bad.asm b/test_bad.asm
new file mode 100644
index 0000000..c11b715
--- /dev/null
+++ b/test_bad.asm
@@ -0,0 +1,96 @@
+
+
+global CrcUpdateT8:function
+
+SECTION .text
+
+%macro CRC1b 0
+ movzx EDX, BYTE [RSI]
+ inc RSI
+ movzx EBX, AL
+ xor EDX, EBX
+ shr EAX, 8
+ xor EAX, [RDI + RDX * 4]
+ dec R8
+%endmacro
+
+
+
+align 16
+CrcUpdateT8:
+
+ push RBX
+ push RBP
+
+ mov EAX, EDI
+ mov R8, RDX
+ mov RDI, RCX
+
+
+ test R8, R8
+ jz sl_end
+ sl:
+ test RSI, 7
+ jz sl_end
+ CRC1b
+ jnz sl
+ sl_end:
+
+ cmp R8, 16
+ jb crc_end
+ mov R9, R8
+ and R8, 7
+ add R8, 8
+ sub R9, R8
+
+ add R9, RSI
+ xor EAX, [RSI]
+ mov EBX, [RSI + 4]
+ movzx ECX, BL
+ align 16
+ main_loop:
+ mov EDX, [RDI + RCX*4 + 0C00h]
+ movzx EBP, BH
+ xor EDX, [RDI + RBP*4 + 0800h]
+ shr EBX, 16
+ movzx ECX, BL
+ xor EDX, [RSI + 8]
+ xor EDX, [RDI + RCX*4 + 0400h]
+ movzx ECX, AL
+ movzx EBP, BH
+ xor EDX, [RDI + RBP*4 + 0000h]
+
+ mov EBX, [RSI + 12]
+
+ xor EDX, [RDI + RCX*4 + 01C00h]
+ movzx EBP, AH
+ shr EAX, 16
+ movzx ECX, AL
+ xor EDX, [RDI + RBP*4 + 01800h]
+ movzx EBP, AH
+ mov EAX, [RDI + RCX*4 + 01400h]
+ add RSI, 8
+ xor EAX, [RDI + RBP*4 + 01000h]
+ movzx ECX, BL
+ xor EAX,EDX
+
+ cmp RSI, R9
+ jne main_loop
+ xor EAX, [RSI]
+
+
+
+ crc_end:
+
+ test R8, R8
+ jz fl_end
+ fl:
+ CRC1b
+ jnz fl
+ fl_end:
+
+ pop RBP
+ pop RBX
+ ret
+
+end
diff --git a/test.c b/test_good.c
index 196d2fc..196d2fc 100644
--- a/test.c
+++ b/test_good.c