changeset 3:56f873c979c3

Added (non-working) 64-bit tests.
author Gregor Richards <Richards@codu.org>
date Sat, 25 Jul 2009 22:36:11 -0400
parents 994ca5c4a51c
children 54ff11eb9191
files elfload/src/elfnative.h elfload/test/Makefile elfload/test/Makefile.orig elfload/test/common/Makefile elfload/test/common/libc_wrap.c elfload/test/common/testdl.c elfload/test/i686-pc-linux-gnu/libc_wrap.c elfload/test/i686-pc-linux-gnu/testdl.c elfload/test/i686-pc-linux-gnu/testhost.s elfload/test/i686-pc-linux-gnu/testso.s elfload/test/i686-pc-linux-gnu/teststatic.s elfload/test/libc_wrap.c elfload/test/testdl.c elfload/test/testdl.c.orig elfload/test/testhost.s elfload/test/testso.s elfload/test/teststatic.s elfload/test/x86_64-pc-linux-gnu/Makefile elfload/test/x86_64-pc-linux-gnu/libc_wrap.c elfload/test/x86_64-pc-linux-gnu/testdl.c elfload/test/x86_64-pc-linux-gnu/testhost.s elfload/test/x86_64-pc-linux-gnu/testso.s elfload/test/x86_64-pc-linux-gnu/teststatic.s
diffstat 23 files changed, 161 insertions(+), 124 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/src/elfnative.h	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,41 @@
+#ifndef ELFNATIVE_H
+#define ELFNATIVE_H
+
+#include "../config.h"
+#include "elfload_elf.h"
+
+#if SIZEOF_VOID_P == 4
+
+#define ElfNative_Ehdr Elf32_Ehdr
+#define ElfNative_Phdr Elf32_Phdr
+#define ElfNative_Dyn Elf32_Dyn
+#define ElfNative_Sym Elf32_Sym
+#define ElfNative_Word Elf32_Word
+#define ElfNative_Rel Elf32_Rel
+#define ElfNative_Rela Elf32_Rela
+
+#define ELFNATIVE_ST_BIND ELF32_ST_BIND
+#define ELFNATIVE_R_SYM ELF32_R_SYM
+#define ELFNATIVE_R_TYPE ELF32_R_TYPE
+
+#elif SIZEOF_VOID_P == 8
+
+#define ElfNative_Ehdr Elf64_Ehdr
+#define ElfNative_Phdr Elf64_Phdr
+#define ElfNative_Dyn Elf64_Dyn
+#define ElfNative_Sym Elf64_Sym
+#define ElfNative_Word Elf64_Word
+#define ElfNative_Rel Elf64_Rel
+#define ElfNative_Rela Elf64_Rela
+
+#define ELFNATIVE_ST_BIND ELF32_ST_BIND
+#define ELFNATIVE_R_SYM ELF64_R_SYM
+#define ELFNATIVE_R_TYPE ELF64_R_TYPE
+
+#else
+
+#error Unsupported bitwidth.
+
+#endif
+
+#endif
--- a/elfload/test/Makefile	Sat Jul 25 16:12:41 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-CC=gcc
-CFLAGS=
-LDFLAGS=
-SOFLAGS=-shared -soname=
-
-TESTSTATIC_OBJS=teststatic.o
-TESTHOST_OBJS=testhost.o
-TESTSO_OBJS=testso.o
-TESTDL_OBJS=testdl.o
-LIBC_OBJS=libc_wrap.o
-
-all: teststatic testhost testso.so testdl libc.so
-
-teststatic: $(TESTSTATIC_OBJS)
-	ld $(LDFLAGS) $(TESTSTATIC_OBJS) -o teststatic
-
-testhost: $(TESTHOST_OBJS) testso.so
-	ld $(LDFLAGS) $(TESTHOST_OBJS) testso.so -o testhost
-
-testso.so: $(TESTSO_OBJS)
-	ld $(LDFLAGS) $(TESTSO_OBJS) $(SOFLAGS)testso.so -o testso.so
-
-testdl: libc.so $(TESTDL_OBJS)
-	ld $(LDFLAGS) $(TESTDL_OBJS) libc.so -o testdl
-
-libc.so: $(LIBC_OBJS)
-	ld $(LDFLAGS) $(LIBC_OBJS) $(SOFLAGS)libhost_libc.so.6 -o libc.so
-
-.s.o:
-	$(CC) $(CFLAGS) -c $< -o $@
-
-.c.o:
-	$(CC) $(CFLAGS) -fPIC -c $< -o $@
-
-clean:
-	rm -f teststatic $(TESTSTATIC_OBJS)
-	rm -f testhost $(TESTHOST_OBJS)
-	rm -f testso.so $(TESTSO_OBJS)
-	rm -f testdl $(TESTDL_OBJS)
-	rm -f libc.so $(LIBC_OBJS)
--- a/elfload/test/Makefile.orig	Sat Jul 25 16:12:41 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-CC=gcc
-CFLAGS=
-LDFLAGS=
-SOFLAGS=-shared -soname=
-
-TESTSTATIC_OBJS=teststatic.o
-TESTHOST_OBJS=testhost.o
-TESTSO_OBJS=testso.o
-TESTDL_OBJS=testdl.o
-
-all: teststatic testhost testso.so testdl
-
-teststatic: $(TESTSTATIC_OBJS)
-	ld $(LDFLAGS) $(TESTSTATIC_OBJS) -o teststatic
-
-testhost: $(TESTHOST_OBJS) testso.so
-	ld $(LDFLAGS) $(TESTHOST_OBJS) testso.so -o testhost
-
-testso.so: $(TESTSO_OBJS)
-	ld $(LDFLAGS) $(TESTSO_OBJS) $(SOFLAGS)testso.so -o testso.so
-
-testdl: $(TESTDL_OBJS)
-	ld $(LDFLAGS) $(TESTDL_OBJS) -o testdl
-
-.s.o:
-	$(CC) $(CFLAGS) -c $< -o $@
-
-.c.o:
-	$(CC) $(CFLAGS) -c $< -o $@
-
-clean:
-	rm -f teststatic $(TESTSTATIC_OBJS)
-	rm -f testhost $(TESTHOST_OBJS)
-	rm -f testso.so $(TESTSO_OBJS)
-	rm -f testdl $(TESTDL_OBJS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/common/Makefile	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,40 @@
+CC=gcc
+CFLAGS=
+LDFLAGS=
+SOFLAGS=-shared -soname=
+
+TESTSTATIC_OBJS=teststatic.o
+TESTHOST_OBJS=testhost.o
+TESTSO_OBJS=testso.o
+TESTDL_OBJS=testdl.o
+LIBC_OBJS=libc_wrap.o
+
+all: teststatic testhost testso.so testdl libc.so
+
+teststatic: $(TESTSTATIC_OBJS)
+	ld $(LDFLAGS) $(TESTSTATIC_OBJS) -o teststatic
+
+testhost: $(TESTHOST_OBJS) testso.so
+	ld $(LDFLAGS) $(TESTHOST_OBJS) testso.so -o testhost
+
+testso.so: $(TESTSO_OBJS)
+	ld $(LDFLAGS) $(TESTSO_OBJS) $(SOFLAGS)testso.so -o testso.so
+
+testdl: libc.so $(TESTDL_OBJS)
+	ld $(LDFLAGS) $(TESTDL_OBJS) libc.so -o testdl
+
+libc.so: $(LIBC_OBJS)
+	ld $(LDFLAGS) $(LIBC_OBJS) $(SOFLAGS)libhost_libc.so.6 -o libc.so
+
+.s.o:
+	$(CC) $(CFLAGS) -c $< -o $@
+
+.c.o:
+	$(CC) $(CFLAGS) -fPIC -c $< -o $@
+
+clean:
+	rm -f teststatic $(TESTSTATIC_OBJS)
+	rm -f testhost $(TESTHOST_OBJS)
+	rm -f testso.so $(TESTSO_OBJS)
+	rm -f testdl $(TESTDL_OBJS)
+	rm -f libc.so $(LIBC_OBJS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/common/libc_wrap.c	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,2 @@
+void puts(){}
+void printf(){}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/common/testdl.c	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void _start()
+{
+    printf("Hello, world!\n");
+    while (1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/i686-pc-linux-gnu/libc_wrap.c	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,1 @@
+#include "../common/libc_wrap.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/i686-pc-linux-gnu/testdl.c	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,1 @@
+#include "../common/testdl.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/i686-pc-linux-gnu/testhost.s	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,10 @@
+.globl _start
+
+_start:
+    mov $4, %eax
+    mov $1, %ebx
+    movl $_str, %ecx
+    mov $14, %edx
+    int $0x80
+    _loop:
+    jmp _loop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/i686-pc-linux-gnu/testso.s	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,6 @@
+.section .rodata
+.globl _str
+
+_str:
+    .string "Hello, world!\n"
+    .size _str,.-_str
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/i686-pc-linux-gnu/teststatic.s	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,17 @@
+.globl _start
+.globl _str
+
+_strdat:
+    .string "Hello, world!\n"
+
+_str:
+    .long _strdat
+
+_start:
+    mov $4, %eax
+    mov $1, %ebx
+    mov _str, %ecx
+    mov $14, %edx
+    int $0x80
+    _loop:
+    jmp _loop
--- a/elfload/test/libc_wrap.c	Sat Jul 25 16:12:41 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-void puts(){}
-void printf(){}
--- a/elfload/test/testdl.c	Sat Jul 25 16:12:41 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-void _start()
-{
-    printf("Hello, world!\n");
-    while (1);
-}
--- a/elfload/test/testdl.c.orig	Sat Jul 25 16:12:41 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-void _start()
-{
-    puts("Hello, world!\n");
-    while (1);
-}
--- a/elfload/test/testhost.s	Sat Jul 25 16:12:41 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-.globl _start
-
-_start:
-    mov $4, %eax
-    mov $1, %ebx
-    movl $_str, %ecx
-    mov $14, %edx
-    int $0x80
-    _loop:
-    jmp _loop
--- a/elfload/test/testso.s	Sat Jul 25 16:12:41 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-.section .rodata
-.globl _str
-
-_str:
-    .string "Hello, world!\n"
-    .size _str,.-_str
--- a/elfload/test/teststatic.s	Sat Jul 25 16:12:41 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-.globl _start
-.globl _str
-
-_strdat:
-    .string "Hello, world!\n"
-
-_str:
-    .long _strdat
-
-_start:
-    mov $4, %eax
-    mov $1, %ebx
-    mov _str, %ecx
-    mov $14, %edx
-    int $0x80
-    _loop:
-    jmp _loop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/x86_64-pc-linux-gnu/Makefile	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,1 @@
+include ../common/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/x86_64-pc-linux-gnu/libc_wrap.c	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,1 @@
+#include "../common/libc_wrap.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/x86_64-pc-linux-gnu/testdl.c	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,1 @@
+#include "../common/testdl.c"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/x86_64-pc-linux-gnu/testhost.s	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,10 @@
+.globl _start
+
+_start:
+    mov $4, %eax
+    mov $1, %ebx
+    movl $_str, %ecx
+    mov $14, %edx
+    int $0x80
+    _loop:
+    jmp _loop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/x86_64-pc-linux-gnu/testso.s	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,6 @@
+.section .rodata
+.globl _str
+
+_str:
+    .string "Hello, world!\n"
+    .size _str,.-_str
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/elfload/test/x86_64-pc-linux-gnu/teststatic.s	Sat Jul 25 22:36:11 2009 -0400
@@ -0,0 +1,17 @@
+.globl _start
+.globl _str
+
+_strdat:
+    .string "Hello, world!\n"
+
+_str:
+    .long _strdat
+
+_start:
+    mov $4, %eax
+    mov $1, %ebx
+    mov _str, %ecx
+    mov $14, %edx
+    int $0x80
+    _loop:
+    jmp _loop