file.c revision 1.3 1 /* $NetBSD: file.c,v 1.3 1997/10/16 07:36:31 lukem Exp $ */
2
3 /*
4 * Copyright (c) 1995-96 Mats O Jansson. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Mats O Jansson.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef LINT
33 static char rcsid[] = "$NetBSD: file.c,v 1.3 1997/10/16 07:36:31 lukem Exp $";
34 #endif
35
36 #include "os.h"
37 #include "common/common.h"
38 #include "common/mopdef.h"
39
40 #ifndef NOAOUT
41 #if defined(__NetBSD__) || defined(__OpenBSD__)
42 #include <sys/exec_aout.h>
43 #endif
44 #if defined(__bsdi__)
45 #define NOAOUT
46 #endif
47 #if defined(__FreeBSD__)
48 #include <sys/imgact_aout.h>
49 #endif
50 #if !defined(MID_VAX)
51 #define MID_VAX 140
52 #endif
53 #endif
54
55 void
56 mopFilePutLX(buf, index, value, cnt)
57 u_char *buf;
58 int index, cnt;
59 u_long value;
60 {
61 int i;
62 for (i = 0; i < cnt; i++) {
63 buf[index+i] = value % 256;
64 value = value / 256;
65 }
66 }
67
68 void
69 mopFilePutBX(buf, index, value, cnt)
70 u_char *buf;
71 int index, cnt;
72 u_long value;
73 {
74 int i;
75 for (i = 0; i < cnt; i++) {
76 buf[index+cnt-1-i] = value % 256;
77 value = value / 256;
78 }
79 }
80
81 u_long
82 mopFileGetLX(buf, index, cnt)
83 u_char *buf;
84 int index, cnt;
85 {
86 u_long ret = 0;
87 int i;
88
89 for (i = 0; i < cnt; i++) {
90 ret = ret*256 + buf[index+cnt-1-i];
91 }
92
93 return(ret);
94 }
95
96 u_long
97 mopFileGetBX(buf, index, cnt)
98 u_char *buf;
99 int index, cnt;
100 {
101 u_long ret = 0;
102 int i;
103
104 for (i = 0; i < cnt; i++) {
105 ret = ret*256 + buf[index+i];
106 }
107
108 return(ret);
109 }
110
111 void
112 mopFileSwapX(buf, index, cnt)
113 u_char *buf;
114 int index, cnt;
115 {
116 int i;
117 u_char c;
118
119 for (i = 0; i < (cnt / 2); i++) {
120 c = buf[index+i];
121 buf[index+i] = buf[index+cnt-1-i];
122 buf[index+cnt-1-i] = c;
123 }
124
125 }
126
127 int
128 CheckMopFile(fd)
129 int fd;
130 {
131 u_char header[512];
132 short image_type;
133
134 if (read(fd, header, 512) != 512)
135 return(-1);
136
137 (void)lseek(fd, (off_t) 0, SEEK_SET);
138
139 image_type = (u_short)(header[IHD_W_ALIAS+1]*256 +
140 header[IHD_W_ALIAS]);
141
142 switch(image_type) {
143 case IHD_C_NATIVE: /* Native mode image (VAX) */
144 case IHD_C_RSX: /* RSX image produced by TKB */
145 case IHD_C_BPA: /* BASIC plus analog */
146 case IHD_C_ALIAS: /* Alias */
147 case IHD_C_CLI: /* Image is CLI */
148 case IHD_C_PMAX: /* PMAX system image */
149 case IHD_C_ALPHA: /* ALPHA system image */
150 break;
151 default:
152 return(-1);
153 }
154
155 return(0);
156 }
157
158 int
159 GetMopFileInfo(fd, load, xfr)
160 int fd;
161 u_long *load, *xfr;
162 {
163 u_char header[512];
164 short image_type;
165 u_long load_addr, xfr_addr, isd, iha, hbcnt, isize;
166
167 if (read(fd, header, 512) != 512)
168 return(-1);
169
170 image_type = (u_short)(header[IHD_W_ALIAS+1]*256 +
171 header[IHD_W_ALIAS]);
172
173 switch(image_type) {
174 case IHD_C_NATIVE: /* Native mode image (VAX) */
175 isd = (header[IHD_W_SIZE+1]*256 +
176 header[IHD_W_SIZE]);
177 iha = (header[IHD_W_ACTIVOFF+1]*256 +
178 header[IHD_W_ACTIVOFF]);
179 hbcnt = (header[IHD_B_HDRBLKCNT]);
180 isize = (header[isd+ISD_W_PAGCNT+1]*256 +
181 header[isd+ISD_W_PAGCNT]) * 512;
182 load_addr = ((header[isd+ISD_V_VPN+1]*256 +
183 header[isd+ISD_V_VPN]) & ISD_M_VPN)
184 * 512;
185 xfr_addr = (header[iha+IHA_L_TFRADR1+3]*0x1000000 +
186 header[iha+IHA_L_TFRADR1+2]*0x10000 +
187 header[iha+IHA_L_TFRADR1+1]*0x100 +
188 header[iha+IHA_L_TFRADR1]) & 0x7fffffff;
189 printf("Native Image (VAX)\n");
190 printf("Header Block Count: %d\n",hbcnt);
191 printf("Image Size: %08x\n",isize);
192 printf("Load Address: %08x\n",load_addr);
193 printf("Transfer Address: %08x\n",xfr_addr);
194 break;
195 case IHD_C_RSX: /* RSX image produced by TKB */
196 hbcnt = header[L_BBLK+1]*256 + header[L_BBLK];
197 isize = (header[L_BLDZ+1]*256 + header[L_BLDZ]) * 64;
198 load_addr = header[L_BSA+1]*256 + header[L_BSA];
199 xfr_addr = header[L_BXFR+1]*256 + header[L_BXFR];
200 printf("RSX Image\n");
201 printf("Header Block Count: %d\n",hbcnt);
202 printf("Image Size: %08x\n",isize);
203 printf("Load Address: %08x\n",load_addr);
204 printf("Transfer Address: %08x\n",xfr_addr);
205 break;
206 case IHD_C_BPA: /* BASIC plus analog */
207 printf("BASIC-Plus Image, not supported\n");
208 return(-1);
209 break;
210 case IHD_C_ALIAS: /* Alias */
211 printf("Alias, not supported\n");
212 return(-1);
213 break;
214 case IHD_C_CLI: /* Image is CLI */
215 printf("CLI, not supported\n");
216 return(-1);
217 break;
218 case IHD_C_PMAX: /* PMAX system image */
219 isd = (header[IHD_W_SIZE+1]*256 +
220 header[IHD_W_SIZE]);
221 iha = (header[IHD_W_ACTIVOFF+1]*256 +
222 header[IHD_W_ACTIVOFF]);
223 hbcnt = (header[IHD_B_HDRBLKCNT]);
224 isize = (header[isd+ISD_W_PAGCNT+1]*256 +
225 header[isd+ISD_W_PAGCNT]) * 512;
226 load_addr = (header[isd+ISD_V_VPN+1]*256 +
227 header[isd+ISD_V_VPN]) * 512;
228 xfr_addr = (header[iha+IHA_L_TFRADR1+3]*0x1000000 +
229 header[iha+IHA_L_TFRADR1+2]*0x10000 +
230 header[iha+IHA_L_TFRADR1+1]*0x100 +
231 header[iha+IHA_L_TFRADR1]);
232 printf("PMAX Image \n");
233 printf("Header Block Count: %d\n",hbcnt);
234 printf("Image Size: %08x\n",isize);
235 printf("Load Address: %08x\n",load_addr);
236 printf("Transfer Address: %08x\n",xfr_addr);
237 break;
238 case IHD_C_ALPHA: /* ALPHA system image */
239 isd = (header[EIHD_L_ISDOFF+3]*0x1000000 +
240 header[EIHD_L_ISDOFF+2]*0x10000 +
241 header[EIHD_L_ISDOFF+1]*0x100 +
242 header[EIHD_L_ISDOFF]);
243 hbcnt = (header[EIHD_L_HDRBLKCNT+3]*0x1000000 +
244 header[EIHD_L_HDRBLKCNT+2]*0x10000 +
245 header[EIHD_L_HDRBLKCNT+1]*0x100 +
246 header[EIHD_L_HDRBLKCNT]);
247 isize = (header[isd+EISD_L_SECSIZE+3]*0x1000000 +
248 header[isd+EISD_L_SECSIZE+2]*0x10000 +
249 header[isd+EISD_L_SECSIZE+1]*0x100 +
250 header[isd+EISD_L_SECSIZE]);
251 load_addr = 0;
252 xfr_addr = 0;
253 printf("Alpha Image \n");
254 printf("Header Block Count: %d\n",hbcnt);
255 printf("Image Size: %08x\n",isize);
256 printf("Load Address: %08x\n",load_addr);
257 printf("Transfer Address: %08x\n",xfr_addr);
258 break;
259 default:
260 printf("Unknown Image (%d)\n",image_type);
261 return(-1);
262 }
263
264 if (load != NULL) {
265 *load = load_addr;
266 }
267
268 if (xfr != NULL) {
269 *xfr = xfr_addr;
270 }
271
272 return(0);
273 }
274
275 #ifndef NOAOUT
276 int
277 getMID(old_mid,new_mid)
278 int old_mid, new_mid;
279 {
280 int mid;
281
282 mid = old_mid;
283
284 switch (new_mid) {
285 case MID_I386:
286 mid = MID_I386;
287 break;
288 #ifdef MID_M68K
289 case MID_M68K:
290 mid = MID_M68K;
291 break;
292 #endif
293 #ifdef MID_M68K4K
294 case MID_M68K4K:
295 mid = MID_M68K4K;
296 break;
297 #endif
298 #ifdef MID_NS32532
299 case MID_NS32532:
300 mid = MID_NS32532;
301 break;
302 #endif
303 /*###323 [cc] for each function it appears in.)%%%*/
304 /*###323 [cc] (Each undeclared identifier is reported only once%%%*/
305 /*###323 [cc] `MID_SPARC' undeclared (first use this function)%%%*/
306 case MID_SPARC:
307 mid = MID_SPARC;
308 break;
309 #ifdef MID_PMAX
310 case MID_PMAX:
311 mid = MID_PMAX;
312 break;
313 #endif
314 #ifdef MID_VAX
315 case MID_VAX:
316 mid = MID_VAX;
317 break;
318 #endif
319 #ifdef MID_ALPHA
320 case MID_ALPHA:
321 mid = MID_ALPHA;
322 break;
323 #endif
324 #ifdef MID_MIPS
325 case MID_MIPS:
326 mid = MID_MIPS;
327 break;
328 #endif
329 #ifdef MID_ARM6
330 case MID_ARM6:
331 mid = MID_ARM6;
332 break;
333 #endif
334 default:
335 /*###352 [cc] syntax error before `}'%%%*/
336 }
337
338 return(mid);
339 }
340
341 int
342 getCLBYTES(mid)
343 int mid;
344 {
345 int clbytes;
346
347 switch (mid) {
348 #ifdef MID_VAX
349 case MID_VAX:
350 clbytes = 1024;
351 break;
352 #endif
353 case MID_I386:
354 #ifdef MID_M68K4K
355 case MID_M68K4K:
356 #endif
357 #ifdef MID_NS32532
358 case MID_NS32532:
359 #endif
360 case MID_SPARC: /* It might be 8192 */
361 #ifdef MID_PMAX
362 case MID_PMAX:
363 #endif
364 #ifdef MID_MIPS
365 case MID_MIPS:
366 #endif
367 #ifdef MID_ARM6
368 case MID_ARM6:
369 #endif
370 clbytes = 4096;
371 break;
372 #ifdef MID_M68K
373 case MID_M68K:
374 #endif
375 #ifdef MID_ALPHA
376 case MID_ALPHA:
377 #endif
378 #if defined(MID_M68K) || defined(MID_ALPHA)
379 clbytes = 8192;
380 break;
381 #endif
382 default:
383 clbytes = 0;
384 }
385
386 return(clbytes);
387 }
388 #endif
389
390 /*###406 [cc] syntax error before `int'%%%*/
391 int
392 CheckAOutFile(fd)
393 int fd;
394 {
395 #ifdef NOAOUT
396 return(-1);
397 #else
398 struct exec ex, ex_swap;
399 int mid = -1;
400
401 /*###416 [cc] `fd' undeclared (first use this function)%%%*/
402 if (read(fd, (char *)&ex, sizeof(ex)) != sizeof(ex))
403 return(-1);
404
405 (void)lseek(fd, (off_t) 0, SEEK_SET);
406
407 if (read(fd, (char *)&ex_swap, sizeof(ex_swap)) != sizeof(ex_swap))
408 return(-1);
409
410 (void)lseek(fd, (off_t) 0, SEEK_SET);
411
412 mid = getMID(mid, N_GETMID (ex));
413
414 if (mid == -1) {
415 mid = getMID(mid, N_GETMID (ex_swap));
416 }
417
418 if (mid != -1) {
419 return(0);
420 } else {
421 return(-1);
422 }
423 #endif NOAOUT
424 }
425
426 /*###440 [cc] syntax error before `int'%%%*/
427 int
428 GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
429 a_data, a_data_fill, a_bss, a_bss_fill, aout)
430 int fd, *aout;
431 u_long *load, *xfr, *a_text, *a_text_fill;
432 u_long *a_data, *a_data_fill, *a_bss, *a_bss_fill;
433 {
434 #ifdef NOAOUT
435 return(-1);
436 #else
437 struct exec ex, ex_swap;
438 int mid = -1;
439 u_long magic, clbytes, clofset;
440
441 if (read(fd, (char *)&ex, sizeof(ex)) != sizeof(ex))
442 return(-1);
443
444 (void)lseek(fd, (off_t) 0, SEEK_SET);
445
446 if (read(fd, (char *)&ex_swap, sizeof(ex_swap)) != sizeof(ex_swap))
447 return(-1);
448
449 mopFileSwapX((u_char *)&ex_swap, 0, 4);
450
451 mid = getMID(mid, N_GETMID (ex));
452
453 if (mid == -1) {
454 mid = getMID(mid, N_GETMID (ex_swap));
455 if (mid != -1) {
456 mopFileSwapX((u_char *)&ex, 0, 4);
457 }
458 }
459
460 if (mid == -1) {
461 return(-1);
462 }
463
464 if (N_BADMAG (ex)) {
465 return(-1);
466 }
467
468 switch (mid) {
469 case MID_I386:
470 #ifdef MID_NS32532
471 case MID_NS32532:
472 #endif
473 #ifdef MID_PMAX
474 case MID_PMAX:
475 #endif
476 #ifdef MID_VAX
477 case MID_VAX:
478 #endif
479 #ifdef MID_ALPHA
480 case MID_ALPHA:
481 #endif
482 #ifdef MID_ARM6
483 case MID_ARM6:
484 #endif
485 ex.a_text = mopFileGetLX((u_char *)&ex_swap, 4, 4);
486 ex.a_data = mopFileGetLX((u_char *)&ex_swap, 8, 4);
487 ex.a_bss = mopFileGetLX((u_char *)&ex_swap, 12, 4);
488 ex.a_syms = mopFileGetLX((u_char *)&ex_swap, 16, 4);
489 ex.a_entry = mopFileGetLX((u_char *)&ex_swap, 20, 4);
490 ex.a_trsize= mopFileGetLX((u_char *)&ex_swap, 24, 4);
491 ex.a_drsize= mopFileGetLX((u_char *)&ex_swap, 28, 4);
492 break;
493 #ifdef MID_M68K
494 case MID_M68K:
495 #endif
496 #ifdef MID_M68K4K
497 case MID_M68K4K:
498 #endif
499 case MID_SPARC:
500 #ifdef MID_MIPS
501 case MID_MIPS:
502 #endif
503 ex.a_text = mopFileGetBX((u_char *)&ex_swap, 4, 4);
504 ex.a_data = mopFileGetBX((u_char *)&ex_swap, 8, 4);
505 ex.a_bss = mopFileGetBX((u_char *)&ex_swap, 12, 4);
506 ex.a_syms = mopFileGetBX((u_char *)&ex_swap, 16, 4);
507 ex.a_entry = mopFileGetBX((u_char *)&ex_swap, 20, 4);
508 ex.a_trsize= mopFileGetBX((u_char *)&ex_swap, 24, 4);
509 ex.a_drsize= mopFileGetBX((u_char *)&ex_swap, 28, 4);
510 break;
511 default:
512 /*###525 [cc] syntax error before `}'%%%*/
513 }
514
515 printf("a.out image (");
516 switch (N_GETMID (ex)) {
517 case MID_I386:
518 printf("i386");
519 break;
520 #ifdef MID_M68K
521 case MID_M68K:
522 printf("m68k");
523 break;
524 #endif
525 #ifdef MID_M68K4K
526 case MID_M68K4K:
527 printf("m68k 4k");
528 break;
529 #endif
530 #ifdef MID_NS32532
531 case MID_NS32532:
532 printf("pc532");
533 break;
534 #endif
535 case MID_SPARC:
536 printf("sparc");
537 break;
538 #ifdef MID_PMAX
539 case MID_PMAX:
540 printf("pmax");
541 break;
542 #endif
543 #ifdef MID_VAX
544 case MID_VAX:
545 printf("vax");
546 break;
547 #endif
548 #ifdef MID_ALPHA
549 case MID_ALPHA:
550 printf("alpha");
551 break;
552 #endif
553 #ifdef MID_MIPS
554 case MID_MIPS:
555 printf("mips");
556 break;
557 #endif
558 #ifdef MID_ARM6
559 case MID_ARM6:
560 printf("arm32");
561 break;
562 #endif
563 default:
564 }
565 printf(") Magic: ");
566 switch (N_GETMAGIC (ex)) {
567 case OMAGIC:
568 printf("OMAGIC");
569 break;
570 case NMAGIC:
571 printf("NMAGIC");
572 break;
573 case ZMAGIC:
574 printf("ZMAGIC");
575 break;
576 case QMAGIC:
577 printf("QMAGIC");
578 break;
579 default:
580 printf("Unknown %d",N_GETMAGIC (ex));
581 }
582 printf("\n");
583 printf("Size of text: %08x\n",ex.a_text);
584 printf("Size of data: %08x\n",ex.a_data);
585 printf("Size of bss: %08x\n",ex.a_bss);
586 printf("Size of symbol tab: %08x\n",ex.a_syms);
587 printf("Transfer Address: %08x\n",ex.a_entry);
588 printf("Size of reloc text: %08x\n",ex.a_trsize);
589 printf("Size of reloc data: %08x\n",ex.a_drsize);
590
591 magic = N_GETMAGIC (ex);
592 clbytes = getCLBYTES(mid);
593 clofset = clbytes - 1;
594
595 /*###608 [cc] `load' undeclared (first use this function)%%%*/
596 if (load != NULL) {
597 *load = 0;
598 }
599
600 /*###612 [cc] `xfr' undeclared (first use this function)%%%*/
601 if (xfr != NULL) {
602 *xfr = ex.a_entry;
603 }
604
605 /*###616 [cc] `a_text' undeclared (first use this function)%%%*/
606 if (a_text != NULL) {
607 *a_text = ex.a_text;
608 }
609
610 /*###620 [cc] `a_text_fill' undeclared (first use this function)%%%*/
611 if (a_text_fill != NULL) {
612 if (magic == ZMAGIC || magic == NMAGIC) {
613 *a_text_fill = clbytes - (ex.a_text & clofset);
614 if (*a_text_fill == clbytes) {
615 *a_text_fill = 0;
616 }
617 } else {
618 *a_text_fill = 0;
619 }
620 }
621
622 /*###631 [cc] `a_data' undeclared (first use this function)%%%*/
623 if (a_data != NULL) {
624 *a_data = ex.a_data;
625 }
626
627 /*###635 [cc] `a_data_fill' undeclared (first use this function)%%%*/
628 if (a_data_fill != NULL) {
629 if (magic == ZMAGIC || magic == NMAGIC) {
630 *a_data_fill = clbytes - (ex.a_data & clofset);
631 if (*a_data_fill == clbytes) {
632 *a_data_fill = 0;
633 }
634 } else {
635 *a_data_fill = 0;
636 }
637 }
638
639 /*###646 [cc] `a_bss' undeclared (first use this function)%%%*/
640 if (a_bss != NULL) {
641 *a_bss = ex.a_bss;
642 }
643
644 /*###650 [cc] `a_bss_fill' undeclared (first use this function)%%%*/
645 if (a_bss_fill != NULL) {
646 if (magic == ZMAGIC || magic == NMAGIC) {
647 *a_bss_fill = clbytes - (ex.a_bss & clofset);
648 if (*a_bss_fill == clbytes) {
649 *a_bss_fill = 0;
650 }
651 } else {
652 *a_bss_fill = clbytes -
653 ((ex.a_text+ex.a_data+ex.a_bss) & clofset);
654 if (*a_text_fill == clbytes) {
655 *a_text_fill = 0;
656 }
657 }
658 }
659
660 /*###665 [cc] `aout' undeclared (first use this function)%%%*/
661 if (aout != NULL) {
662 *aout = mid;
663 }
664
665 return(0);
666 #endif NOAOUT
667 }
668
669 /*###673 [cc] syntax error before `int'%%%*/
670 int
671 GetFileInfo(fd, load, xfr, aout,
672 a_text, a_text_fill, a_data, a_data_fill, a_bss, a_bss_fill)
673 int fd, *aout;
674 u_long *load, *xfr, *a_text, *a_text_fill;
675 u_long *a_data, *a_data_fill, *a_bss, *a_bss_fill;
676 {
677 int err;
678
679 err = CheckAOutFile(fd);
680
681 if (err == 0) {
682 err = GetAOutFileInfo(fd, load, xfr,
683 a_text, a_text_fill,
684 a_data, a_data_fill,
685 a_bss, a_bss_fill,
686 aout);
687 if (err != 0) {
688 return(-1);
689 }
690 } else {
691 err = CheckMopFile(fd);
692
693 if (err == 0) {
694 err = GetMopFileInfo(fd, load, xfr);
695 if (err != 0) {
696 return(-1);
697 }
698 *aout = -1;
699 } else {
700 return(-1);
701 }
702 }
703
704 return(0);
705 }
706
707 ssize_t
708 /*###711 [cc] syntax error before `mopFileRead'%%%*/
709 mopFileRead(dlslot, buf)
710 struct dllist *dlslot;
711 u_char *buf;
712 {
713 ssize_t len, outlen;
714 int bsz;
715 long pos, notdone, total;
716
717 /*###719 [cc] `dlslot' undeclared (first use this function)%%%*/
718 if (dlslot->aout == -1) {
719 /*###720 [cc] `buf' undeclared (first use this function)%%%*/
720 len = read(dlslot->ldfd,buf,dlslot->dl_bsz);
721 } else {
722 bsz = dlslot->dl_bsz;
723 pos = dlslot->a_lseek;
724 len = 0;
725
726 total = dlslot->a_text;
727
728 if (pos < total) {
729 notdone = total - pos;
730 if (notdone <= bsz) {
731 /*###731 [cc] subscripted value is neither array nor pointer%%%*/
732 outlen = read(dlslot->ldfd,&buf[len],notdone);
733 } else {
734 /*###733 [cc] subscripted value is neither array nor pointer%%%*/
735 outlen = read(dlslot->ldfd,&buf[len],bsz);
736 }
737 len = len + outlen;
738 pos = pos + outlen;
739 bsz = bsz - outlen;
740 }
741
742 total = total + dlslot->a_text_fill;
743
744 if ((bsz > 0) && (pos < total)) {
745 notdone = total - pos;
746 if (notdone <= bsz) {
747 outlen = notdone;
748 } else {
749 outlen = bsz;
750 }
751 /*###749 [cc] subscripted value is neither array nor pointer%%%*/
752 bzero(&buf[len],outlen);
753 len = len + outlen;
754 pos = pos + outlen;
755 bsz = bsz - outlen;
756 }
757
758 total = total + dlslot->a_data;
759
760 if ((bsz > 0) && (pos < total)) {
761 notdone = total - pos;
762 if (notdone <= bsz) {
763 /*###760 [cc] subscripted value is neither array nor pointer%%%*/
764 outlen = read(dlslot->ldfd,&buf[len],notdone);
765 } else {
766 /*###762 [cc] subscripted value is neither array nor pointer%%%*/
767 outlen = read(dlslot->ldfd,&buf[len],bsz);
768 }
769 len = len + outlen;
770 pos = pos + outlen;
771 bsz = bsz - outlen;
772 }
773
774 total = total + dlslot->a_data_fill;
775
776 if ((bsz > 0) && (pos < total)) {
777 notdone = total - pos;
778 if (notdone <= bsz) {
779 outlen = notdone;
780 } else {
781 outlen = bsz;
782 }
783 /*###778 [cc] subscripted value is neither array nor pointer%%%*/
784 bzero(&buf[len],outlen);
785 len = len + outlen;
786 pos = pos + outlen;
787 bsz = bsz - outlen;
788 }
789
790 total = total + dlslot->a_bss;
791
792 if ((bsz > 0) && (pos < total)) {
793 notdone = total - pos;
794 if (notdone <= bsz) {
795 outlen = notdone;
796 } else {
797 outlen = bsz;
798 }
799 /*###793 [cc] subscripted value is neither array nor pointer%%%*/
800 bzero(&buf[len],outlen);
801 len = len + outlen;
802 pos = pos + outlen;
803 bsz = bsz - outlen;
804 }
805
806 total = total + dlslot->a_bss_fill;
807
808 if ((bsz > 0) && (pos < total)) {
809 notdone = total - pos;
810 if (notdone <= bsz) {
811 outlen = notdone;
812 } else {
813 outlen = bsz;
814 }
815 /*###808 [cc] subscripted value is neither array nor pointer%%%*/
816 bzero(&buf[len],outlen);
817 len = len + outlen;
818 pos = pos + outlen;
819 bsz = bsz - outlen;
820 }
821
822 dlslot->a_lseek = pos;
823
824 }
825
826 return(len);
827 }
828 /*###820 [cc] syntax error at end of input%%%*/
829