coff32new.c (498B)
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #include <scc/mach.h> 5 #include <scc/coff32.h> 6 7 #include "../libmach.h" 8 9 int 10 coff32new(Obj *obj, int type) 11 { 12 struct arch *p; 13 struct coff32 *coff; 14 FILHDR *hdr; 15 16 for (p = coff32archs; p->name && p->type != type; ++p) 17 ; 18 if (!p->name) 19 return -1; 20 21 if ((coff = calloc(1, sizeof(*coff))) == NULL) 22 return -1; 23 24 hdr = &coff->hdr; 25 hdr->f_magic = p->magic[1] << 8 | p->magic[0]; 26 hdr->f_flags = p->flags; 27 28 obj->data = coff; 29 obj->index = "/"; 30 return 0; 31 }