scc

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

coff32str.c (385B)


      1 #include <stdio.h>
      2 
      3 #include <scc/mach.h>
      4 #include <scc/coff32.h>
      5 
      6 #define NAMELEN 8
      7 
      8 union name {
      9 	char name[NAMELEN];  /* name */
     10 	struct {
     11 		long zeroes;  /* if name[0-3] == 0 */
     12 		long offset;  /* offset into string table */
     13 	} s;
     14 };
     15 
     16 char *
     17 coff32str(Coff32 *coff, void *hdr)
     18 {
     19 	union name *p = hdr;
     20 
     21 	if (p->s.zeroes != 0)
     22 		return p->name;
     23 	return &coff->strtbl[p->s.offset];
     24 }