coff32new.c - scc - simple c99 compiler
(HTM) git clone git://git.simple-cc.org/scc
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
coff32new.c (515B)
---
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 #include "fun.h"
9
10 int
11 coff32new(Obj *obj, int type)
12 {
13 struct arch *p;
14 struct coff32 *coff;
15 FILHDR *hdr;
16
17 for (p = coff32archs; p->name && p->type != type; ++p)
18 ;
19 if (!p->name)
20 return -1;
21
22 if ((coff = calloc(1, sizeof(*coff))) == NULL)
23 return -1;
24
25 hdr = &coff->hdr;
26 hdr->f_magic = p->magic[1] << 8 | p->magic[0];
27 hdr->f_flags = p->flags;
28
29 obj->data = coff;
30 obj->index = "/";
31 return 0;
32 }