scc

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

mach.h (1901B)


      1 typedef struct segment Segment;
      2 typedef struct section Section;
      3 typedef struct symbol Symbol;
      4 typedef struct objops Objops;
      5 typedef struct obj Obj;
      6 typedef struct map Map;
      7 typedef struct mapsec Mapsec;
      8 
      9 enum sectype {
     10 	SREAD   = 1 << 0,
     11 	SWRITE  = 1 << 1,
     12 	SEXEC   = 1 << 2,
     13 	SLOAD   = 1 << 3,
     14 	SALLOC  = 1 << 4,
     15 	SRELOC  = 1 << 5,
     16 	SABS    = 1 << 6,
     17 	SSHARED = 1 << 7,
     18 };
     19 
     20 struct obj {
     21 	char *index;
     22 	Objops *ops;
     23 	int type;
     24 	long pos;
     25 	void *data;
     26 	Obj *next;
     27 };
     28 
     29 struct segment {
     30 	char *name;
     31 	unsigned long long base;
     32 	unsigned long long size;
     33 	unsigned flags;
     34 	int index;
     35 	int type;
     36 	int align;
     37 	int nsec;
     38 	Section **sections;
     39 };
     40 
     41 struct section {
     42 	char *name;
     43 	unsigned long long base;
     44 	unsigned long long size;
     45 	unsigned flags;
     46 	int index;
     47 	int type;
     48 	int align;
     49 };
     50 
     51 struct symbol {
     52 	char *name;
     53 	unsigned long long size;
     54 	unsigned long long value;
     55 	int index;
     56 	int section;
     57 	char type;
     58 };
     59 
     60 extern int archive(FILE *fp);
     61 extern long armember(FILE *fp, char *member);
     62 
     63 extern int objtype(FILE *fp, char **name);
     64 extern Obj *newobj(int type);
     65 extern void delobj(Obj *obj);
     66 
     67 extern int readobj(Obj *obj, FILE *fp);
     68 extern int writeobj(Obj *obj, Map *map, FILE *fp);
     69 
     70 extern int strip(Obj *obj);
     71 extern int pc2line(Obj *obj, unsigned long long pc, char *fname, int *ln);
     72 extern int rebase(Obj *obj, int index, unsigned long long offset);
     73 
     74 extern Map *loadmap(Obj *obj, FILE *fp);
     75 extern Map *newmap(int n, FILE *fp);
     76 extern int findsec(Map *map, char *name);
     77 extern int setmap(Map *map,
     78                   char *name,
     79                   FILE *fp,
     80                   unsigned long long begin,
     81                   unsigned long long end,
     82                   long off);
     83 
     84 extern Symbol *getsym(Obj *obj, int *index, Symbol *sym);
     85 extern Section *getsec(Obj *obj, int *index, Section *sec);
     86 
     87 extern int setindex(int, long, char **, long *, FILE *);
     88 extern int getindex(int, long *, char ***, long **, FILE *);