1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef _IBCS2_EXEC_H_
35 #define _IBCS2_EXEC_H_
36
37
38
39
40
41 struct coff_filehdr {
42 u_short f_magic;
43 u_short f_nscns;
44 long f_timdat;
45 long f_symptr;
46 long f_nsyms;
47 u_short f_opthdr;
48 u_short f_flags;
49 };
50
51
52 #define COFF_MAGIC_I386 0x14c
53
54
55 #define COFF_F_RELFLG 0x1
56 #define COFF_F_EXEC 0x2
57 #define COFF_F_LNNO 0x4
58 #define COFF_F_LSYMS 0x8
59 #define COFF_F_SWABD 0x40
60 #define COFF_F_AR16WR 0x80
61 #define COFF_F_AR32WR 0x100
62
63
64
65
66
67 struct coff_aouthdr {
68 short a_magic;
69 short a_vstamp;
70 long a_tsize;
71 long a_dsize;
72 long a_bsize;
73 long a_entry;
74 long a_tstart;
75 long a_dstart;
76 };
77
78
79 #define COFF_OMAGIC 0407
80
81 #define COFF_NMAGIC 0410
82
83 #define COFF_ZMAGIC 0413
84
85 #define COFF_SMAGIC 0443
86
87
88
89
90
91 struct coff_scnhdr {
92 char s_name[8];
93 long s_paddr;
94 long s_vaddr;
95 long s_size;
96 long s_scnptr;
97 long s_relptr;
98 long s_lnnoptr;
99 u_short s_nreloc;
100 u_short s_nlnno;
101 long s_flags;
102 };
103
104
105 #define COFF_STYP_REG 0x00
106 #define COFF_STYP_DSECT 0x01
107 #define COFF_STYP_NOLOAD 0x02
108 #define COFF_STYP_GROUP 0x04
109 #define COFF_STYP_PAD 0x08
110 #define COFF_STYP_COPY 0x10
111 #define COFF_STYP_TEXT 0x20
112 #define COFF_STYP_DATA 0x40
113 #define COFF_STYP_BSS 0x80
114 #define COFF_STYP_INFO 0x200
115 #define COFF_STYP_OVER 0x400
116 #define COFF_STYP_SHLIB 0x800
117
118
119
120
121
122 struct coff_slhdr {
123 long entry_len;
124 long path_index;
125 char sl_name[1];
126 };
127
128 #define COFF_ROUND(val, by) (((val) + by - 1) & ~(by - 1))
129
130 #define COFF_ALIGN(a) ((a) & ~(COFF_LDPGSZ - 1))
131
132 #define COFF_HDR_SIZE \
133 (sizeof(struct coff_filehdr) + sizeof(struct coff_aouthdr))
134
135 #define COFF_BLOCK_ALIGN(ap, value) \
136 (ap->a_magic == COFF_ZMAGIC ? COFF_ROUND(value, COFF_LDPGSZ) : \
137 value)
138
139 #define COFF_TXTOFF(fp, ap) \
140 (ap->a_magic == COFF_ZMAGIC ? 0 : \
141 COFF_ROUND(COFF_HDR_SIZE + fp->f_nscns * \
142 sizeof(struct coff_scnhdr), COFF_SEGMENT_ALIGNMENT(ap)))
143
144 #define COFF_DATOFF(fp, ap) \
145 (COFF_BLOCK_ALIGN(ap, COFF_TXTOFF(fp, ap) + ap->a_tsize))
146
147 #define COFF_SEGMENT_ALIGN(ap, value) \
148 (COFF_ROUND(value, (ap->a_magic == COFF_ZMAGIC ? COFF_LDPGSZ : \
149 COFF_SEGMENT_ALIGNMENT(ap))))
150
151 #define COFF_LDPGSZ 4096
152
153 #define COFF_SEGMENT_ALIGNMENT(ap) 4
154
155 #define COFF_BADMAG(ex) (ex->f_magic != COFF_MAGIC_I386)
156
157 #define IBCS2_HIGH_SYSCALL(n) (((n) & 0x7f) == 0x28)
158 #define IBCS2_CVT_HIGH_SYSCALL(n) (((n) >> 8) + 128)
159
160 struct exec_package;
161 int exec_ibcs2_coff_makecmds(struct proc *, struct exec_package *);
162
163
164
165
166
167 struct xexec {
168 u_short x_magic;
169 u_short x_ext;
170 long x_text;
171 long x_data;
172 long x_bss;
173 long x_syms;
174 long x_reloc;
175 long x_entry;
176 char x_cpu;
177 char x_relsym;
178 u_short x_renv;
179 };
180
181
182 #define XOUT_MAGIC 0x0206
183
184
185 #define XC_386 0x004a
186
187
188 #define XE_V5 0xc000
189 #define XE_SEG 0x0800
190 #define XE_ABS 0x0400
191 #define XE_ITER 0x0200
192 #define XE_VMOD 0x0100
193 #define XE_FPH 0x0080
194 #define XE_LTEXT 0x0040
195 #define XE_LDATA 0x0020
196 #define XE_OVER 0x0010
197 #define XE_FS 0x0008
198 #define XE_PURE 0x0004
199 #define XE_SEP 0x0002
200 #define XE_EXEC 0x0001
201
202
203
204
205
206 struct xext {
207 long xe_trsize;
208 long xe_drsize;
209 long xe_tbase;
210 long xe_dbase;
211 long xe_stksize;
212 long xe_segpos;
213 long xe_segsize;
214 long xe_mdtpos;
215 long xe_mdtsize;
216 char xe_mdttype;
217 char xe_pagesize;
218 char xe_ostype;
219 char xe_osvers;
220 u_short xe_eseg;
221 u_short xe_sres;
222 };
223
224
225
226
227
228 struct xseg {
229 u_short xs_type;
230 u_short xs_attr;
231 u_short xs_seg;
232 char xs_align;
233 char xs_cres;
234 long xs_filpos;
235 long xs_psize;
236 long xs_vsize;
237 long xs_rbase;
238 u_short xs_noff;
239 u_short xs_sres;
240 long xs_lres;
241 };
242
243
244 #define XS_TNULL 0
245 #define XS_TTEXT 1
246 #define XS_TDATA 2
247 #define XS_TSYMS 3
248 #define XS_TREL 4
249 #define XS_TSESTR 5
250 #define XS_TGRPS 6
251
252 #define XS_TIDATA 64
253 #define XS_TTSS 65
254 #define XS_TLFIX 66
255 #define XS_TDNAME 67
256 #define XS_TDTEXT 68
257 #define XS_TDFIX 69
258 #define XS_TOVTAB 70
259 #define XS_T71 71
260 #define XS_TSYSTR 72
261
262
263 #define XS_AMEM 0x8000
264 #define XS_AITER 0x0001
265 #define XS_AHUGE 0x0002
266 #define XS_ABSS 0x0004
267 #define XS_APURE 0x0008
268 #define XS_AEDOWN 0x0010
269 #define XS_APRIV 0x0020
270 #define XS_A32BIT 0x0040
271
272
273
274
275
276 struct xiter {
277 long xi_size;
278 long xi_rep;
279 long xi_offset;
280 };
281
282 #define XOUT_HDR_SIZE (sizeof(struct xexec) + sizeof(struct xext))
283
284 int exec_ibcs2_xout_makecmds(struct proc *, struct exec_package *);
285
286 #endif