Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6446 GerdtR 1
#include "tok.h"
2
 
3
 
4
 
5
void  obj_outLEDATA(unsigned int segm,unsigned int offset,unsigned int recordlength,
6
 
7
8
 
9
10
 
11
int maxnumextname=MAXNUMEXTNAME;
12
 
13
 
14
 
15
int postseg,stackseg;
16
 
17
 
18
 
19
	for(unsigned int i=0;i
20
 
21
	}
22
 
23
}
24
 
25
int MakeObj()
26
 
27
 
28
 
29
	hout=CreateOutPut("obj","wb");
30
 
31
 
32
 
33
	obj_outrecord(0x80,i+1,&string2[0]);// output the LNAMES
34
 
35
	i=strlen((char *)&string2[3]);
36
 
37
	string2[2]=(unsigned char)i;
38
 
39
	for(count=0;count
40
 
41
		strcpy((char *)&string2[7],(startfileinfo+count)->filename);
42
 
43
		*(short *)&string2[0]=0xE940;
44
 
45
		obj_outrecord(0x88,i+7,&string2[0]);// output the LNAMES
46
 
47
 
48
 
49
	*(short *)&string2[0]=0xE940;
50
 
51
	if(!am32){
52
 
53
		string2[2]=1;
54
 
55
		obj_outrecord(0x88,4,&string2[0]);
56
 
57
	else{
58
 
59
		obj_outrecord(0x88,2,&string2[0]);
60
 
61
	obj_outrecord(0x96,39,(unsigned char *)"\000\005_TEXT\004CODE\004_BSS\003BSS\006DGROUP\005_DATA\004DATA");
62
 
63
	if(!am32){
64
 
65
		*(short *)&string2[1]=(short)outptr;//count;// Set the length of the segment of DATA or CODE
66
 
67
		*(short *)&string2[4]=0x0103;	//класс CODE Overlay NONE 1
68
 
69
		i=2;
70
 
71
		if(comfile==file_exe&&modelmem==SMALL){
72
 
73
			*(short *)&string2[1]=outptrdata;// Set the length of the segment DATA
74
 
75
			*(short *)&string2[4]=0x0108;	//класс DATA Overlay NONE
76
 
77
			i++;
78
 
79
80
 
81
		string2[0]=(unsigned char)0x48;
82
 
83
		string2[3]=0x04;	//имя сегмента _BSS
84
 
85
		obj_outrecord(0x98,6,string2);
86
 
87
88
 
89
			obj_outrecord(0x96,6,(unsigned char *)"\005STACK");
90
 
91
			*(short *)&string2[1]=(short)stacksize;// Set the length of the segment STACK
92
 
93
			*(short *)&string2[4]=0x0109;	//класс STACK Overlay NONE
94
 
95
			stackseg=i;
96
 
97
		string2[0]=6;	//имя DGROUP
98
 
99
			*(short *)&string2[1]=0x2FF;
100
 
101
			*(short *)&string2[5]=0x4ff;//stackseg*256+255;//0x4FF;
102
 
103
		}
104
 
105
			*(short *)&string2[1]=0x1FF;
106
 
107
			*(short *)&string2[3]=0x2ff;//postseg*256+255;//0x3FF;
108
 
109
		}
110
 
111
	}
112
 
113
		string2[0]=(unsigned char)0xA9;
114
 
115
		string2[5]=0x02;	//имя сегмента _TEXT
116
 
117
		obj_outrecord(0x99,8,string2);
118
 
119
/*
120
 
121
		*(long *)&string2[1]=0;// Set the length of the segment DATA
122
 
123
		*(short *)&string2[6]=0x0108;	//класс DATA Overlay NONE
124
 
125
		i++;*/
126
 
127
		postseg=i;
128
 
129
		*(long *)&string2[1]=(long)postsize;// Set the length of the segment BSS
130
 
131
		*(short *)&string2[6]=0x0105;	//класс BSS Overlay NONE
132
 
133
		i++;
134
 
135
		obj_outrecord(0x96,11,(unsigned char *)"\005STACK\004FLAT");//9,10
136
 
137
		if(comfile!=file_w32){
138
 
139
 
140
 
141
			*(short *)&string2[6]=0x0109;	//класс STACK Overlay NONE
142
 
143
			stackseg=i;
144
 
145
		string2[0]=10;
146
 
147
		obj_outrecord(0x9A,1,string2);	//GRPDEF Group: FLAT
148
 
149
		i=1;
150
 
151
//		i+=2;
152
 
153
		i+=2;
154
 
155
			*(short *)&string2[i]=stackseg*256+255;//0x4FF
156
 
157
 
158
 
159
	}
160
 
161
	while(externnum>maxnumextname)maxnumextname+=MAXNUMEXTNAME;
162
 
163
// output the PUBDEF records for each exteral procedures (all procedures)
164
 
165
	if(lenextstr!=0)obj_outrecord(0x8c,lenextstr,&string[0]);
166
 
167
	i=0;
168
 
169
	while(i
170
 
171
		sizeblock=1024;
172
 
173
 
174
 
175
					(postbuf+j)->loc>=(i+startptr)&&(postbuf+j)->loc<(i+sizeblock+startptr)){
176
 
177
					sizeblock=(postbuf+j)->loc-i-startptr;//изменить размер блока
178
 
179
				}
180
 
181
		}
182
 
183
		obj_outLEDATA(1,i+startptr,sizeblock,data+i);
184
 
185
		for(j=0;j
186
 
187
				int hold=(postbuf+j)->loc-i-startptr;
188
 
189
					bufobj[ofsfix++]=(unsigned char)((am32==FALSE?0xC4:0xE4)|(hold/256));
190
 
191
					bufobj[ofsfix++]=0x14;
192
 
193
					switch((postbuf+j)->type){
194
 
195
						case POST_VAR32:
196
 
197
							break;
198
 
199
						case FIX_VAR32:
200
 
201
							break;
202
 
203
						case FIX_CODE32:
204
 
205
							break;
206
 
207
				}
208
 
209
210
 
211
				else if((postbuf+j)->type==CALL_EXT){
212
 
213
					if(numext!=0){
214
 
215
						bufobj[ofsfix++]=(unsigned char)(hold%256);
216
 
217
						bufobj[ofsfix++]=(unsigned char)numext;
218
 
219
				}
220
 
221
					int numext=findextname((postbuf+j)->num);
222
 
223
						bufobj[ofsfix++]=(unsigned char)((am32==FALSE?0xC4:0xE4)|(hold/256));
224
 
225
						bufobj[ofsfix++]=0x16;
226
 
227
						bufobj[ofsfix++]=(unsigned char)numext;
228
 
229
				}
230
 
231
		}
232
 
233
		i+=sizeblock;
234
 
235
	free(bufobj);
236
 
237
		i=0;
238
 
239
			if((i+1024)>outptrdata)obj_outLEDATA(2,i,outptrdata-i,outputdata+i);
240
 
241
			i+=1024;
242
 
243
	}
