-/*
- 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 (bfd * abfd ATTRIBUTE_UNUSED,
- void * src,
- void * 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 (bfd * abfd, void * in, void * 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 (bfd * abfd ATTRIBUTE_UNUSED,
- void * in,
- void * 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 (bfd * abfd ATTRIBUTE_UNUSED,
- void * ext ATTRIBUTE_UNUSED,
- void * 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 (bfd * abfd ATTRIBUTE_UNUSED,
- void * in,
- void * 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 (bfd * abfd ATTRIBUTE_UNUSED,
- void * in,
- void * 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 (bfd * abfd ATTRIBUTE_UNUSED,
- void * ext1 ATTRIBUTE_UNUSED,
- int type,
- int in_class,
- int indx ATTRIBUTE_UNUSED,
- int numaux ATTRIBUTE_UNUSED,
- void * in1)
-{
- union internal_auxent *in = (union internal_auxent *) in1;
-
- if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
- || ISTAG (in_class))
- {
- ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE);
- }
-}
-
-static void
-adjust_aux_out_pre (bfd *abfd ATTRIBUTE_UNUSED,
- void * inp,
- int type,
- int in_class,
- int indx ATTRIBUTE_UNUSED,
- int numaux ATTRIBUTE_UNUSED,
- void * extp ATTRIBUTE_UNUSED)
-{
- union internal_auxent *in = (union internal_auxent *) inp;
-
- if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
- || ISTAG (in_class))
- {
- ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -GO32_STUBSIZE);
- }
-}
-
-static void
-adjust_aux_out_post (bfd *abfd ATTRIBUTE_UNUSED,
- void * inp,
- int type,
- int in_class,
- int indx ATTRIBUTE_UNUSED,
- int numaux ATTRIBUTE_UNUSED,
- void * extp ATTRIBUTE_UNUSED)
-{
- union internal_auxent *in = (union internal_auxent *) inp;
-
- if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
- || ISTAG (in_class))
- {
- ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE);
- }
-}