mach.h (2498B)
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 64 unsigned flags; 65 int index; 66 int align; 67 int fill; 68 char type; 69 }; 70 71 /** 72 * @stype: Used internally by libmach 73 * @dtype: Coff debug type 74 * @flags: Used only by the assembler 75 */ 76 struct symbol { 77 char *name; 78 unsigned long long size; 79 unsigned long long value; 80 int index; 81 int section; 82 char type; 83 int stype; 84 int dtype; 85 unsigned flags; 86 }; 87 88 #ifdef stdin 89 extern int archive(FILE *); 90 extern long armember(FILE *, char *); 91 92 extern int objprobe(FILE *, char **); 93 94 extern int readobj(Obj *, FILE *); 95 extern int writeobj(Obj *, Map *, FILE *); 96 97 extern Map *loadmap(Obj *, FILE *); 98 99 extern int setmap(Map *, 100 char *, 101 FILE *, 102 unsigned long long, 103 unsigned long long, 104 long); 105 106 extern int setindex(int, long, char **, long *, FILE *); 107 extern int getindex(int, long *, char ***, long **, FILE *); 108 109 #endif 110 111 extern Map *newmap(Map *, int); 112 extern Map *remap(Map *, int); 113 114 extern int objtype(char *); 115 extern Obj *newobj(int); 116 extern void delobj(Obj *); 117 118 extern int strip(Obj *); 119 extern int pc2line(Obj *, unsigned long long, char *, int *); 120 extern int rebase(Obj *, int, unsigned long long); 121 122 extern int findsec(Map *, char *); 123 124 extern Symbol *getsym(Obj *, int *, Symbol *); 125 extern Section *getsec(Obj *, int *, Section *); 126 extern Section *setsec(Obj *, int *, Section *);