pass4.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
---
pass4.c (724B)
---
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include <scc/mach.h>
5
6 #include "ld.h"
7
8 void
9 pass4(int argc, char *argv[])
10 {
11 Objlst *lp;
12 Objsec *sp;
13 Section *sec;
14 unsigned long i;
15 FILE *fp;
16
17 for (lp = objhead; lp; lp = lp->next) {
18 /* TODO: fp = lp->obj->fp; */
19 for (sp = lp->obj->secs; sp; sp = sp->next) {
20 /* TODO:
21 * if (!objpos(lp->obj, lp->obj->fp, sp->seek))
22 * error("seeking for section content");
23 */
24 sec = section(sp->name);
25 if (!sec->fp) {
26 sec->fp = tmpfile();
27 if (!sec->fp) {
28 error("out of memory");
29 exit(EXIT_FAILURE);
30 }
31 }
32
33 /* TODO: add symbol alignment */
34
35 for (i = 0; i < sp->size; i++)
36 putc(getc(fp), sec->fp);
37
38 /* TODO: Apply relocations */
39 }
40 }
41 }