|
|
1.1 root 1: /* bytesex.h */
2: #import <mach-o/fat.h>
3: #import <mach-o/loader.h>
4: #import <mach/m68k/thread_status.h>
5: #import <mach/m98k/thread_status.h>
6: #import <mach/m88k/thread_status.h>
7: #import <mach/i860/thread_status.h>
8: #import <mach/i386/thread_status.h>
9: #import <mach/hppa/thread_status.h>
10: #import <mach/sparc/thread_status.h>
11: #import <mach-o/nlist.h>
12: #import <mach-o/reloc.h>
13: #import <bsd/ranlib.h>
14: #import "stuff/bool.h"
15:
16: enum byte_sex {
17: UNKNOWN_BYTE_SEX,
18: BIG_ENDIAN_BYTE_SEX,
19: LITTLE_ENDIAN_BYTE_SEX
20: };
21:
22: #define SWAP_SHORT(a) ( ((a & 0xff) << 8) | ((unsigned short)(a) >> 8) )
23:
24: #define SWAP_LONG(a) ( ((a) << 24) | \
25: (((a) << 8) & 0x00ff0000) | \
26: (((a) >> 8) & 0x0000ff00) | \
27: ((unsigned long)(a) >> 24) )
28:
29: extern float SWAP_FLOAT(
30: float f);
31:
32: extern double SWAP_DOUBLE(
33: double d);
34:
35: extern enum byte_sex get_host_byte_sex(
36: void);
37:
38: extern void swap_fat_header(
39: struct fat_header *fat_header,
40: enum byte_sex target_byte_sex);
41:
42: extern void swap_fat_arch(
43: struct fat_arch *fat_archs,
44: unsigned long nfat_arch,
45: enum byte_sex target_byte_sex);
46:
47: extern void swap_mach_header(
48: struct mach_header *mh,
49: enum byte_sex target_byte_sex);
50:
51: extern void swap_load_command(
52: struct load_command *lc,
53: enum byte_sex target_byte_sex);
54:
55: extern void swap_segment_command(
56: struct segment_command *sg,
57: enum byte_sex target_byte_sex);
58:
59: extern void swap_section(
60: struct section *s,
61: unsigned long nsects,
62: enum byte_sex target_byte_sex);
63:
64: extern void swap_symtab_command(
65: struct symtab_command *st,
66: enum byte_sex target_byte_sex);
67:
68: extern void swap_dysymtab_command(
69: struct dysymtab_command *dyst,
70: enum byte_sex target_byte_sex);
71:
72: extern void swap_symseg_command(
73: struct symseg_command *ss,
74: enum byte_sex target_byte_sex);
75:
76: extern void swap_fvmlib_command(
77: struct fvmlib_command *fl,
78: enum byte_sex target_byte_sex);
79:
80: extern void swap_dylib_command(
81: struct dylib_command *dl,
82: enum byte_sex target_byte_sex);
83:
84: extern void swap_dylinker_command(
85: struct dylinker_command *dyld,
86: enum byte_sex target_byte_sex);
87:
88: extern void swap_fvmfile_command(
89: struct fvmfile_command *ff,
90: enum byte_sex target_byte_sex);
91:
92: extern void swap_thread_command(
93: struct thread_command *ut,
94: enum byte_sex target_byte_sex);
95:
96: extern void swap_m68k_thread_state_regs(
97: struct m68k_thread_state_regs *cpu,
98: enum byte_sex target_byte_sex);
99:
100: extern void swap_m68k_thread_state_68882(
101: struct m68k_thread_state_68882 *fpu,
102: enum byte_sex target_byte_sex);
103:
104: extern void swap_m68k_thread_state_user_reg(
105: struct m68k_thread_state_user_reg *user_reg,
106: enum byte_sex target_byte_sex);
107:
108: extern void swap_m98k_thread_state_grf_t(
109: m98k_thread_state_grf_t *cpu,
110: enum byte_sex target_byte_sex);
111:
112: extern void swap_m88k_thread_state_grf_t(
113: m88k_thread_state_grf_t *cpu,
114: enum byte_sex target_byte_sex);
115:
116: extern void swap_m88k_thread_state_xrf_t(
117: m88k_thread_state_xrf_t *fpu,
118: enum byte_sex target_byte_sex);
119:
120: extern void swap_m88k_thread_state_user_t(
121: m88k_thread_state_user_t *user,
122: enum byte_sex target_byte_sex);
123:
124: extern void swap_m88110_thread_state_impl_t(
125: m88110_thread_state_impl_t *spu,
126: enum byte_sex target_byte_sex);
127:
128: extern void swap_i860_thread_state_regs(
129: struct i860_thread_state_regs *cpu,
130: enum byte_sex target_byte_sex);
131:
132: extern void swap_i386_thread_state(
133: i386_thread_state_t *cpu,
134: enum byte_sex target_byte_sex);
135:
136: extern void swap_i386_thread_fpstate(
137: i386_thread_fpstate_t *fpu,
138: enum byte_sex target_byte_sex);
139:
140: extern void swap_i386_thread_exceptstate(
141: i386_thread_exceptstate_t *exc,
142: enum byte_sex target_byte_sex);
143:
144: extern void swap_i386_thread_cthreadstate(
145: i386_thread_cthreadstate_t *user,
146: enum byte_sex target_byte_sex);
147:
148: extern void swap_hppa_integer_thread_state(
149: struct hp_pa_integer_thread_state *regs,
150: enum byte_sex target_byte_order);
151:
152: extern void swap_hppa_frame_thread_state(
153: struct hp_pa_frame_thread_state *frame,
154: enum byte_sex target_byte_order);
155:
156: extern void swap_hppa_fp_thread_state(
157: struct hp_pa_fp_thread_state *fp,
158: enum byte_sex target_byte_order);
159:
160: extern void swap_sparc_thread_state_regs(
161: struct sparc_thread_state_regs *cpu,
162: enum byte_sex target_byte_order);
163:
164: extern void swap_sparc_thread_state_fpu(
165: struct sparc_thread_state_fpu *fpu,
166: enum byte_sex target_byte_order);
167:
168: extern void swap_ident_command(
169: struct ident_command *id_cmd,
170: enum byte_sex target_byte_sex);
171:
172: extern void swap_nlist(
173: struct nlist *symbols,
174: unsigned long nsymbols,
175: enum byte_sex target_byte_sex);
176:
177: extern void swap_ranlib(
178: struct ranlib *ranlibs,
179: unsigned long nranlibs,
180: enum byte_sex target_byte_sex);
181:
182: extern void swap_relocation_info(
183: struct relocation_info *relocs,
184: unsigned long nrelocs,
185: enum byte_sex target_byte_sex);
186:
187: extern void swap_indirect_symbols(
188: unsigned long *indirect_symbols,
189: unsigned long nindirect_symbols,
190: enum byte_sex target_byte_sex);
191:
192: extern void swap_dylib_reference(
193: struct dylib_reference *refs,
194: unsigned long nrefs,
195: enum byte_sex target_byte_sex);
196:
197: extern void swap_dylib_module(
198: struct dylib_module *mods,
199: unsigned long nmods,
200: enum byte_sex target_byte_sex);
201:
202: extern void swap_dylib_table_of_contents(
203: struct dylib_table_of_contents *tocs,
204: unsigned long ntocs,
205: enum byte_sex target_byte_sex);
206:
207: /*
208: * swap_object_headers() swaps the object file headers from the host byte sex
209: * into the non-host byte sex. It returns TRUE if it can and did swap the
210: * headers else returns FALSE and does not touch the headers and prints an error
211: * using the error() routine.
212: */
213: extern enum bool swap_object_headers(
214: struct mach_header *mh,
215: struct load_command *load_commands);
216:
217: /*
218: * get_toc_byte_sex() guesses the byte sex of the table of contents of the
219: * library mapped in at the address, addr, of size, size based on the first
220: * object file's bytesex. If it can't figure it out, because the library has
221: * no object file members or is malformed it will return UNKNOWN_BYTE_SEX.
222: */
223: extern enum byte_sex get_toc_byte_sex(
224: char *addr,
225: unsigned long size);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.