scc

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

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

 1#include <stdlib.h>
 2#include <stdio.h>
 3#include <limits.h>
 4
 5#include <scc/mach.h>
 6
 7#include "ld.h"
 8
 9static void
10mksecs(void)
11{
12	int i;
13	Obj *obj;
14	Section sec, *sp;
15
16	for (obj = objhead; obj; obj = obj->next) {
17		for (i = 0; getsec(obj, &i, &sec); i++) {
18			sp = lookupsec(sec.name);
19			if (sp->type == '?') {
20				sp->type = sec.type;
21				sp->flags = sec.flags;
22			}
23
24			if (sp->type != sec.type || sp->flags != sec.flags) {
25				error("incompatible definitions of section '%s'",
26				      sp->name);
27			}
28
29			sp->size = sp->size+sp->align-1 & sp->align-1;
30			sp->size += sec.size;
31		}
32	}
33}
34
35static void
36mksegs(void)
37{
38	merge(&text);
39	merge(&rodata);
40	merge(&data);
41	merge(&bss);
42}
43
44void
45pass2(int argc, char *argv[])
46{
47	unsigned long long n;
48	char *end;
49
50	mksecs();
51	mksegs();
52}