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