summaryrefslogtreecommitdiff
path: root/test/elftest64.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-10-17 17:13:26 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-10-17 17:13:26 -0700
commite41b69beaf51a725a98b1ba4480751333b24a06f (patch)
treeb40ec2308741a20be270f3f50f085fe807a7c3a0 /test/elftest64.c
parentd83fb7e3388e516263fceaba27f2d36450bdf74a (diff)
downloadnasm-e41b69beaf51a725a98b1ba4480751333b24a06f.tar.gz
nasm-e41b69beaf51a725a98b1ba4480751333b24a06f.tar.bz2
nasm-e41b69beaf51a725a98b1ba4480751333b24a06f.zip
Test and Makefile rules for 32- and 64-bit ELF shared libraries
Add Makefile rules for the 32-bit ELF shared library test, and add a 64-bit ELF shared library test (still work in progress.)
Diffstat (limited to 'test/elftest64.c')
-rw-r--r--test/elftest64.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/elftest64.c b/test/elftest64.c
new file mode 100644
index 0000000..5f009a7
--- /dev/null
+++ b/test/elftest64.c
@@ -0,0 +1,42 @@
+/*
+ * build with:
+ * nasm -f elf64 elf64so.asm
+ * ld -shared -o elf64so.so elf64so.o
+ * test with:
+ * gcc -o elf64so elftest64.c ./elf64so.so
+ * ./elf64so
+ */
+
+#include <stdio.h>
+#include <inttypes.h>
+
+extern long lrotate(long, int);
+extern void greet(void);
+extern int8_t asmstr[];
+extern void *selfptr;
+extern void *textptr;
+extern long integer;
+long commvar;
+
+int main(void)
+{
+
+ printf("Testing lrotate: should get 0x00400000, 0x00000001\n");
+ printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000, 4));
+ printf("lrotate(0x00040000, 46) = 0x%08lx\n", lrotate(0x40000, 46));
+
+ printf("This string should read `hello, world': `%s'\n", asmstr);
+
+ printf("&integer = %p, &commvar = %p\n", &integer, &commvar);
+ printf("The integers here should be 1234, 1235 and 4321:\n");
+ integer = 1234;
+ commvar = 4321;
+
+ greet();
+
+ printf("These pointers should be equal: %p and %p\n", &greet, textptr);
+
+ printf("So should these: %p and %p\n", selfptr, &selfptr);
+
+ return 0;
+}