1
1
/* BFD back-end for Intel 386 COFF files (DJGPP variant with a stub).
2
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2006, 2007
2
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2005, 2006, 2007, 2009
3
3
Free Software Foundation, Inc.
4
4
Written by Robert Hoehne.
134
131
adjust_filehdr_in_post (abfd, src, dst)
132
bfd *abfd ATTRIBUTE_UNUSED;
139
136
FILHDR *filehdr_src = (FILHDR *) src;
140
137
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
142
ADJUST_VAL (filehdr_dst->f_symptr, STUBSIZE);
144
/* Save now the stub to be used later. */
145
bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
147
/* Since this function returns no status, I do not set here
149
That means, before the use of bfd_coff_go32stub (), this value
150
should be checked if it is != NULL. */
151
if (bfd_coff_go32stub (abfd) == NULL)
153
memcpy (bfd_coff_go32stub (abfd), filehdr_src->stub, STUBSIZE);
139
ADJUST_VAL (filehdr_dst->f_symptr, GO32_STUBSIZE);
141
/* Save now the stub to be used later. Put the stub data to FILEHDR_DST
142
first as coff_data (abfd) still does not exist. It may not even be ever
143
created as we are just checking the file format of ABFD. */
144
memcpy (filehdr_dst->go32stub, filehdr_src->stub, GO32_STUBSIZE);
145
filehdr_dst->f_flags |= F_GO32STUB;
166
158
create_go32_stub (abfd);
168
160
/* Copy the stub to the file header. */
169
if (bfd_coff_go32stub (abfd) != NULL)
170
memcpy (filehdr_out->stub, bfd_coff_go32stub (abfd), STUBSIZE);
161
if (coff_data (abfd)->go32stub != NULL)
162
memcpy (filehdr_out->stub, coff_data (abfd)->go32stub, GO32_STUBSIZE);
172
164
/* Use the default. */
173
memcpy (filehdr_out->stub, stub_bytes, STUBSIZE);
165
memcpy (filehdr_out->stub, stub_bytes, GO32_STUBSIZE);
175
ADJUST_VAL (filehdr_in->f_symptr, -STUBSIZE);
167
ADJUST_VAL (filehdr_in->f_symptr, -GO32_STUBSIZE);
221
213
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
223
ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
224
ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
225
ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
215
ADJUST_VAL (scnhdr_int->s_scnptr, GO32_STUBSIZE);
216
ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE);
217
ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_STUBSIZE);
229
adjust_aux_in_post (abfd, ext1, type, class, indx, numaux, in1)
221
adjust_aux_in_post (abfd, ext1, type, in_class, indx, numaux, in1)
230
222
bfd *abfd ATTRIBUTE_UNUSED;
231
223
PTR ext1 ATTRIBUTE_UNUSED;
234
226
int indx ATTRIBUTE_UNUSED;
235
227
int numaux ATTRIBUTE_UNUSED;
238
230
union internal_auxent *in = (union internal_auxent *) in1;
240
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
242
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
247
adjust_aux_out_pre (abfd, inp, type, class, indx, numaux, extp)
248
bfd *abfd ATTRIBUTE_UNUSED;
252
int indx ATTRIBUTE_UNUSED;
253
int numaux ATTRIBUTE_UNUSED;
254
PTR extp ATTRIBUTE_UNUSED;
256
union internal_auxent *in = (union internal_auxent *) inp;
258
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
260
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -STUBSIZE);
265
adjust_aux_out_post (abfd, inp, type, class, indx, numaux, extp)
266
bfd *abfd ATTRIBUTE_UNUSED;
270
int indx ATTRIBUTE_UNUSED;
271
int numaux ATTRIBUTE_UNUSED;
272
PTR extp ATTRIBUTE_UNUSED;
274
union internal_auxent *in = (union internal_auxent *) inp;
276
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
278
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
232
if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
235
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE);
240
adjust_aux_out_pre (abfd, inp, type, in_class, indx, numaux, extp)
241
bfd *abfd ATTRIBUTE_UNUSED;
245
int indx ATTRIBUTE_UNUSED;
246
int numaux ATTRIBUTE_UNUSED;
247
PTR extp ATTRIBUTE_UNUSED;
249
union internal_auxent *in = (union internal_auxent *) inp;
251
if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
254
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -GO32_STUBSIZE);
259
adjust_aux_out_post (abfd, inp, type, in_class, indx, numaux, extp)
260
bfd *abfd ATTRIBUTE_UNUSED;
264
int indx ATTRIBUTE_UNUSED;
265
int numaux ATTRIBUTE_UNUSED;
266
PTR extp ATTRIBUTE_UNUSED;
268
union internal_auxent *in = (union internal_auxent *) inp;
270
if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
273
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE);
364
359
/* Now we found a correct stub (hopefully). */
365
bfd_coff_go32stub (abfd)
366
= (PTR) bfd_alloc (abfd, (bfd_size_type) coff_start);
367
if (bfd_coff_go32stub (abfd) == NULL)
360
coff_data (abfd)->go32stub = bfd_alloc (abfd, (bfd_size_type) coff_start);
361
if (coff_data (abfd)->go32stub == NULL)
372
366
lseek (f, 0L, SEEK_SET);
373
if ((unsigned long) read (f, bfd_coff_go32stub (abfd), coff_start)
367
if ((unsigned long) read (f, coff_data (abfd)->go32stub, coff_start)
376
bfd_release (abfd, bfd_coff_go32stub (abfd));
377
bfd_coff_go32stub (abfd) = NULL;
370
bfd_release (abfd, coff_data (abfd)->go32stub);
371
coff_data (abfd)->go32stub = NULL;
382
376
/* There was something wrong above, so use now the standard builtin
384
if (bfd_coff_go32stub (abfd) == NULL)
378
if (coff_data (abfd)->go32stub == NULL)
386
bfd_coff_go32stub (abfd)
387
= (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
388
if (bfd_coff_go32stub (abfd) == NULL)
380
coff_data (abfd)->go32stub
381
= bfd_alloc (abfd, (bfd_size_type) GO32_STUBSIZE);
382
if (coff_data (abfd)->go32stub == NULL)
390
memcpy (bfd_coff_go32stub (abfd), stub_bytes, STUBSIZE);
384
memcpy (coff_data (abfd)->go32stub, stub_bytes, GO32_STUBSIZE);
403
397
if (ibfd->xvec != obfd->xvec)
406
/* Check if both have a valid stub. */
407
if (bfd_coff_go32stub (ibfd) == NULL
408
|| bfd_coff_go32stub (obfd) == NULL)
400
/* Check if we have a source stub. */
401
if (coff_data (ibfd)->go32stub == NULL)
404
/* As adjust_filehdr_out_pre may get called only after this function,
405
optionally allocate the output stub. */
406
if (coff_data (obfd)->go32stub == NULL)
407
coff_data (obfd)->go32stub = bfd_alloc (obfd,
408
(bfd_size_type) GO32_STUBSIZE);
411
410
/* Now copy the stub. */
412
memcpy (bfd_coff_go32stub (obfd), bfd_coff_go32stub (ibfd), STUBSIZE);
411
if (coff_data (obfd)->go32stub != NULL)
412
memcpy (coff_data (obfd)->go32stub, coff_data (ibfd)->go32stub,