244
 
245
// output end of OBJ notifier
246
 
247
		i=1;
248
 
249
	else{
250
 
251
 
252
 
253
		if(count<65536){
254
 
255
			i=6;
256
 
257
		else{
258
 
259
			i=8;
260
 
261
	}
262
 
263
	free(numextname);
264
 
265
	fclose(hout);
266
 
267
 
268
 
269
270
 
271
 
272
 
273
int i;
274
 
275
	buf[3]=(unsigned char)segm;
276
 
277
		*(short *)&buf[1]=(short)(recordlength+6);
278
 
279
		*(long *)&buf[4]=(long)offset;
280
 
281
	}
282
 
283
		*(short *)&buf[1]=(short)(recordlength+4);
284
 
285
		*(short *)&buf[4]=(short)offset;
286
 
287
	}
288
 
289
	for(i--;i>=0;i--)checksum+=buf[i];
290
 
291
 
292
 
293
	fwrite(&checksum,1,1,hout);
294
 
295
296
 
297
// Outputs an OBJ record.
298
 
299
int checksum;
300
 
301
	recordlength++;
302
 
303
	fwrite(&recordtype,1,1,hout);
304
 
305
	checksum+=(recordlength&255);
306
 
307
	recordlength--;
308
 
309
	fwrite(data,recordlength,1,hout);
310
 
311
	fwrite(&checksum,1,1,hout);
312
 
313
314
 
315
{
316
 
317
	if(ptr!=NULL){
318
 
319
		if(ptr->rectok==tk_apiproc){
320
 
321
			for(unsigned int j=0;j
322
 
323
					i++;
324
 
325
					externnum++;
326
 
327
						maxnumextname+=MAXNUMEXTNAME;
328
 
329
					}
330
 
331
			}
332
 
333
			goto endp;
334
 
335
		if(externnum!=0&&ptr->rectok==tk_undefproc&&(ptr->flag&f_extern)!=0){
336
 
337
			numextname[numextern++]=ptr->recnumber;
338
 
339
			if((lenextstr+i+2)>=STRLEN){
340
 
341
				lenextstr=0;
342
 
343
			string[lenextstr++]=(unsigned char)i;
344
 
345
			lenextstr+=i+1;
346
 
347
		else{
348
 
349
				string2[0]=(unsigned char)(am32==0?0:1);
350
 
351
			}
352
 
353
				if((ptr->flag&f_extern))goto nameext;
354
 
355
					string2[0]=1;
356
 
357
				}
358
 
359
					string2[0]=1;
360
 
361
				}
362
 
363
					string2[0]=(unsigned char)(ptr->recpost==0?0:1);
364
 
365
				}
366
 
367
			else goto endp;
368
 
369
			string2[2]=(unsigned char)i;
370
 
371
				*(short *)&string2[i+3]=(short)ptr->recnumber;
372
 
373
				obj_outrecord(0x90,i+6,&string2[0]);
374
 
375
			else{
376
 
377
				string2[i+7]=0x00;
378
 
379
			}
380
 
381
endp:
382
 
383
	}
384
 
385
>
386
 
387
>
388
 
389
>
390
 
391
>
392
 
393
>
394
 
395
>
396
 
397
>
398
 
399
>
400