-/*
- I have not commented each swap function below, because the
- technique is in any function the same. For the ...in function,
- all the pointers are adjusted by adding STUBSIZE and for the
- ...out function, it is subtracted first and after calling the
- standard swap function it is reset to the old value */
-
-/* This macro is used for adjusting the filepointers, which
- is done only, if the pointer is nonzero */
-
-#define ADJUST_VAL(val,diff) \
- if (val != 0) val += diff
-
-static void
-adjust_filehdr_in_post (abfd, src, dst)
- bfd *abfd;
- PTR src;
- PTR dst;
-{
- FILHDR *filehdr_src = (FILHDR *) src;
- struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
-
- ADJUST_VAL (filehdr_dst->f_symptr, STUBSIZE);
-
- /* Save now the stub to be used later */
- bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, STUBSIZE);
-
- /* Since this function returns no status, I do not set here
- any bfd_error_...
- That means, before the use of bfd_coff_go32stub (), this value
- should be checked if it is != NULL */
- if (bfd_coff_go32stub (abfd) == NULL)
- return;
- memcpy (bfd_coff_go32stub (abfd), filehdr_src->stub, STUBSIZE);
-}
-
-static void
-adjust_filehdr_out_pre (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
-{
- struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
- FILHDR *filehdr_out = (FILHDR *) out;
-
- /* Generate the stub */
- create_go32_stub (abfd);
-
- /* Copy the stub to the file header */
- if (bfd_coff_go32stub (abfd) != NULL)
- memcpy (filehdr_out->stub, bfd_coff_go32stub (abfd), STUBSIZE);
- else
- /* use the default */
- memcpy (filehdr_out->stub, stub_bytes, STUBSIZE);
-
- ADJUST_VAL (filehdr_in->f_symptr, -STUBSIZE);
-}
-
-static void
-adjust_filehdr_out_post (abfd, in, out)
- bfd *abfd ATTRIBUTE_UNUSED;
- PTR in;
- PTR out ATTRIBUTE_UNUSED;
-{
- struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
- /* undo the above change */
- ADJUST_VAL (filehdr_in->f_symptr, STUBSIZE);
-}
-
-static void
-adjust_scnhdr_in_post (abfd, ext, in)
- bfd *abfd ATTRIBUTE_UNUSED;
- PTR ext ATTRIBUTE_UNUSED;
- PTR in;
-{
- struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
-
- ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
-}
-
-static void
-adjust_scnhdr_out_pre (abfd, in, out)
- bfd *abfd ATTRIBUTE_UNUSED;
- PTR in;
- PTR out ATTRIBUTE_UNUSED;
-{
- struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
-
- ADJUST_VAL (scnhdr_int->s_scnptr, -STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_relptr, -STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_lnnoptr, -STUBSIZE);
-}
-
-static void
-adjust_scnhdr_out_post (abfd, in, out)
- bfd *abfd ATTRIBUTE_UNUSED;
- PTR in;
- PTR out ATTRIBUTE_UNUSED;
-{
- struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
-
- ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
-}
-
-static void
-adjust_aux_in_post (abfd, ext1, type, class, indx, numaux, in1)
- bfd *abfd ATTRIBUTE_UNUSED;
- PTR ext1 ATTRIBUTE_UNUSED;
- int type;
- int class;
- int indx ATTRIBUTE_UNUSED;
- int numaux ATTRIBUTE_UNUSED;
- PTR in1;
-{
- union internal_auxent *in = (union internal_auxent *) in1;
-
- if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
- {
- ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
- }
-}
-
-static void
-adjust_aux_out_pre (abfd, inp, type, class, indx, numaux, extp)
- bfd *abfd ATTRIBUTE_UNUSED;
- PTR inp;
- int type;
- int class;
- int indx ATTRIBUTE_UNUSED;
- int numaux ATTRIBUTE_UNUSED;
- PTR extp ATTRIBUTE_UNUSED;
-{
- union internal_auxent *in = (union internal_auxent *) inp;
-
- if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
- {
- ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -STUBSIZE);
- }
-}
-
-static void
-adjust_aux_out_post (abfd, inp, type, class, indx, numaux, extp)
- bfd *abfd ATTRIBUTE_UNUSED;
- PTR inp;
- int type;
- int class;
- int indx ATTRIBUTE_UNUSED;
- int numaux ATTRIBUTE_UNUSED;
- PTR extp ATTRIBUTE_UNUSED;
-{
- union internal_auxent *in = (union internal_auxent *) inp;