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".
11 * Parts of the output file.
29 #define NPARTS (PARTDBUG + 1)
31 static long offset
[MAXSECT
];
34 static long outseek
[NPARTS
];
38 (outseek[PARTEMIT] = offset[i])
39 #define BEGINSEEK(p, o) \
49 register long l
= outseek
[p
];
54 rd_bytes(outfile
, b
, n
);
61 * Open the output file according to the chosen strategy.
68 if ((outfile
= open(f
, 0)) < 0)
70 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
;
109 register struct outhead
*head
;
113 OUTREAD(PARTEMIT
, (char *) head
, (long) SZ_HEAD
);
114 #if BYTE_ORDER == 0x0123
115 if (sizeof(struct outhead
) != SZ_HEAD
)
118 register char *c
= (char *) head
+ (SZ_HEAD
-4);
120 head
->oh_nchar
= get4(c
);
121 c
-= 4; head
->oh_nemit
= get4(c
);
122 c
-= 2; head
->oh_nname
= uget2(c
);
123 c
-= 2; head
->oh_nrelo
= uget2(c
);
124 c
-= 2; head
->oh_nsect
= uget2(c
);
125 c
-= 2; head
->oh_flags
= uget2(c
);
126 c
-= 2; head
->oh_stamp
= uget2(c
);
127 c
-= 2; head
->oh_magic
= uget2(c
);
129 off
= OFF_RELO(*head
) + rd_base
;
130 BEGINSEEK(PARTRELO
, off
);
131 off
+= (long) head
->oh_nrelo
* SZ_RELO
;
132 BEGINSEEK(PARTNAME
, off
);
133 off
+= (long) head
->oh_nname
* SZ_NAME
;
134 BEGINSEEK(PARTCHAR
, off
);
136 off
+= head
->oh_nchar
;
137 BEGINSEEK(PARTDBUG
, off
);
143 register struct outhead
*head
;
145 register long off
= OFF_RELO(*head
) + rd_base
;
147 BEGINSEEK(PARTRELO
, off
);
152 register struct outsect
*sect
;
153 register unsigned int cnt
;
155 register char *c
= (char *) sect
+ cnt
* SZ_SECT
;
157 OUTREAD(PARTEMIT
, (char *) sect
, (long)cnt
* SZ_SECT
);
162 #if BYTE_ORDER == 0x0123
163 if (sizeof(struct outsect
) != SZ_SECT
)
166 c
-= 4; sect
->os_lign
= get4(c
);
167 c
-= 4; sect
->os_flen
= get4(c
);
168 c
-= 4; sect
->os_foff
= get4(c
);
169 c
-= 4; sect
->os_size
= get4(c
);
170 c
-= 4; sect
->os_base
= get4(c
);
172 offset
[--offcnt
] = sect
->os_foff
+ rd_base
;
184 * We don't have to worry about byte order here.
191 OUTREAD(PARTEMIT
, emit
, cnt
);
192 offset
[sectionnr
] += cnt
;
197 register struct outrelo
*relo
;
198 register unsigned int cnt
;
201 OUTREAD(PARTRELO
, (char *) relo
, (long) cnt
* SZ_RELO
);
202 #if BYTE_ORDER == 0x0123
203 if (sizeof(struct outrelo
) != SZ_RELO
)
206 register char *c
= (char *) relo
+ (long) cnt
* SZ_RELO
;
211 c
-= 4; relo
->or_addr
= get4(c
);
212 c
-= 2; relo
->or_nami
= uget2(c
);
213 relo
->or_sect
= *--c
;
214 relo
->or_type
= *--c
;
221 register struct outname
*name
;
222 register unsigned int cnt
;
225 OUTREAD(PARTNAME
, (char *) name
, (long) cnt
* SZ_NAME
);
226 #if BYTE_ORDER == 0x0123
227 if (sizeof(struct outname
) != SZ_NAME
)
230 register char *c
= (char *) name
+ (long) cnt
* SZ_NAME
;
235 c
-= 4; name
->on_valu
= get4(c
);
236 c
-= 2; name
->on_desc
= uget2(c
);
237 c
-= 2; name
->on_type
= uget2(c
);
238 c
-= 4; name
->on_foff
= get4(c
);
249 OUTREAD(PARTCHAR
, addr
, len
);
258 OUTREAD(PARTDBUG
, buf
, size
);