Home | History | Annotate | Line # | Download | only in bfd
      1       1.1  christos /* Generic ECOFF swapping routines, for BFD.
      2  1.1.1.10  christos    Copyright (C) 1992-2025 Free Software Foundation, Inc.
      3       1.1  christos    Written by Cygnus Support.
      4       1.1  christos 
      5       1.1  christos    This file is part of BFD, the Binary File Descriptor library.
      6       1.1  christos 
      7       1.1  christos    This program is free software; you can redistribute it and/or modify
      8       1.1  christos    it under the terms of the GNU General Public License as published by
      9       1.1  christos    the Free Software Foundation; either version 3 of the License, or
     10       1.1  christos    (at your option) any later version.
     11       1.1  christos 
     12       1.1  christos    This program is distributed in the hope that it will be useful,
     13       1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14       1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15       1.1  christos    GNU General Public License for more details.
     16       1.1  christos 
     17       1.1  christos    You should have received a copy of the GNU General Public License
     18       1.1  christos    along with this program; if not, write to the Free Software
     19       1.1  christos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     20       1.1  christos    MA 02110-1301, USA.  */
     21       1.1  christos 
     22       1.1  christos 
     23       1.1  christos /* NOTE: This is a header file, but it contains executable routines.
     24       1.1  christos    This is done this way because these routines are substantially
     25       1.1  christos    similar, but are not identical, for all ECOFF targets.
     26       1.1  christos 
     27       1.1  christos    These are routines to swap the ECOFF symbolic information in and
     28       1.1  christos    out.  The routines are defined statically.  You can set breakpoints
     29       1.1  christos    on them in gdb by naming the including source file; e.g.,
     30       1.1  christos    'coff-mips.c':ecoff_swap_hdr_in.
     31       1.1  christos 
     32       1.1  christos    Before including this header file, one of ECOFF_32, ECOFF_64,
     33       1.1  christos    ECOFF_SIGNED_32 or ECOFF_SIGNED_64 must be defined.  These are
     34       1.1  christos    checked when swapping information that depends upon the target
     35       1.1  christos    size.  This code works for 32 bit and 64 bit ECOFF, but may need to
     36       1.1  christos    be generalized in the future.
     37       1.1  christos 
     38       1.1  christos    Some header file which defines the external forms of these
     39       1.1  christos    structures must also be included before including this header file.
     40       1.1  christos    Currently this is either coff/mips.h or coff/alpha.h.
     41       1.1  christos 
     42       1.1  christos    If the symbol TEST is defined when this file is compiled, a
     43       1.1  christos    comparison is made to ensure that, in fact, the output is
     44       1.1  christos    bit-for-bit the same as the input.  Of course, this symbol should
     45       1.1  christos    only be defined when deliberately testing the code on a machine
     46       1.1  christos    with the proper byte sex and such.  */
     47       1.1  christos 
     48       1.1  christos #ifdef ECOFF_32
     49       1.1  christos #define ECOFF_GET_OFF H_GET_32
     50       1.1  christos #define ECOFF_PUT_OFF H_PUT_32
     51       1.1  christos #endif
     52       1.1  christos #ifdef ECOFF_64
     53       1.1  christos #define ECOFF_GET_OFF H_GET_64
     54       1.1  christos #define ECOFF_PUT_OFF H_PUT_64
     55       1.1  christos #endif
     56       1.1  christos #ifdef ECOFF_SIGNED_32
     57       1.1  christos #define ECOFF_GET_OFF H_GET_S32
     58       1.1  christos #define ECOFF_PUT_OFF H_PUT_S32
     59       1.1  christos #endif
     60       1.1  christos #ifdef ECOFF_SIGNED_64
     61       1.1  christos #define ECOFF_GET_OFF H_GET_S64
     62       1.1  christos #define ECOFF_PUT_OFF H_PUT_S64
     63       1.1  christos #endif
     64       1.1  christos 
     65       1.1  christos /* ECOFF auxiliary information swapping routines.  These are the same
     66       1.1  christos    for all ECOFF targets, so they are defined in ecofflink.c.  */
     67       1.1  christos 
     68       1.1  christos extern void _bfd_ecoff_swap_tir_in
     69       1.1  christos   (int, const struct tir_ext *, TIR *);
     70       1.1  christos extern void _bfd_ecoff_swap_tir_out
     71       1.1  christos   (int, const TIR *, struct tir_ext *);
     72       1.1  christos extern void _bfd_ecoff_swap_rndx_in
     73       1.1  christos   (int, const struct rndx_ext *, RNDXR *);
     74       1.1  christos extern void _bfd_ecoff_swap_rndx_out
     75       1.1  christos   (int, const RNDXR *, struct rndx_ext *);
     76       1.1  christos 
     77       1.1  christos /* Prototypes for functions defined in this file.  */
     78       1.1  christos 
     79       1.1  christos static void ecoff_swap_hdr_in (bfd *, void *, HDRR *);
     80       1.1  christos static void ecoff_swap_hdr_out (bfd *, const HDRR *, void *);
     81       1.1  christos static void ecoff_swap_fdr_in (bfd *, void *, FDR *);
     82       1.1  christos static void ecoff_swap_fdr_out (bfd *, const FDR *, void *);
     83       1.1  christos static void ecoff_swap_pdr_in (bfd *, void *, PDR *);
     84       1.1  christos static void ecoff_swap_pdr_out (bfd *, const PDR *, void *);
     85       1.1  christos static void ecoff_swap_sym_in (bfd *, void *, SYMR *);
     86       1.1  christos static void ecoff_swap_sym_out (bfd *, const SYMR *, void *);
     87       1.1  christos static void ecoff_swap_ext_in (bfd *, void *, EXTR *);
     88       1.1  christos static void ecoff_swap_ext_out (bfd *, const EXTR *, void *);
     89       1.1  christos static void ecoff_swap_rfd_in (bfd *, void *, RFDT *);
     90       1.1  christos static void ecoff_swap_rfd_out (bfd *, const RFDT *, void *);
     91       1.1  christos static void ecoff_swap_opt_in (bfd *, void *, OPTR *);
     92       1.1  christos static void ecoff_swap_opt_out (bfd *, const OPTR *, void *);
     93       1.1  christos static void ecoff_swap_dnr_in (bfd *, void *, DNR *);
     94       1.1  christos static void ecoff_swap_dnr_out (bfd *, const DNR *, void *);
     95       1.1  christos 
     96       1.1  christos /* Swap in the symbolic header.  */
     97       1.1  christos 
     98       1.1  christos static void
     99       1.1  christos ecoff_swap_hdr_in (bfd *abfd, void * ext_copy, HDRR *intern)
    100       1.1  christos {
    101       1.1  christos   struct hdr_ext ext[1];
    102       1.1  christos 
    103       1.1  christos   *ext = *(struct hdr_ext *) ext_copy;
    104       1.1  christos 
    105   1.1.1.6  christos   intern->magic		= H_GET_S16	(abfd, ext->h_magic);
    106   1.1.1.6  christos   intern->vstamp	= H_GET_S16	(abfd, ext->h_vstamp);
    107   1.1.1.6  christos   intern->ilineMax	= H_GET_32	(abfd, ext->h_ilineMax);
    108   1.1.1.6  christos   intern->cbLine	= ECOFF_GET_OFF (abfd, ext->h_cbLine);
    109   1.1.1.6  christos   intern->cbLineOffset	= ECOFF_GET_OFF (abfd, ext->h_cbLineOffset);
    110   1.1.1.6  christos   intern->idnMax	= H_GET_32	(abfd, ext->h_idnMax);
    111   1.1.1.6  christos   intern->cbDnOffset	= ECOFF_GET_OFF (abfd, ext->h_cbDnOffset);
    112   1.1.1.6  christos   intern->ipdMax	= H_GET_32	(abfd, ext->h_ipdMax);
    113   1.1.1.6  christos   intern->cbPdOffset	= ECOFF_GET_OFF (abfd, ext->h_cbPdOffset);
    114   1.1.1.6  christos   intern->isymMax	= H_GET_32	(abfd, ext->h_isymMax);
    115   1.1.1.6  christos   intern->cbSymOffset	= ECOFF_GET_OFF (abfd, ext->h_cbSymOffset);
    116   1.1.1.6  christos   intern->ioptMax	= H_GET_32	(abfd, ext->h_ioptMax);
    117   1.1.1.6  christos   intern->cbOptOffset	= ECOFF_GET_OFF (abfd, ext->h_cbOptOffset);
    118   1.1.1.6  christos   intern->iauxMax	= H_GET_32	(abfd, ext->h_iauxMax);
    119   1.1.1.6  christos   intern->cbAuxOffset	= ECOFF_GET_OFF (abfd, ext->h_cbAuxOffset);
    120   1.1.1.6  christos   intern->issMax	= H_GET_32	(abfd, ext->h_issMax);
    121   1.1.1.6  christos   intern->cbSsOffset	= ECOFF_GET_OFF (abfd, ext->h_cbSsOffset);
    122   1.1.1.6  christos   intern->issExtMax	= H_GET_32	(abfd, ext->h_issExtMax);
    123       1.1  christos   intern->cbSsExtOffset = ECOFF_GET_OFF (abfd, ext->h_cbSsExtOffset);
    124   1.1.1.6  christos   intern->ifdMax	= H_GET_32	(abfd, ext->h_ifdMax);
    125   1.1.1.6  christos   intern->cbFdOffset	= ECOFF_GET_OFF (abfd, ext->h_cbFdOffset);
    126   1.1.1.6  christos   intern->crfd		= H_GET_32	(abfd, ext->h_crfd);
    127   1.1.1.6  christos   intern->cbRfdOffset	= ECOFF_GET_OFF (abfd, ext->h_cbRfdOffset);
    128   1.1.1.6  christos   intern->iextMax	= H_GET_32	(abfd, ext->h_iextMax);
    129   1.1.1.6  christos   intern->cbExtOffset	= ECOFF_GET_OFF (abfd, ext->h_cbExtOffset);
    130       1.1  christos 
    131       1.1  christos #ifdef TEST
    132       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    133       1.1  christos     abort ();
    134       1.1  christos #endif
    135       1.1  christos }
    136       1.1  christos 
    137       1.1  christos /* Swap out the symbolic header.  */
    138       1.1  christos 
    139       1.1  christos static void
    140       1.1  christos ecoff_swap_hdr_out (bfd *abfd, const HDRR *intern_copy, void * ext_ptr)
    141       1.1  christos {
    142       1.1  christos   struct hdr_ext *ext = (struct hdr_ext *) ext_ptr;
    143       1.1  christos   HDRR intern[1];
    144       1.1  christos 
    145       1.1  christos   *intern = *intern_copy;
    146       1.1  christos 
    147   1.1.1.6  christos   H_PUT_S16	(abfd, intern->magic,	      ext->h_magic);
    148   1.1.1.6  christos   H_PUT_S16	(abfd, intern->vstamp,	      ext->h_vstamp);
    149   1.1.1.6  christos   H_PUT_32	(abfd, intern->ilineMax,      ext->h_ilineMax);
    150   1.1.1.6  christos   ECOFF_PUT_OFF (abfd, intern->cbLine,	      ext->h_cbLine);
    151       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbLineOffset,  ext->h_cbLineOffset);
    152   1.1.1.6  christos   H_PUT_32	(abfd, intern->idnMax,	      ext->h_idnMax);
    153       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbDnOffset,    ext->h_cbDnOffset);
    154   1.1.1.6  christos   H_PUT_32	(abfd, intern->ipdMax,	      ext->h_ipdMax);
    155       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbPdOffset,    ext->h_cbPdOffset);
    156   1.1.1.6  christos   H_PUT_32	(abfd, intern->isymMax,	      ext->h_isymMax);
    157       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbSymOffset,   ext->h_cbSymOffset);
    158   1.1.1.6  christos   H_PUT_32	(abfd, intern->ioptMax,	      ext->h_ioptMax);
    159       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbOptOffset,   ext->h_cbOptOffset);
    160   1.1.1.6  christos   H_PUT_32	(abfd, intern->iauxMax,	      ext->h_iauxMax);
    161       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbAuxOffset,   ext->h_cbAuxOffset);
    162   1.1.1.6  christos   H_PUT_32	(abfd, intern->issMax,	      ext->h_issMax);
    163       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbSsOffset,    ext->h_cbSsOffset);
    164   1.1.1.6  christos   H_PUT_32	(abfd, intern->issExtMax,     ext->h_issExtMax);
    165       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbSsExtOffset, ext->h_cbSsExtOffset);
    166   1.1.1.6  christos   H_PUT_32	(abfd, intern->ifdMax,	      ext->h_ifdMax);
    167       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbFdOffset,    ext->h_cbFdOffset);
    168   1.1.1.6  christos   H_PUT_32	(abfd, intern->crfd,	      ext->h_crfd);
    169       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbRfdOffset,   ext->h_cbRfdOffset);
    170   1.1.1.6  christos   H_PUT_32	(abfd, intern->iextMax,	      ext->h_iextMax);
    171       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbExtOffset,   ext->h_cbExtOffset);
    172       1.1  christos 
    173       1.1  christos #ifdef TEST
    174       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    175       1.1  christos     abort ();
    176       1.1  christos #endif
    177       1.1  christos }
    178       1.1  christos 
    179       1.1  christos /* Swap in the file descriptor record.  */
    180       1.1  christos 
    181       1.1  christos static void
    182       1.1  christos ecoff_swap_fdr_in (bfd *abfd, void * ext_copy, FDR *intern)
    183       1.1  christos {
    184       1.1  christos   struct fdr_ext ext[1];
    185       1.1  christos 
    186       1.1  christos   *ext = *(struct fdr_ext *) ext_copy;
    187       1.1  christos 
    188   1.1.1.6  christos   intern->adr		= ECOFF_GET_OFF (abfd, ext->f_adr);
    189   1.1.1.6  christos   intern->rss		= H_GET_32 (abfd, ext->f_rss);
    190       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    191       1.1  christos   if (intern->rss == (signed long) 0xffffffff)
    192       1.1  christos     intern->rss = -1;
    193       1.1  christos #endif
    194   1.1.1.6  christos   intern->issBase	= H_GET_32 (abfd, ext->f_issBase);
    195   1.1.1.6  christos   intern->cbSs		= ECOFF_GET_OFF (abfd, ext->f_cbSs);
    196   1.1.1.6  christos   intern->isymBase	= H_GET_32 (abfd, ext->f_isymBase);
    197   1.1.1.6  christos   intern->csym		= H_GET_32 (abfd, ext->f_csym);
    198   1.1.1.6  christos   intern->ilineBase	= H_GET_32 (abfd, ext->f_ilineBase);
    199   1.1.1.6  christos   intern->cline		= H_GET_32 (abfd, ext->f_cline);
    200   1.1.1.6  christos   intern->ioptBase	= H_GET_32 (abfd, ext->f_ioptBase);
    201   1.1.1.6  christos   intern->copt		= H_GET_32 (abfd, ext->f_copt);
    202       1.1  christos #if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
    203   1.1.1.6  christos   intern->ipdFirst	= H_GET_16 (abfd, ext->f_ipdFirst);
    204   1.1.1.6  christos   intern->cpd		= H_GET_16 (abfd, ext->f_cpd);
    205       1.1  christos #endif
    206       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    207   1.1.1.6  christos   intern->ipdFirst	= H_GET_32 (abfd, ext->f_ipdFirst);
    208   1.1.1.6  christos   intern->cpd		= H_GET_32 (abfd, ext->f_cpd);
    209       1.1  christos #endif
    210   1.1.1.6  christos   intern->iauxBase	= H_GET_32 (abfd, ext->f_iauxBase);
    211   1.1.1.6  christos   intern->caux		= H_GET_32 (abfd, ext->f_caux);
    212   1.1.1.6  christos   intern->rfdBase	= H_GET_32 (abfd, ext->f_rfdBase);
    213   1.1.1.6  christos   intern->crfd		= H_GET_32 (abfd, ext->f_crfd);
    214       1.1  christos 
    215       1.1  christos   /* Now the fun stuff...  */
    216       1.1  christos   if (bfd_header_big_endian (abfd))
    217       1.1  christos     {
    218       1.1  christos       intern->lang       = ((ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
    219       1.1  christos 			    >> FDR_BITS1_LANG_SH_BIG);
    220       1.1  christos       intern->fMerge     = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
    221       1.1  christos       intern->fReadin    = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
    222       1.1  christos       intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
    223       1.1  christos       intern->glevel     = ((ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
    224       1.1  christos 			    >> FDR_BITS2_GLEVEL_SH_BIG);
    225       1.1  christos     }
    226       1.1  christos   else
    227       1.1  christos     {
    228       1.1  christos       intern->lang       = ((ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
    229       1.1  christos 			    >> FDR_BITS1_LANG_SH_LITTLE);
    230       1.1  christos       intern->fMerge     = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
    231       1.1  christos       intern->fReadin    = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
    232       1.1  christos       intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
    233       1.1  christos       intern->glevel     = ((ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
    234       1.1  christos 			    >> FDR_BITS2_GLEVEL_SH_LITTLE);
    235       1.1  christos     }
    236       1.1  christos   intern->reserved = 0;
    237       1.1  christos 
    238   1.1.1.6  christos   intern->cbLineOffset	= ECOFF_GET_OFF (abfd, ext->f_cbLineOffset);
    239   1.1.1.6  christos   intern->cbLine	= ECOFF_GET_OFF (abfd, ext->f_cbLine);
    240       1.1  christos 
    241       1.1  christos #ifdef TEST
    242       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    243       1.1  christos     abort ();
    244       1.1  christos #endif
    245       1.1  christos }
    246       1.1  christos 
    247       1.1  christos /* Swap out the file descriptor record.  */
    248       1.1  christos 
    249       1.1  christos static void
    250       1.1  christos ecoff_swap_fdr_out (bfd *abfd, const FDR *intern_copy, void * ext_ptr)
    251       1.1  christos {
    252       1.1  christos   struct fdr_ext *ext = (struct fdr_ext *) ext_ptr;
    253       1.1  christos   FDR intern[1];
    254       1.1  christos 
    255       1.1  christos   /* Make it reasonable to do in-place.  */
    256       1.1  christos   *intern = *intern_copy;
    257       1.1  christos 
    258       1.1  christos   ECOFF_PUT_OFF (abfd, intern->adr,       ext->f_adr);
    259       1.1  christos   H_PUT_32      (abfd, intern->rss,       ext->f_rss);
    260       1.1  christos   H_PUT_32      (abfd, intern->issBase,   ext->f_issBase);
    261       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbSs,      ext->f_cbSs);
    262       1.1  christos   H_PUT_32      (abfd, intern->isymBase,  ext->f_isymBase);
    263       1.1  christos   H_PUT_32      (abfd, intern->csym,      ext->f_csym);
    264       1.1  christos   H_PUT_32      (abfd, intern->ilineBase, ext->f_ilineBase);
    265       1.1  christos   H_PUT_32      (abfd, intern->cline,     ext->f_cline);
    266       1.1  christos   H_PUT_32      (abfd, intern->ioptBase,  ext->f_ioptBase);
    267       1.1  christos   H_PUT_32      (abfd, intern->copt,      ext->f_copt);
    268       1.1  christos #if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
    269       1.1  christos   H_PUT_16      (abfd, intern->ipdFirst,  ext->f_ipdFirst);
    270       1.1  christos   H_PUT_16      (abfd, intern->cpd,       ext->f_cpd);
    271       1.1  christos #endif
    272       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    273       1.1  christos   H_PUT_32      (abfd, intern->ipdFirst,  ext->f_ipdFirst);
    274       1.1  christos   H_PUT_32      (abfd, intern->cpd,       ext->f_cpd);
    275       1.1  christos #endif
    276       1.1  christos   H_PUT_32      (abfd, intern->iauxBase,  ext->f_iauxBase);
    277       1.1  christos   H_PUT_32      (abfd, intern->caux,      ext->f_caux);
    278       1.1  christos   H_PUT_32      (abfd, intern->rfdBase,   ext->f_rfdBase);
    279       1.1  christos   H_PUT_32      (abfd, intern->crfd,      ext->f_crfd);
    280       1.1  christos 
    281       1.1  christos   /* Now the fun stuff...  */
    282       1.1  christos   if (bfd_header_big_endian (abfd))
    283       1.1  christos     {
    284       1.1  christos       ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
    285       1.1  christos 			  & FDR_BITS1_LANG_BIG)
    286       1.1  christos 			 | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
    287       1.1  christos 			 | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
    288       1.1  christos 			 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
    289       1.1  christos       ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
    290       1.1  christos 			 & FDR_BITS2_GLEVEL_BIG);
    291       1.1  christos       ext->f_bits2[1] = 0;
    292       1.1  christos       ext->f_bits2[2] = 0;
    293       1.1  christos     }
    294       1.1  christos   else
    295       1.1  christos     {
    296       1.1  christos       ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
    297       1.1  christos 			  & FDR_BITS1_LANG_LITTLE)
    298       1.1  christos 			 | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
    299       1.1  christos 			 | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
    300       1.1  christos 			 | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
    301       1.1  christos       ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
    302       1.1  christos 			 & FDR_BITS2_GLEVEL_LITTLE);
    303       1.1  christos       ext->f_bits2[1] = 0;
    304       1.1  christos       ext->f_bits2[2] = 0;
    305       1.1  christos     }
    306       1.1  christos 
    307       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbLineOffset, ext->f_cbLineOffset);
    308       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbLine, ext->f_cbLine);
    309       1.1  christos 
    310       1.1  christos #ifdef TEST
    311       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    312       1.1  christos     abort ();
    313       1.1  christos #endif
    314       1.1  christos }
    315       1.1  christos 
    316       1.1  christos /* Swap in the procedure descriptor record.  */
    317       1.1  christos 
    318       1.1  christos static void
    319       1.1  christos ecoff_swap_pdr_in (bfd *abfd, void * ext_copy, PDR *intern)
    320       1.1  christos {
    321       1.1  christos   struct pdr_ext ext[1];
    322       1.1  christos 
    323       1.1  christos   *ext = *(struct pdr_ext *) ext_copy;
    324       1.1  christos 
    325       1.1  christos   memset ((void *) intern, 0, sizeof (*intern));
    326       1.1  christos 
    327   1.1.1.6  christos   intern->adr		= ECOFF_GET_OFF (abfd, ext->p_adr);
    328   1.1.1.6  christos   intern->isym		= H_GET_32 (abfd, ext->p_isym);
    329   1.1.1.6  christos   intern->iline		= H_GET_32 (abfd, ext->p_iline);
    330   1.1.1.6  christos   intern->regmask	= H_GET_32 (abfd, ext->p_regmask);
    331   1.1.1.6  christos   intern->regoffset	= H_GET_S32 (abfd, ext->p_regoffset);
    332   1.1.1.6  christos   intern->iopt		= H_GET_S32 (abfd, ext->p_iopt);
    333   1.1.1.6  christos   intern->fregmask	= H_GET_32 (abfd, ext->p_fregmask);
    334   1.1.1.6  christos   intern->fregoffset	= H_GET_S32 (abfd, ext->p_fregoffset);
    335   1.1.1.6  christos   intern->frameoffset	= H_GET_S32 (abfd, ext->p_frameoffset);
    336   1.1.1.6  christos   intern->framereg	= H_GET_16 (abfd, ext->p_framereg);
    337   1.1.1.6  christos   intern->pcreg		= H_GET_16 (abfd, ext->p_pcreg);
    338   1.1.1.6  christos   intern->lnLow		= H_GET_32 (abfd, ext->p_lnLow);
    339   1.1.1.6  christos   intern->lnHigh	= H_GET_32 (abfd, ext->p_lnHigh);
    340   1.1.1.6  christos   intern->cbLineOffset	= ECOFF_GET_OFF (abfd, ext->p_cbLineOffset);
    341       1.1  christos 
    342       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    343       1.1  christos   if (intern->isym == (signed long) 0xffffffff)
    344       1.1  christos     intern->isym = -1;
    345       1.1  christos   if (intern->iline == (signed long) 0xffffffff)
    346       1.1  christos     intern->iline = -1;
    347       1.1  christos 
    348       1.1  christos   intern->gp_prologue = H_GET_8 (abfd, ext->p_gp_prologue);
    349       1.1  christos   if (bfd_header_big_endian (abfd))
    350       1.1  christos     {
    351       1.1  christos       intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG);
    352       1.1  christos       intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG);
    353       1.1  christos       intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_BIG);
    354       1.1  christos       intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG)
    355       1.1  christos 			   << PDR_BITS1_RESERVED_SH_LEFT_BIG)
    356       1.1  christos 			  | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG)
    357       1.1  christos 			     >> PDR_BITS2_RESERVED_SH_BIG));
    358       1.1  christos     }
    359       1.1  christos   else
    360       1.1  christos     {
    361       1.1  christos       intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE);
    362       1.1  christos       intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE);
    363       1.1  christos       intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_LITTLE);
    364       1.1  christos       intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE)
    365       1.1  christos 			   >> PDR_BITS1_RESERVED_SH_LITTLE)
    366       1.1  christos 			  | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE)
    367       1.1  christos 			     << PDR_BITS2_RESERVED_SH_LEFT_LITTLE));
    368       1.1  christos     }
    369       1.1  christos   intern->localoff = H_GET_8 (abfd, ext->p_localoff);
    370       1.1  christos #endif
    371       1.1  christos 
    372       1.1  christos #ifdef TEST
    373       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    374       1.1  christos     abort ();
    375       1.1  christos #endif
    376       1.1  christos }
    377       1.1  christos 
    378       1.1  christos /* Swap out the procedure descriptor record.  */
    379       1.1  christos 
    380       1.1  christos static void
    381       1.1  christos ecoff_swap_pdr_out (bfd *abfd, const PDR *intern_copy, void * ext_ptr)
    382       1.1  christos {
    383       1.1  christos   struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
    384       1.1  christos   PDR intern[1];
    385       1.1  christos 
    386       1.1  christos   /* Make it reasonable to do in-place.  */
    387       1.1  christos   *intern = *intern_copy;
    388       1.1  christos 
    389   1.1.1.6  christos   ECOFF_PUT_OFF (abfd, intern->adr,	     ext->p_adr);
    390   1.1.1.6  christos   H_PUT_32	(abfd, intern->isym,	     ext->p_isym);
    391   1.1.1.6  christos   H_PUT_32	(abfd, intern->iline,	     ext->p_iline);
    392   1.1.1.6  christos   H_PUT_32	(abfd, intern->regmask,	     ext->p_regmask);
    393   1.1.1.6  christos   H_PUT_32	(abfd, intern->regoffset,    ext->p_regoffset);
    394   1.1.1.6  christos   H_PUT_32	(abfd, intern->iopt,	     ext->p_iopt);
    395   1.1.1.6  christos   H_PUT_32	(abfd, intern->fregmask,     ext->p_fregmask);
    396   1.1.1.6  christos   H_PUT_32	(abfd, intern->fregoffset,   ext->p_fregoffset);
    397   1.1.1.6  christos   H_PUT_32	(abfd, intern->frameoffset,  ext->p_frameoffset);
    398   1.1.1.6  christos   H_PUT_16	(abfd, intern->framereg,     ext->p_framereg);
    399   1.1.1.6  christos   H_PUT_16	(abfd, intern->pcreg,	     ext->p_pcreg);
    400   1.1.1.6  christos   H_PUT_32	(abfd, intern->lnLow,	     ext->p_lnLow);
    401   1.1.1.6  christos   H_PUT_32	(abfd, intern->lnHigh,	     ext->p_lnHigh);
    402       1.1  christos   ECOFF_PUT_OFF (abfd, intern->cbLineOffset, ext->p_cbLineOffset);
    403       1.1  christos 
    404       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    405       1.1  christos   H_PUT_8       (abfd, intern->gp_prologue,  ext->p_gp_prologue);
    406       1.1  christos 
    407       1.1  christos   if (bfd_header_big_endian (abfd))
    408       1.1  christos     {
    409       1.1  christos       ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0)
    410       1.1  christos 			 | (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0)
    411       1.1  christos 			 | (intern->prof ? PDR_BITS1_PROF_BIG : 0)
    412       1.1  christos 			 | ((intern->reserved
    413       1.1  christos 			     >> PDR_BITS1_RESERVED_SH_LEFT_BIG)
    414       1.1  christos 			    & PDR_BITS1_RESERVED_BIG));
    415       1.1  christos       ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG)
    416       1.1  christos 			 & PDR_BITS2_RESERVED_BIG);
    417       1.1  christos     }
    418       1.1  christos   else
    419       1.1  christos     {
    420       1.1  christos       ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0)
    421       1.1  christos 			 | (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0)
    422       1.1  christos 			 | (intern->prof ? PDR_BITS1_PROF_LITTLE : 0)
    423       1.1  christos 			 | ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE)
    424       1.1  christos 			    & PDR_BITS1_RESERVED_LITTLE));
    425       1.1  christos       ext->p_bits2[0] = ((intern->reserved >>
    426       1.1  christos 			  PDR_BITS2_RESERVED_SH_LEFT_LITTLE)
    427       1.1  christos 			 & PDR_BITS2_RESERVED_LITTLE);
    428       1.1  christos     }
    429       1.1  christos   H_PUT_8 (abfd, intern->localoff, ext->p_localoff);
    430       1.1  christos #endif
    431       1.1  christos 
    432       1.1  christos #ifdef TEST
    433       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    434       1.1  christos     abort ();
    435       1.1  christos #endif
    436       1.1  christos }
    437       1.1  christos 
    438       1.1  christos /* Swap in a symbol record.  */
    439       1.1  christos 
    440       1.1  christos static void
    441       1.1  christos ecoff_swap_sym_in (bfd *abfd, void * ext_copy, SYMR *intern)
    442       1.1  christos {
    443       1.1  christos   struct sym_ext ext[1];
    444       1.1  christos 
    445       1.1  christos   *ext = *(struct sym_ext *) ext_copy;
    446       1.1  christos 
    447   1.1.1.6  christos   intern->iss		= H_GET_32 (abfd, ext->s_iss);
    448   1.1.1.6  christos   intern->value		= ECOFF_GET_OFF (abfd, ext->s_value);
    449       1.1  christos 
    450       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    451       1.1  christos   if (intern->iss == (signed long) 0xffffffff)
    452       1.1  christos     intern->iss = -1;
    453   1.1.1.2  christos #endif
    454       1.1  christos 
    455       1.1  christos   /* Now the fun stuff...  */
    456       1.1  christos   if (bfd_header_big_endian (abfd))
    457       1.1  christos     {
    458   1.1.1.6  christos       intern->st	  =  (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
    459       1.1  christos 					     >> SYM_BITS1_ST_SH_BIG;
    460   1.1.1.6  christos       intern->sc	  = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
    461       1.1  christos 					     << SYM_BITS1_SC_SH_LEFT_BIG)
    462       1.1  christos 			  | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
    463       1.1  christos 					     >> SYM_BITS2_SC_SH_BIG);
    464   1.1.1.6  christos       intern->reserved	  = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
    465   1.1.1.6  christos       intern->index	  = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
    466       1.1  christos 					     << SYM_BITS2_INDEX_SH_LEFT_BIG)
    467       1.1  christos 			  | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
    468       1.1  christos 			  | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
    469       1.1  christos     }
    470       1.1  christos   else
    471       1.1  christos     {
    472   1.1.1.6  christos       intern->st	  =  (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
    473       1.1  christos 					     >> SYM_BITS1_ST_SH_LITTLE;
    474   1.1.1.6  christos       intern->sc	  = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
    475       1.1  christos 					     >> SYM_BITS1_SC_SH_LITTLE)
    476       1.1  christos 			  | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
    477       1.1  christos 					     << SYM_BITS2_SC_SH_LEFT_LITTLE);
    478   1.1.1.6  christos       intern->reserved	  = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
    479   1.1.1.6  christos       intern->index	  = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
    480       1.1  christos 					     >> SYM_BITS2_INDEX_SH_LITTLE)
    481       1.1  christos 			  | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
    482       1.1  christos 			  | ((unsigned int) ext->s_bits4[0]
    483       1.1  christos 			     << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
    484       1.1  christos     }
    485       1.1  christos 
    486       1.1  christos #ifdef TEST
    487       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    488       1.1  christos     abort ();
    489       1.1  christos #endif
    490       1.1  christos }
    491       1.1  christos 
    492       1.1  christos /* Swap out a symbol record.  */
    493       1.1  christos 
    494       1.1  christos static void
    495       1.1  christos ecoff_swap_sym_out (bfd *abfd, const SYMR *intern_copy, void * ext_ptr)
    496       1.1  christos {
    497       1.1  christos   struct sym_ext *ext = (struct sym_ext *) ext_ptr;
    498       1.1  christos   SYMR intern[1];
    499       1.1  christos 
    500       1.1  christos   /* Make it reasonable to do in-place.  */
    501       1.1  christos   *intern = *intern_copy;
    502       1.1  christos 
    503       1.1  christos   H_PUT_32 (abfd, intern->iss, ext->s_iss);
    504       1.1  christos   ECOFF_PUT_OFF (abfd, intern->value, ext->s_value);
    505       1.1  christos 
    506       1.1  christos   /* Now the fun stuff...  */
    507       1.1  christos   if (bfd_header_big_endian (abfd))
    508       1.1  christos     {
    509       1.1  christos       ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
    510       1.1  christos 			  & SYM_BITS1_ST_BIG)
    511       1.1  christos 			 | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
    512       1.1  christos 			    & SYM_BITS1_SC_BIG));
    513       1.1  christos       ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
    514       1.1  christos 			  & SYM_BITS2_SC_BIG)
    515       1.1  christos 			 | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
    516       1.1  christos 			 | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
    517       1.1  christos 			    & SYM_BITS2_INDEX_BIG));
    518       1.1  christos       ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
    519       1.1  christos       ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
    520       1.1  christos     }
    521       1.1  christos   else
    522       1.1  christos     {
    523       1.1  christos       ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
    524       1.1  christos 			  & SYM_BITS1_ST_LITTLE)
    525       1.1  christos 			 | ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
    526       1.1  christos 			    & SYM_BITS1_SC_LITTLE));
    527       1.1  christos       ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
    528       1.1  christos 			  & SYM_BITS2_SC_LITTLE)
    529       1.1  christos 			 | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
    530       1.1  christos 			 | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
    531       1.1  christos 			    & SYM_BITS2_INDEX_LITTLE));
    532       1.1  christos       ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
    533       1.1  christos       ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
    534       1.1  christos     }
    535       1.1  christos 
    536       1.1  christos #ifdef TEST
    537       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    538       1.1  christos     abort ();
    539       1.1  christos #endif
    540       1.1  christos }
    541       1.1  christos 
    542       1.1  christos /* Swap in an external symbol record.  */
    543       1.1  christos 
    544       1.1  christos static void
    545       1.1  christos ecoff_swap_ext_in (bfd *abfd, void * ext_copy, EXTR *intern)
    546       1.1  christos {
    547       1.1  christos   struct ext_ext ext[1];
    548       1.1  christos 
    549       1.1  christos   *ext = *(struct ext_ext *) ext_copy;
    550       1.1  christos 
    551       1.1  christos   /* Now the fun stuff...  */
    552       1.1  christos   if (bfd_header_big_endian (abfd))
    553       1.1  christos     {
    554       1.1  christos       intern->jmptbl      = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
    555       1.1  christos       intern->cobol_main  = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
    556       1.1  christos       intern->weakext     = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
    557       1.1  christos     }
    558       1.1  christos   else
    559       1.1  christos     {
    560       1.1  christos       intern->jmptbl      = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
    561       1.1  christos       intern->cobol_main  = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
    562       1.1  christos       intern->weakext     = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
    563       1.1  christos     }
    564       1.1  christos   intern->reserved = 0;
    565       1.1  christos 
    566       1.1  christos #if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
    567       1.1  christos   intern->ifd = H_GET_S16 (abfd, ext->es_ifd);
    568       1.1  christos #endif
    569       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    570       1.1  christos   intern->ifd = H_GET_S32 (abfd, ext->es_ifd);
    571       1.1  christos #endif
    572       1.1  christos 
    573       1.1  christos   ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
    574       1.1  christos 
    575       1.1  christos #ifdef TEST
    576       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    577       1.1  christos     abort ();
    578       1.1  christos #endif
    579       1.1  christos }
    580       1.1  christos 
    581       1.1  christos /* Swap out an external symbol record.  */
    582       1.1  christos 
    583       1.1  christos static void
    584       1.1  christos ecoff_swap_ext_out (bfd *abfd, const EXTR *intern_copy, void * ext_ptr)
    585       1.1  christos {
    586       1.1  christos   struct ext_ext *ext = (struct ext_ext *) ext_ptr;
    587       1.1  christos   EXTR intern[1];
    588       1.1  christos 
    589       1.1  christos   /* Make it reasonable to do in-place.  */
    590       1.1  christos   *intern = *intern_copy;
    591       1.1  christos 
    592       1.1  christos   /* Now the fun stuff...  */
    593       1.1  christos   if (bfd_header_big_endian (abfd))
    594       1.1  christos     {
    595       1.1  christos       ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
    596       1.1  christos 			  | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
    597       1.1  christos 			  | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
    598       1.1  christos       ext->es_bits2[0] = 0;
    599       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    600       1.1  christos       ext->es_bits2[1] = 0;
    601       1.1  christos       ext->es_bits2[2] = 0;
    602       1.1  christos #endif
    603       1.1  christos     }
    604       1.1  christos   else
    605       1.1  christos     {
    606       1.1  christos       ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
    607       1.1  christos 			  | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
    608       1.1  christos 			  | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
    609       1.1  christos       ext->es_bits2[0] = 0;
    610       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    611       1.1  christos       ext->es_bits2[1] = 0;
    612       1.1  christos       ext->es_bits2[2] = 0;
    613       1.1  christos #endif
    614       1.1  christos     }
    615       1.1  christos 
    616       1.1  christos #if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
    617       1.1  christos   H_PUT_S16 (abfd, intern->ifd, ext->es_ifd);
    618       1.1  christos #endif
    619       1.1  christos #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
    620       1.1  christos   H_PUT_S32 (abfd, intern->ifd, ext->es_ifd);
    621       1.1  christos #endif
    622       1.1  christos 
    623       1.1  christos   ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
    624       1.1  christos 
    625       1.1  christos #ifdef TEST
    626       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    627       1.1  christos     abort ();
    628       1.1  christos #endif
    629       1.1  christos }
    630       1.1  christos 
    631       1.1  christos /* Swap in a relative file descriptor.  */
    632       1.1  christos 
    633       1.1  christos static void
    634       1.1  christos ecoff_swap_rfd_in (bfd *abfd, void * ext_ptr, RFDT *intern)
    635       1.1  christos {
    636       1.1  christos   struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
    637       1.1  christos 
    638       1.1  christos   *intern = H_GET_32 (abfd, ext->rfd);
    639       1.1  christos 
    640       1.1  christos #ifdef TEST
    641       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    642       1.1  christos     abort ();
    643       1.1  christos #endif
    644       1.1  christos }
    645       1.1  christos 
    646       1.1  christos /* Swap out a relative file descriptor.  */
    647       1.1  christos 
    648       1.1  christos static void
    649       1.1  christos ecoff_swap_rfd_out (bfd *abfd, const RFDT *intern, void * ext_ptr)
    650       1.1  christos {
    651       1.1  christos   struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
    652       1.1  christos 
    653       1.1  christos   H_PUT_32 (abfd, *intern, ext->rfd);
    654       1.1  christos 
    655       1.1  christos #ifdef TEST
    656       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    657       1.1  christos     abort ();
    658       1.1  christos #endif
    659       1.1  christos }
    660       1.1  christos 
    661       1.1  christos /* Swap in an optimization symbol.  */
    662       1.1  christos 
    663       1.1  christos static void
    664       1.1  christos ecoff_swap_opt_in (bfd *abfd, void * ext_copy, OPTR * intern)
    665       1.1  christos {
    666       1.1  christos   struct opt_ext ext[1];
    667       1.1  christos 
    668       1.1  christos   *ext = *(struct opt_ext *) ext_copy;
    669       1.1  christos 
    670       1.1  christos   if (bfd_header_big_endian (abfd))
    671       1.1  christos     {
    672       1.1  christos       intern->ot = ext->o_bits1[0];
    673       1.1  christos       intern->value = (((unsigned int) ext->o_bits2[0]
    674       1.1  christos 			<< OPT_BITS2_VALUE_SH_LEFT_BIG)
    675       1.1  christos 		       | ((unsigned int) ext->o_bits3[0]
    676       1.1  christos 			  << OPT_BITS2_VALUE_SH_LEFT_BIG)
    677       1.1  christos 		       | ((unsigned int) ext->o_bits4[0]
    678       1.1  christos 			  << OPT_BITS2_VALUE_SH_LEFT_BIG));
    679       1.1  christos     }
    680       1.1  christos   else
    681       1.1  christos     {
    682       1.1  christos       intern->ot = ext->o_bits1[0];
    683       1.1  christos       intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
    684       1.1  christos 		       | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
    685       1.1  christos 		       | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
    686       1.1  christos     }
    687       1.1  christos 
    688       1.1  christos   _bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd),
    689       1.1  christos 			   &ext->o_rndx, &intern->rndx);
    690       1.1  christos 
    691       1.1  christos   intern->offset = H_GET_32 (abfd, ext->o_offset);
    692       1.1  christos 
    693       1.1  christos #ifdef TEST
    694       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    695       1.1  christos     abort ();
    696       1.1  christos #endif
    697       1.1  christos }
    698       1.1  christos 
    699       1.1  christos /* Swap out an optimization symbol.  */
    700       1.1  christos 
    701       1.1  christos static void
    702       1.1  christos ecoff_swap_opt_out (bfd *abfd, const OPTR *intern_copy, void * ext_ptr)
    703       1.1  christos {
    704       1.1  christos   struct opt_ext *ext = (struct opt_ext *) ext_ptr;
    705       1.1  christos   OPTR intern[1];
    706       1.1  christos 
    707       1.1  christos   /* Make it reasonable to do in-place.  */
    708       1.1  christos   *intern = *intern_copy;
    709       1.1  christos 
    710       1.1  christos   if (bfd_header_big_endian (abfd))
    711       1.1  christos     {
    712       1.1  christos       ext->o_bits1[0] = intern->ot;
    713       1.1  christos       ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
    714       1.1  christos       ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
    715       1.1  christos       ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
    716       1.1  christos     }
    717       1.1  christos   else
    718       1.1  christos     {
    719       1.1  christos       ext->o_bits1[0] = intern->ot;
    720       1.1  christos       ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
    721       1.1  christos       ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
    722       1.1  christos       ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
    723       1.1  christos     }
    724       1.1  christos 
    725       1.1  christos   _bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd),
    726       1.1  christos 			    &intern->rndx, &ext->o_rndx);
    727       1.1  christos 
    728       1.1  christos   H_PUT_32 (abfd, intern->value, ext->o_offset);
    729       1.1  christos 
    730       1.1  christos #ifdef TEST
    731       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    732       1.1  christos     abort ();
    733       1.1  christos #endif
    734       1.1  christos }
    735       1.1  christos 
    736       1.1  christos /* Swap in a dense number.  */
    737       1.1  christos 
    738       1.1  christos static void
    739       1.1  christos ecoff_swap_dnr_in (bfd *abfd, void * ext_copy, DNR *intern)
    740       1.1  christos {
    741       1.1  christos   struct dnr_ext ext[1];
    742       1.1  christos 
    743       1.1  christos   *ext = *(struct dnr_ext *) ext_copy;
    744       1.1  christos 
    745       1.1  christos   intern->rfd = H_GET_32 (abfd, ext->d_rfd);
    746       1.1  christos   intern->index = H_GET_32 (abfd, ext->d_index);
    747       1.1  christos 
    748       1.1  christos #ifdef TEST
    749       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    750       1.1  christos     abort ();
    751       1.1  christos #endif
    752       1.1  christos }
    753       1.1  christos 
    754       1.1  christos /* Swap out a dense number.  */
    755       1.1  christos 
    756       1.1  christos static void
    757       1.1  christos ecoff_swap_dnr_out (bfd *abfd, const DNR *intern_copy, void * ext_ptr)
    758       1.1  christos {
    759       1.1  christos   struct dnr_ext *ext = (struct dnr_ext *) ext_ptr;
    760       1.1  christos   DNR intern[1];
    761       1.1  christos 
    762       1.1  christos   /* Make it reasonable to do in-place.  */
    763       1.1  christos   *intern = *intern_copy;
    764       1.1  christos 
    765       1.1  christos   H_PUT_32 (abfd, intern->rfd, ext->d_rfd);
    766       1.1  christos   H_PUT_32 (abfd, intern->index, ext->d_index);
    767       1.1  christos 
    768       1.1  christos #ifdef TEST
    769       1.1  christos   if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
    770       1.1  christos     abort ();
    771       1.1  christos #endif
    772       1.1  christos }
    773