scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

coff32loadmap.c (544B)


      1 #include <stdio.h>
      2 
      3 #include <scc/mach.h>
      4 
      5 #include "../libmach.h"
      6 #include "coff32.h"
      7 
      8 Map *
      9 coff32loadmap(Obj *obj, FILE *fp)
     10 {
     11 	long i;
     12 	Map *map;
     13 	long nsec;
     14 	SCNHDR *scn;
     15 	struct coff32 *coff = obj->data;
     16 	FILHDR *hdr = &coff->hdr;
     17 
     18 	nsec = hdr->f_nscns;
     19 	if ((map = newmap(nsec, fp)) == NULL)
     20 		return NULL;
     21 
     22 	for (scn = coff->scns; nsec--; ++scn) {
     23 		unsigned long o = obj->pos + scn->s_scnptr;
     24 		unsigned long long b = scn->s_paddr;
     25 		unsigned long long e = b + scn->s_size;
     26 
     27 		setmap(map, scn->s_name, fp, b, e, o);
     28 	}
     29 
     30 	return map;
     31 }