scc

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

mach.h (1672B)


      1 #define NR_SYMHASH 32
      2 
      3 typedef struct objsect Objsect;
      4 typedef struct objsym Objsym;
      5 typedef struct objsymdef Objsymdef;
      6 typedef struct object 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 type;
     22 	unsigned flags;
     23 	long offset;
     24 	int align;
     25 	unsigned long long size;
     26 	Objsect *next;
     27 };
     28 
     29 struct objsym {
     30 	char type;
     31 	char *name;
     32 	unsigned long long size;
     33 	unsigned long long value;
     34 	Objsym *next, *hash;
     35 };
     36 
     37 struct objsymdef {
     38 	char *name;
     39 	int type;
     40 	long offset;
     41 	Objsymdef *hash, *next;
     42 };
     43 
     44 struct object {
     45 	int type;
     46 	char *index;
     47 	Objsym *htab[NR_SYMHASH];
     48 	Objsym *syms;;
     49 	Objsect *secs;
     50 	fpos_t pos;
     51 	int nsecs;
     52 	int nsyms;
     53 	void *data;
     54 };
     55 
     56 
     57 extern int formember(FILE *fp,
     58                      int (*fn)(FILE *, char *, void *),
     59                      void *data);
     60 
     61 extern int objtype(FILE *fp, char **name);
     62 extern Obj *objnew(int type);
     63 extern void objdel(Obj *obj);
     64 extern int objread(Obj *obj, FILE *fp);
     65 extern Objsym *objlookup(Obj *obj, char *name, int install);
     66 extern int objstrip(Obj *obj);
     67 extern int objwrite(Obj *obj, FILE *fp);
     68 extern int objsect(Obj *obj);
     69 extern int objsyms(Obj *obj);
     70 extern int archive(FILE *fp);
     71 extern long armember(FILE *fp, char *member);
     72 extern long setindex(int type, long nsyms, Objsymdef *def, FILE *fp);
     73 extern int getindex(int type, long *nsyms, Objsymdef **def, FILE *fp);
     74 
     75 /* TODO */
     76 extern int objload(Obj *obj, Obj *to);
     77 extern int objreloc(Obj *obj, char *sect, void *rel);
     78 extern int addr2line(Obj *obj, unsigned long long addr, char *fname, int *line);