home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / src / binutils.2 / bfd / coffswap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  21.4 KB  |  585 lines

  1. /* Generic COFF swapping routines, for BFD.
  2.    Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  3.    Written by Cygnus Support.
  4.  
  5. This file is part of BFD, the Binary File Descriptor library.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* This file contains routines used to swap COFF data.  It is a header
  22.    file because the details of swapping depend on the details of the
  23.    structures used by each COFF implementation.  This is included by
  24.    coffcode.h, as well as by the ECOFF backend.
  25.  
  26.    Any file which uses this must first include "coff/internal.h" and
  27.    "coff/CPU.h".  The functions will then be correct for that CPU.  */
  28.  
  29. #define PUTWORD bfd_h_put_32
  30. #define PUTHALF bfd_h_put_16
  31. #define    PUTBYTE bfd_h_put_8
  32.  
  33. #ifndef GET_FCN_LNNOPTR
  34. #define GET_FCN_LNNOPTR(abfd, ext)  bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
  35. #endif
  36.  
  37. #ifndef GET_FCN_ENDNDX
  38. #define GET_FCN_ENDNDX(abfd, ext)  bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
  39. #endif
  40.  
  41. #ifndef PUT_FCN_LNNOPTR
  42. #define PUT_FCN_LNNOPTR(abfd, in, ext)  PUTWORD(abfd,  in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
  43. #endif
  44. #ifndef PUT_FCN_ENDNDX
  45. #define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
  46. #endif
  47. #ifndef GET_LNSZ_LNNO
  48. #define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
  49. #endif
  50. #ifndef GET_LNSZ_SIZE
  51. #define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
  52. #endif
  53. #ifndef PUT_LNSZ_LNNO
  54. #define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
  55. #endif
  56. #ifndef PUT_LNSZ_SIZE
  57. #define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
  58. #endif
  59. #ifndef GET_SCN_SCNLEN
  60. #define GET_SCN_SCNLEN(abfd,  ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
  61. #endif
  62. #ifndef GET_SCN_NRELOC
  63. #define GET_SCN_NRELOC(abfd,  ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
  64. #endif
  65. #ifndef GET_SCN_NLINNO
  66. #define GET_SCN_NLINNO(abfd, ext)  bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
  67. #endif
  68. #ifndef PUT_SCN_SCNLEN
  69. #define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
  70. #endif
  71. #ifndef PUT_SCN_NRELOC
  72. #define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
  73. #endif
  74. #ifndef PUT_SCN_NLINNO
  75. #define PUT_SCN_NLINNO(abfd,in, ext)  bfd_h_put_16(abfd,in, (bfd_byte  *) ext->x_scn.x_nlinno)
  76. #endif
  77. #ifndef GET_LINENO_LNNO
  78. #define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
  79. #endif
  80. #ifndef PUT_LINENO_LNNO
  81. #define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val,  (bfd_byte *) (ext->l_lnno));
  82. #endif
  83.  
  84. #ifndef NO_COFF_RELOCS
  85.  
  86. static void
  87. DEFUN(bfd_swap_reloc_in,(abfd, reloc_src, reloc_dst),
  88.       bfd            *abfd AND
  89.       RELOC *reloc_src AND
  90.       struct internal_reloc *reloc_dst)
  91. {
  92.   reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
  93.   reloc_dst->r_symndx = bfd_h_get_32(abfd, (bfd_byte *) reloc_src->r_symndx);
  94.  
  95. #ifdef RS6000COFF_C
  96.   reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
  97.   reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
  98. #else
  99.   reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
  100. #endif
  101.  
  102. #ifdef SWAP_IN_RELOC_OFFSET
  103.   reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
  104.                          (bfd_byte *) reloc_src->r_offset);
  105. #endif
  106. }
  107.  
  108.  
  109. static unsigned int
  110. DEFUN(coff_swap_reloc_out,(abfd, src, dst),
  111.       bfd       *abfd AND
  112.       PTR    src AND
  113.       PTR    dst)
  114. {
  115.   struct internal_reloc *reloc_src = (struct internal_reloc *)src;
  116.   struct external_reloc *reloc_dst = (struct external_reloc *)dst;
  117.   bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
  118.   bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
  119.   bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
  120.            reloc_dst->r_type);
  121.  
  122. #ifdef SWAP_OUT_RELOC_OFFSET
  123.   SWAP_OUT_RELOC_OFFSET(abfd,
  124.             reloc_src->r_offset,
  125.             (bfd_byte *) reloc_dst->r_offset);
  126. #endif
  127. #ifdef SWAP_OUT_RELOC_EXTRA
  128.   SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
  129. #endif
  130.  
  131.   return sizeof(struct external_reloc);
  132. }
  133.  
  134. #endif /* NO_COFF_RELOCS */
  135.  
  136. static void
  137. DEFUN(coff_swap_filehdr_in,(abfd, src, dst),
  138.       bfd            *abfd AND
  139.       PTR         src AND
  140.       PTR         dst)
  141. {
  142.   FILHDR *filehdr_src = (FILHDR *) src;
  143.   struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
  144.   filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
  145.   filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
  146.   filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
  147.   filehdr_dst->f_symptr = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_symptr);
  148.   filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
  149.   filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
  150.   filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
  151. }
  152.  
  153. static  unsigned int
  154. DEFUN(coff_swap_filehdr_out,(abfd, in, out),
  155.       bfd       *abfd AND
  156.       PTR    in AND
  157.       PTR    out)
  158. {
  159.   struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
  160.   FILHDR *filehdr_out = (FILHDR *)out;
  161.   bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
  162.   bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
  163.   bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
  164.   bfd_h_put_32(abfd, filehdr_in->f_symptr, (bfd_byte *) filehdr_out->f_symptr);
  165.   bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
  166.   bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
  167.   bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
  168.   return sizeof(FILHDR);
  169. }
  170.  
  171.  
  172. #ifndef NO_COFF_SYMBOLS
  173.  
  174. static void
  175. DEFUN(coff_swap_sym_in,(abfd, ext1, in1),
  176.       bfd            *abfd AND
  177.       PTR ext1 AND
  178.       PTR in1)
  179. {
  180.   SYMENT *ext = (SYMENT *)ext1;
  181.   struct internal_syment      *in = (struct internal_syment *)in1;
  182.  
  183.   if( ext->e.e_name[0] == 0) {
  184.     in->_n._n_n._n_zeroes = 0;
  185.     in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
  186.   }
  187.   else {
  188. #if SYMNMLEN != E_SYMNMLEN
  189.    -> Error, we need to cope with truncating or extending SYMNMLEN!;
  190. #else
  191.     memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
  192. #endif
  193.   }
  194.   in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
  195.   in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
  196.   if (sizeof(ext->e_type) == 2){
  197.     in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
  198.   }
  199.   else {
  200.     in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
  201.   }
  202.   in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
  203.   in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
  204. }
  205.  
  206. static unsigned int
  207. DEFUN(coff_swap_sym_out,(abfd, inp, extp),
  208.       bfd       *abfd AND
  209.       PTR    inp AND
  210.       PTR    extp)
  211. {
  212.   struct internal_syment *in = (struct internal_syment *)inp;
  213.   SYMENT *ext =(SYMENT *)extp;
  214.   if(in->_n._n_name[0] == 0) {
  215.     bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
  216.     bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *)  ext->e.e.e_offset);
  217.   }
  218.   else {
  219. #if SYMNMLEN != E_SYMNMLEN
  220.     -> Error, we need to cope with truncating or extending SYMNMLEN!;
  221. #else
  222.     memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
  223. #endif
  224.   }
  225.   bfd_h_put_32(abfd,  in->n_value , (bfd_byte *) ext->e_value);
  226.   bfd_h_put_16(abfd,  in->n_scnum , (bfd_byte *) ext->e_scnum);
  227.   if (sizeof(ext->e_type) == 2)
  228.       {
  229.     bfd_h_put_16(abfd,  in->n_type , (bfd_byte *) ext->e_type);
  230.       }
  231.   else
  232.       {
  233.     bfd_h_put_32(abfd,  in->n_type , (bfd_byte *) ext->e_type);
  234.       }
  235.   bfd_h_put_8(abfd,  in->n_sclass , ext->e_sclass);
  236.   bfd_h_put_8(abfd,  in->n_numaux , ext->e_numaux);
  237.   return sizeof(SYMENT);
  238. }
  239.  
  240. static void
  241. DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
  242.       bfd            *abfd AND
  243.       PTR           ext1 AND
  244.       int             type AND
  245.       int             class AND
  246.       PTR           in1)
  247. {
  248.   AUXENT    *ext = (AUXENT *)ext1;
  249.   union internal_auxent *in = (union internal_auxent *)in1;
  250.  
  251.   switch (class) {
  252.     case C_FILE:
  253.       if (ext->x_file.x_fname[0] == 0) {
  254.       in->x_file.x_n.x_zeroes = 0;
  255.       in->x_file.x_n.x_offset = 
  256.        bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
  257.     } else {
  258. #if FILNMLEN != E_FILNMLEN
  259.         -> Error, we need to cope with truncating or extending FILNMLEN!;
  260. #else
  261.         memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
  262. #endif
  263.       }
  264.       break;
  265.  
  266.       /* RS/6000 "csect" auxents */
  267. #ifdef RS6000COFF_C
  268.     case C_EXT:
  269.     case C_HIDEXT:
  270.       in->x_csect.x_scnlen   = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_scnlen);
  271.       in->x_csect.x_parmhash = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_parmhash);
  272.       in->x_csect.x_snhash   = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snhash);
  273.       /* We don't have to hack bitfields in x_smtyp because it's defined by
  274.      shifts-and-ands, which are equivalent on all byte orders.  */
  275.       in->x_csect.x_smtyp    = bfd_h_get_8  (abfd, (bfd_byte *) ext->x_csect.x_smtyp);
  276.       in->x_csect.x_smclas   = bfd_h_get_8  (abfd, (bfd_byte *) ext->x_csect.x_smclas);
  277.       in->x_csect.x_stab     = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_stab);
  278.       in->x_csect.x_snstab   = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snstab);
  279.       break;
  280. #endif
  281.  
  282.     case C_STAT:
  283. #ifdef C_LEAFSTAT
  284.     case C_LEAFSTAT:
  285. #endif
  286.     case C_HIDDEN:
  287.       if (type == T_NULL) {
  288.       in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
  289.       in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
  290.       in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
  291.       break;
  292.     }
  293.     default:
  294.       in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
  295. #ifndef NO_TVNDX
  296.       in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
  297. #endif
  298.  
  299.       if (ISARY(type)) {
  300. #if DIMNUM != E_DIMNUM
  301.       -> Error, we need to cope with truncating or extending DIMNUM!;
  302. #else
  303.       in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
  304.       in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
  305.       in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
  306.       in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
  307. #endif
  308.     }
  309.       if (class == C_BLOCK || ISFCN(type) || ISTAG(class)) {
  310.     in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR(abfd, ext);
  311.     in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX(abfd, ext);
  312.       }
  313.  
  314.       if (ISFCN(type)) {
  315.       in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
  316.     }
  317.       else {
  318.       in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
  319.       in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
  320.     }
  321.     }
  322. }
  323.  
  324. static unsigned int
  325. DEFUN(coff_swap_aux_out,(abfd, inp, type, class, extp),
  326.   bfd   *abfd AND
  327.   PTR     inp AND
  328.   int   type AND
  329.   int   class AND
  330.   PTR    extp)
  331. {
  332.   union internal_auxent *in = (union internal_auxent *)inp;
  333.   AUXENT *ext = (AUXENT *)extp;
  334.  
  335.   memset((PTR)ext, 0, AUXESZ);
  336.   switch (class) {
  337.   case C_FILE:
  338.     if (in->x_file.x_fname[0] == 0) {
  339.       PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
  340.       PUTWORD(abfd,
  341.           in->x_file.x_n.x_offset,
  342.           (bfd_byte *) ext->x_file.x_n.x_offset);
  343.     }
  344.     else {
  345. #if FILNMLEN != E_FILNMLEN
  346.       -> Error, we need to cope with truncating or extending FILNMLEN!;
  347. #else
  348.       memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
  349. #endif
  350.     }
  351.     break;
  352.  
  353. #ifdef RS6000COFF_C
  354.   /* RS/6000 "csect" auxents */
  355.   case C_EXT:
  356.   case C_HIDEXT:
  357.     PUTWORD (abfd, in->x_csect.x_scnlen,    ext->x_csect.x_scnlen);
  358.     PUTWORD (abfd, in->x_csect.x_parmhash,    ext->x_csect.x_parmhash);
  359.     PUTHALF (abfd, in->x_csect.x_snhash,    ext->x_csect.x_snhash);
  360.     /* We don't have to hack bitfields in x_smtyp because it's defined by
  361.        shifts-and-ands, which are equivalent on all byte orders.  */
  362.     PUTBYTE (abfd, in->x_csect.x_smtyp,        ext->x_csect.x_smtyp);
  363.     PUTBYTE (abfd, in->x_csect.x_smclas,    ext->x_csect.x_smclas);
  364.     PUTWORD (abfd, in->x_csect.x_stab,        ext->x_csect.x_stab);
  365.     PUTHALF (abfd, in->x_csect.x_snstab,    ext->x_csect.x_snstab);
  366.     break;
  367. #endif
  368.  
  369.   case C_STAT:
  370. #ifdef C_LEAFSTAT
  371.   case C_LEAFSTAT:
  372. #endif
  373.   case C_HIDDEN:
  374.     if (type == T_NULL) {
  375.       PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
  376.       PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
  377.       PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
  378.       break;
  379.     }
  380.   default:
  381.     PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
  382. #ifndef NO_TVNDX
  383.     bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
  384. #endif
  385.  
  386.     if (class == C_BLOCK || ISFCN(type) || ISTAG(class)) {
  387.       PUT_FCN_LNNOPTR(abfd,  in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
  388.       PUT_FCN_ENDNDX(abfd,  in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
  389.     }
  390.  
  391.     if (ISFCN(type)) {
  392.       PUTWORD(abfd, in->x_sym.x_misc.x_fsize, (bfd_byte *)  ext->x_sym.x_misc.x_fsize);
  393.     }
  394.     else {
  395.       if (ISARY(type)) {
  396. #if DIMNUM != E_DIMNUM
  397.     -> Error, we need to cope with truncating or extending DIMNUM!;
  398. #else
  399.     bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
  400.     bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
  401.     bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
  402.     bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
  403. #endif
  404.       }
  405.       PUT_LNSZ_LNNO(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
  406.       PUT_LNSZ_SIZE(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
  407.     }
  408.   }
  409. return sizeof(AUXENT);
  410. }
  411.  
  412. #endif /* NO_COFF_SYMBOLS */
  413.  
  414. #ifndef NO_COFF_LINENOS
  415.  
  416. static void
  417. DEFUN(coff_swap_lineno_in,(abfd, ext1, in1),
  418.       bfd            *abfd AND
  419.       PTR ext1 AND
  420.       PTR in1)
  421. {
  422.   LINENO *ext = (LINENO *)ext1;
  423.   struct internal_lineno      *in = (struct internal_lineno *)in1;
  424.  
  425.   in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
  426.   in->l_lnno = GET_LINENO_LNNO(abfd, ext);
  427. }
  428.  
  429. static unsigned int
  430. DEFUN(coff_swap_lineno_out,(abfd, inp, outp),
  431.       bfd       *abfd AND
  432.       PTR    inp AND
  433.       PTR    outp)
  434. {
  435.   struct internal_lineno *in = (struct internal_lineno *)inp;
  436.   struct external_lineno *ext = (struct external_lineno *)outp;
  437.   PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
  438.       ext->l_addr.l_symndx);
  439.  
  440.   PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
  441.   return sizeof(struct external_lineno);
  442. }
  443.  
  444. #endif /* NO_COFF_LINENOS */
  445.  
  446.  
  447. static void
  448. DEFUN(coff_swap_aouthdr_in,(abfd, aouthdr_ext1, aouthdr_int1),
  449.       bfd            *abfd AND
  450.       PTR aouthdr_ext1 AND
  451.       PTR aouthdr_int1)
  452. {
  453.   AOUTHDR        *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
  454.   struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
  455.  
  456.   aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
  457.   aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
  458.   aouthdr_int->tsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tsize);
  459.   aouthdr_int->dsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->dsize);
  460.   aouthdr_int->bsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->bsize);
  461.   aouthdr_int->entry = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->entry);
  462.   aouthdr_int->text_start = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->text_start);
  463.   aouthdr_int->data_start = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->data_start);
  464. #ifdef I960
  465.   aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
  466. #endif
  467.  
  468. #ifdef RS6000COFF_C
  469.   aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
  470.   aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
  471.   aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
  472.   aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
  473.   aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
  474.   aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
  475.   aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
  476.   aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
  477.   aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
  478.   aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
  479.   aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
  480. #endif
  481.  
  482. #ifdef MIPSECOFF
  483.   aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
  484.   aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
  485.   aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
  486.   aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
  487.   aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
  488.   aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
  489.   aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
  490. #endif
  491. }
  492.  
  493. static unsigned int
  494. DEFUN(coff_swap_aouthdr_out,(abfd, in, out),
  495.       bfd       *abfd AND
  496.       PTR    in AND
  497.       PTR    out)
  498. {
  499.   struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
  500.   AOUTHDR *aouthdr_out = (AOUTHDR *)out;
  501.   bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
  502.   bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
  503.   bfd_h_put_32(abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
  504.   bfd_h_put_32(abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
  505.   bfd_h_put_32(abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
  506.   bfd_h_put_32(abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
  507.   bfd_h_put_32(abfd, aouthdr_in->text_start,
  508.            (bfd_byte *) aouthdr_out->text_start);
  509.   bfd_h_put_32(abfd, aouthdr_in->data_start, (bfd_byte *) aouthdr_out->data_start);
  510. #ifdef I960
  511.   bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
  512. #endif
  513.  
  514. #ifdef MIPSECOFF
  515.   bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
  516.   bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
  517.   bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
  518.   bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
  519.   bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
  520.   bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
  521.   bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
  522. #endif
  523.  
  524.   return sizeof(AOUTHDR);
  525. }
  526.  
  527. static void
  528. DEFUN(coff_swap_scnhdr_in,(abfd, ext, in),
  529.       bfd            *abfd AND
  530.       PTR         ext AND
  531.       PTR         in)
  532. {
  533.   SCNHDR *scnhdr_ext = (SCNHDR *) ext;
  534.   struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
  535.   memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
  536.   scnhdr_int->s_vaddr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
  537.   scnhdr_int->s_paddr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_paddr);
  538.   scnhdr_int->s_size = bfd_h_get_32(abfd, (bfd_byte *)  scnhdr_ext->s_size);
  539.  
  540.   scnhdr_int->s_scnptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
  541.   scnhdr_int->s_relptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_relptr);
  542.   scnhdr_int->s_lnnoptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
  543.   scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
  544. #if defined(M88)
  545.   scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
  546.   scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
  547. #else
  548.   scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
  549.   scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
  550. #endif
  551. #ifdef I960
  552.   scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
  553. #endif
  554. }
  555.  
  556. static unsigned int
  557. DEFUN(coff_swap_scnhdr_out,(abfd, in, out),
  558.       bfd       *abfd AND
  559.       PTR    in AND
  560.       PTR    out)
  561. {
  562.   struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
  563.   SCNHDR *scnhdr_ext = (SCNHDR *)out;
  564.   memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
  565.   PUTWORD(abfd, scnhdr_int->s_vaddr, (bfd_byte *) scnhdr_ext->s_vaddr);
  566.   PUTWORD(abfd, scnhdr_int->s_paddr, (bfd_byte *) scnhdr_ext->s_paddr);
  567.   PUTWORD(abfd, scnhdr_int->s_size, (bfd_byte *) scnhdr_ext->s_size);
  568.   PUTWORD(abfd, scnhdr_int->s_scnptr, (bfd_byte *) scnhdr_ext->s_scnptr);
  569.   PUTWORD(abfd, scnhdr_int->s_relptr, (bfd_byte *) scnhdr_ext->s_relptr);
  570.   PUTWORD(abfd, scnhdr_int->s_lnnoptr, (bfd_byte *) scnhdr_ext->s_lnnoptr);
  571.   PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags);
  572. #if defined(M88)
  573.   PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
  574.   PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
  575. #else
  576.   PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
  577.   PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
  578. #endif
  579.  
  580. #if defined(I960)
  581.   PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
  582. #endif
  583.   return sizeof(SCNHDR);
  584. }
  585.