scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 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
10int
11coff32new(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}