-/*
- 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 GO32_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 ATTRIBUTE_UNUSED;
- PTR src;
- PTR dst;
-{
- FILHDR *filehdr_src = (FILHDR *) src;
- struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
-
- ADJUST_VAL (filehdr_dst->f_symptr, GO32_STUBSIZE);
-
- /* Save now the stub to be used later. Put the stub data to FILEHDR_DST
- first as coff_data (abfd) still does not exist. It may not even be ever
- created as we are just checking the file format of ABFD. */
- memcpy (filehdr_dst->go32stub, filehdr_src->stub, GO32_STUBSIZE);
- filehdr_dst->f_flags |= F_GO32STUB;
-}
-
-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 (coff_data (abfd)->go32stub != NULL)
- memcpy (filehdr_out->stub, coff_data (abfd)->go32stub, GO32_STUBSIZE);
- else
- /* Use the default. */
- memcpy (filehdr_out->stub, stub_bytes, GO32_STUBSIZE);
-
- ADJUST_VAL (filehdr_in->f_symptr, -GO32_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, GO32_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, GO32_STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_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, -GO32_STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_relptr, -GO32_STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_lnnoptr, -GO32_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, GO32_STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE);
- ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_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, GO32_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, -GO32_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;
-
- if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
- {
- ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE);
- }
-}