scc

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

libmach.h (1354B)


      1 #define NBYTES 20
      2 #define OBJ(format,arch,order) ((order) << 10 | (arch) << 5 | (format)) 
      3 #define FORMAT(t) ((t) & 0x1f)
      4 #define ARCH(t) (((t) >> 5) & 0x1f)
      5 #define ORDER(t) (((t) >> 10) & 0x1f)
      6 
      7 
      8 enum objformat {
      9 	COFF32,
     10 	NFORMATS,
     11 };
     12 
     13 enum objarch {
     14 	ARCH286,
     15 	ARCH386,
     16 	ARCHAMD64,
     17 	ARCHZ80,
     18 	ARCHARM32,
     19 	ARCHARM64,
     20 };
     21 
     22 enum order {
     23 	LITTLE_ENDIAN,
     24 	BIG_ENDIAN,
     25 };
     26 
     27 struct objops {
     28 	int (*probe)(unsigned char *buf, char **name);
     29 
     30 	int (*new)(Obj *obj);
     31 	void (*del)(Obj *obj);
     32 
     33 	int (*read)(Obj *obj, FILE *fp);
     34 	int (*write)(Obj *obj, Map *map, FILE *fp);
     35 
     36 	int (*strip)(Obj *obj);
     37 	int (*pc2line)(Obj *, unsigned long long , char *, int *);
     38 
     39 	Map *(*loadmap)(Obj *obj, FILE *fp);
     40 
     41 	Symbol *(*getsym)(Obj *obj, int *index, Symbol *sym);
     42 	Section *(*getsec)(Obj *obj, int *index, Section *sec);
     43 
     44 	int (*setidx)(long nsyms, char *names[], long offset[], FILE *fp);
     45 	int (*getidx)(long *nsyms, char ***names, long **offset, FILE *fp);
     46 };
     47 
     48 
     49 struct map {
     50 	int n;
     51 	struct mapsec {
     52 		char *name;
     53 		FILE *fp;
     54 		unsigned long long begin;
     55 		unsigned long long end;
     56 		long offset;
     57 	} sec[];
     58 };
     59 
     60 /* common functions */
     61 extern int pack(int order, unsigned char *dst, char *fmt, ...);
     62 extern int unpack(int order, unsigned char *src, char *fmt, ...);
     63 extern int objpos(Obj *obj, FILE *fp, long pos);
     64 
     65 /* globals */
     66 extern Objops *objops[];
     67 extern Objops coff32;