3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
12 * Parts of the output file.
30 #define NPARTS (PARTDBUG + 1)
32 static long offset
[MAXSECT
];
35 static long outseek
[NPARTS
];
39 (outseek[PARTEMIT] = offset[i])
40 #define BEGINSEEK(p, o) \
50 register long l
= outseek
[p
];
55 rd_bytes(outfile
, b
, n
);
62 * Open the output file according to the chosen strategy.
69 if ((outfile
= open(f
, 0)) < 0)
71 return rd_fdopen(outfile
);
80 for (i
= 0; i
< NPARTS
; i
++) outseek
[i
] = 0;
82 rd_base
= lseek(fd
, 0L, 1);
87 outseek
[PARTEMIT
] = currpos
;
106 register struct outhead
*head
;
110 OUTREAD(PARTEMIT
, (char *) head
, (long) SZ_HEAD
);
111 #if ! (BYTES_REVERSED || WORDS_REVERSED)
112 if (sizeof(struct outhead
) != SZ_HEAD
)
115 register char *c
= (char *) head
+ (SZ_HEAD
-4);
117 head
->oh_nchar
= get4(c
);
118 c
-= 4; head
->oh_nemit
= get4(c
);
119 c
-= 2; head
->oh_nname
= uget2(c
);
120 c
-= 2; head
->oh_nrelo
= uget2(c
);
121 c
-= 2; head
->oh_nsect
= uget2(c
);
122 c
-= 2; head
->oh_flags
= uget2(c
);
123 c
-= 2; head
->oh_stamp
= uget2(c
);
124 c
-= 2; head
->oh_magic
= uget2(c
);
126 off
= OFF_RELO(*head
) + rd_base
;
127 BEGINSEEK(PARTRELO
, off
);
128 off
+= (long) head
->oh_nrelo
* SZ_RELO
;
129 BEGINSEEK(PARTNAME
, off
);
130 off
+= (long) head
->oh_nname
* SZ_NAME
;
131 BEGINSEEK(PARTCHAR
, off
);
133 off
+= head
->oh_nchar
;
134 BEGINSEEK(PARTDBUG
, off
);
139 register struct outhead
*head
;
141 register long off
= OFF_RELO(*head
) + rd_base
;
143 BEGINSEEK(PARTRELO
, off
);
147 register struct outsect
*sect
;
148 register unsigned int cnt
;
150 register char *c
= (char *) sect
+ cnt
* SZ_SECT
;
152 OUTREAD(PARTEMIT
, (char *) sect
, (long)cnt
* SZ_SECT
);
157 #if ! (BYTES_REVERSED || WORDS_REVERSED)
158 if (sizeof(struct outsect
) != SZ_SECT
)
161 c
-= 4; sect
->os_lign
= get4(c
);
162 c
-= 4; sect
->os_flen
= get4(c
);
163 c
-= 4; sect
->os_foff
= get4(c
);
165 offset
[--offcnt
] = sect
->os_foff
+ rd_base
;
166 #if ! (BYTES_REVERSED || WORDS_REVERSED)
167 if (sizeof(struct outsect
) != SZ_SECT
)
170 c
-= 4; sect
->os_size
= get4(c
);
171 c
-= 4; sect
->os_base
= get4(c
);
183 * We don't have to worry about byte order here.
189 OUTREAD(PARTEMIT
, emit
, cnt
);
190 offset
[sectionnr
] += cnt
;
194 register struct outrelo
*relo
;
195 register unsigned int cnt
;
198 OUTREAD(PARTRELO
, (char *) relo
, (long) cnt
* SZ_RELO
);
199 #if ! (BYTES_REVERSED || WORDS_REVERSED)
200 if (sizeof(struct outrelo
) != SZ_RELO
)
203 register char *c
= (char *) relo
+ (long) cnt
* SZ_RELO
;
208 c
-= 4; relo
->or_addr
= get4(c
);
209 c
-= 2; relo
->or_nami
= uget2(c
);
210 relo
->or_sect
= *--c
;
211 relo
->or_type
= *--c
;
217 register struct outname
*name
;
218 register unsigned int cnt
;
221 OUTREAD(PARTNAME
, (char *) name
, (long) cnt
* SZ_NAME
);
222 #if ! (BYTES_REVERSED || WORDS_REVERSED)
223 if (sizeof(struct outname
) != SZ_NAME
)
226 register char *c
= (char *) name
+ (long) cnt
* SZ_NAME
;
231 c
-= 4; name
->on_valu
= get4(c
);
232 c
-= 2; name
->on_desc
= uget2(c
);
233 c
-= 2; name
->on_type
= uget2(c
);
234 c
-= 4; name
->on_foff
= get4(c
);
244 OUTREAD(PARTCHAR
, addr
, len
);
252 OUTREAD(PARTDBUG
, buf
, size
);