1/* 2 * test source file for assembling to ELF 3 * copied from cofftest.c; s/coff/elf/g 4 * build with (under Linux, for example): 5 * yasm -f elf elftest.asm 6 * gcc -o elftest elftest.c elftest.o 7 */ 8 9#include <stdio.h> 10 11extern int lrotate(long, int); 12extern void greet(void); 13extern char asmstr[]; 14extern void *selfptr; 15extern void *textptr; 16extern int integer, commvar; 17 18int main(void) { 19 20 printf("Testing lrotate: should get 0x00400000, 0x00000001\n"); 21 printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000,4)); 22 printf("lrotate(0x00040000, 14) = 0x%08lx\n", lrotate(0x40000,14)); 23 24 printf("This string should read `hello, world': `%s'\n", asmstr); 25 26 printf("The integers here should be 1234, 1235 and 4321:\n"); 27 integer = 1234; 28 commvar = 4321; 29 greet(); 30 31 printf("These pointers should be equal: %p and %p\n", 32 &greet, textptr); 33 34 printf("So should these: %p and %p\n", selfptr, &selfptr); 35} 36