scc

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

coff32xsetidx.c (538B)


      1 #include <stdio.h>
      2 #include <string.h>
      3 
      4 #include <scc/mach.h>
      5 
      6 #include "../libmach.h"
      7 
      8 int
      9 coff32xsetidx(int order, long nsyms, char *names[], long offs[], FILE *fp)
     10 {
     11 	long i, n;
     12 	size_t len;
     13 	unsigned char buff[4];
     14 
     15 	pack(order, buff, "l", nsyms);
     16 	fwrite(buff, 4, 1, fp);
     17 	n = 4;
     18 
     19 	for (i = 0; i < nsyms; i++) {
     20 		pack(order, buff, "l", offs[i]);
     21 		fwrite(buff, 4, 1, fp);
     22 		n += 4;
     23 	}
     24 
     25 	for (i = 0; i < nsyms; i++) {
     26 		len = strlen(names[i]) + 1;
     27 		fwrite(names[i], len, 1, fp);
     28 		n += len;
     29 	}
     30 
     31 	return fflush(fp) == EOF ? -1 : 0;
     32 }