readobj.c (352B)
1 #include <stdio.h> 2 3 #include <scc/mach.h> 4 5 #include "libmach.h" 6 7 #include "elf/fun.h" 8 #include "coff32/fun.h" 9 10 static int (*ops[NFORMATS])(Obj *, FILE *) = { 11 [COFF32] = coff32read, 12 [ELF] = elfread, 13 }; 14 15 int 16 readobj(Obj *obj, FILE *fp) 17 { 18 long off; 19 20 if ((off = ftell(fp)) == EOF) 21 return -1; 22 obj->pos = off; 23 24 return (*ops[objfmt(obj)])(obj, fp); 25 }