scc

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

mach.h (2343B)


      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 /**
     10  * enum sectype - Section property flags
     11  * @SREAD: The segment has read rights
     12  * @SWRITE: The segment has write rights
     13  * @SEXEC: The segment has execution rights
     14  * @SLOAD: Segment data is loaded from disk to memory
     15  * @SALLOC: Segment is allocated in memory
     16  * @SRELOC: Segment has to be relocated
     17  * @SABS: Segment is loaded in a specific address
     18  */
     19 enum sectype {
     20 	SREAD   = 1 << 0,
     21 	SWRITE  = 1 << 1,
     22 	SEXEC   = 1 << 2,
     23 	SLOAD   = 1 << 3,
     24 	SALLOC  = 1 << 4,
     25 	SRELOC  = 1 << 5,
     26 	SABS    = 1 << 6,
     27 };
     28 
     29 enum symtype {
     30 	SYMNOTYPE,
     31 	SYMOBJECT,
     32 	SYMFUNC,
     33 	SYMSECTION,
     34 	SYMFILE,
     35 	SYMCOMMON,
     36 };
     37 
     38 struct obj {
     39 	char *index;
     40 	Objops *ops;
     41 	int type;
     42 	long pos;
     43 	void *data;
     44 	Obj *next;
     45 };
     46 
     47 struct segment {
     48 	char *name;
     49 	unsigned long long base;
     50 	unsigned long long size;
     51 	unsigned flags;
     52 	int index;
     53 	int type;
     54 	int align;
     55 	int nsec;
     56 	Section **sections;
     57 };
     58 
     59 struct section {
     60 	char *name;
     61 	unsigned long long base;
     62 	unsigned long long size;
     63 	unsigned flags;
     64 	int index;
     65 	int align;
     66 	char type;
     67 };
     68 
     69 struct symbol {
     70 	char *name;
     71 	unsigned long long size;
     72 	unsigned long long value;
     73 	int index;
     74 	int section;
     75 	char type;
     76 	int stype;
     77 };
     78 
     79 extern int archive(FILE *fp);
     80 extern long armember(FILE *fp, char *member);
     81 
     82 extern int objtype(FILE *fp, char **name);
     83 extern Obj *newobj(int type);
     84 extern void delobj(Obj *obj);
     85 
     86 extern int readobj(Obj *obj, FILE *fp);
     87 extern int writeobj(Obj *obj, Map *map, FILE *fp);
     88 
     89 extern int strip(Obj *obj);
     90 extern int pc2line(Obj *obj, unsigned long long pc, char *fname, int *ln);
     91 extern int rebase(Obj *obj, int index, unsigned long long offset);
     92 
     93 extern Map *loadmap(Obj *obj, FILE *fp);
     94 extern Map *newmap(int n, FILE *fp);
     95 extern int findsec(Map *map, char *name);
     96 extern int setmap(Map *map,
     97                   char *name,
     98                   FILE *fp,
     99                   unsigned long long begin,
    100                   unsigned long long end,
    101                   long off);
    102 
    103 extern Symbol *getsym(Obj *obj, int *index, Symbol *sym);
    104 extern Section *getsec(Obj *obj, int *index, Section *sec);
    105 
    106 extern int setindex(int, long, char **, long *, FILE *);
    107 extern int getindex(int, long *, char ***, long **, FILE *);