scc

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

mach.h (1699B)


      1 #define NR_SYMHASH 32
      2 
      3 typedef struct objsect Objsect;
      4 typedef struct objsym Objsym;
      5 typedef struct objsymdef Objsymdef;
      6 typedef struct obj Obj;
      7 
      8 enum sectype {
      9 	SREAD   = 1 << 0,
     10 	SWRITE  = 1 << 1,
     11 	SEXEC   = 1 << 2,
     12 	SLOAD   = 1 << 3,
     13 	SALLOC  = 1 << 4,
     14 	SRELOC  = 1 << 5,
     15 	SABS    = 1 << 6,
     16 	SSHARED = 1 << 7,
     17 };
     18 
     19 struct objsect {
     20 	char *name;
     21 	int id;
     22 	int type;
     23 	int align;
     24 	unsigned flags;
     25 	long seek;
     26 	unsigned long long size, base;
     27 	Objsect *next;
     28 };
     29 
     30 struct objsym {
     31 	char *name;
     32 	int type;
     33 	int sect;
     34 	unsigned long long size;
     35 	unsigned long long value;
     36 	Objsym *next, *hash;
     37 };
     38 
     39 struct objsymdef {
     40 	char *name;
     41 	int type;
     42 	long offset;
     43 	Objsymdef *hash, *next;
     44 };
     45 
     46 struct obj {
     47 	int type;
     48 	char *index;
     49 	Objsym *htab[NR_SYMHASH];
     50 	Objsym *syms;
     51 	Objsect *secs;
     52 	FILE *fp;
     53 	fpos_t pos;
     54 	int nsecs;
     55 	int nsyms;
     56 	void *data;
     57 };
     58 
     59 
     60 extern int formember(FILE *fp,
     61                      int (*fn)(FILE *, char *, void *),
     62                      void *data);
     63 
     64 extern int objtype(FILE *fp, char **name);
     65 extern Obj *objnew(int type);
     66 extern void objdel(Obj *obj);
     67 extern int objread(Obj *obj, FILE *fp);
     68 extern Objsym *objlookup(Obj *obj, char *name, int install);
     69 extern int objstrip(Obj *obj);
     70 extern int objwrite(Obj *obj, FILE *fp);
     71 extern int objsect(Obj *obj);
     72 extern int objsyms(Obj *obj);
     73 extern int archive(FILE *fp);
     74 extern long armember(FILE *fp, char *member);
     75 extern long setindex(int type, long nsyms, Objsymdef *def, FILE *fp);
     76 extern int getindex(int type, long *nsyms, Objsymdef **def, FILE *fp);
     77 
     78 /* TODO */
     79 extern int objload(Obj *obj, Obj *to);
     80 extern int objreloc(Obj *obj, char *sect, void *rel);
     81 extern int addr2line(Obj *obj, unsigned long long addr, char *fname, int *line);