ecoffswap.h revision 33965
169783Smsmith/* Generic ECOFF swapping routines, for BFD. 269783Smsmith Copyright 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. 369783Smsmith Written by Cygnus Support. 469783Smsmith 569783SmsmithThis file is part of BFD, the Binary File Descriptor library. 669783Smsmith 769783SmsmithThis program is free software; you can redistribute it and/or modify 869783Smsmithit under the terms of the GNU General Public License as published by 969783Smsmiththe Free Software Foundation; either version 2 of the License, or 1069783Smsmith(at your option) any later version. 1169783Smsmith 1269783SmsmithThis program is distributed in the hope that it will be useful, 1369783Smsmithbut WITHOUT ANY WARRANTY; without even the implied warranty of 1469783SmsmithMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1569783SmsmithGNU General Public License for more details. 1669783Smsmith 1769783SmsmithYou should have received a copy of the GNU General Public License 1869783Smsmithalong with this program; if not, write to the Free Software 1969783SmsmithFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2069783Smsmith 2169783Smsmith/* NOTE: This is a header file, but it contains executable routines. 2269783Smsmith This is done this way because these routines are substantially 2369783Smsmith similar, but are not identical, for all ECOFF targets. 2469783Smsmith 2569783Smsmith These are routines to swap the ECOFF symbolic information in and 2669783Smsmith out. The routines are defined statically. You can set breakpoints 2769783Smsmith on them in gdb by naming the including source file; e.g., 2869783Smsmith 'coff-mips.c':ecoff_swap_hdr_in. 2969783Smsmith 3069783Smsmith Before including this header file, one of ECOFF_32 or ECOFF_64 must 31119418Sobrien be defined. These are checked when swapping information that 32119418Sobrien depends upon the target size. This code works for 32 bit and 64 33119418Sobrien bit ECOFF, but may need to be generalized in the future. 3469783Smsmith 3569783Smsmith Some header file which defines the external forms of these 3669783Smsmith structures must also be included before including this header file. 3769783Smsmith Currently this is either coff/mips.h or coff/alpha.h. 3869783Smsmith 3969783Smsmith If the symbol TEST is defined when this file is compiled, a 4069783Smsmith comparison is made to ensure that, in fact, the output is 41129876Sphk bit-for-bit the same as the input. Of course, this symbol should 4269783Smsmith only be defined when deliberately testing the code on a machine 43107546Simp with the proper byte sex and such. */ 44107546Simp 45106844Smdodd#ifdef ECOFF_32 4669783Smsmith#define ecoff_get_off bfd_h_get_32 4769783Smsmith#define ecoff_put_off bfd_h_put_32 4869783Smsmith#endif 49119285Simp#ifdef ECOFF_64 50119285Simp#define ecoff_get_off bfd_h_get_64 51119285Simp#define ecoff_put_off bfd_h_put_64 5269783Smsmith#endif 5369783Smsmith 5469783Smsmith/* ECOFF auxiliary information swapping routines. These are the same 5569783Smsmith for all ECOFF targets, so they are defined in ecofflink.c. */ 5669783Smsmith 5769783Smsmithextern void _bfd_ecoff_swap_tir_in 5869783Smsmith PARAMS ((int, const struct tir_ext *, TIR *)); 5969783Smsmithextern void _bfd_ecoff_swap_tir_out 6069783Smsmith PARAMS ((int, const TIR *, struct tir_ext *)); 6169783Smsmithextern void _bfd_ecoff_swap_rndx_in 6269783Smsmith PARAMS ((int, const struct rndx_ext *, RNDXR *)); 6369783Smsmithextern void _bfd_ecoff_swap_rndx_out 6469783Smsmith PARAMS ((int, const RNDXR *, struct rndx_ext *)); 6569783Smsmith 6669783Smsmith/* Prototypes for functions defined in this file. */ 6769783Smsmith 6869783Smsmithstatic void ecoff_swap_hdr_in PARAMS ((bfd *, PTR, HDRR *)); 6969783Smsmithstatic void ecoff_swap_hdr_out PARAMS ((bfd *, const HDRR *, PTR)); 7069783Smsmithstatic void ecoff_swap_fdr_in PARAMS ((bfd *, PTR, FDR *)); 7169783Smsmithstatic void ecoff_swap_fdr_out PARAMS ((bfd *, const FDR *, PTR)); 7269783Smsmithstatic void ecoff_swap_pdr_in PARAMS ((bfd *, PTR, PDR *)); 7369783Smsmithstatic void ecoff_swap_pdr_out PARAMS ((bfd *, const PDR *, PTR)); 7469783Smsmithstatic void ecoff_swap_sym_in PARAMS ((bfd *, PTR, SYMR *)); 7569783Smsmithstatic void ecoff_swap_sym_out PARAMS ((bfd *, const SYMR *, PTR)); 7669783Smsmithstatic void ecoff_swap_ext_in PARAMS ((bfd *, PTR, EXTR *)); 7769783Smsmithstatic void ecoff_swap_ext_out PARAMS ((bfd *, const EXTR *, PTR)); 7869783Smsmithstatic void ecoff_swap_rfd_in PARAMS ((bfd *, PTR, RFDT *)); 7969783Smsmithstatic void ecoff_swap_rfd_out PARAMS ((bfd *, const RFDT *, PTR)); 8069783Smsmithstatic void ecoff_swap_opt_in PARAMS ((bfd *, PTR, OPTR *)); 8169783Smsmithstatic void ecoff_swap_opt_out PARAMS ((bfd *, const OPTR *, PTR)); 8269783Smsmithstatic void ecoff_swap_dnr_in PARAMS ((bfd *, PTR, DNR *)); 8369783Smsmithstatic void ecoff_swap_dnr_out PARAMS ((bfd *, const DNR *, PTR)); 8469783Smsmith 8569783Smsmith/* Swap in the symbolic header. */ 8669783Smsmith 8769783Smsmithstatic void 8869783Smsmithecoff_swap_hdr_in (abfd, ext_copy, intern) 8969783Smsmith bfd *abfd; 9069783Smsmith PTR ext_copy; 91102441Sjhb HDRR *intern; 9269783Smsmith{ 9369783Smsmith struct hdr_ext ext[1]; 9469783Smsmith 9569783Smsmith *ext = *(struct hdr_ext *) ext_copy; 9669783Smsmith 9769783Smsmith intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic); 9869783Smsmith intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp); 9969783Smsmith intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax); 10069783Smsmith intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine); 10169783Smsmith intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset); 10269783Smsmith intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax); 10369783Smsmith intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset); 10469783Smsmith intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax); 10569783Smsmith intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset); 10669783Smsmith intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax); 10769783Smsmith intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset); 10869783Smsmith intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax); 109102441Sjhb intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset); 110102441Sjhb intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax); 11169783Smsmith intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset); 11269783Smsmith intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax); 113119266Simp intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset); 11469783Smsmith intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax); 11569783Smsmith intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset); 11669783Smsmith intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax); 11769783Smsmith intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset); 11869908Smsmith intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd); 11969908Smsmith intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset); 12069908Smsmith intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax); 12169953Smsmith intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset); 12269908Smsmith 12369908Smsmith#ifdef TEST 12469908Smsmith if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 12569908Smsmith abort(); 12669908Smsmith#endif 12769783Smsmith} 12869908Smsmith 12969908Smsmith/* Swap out the symbolic header. */ 13069908Smsmith 13169953Smsmithstatic void 13269953Smsmithecoff_swap_hdr_out (abfd, intern_copy, ext_ptr) 13369953Smsmith bfd *abfd; 13469953Smsmith const HDRR *intern_copy; 13569953Smsmith PTR ext_ptr; 13669953Smsmith{ 13769953Smsmith struct hdr_ext *ext = (struct hdr_ext *) ext_ptr; 13869953Smsmith HDRR intern[1]; 13969908Smsmith 14069953Smsmith *intern = *intern_copy; 14169953Smsmith 14269953Smsmith bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic); 14369953Smsmith bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp); 14469953Smsmith bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax); 14569953Smsmith ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine); 14669953Smsmith ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset); 14769908Smsmith bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax); 14869908Smsmith ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset); 14969908Smsmith bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax); 15069908Smsmith ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset); 15169908Smsmith bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax); 15269953Smsmith ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset); 15369953Smsmith bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax); 15469953Smsmith ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset); 15569953Smsmith bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax); 15669953Smsmith ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset); 15769953Smsmith bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax); 15869953Smsmith ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset); 15969953Smsmith bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax); 16069908Smsmith ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset); 16169908Smsmith bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax); 16269908Smsmith ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset); 16369908Smsmith bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd); 16469908Smsmith ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset); 165124365Simp bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax); 16669908Smsmith ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset); 167119266Simp 16869908Smsmith#ifdef TEST 16969908Smsmith if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 17069908Smsmith abort(); 17169908Smsmith#endif 17269908Smsmith} 17369908Smsmith 174124365Simp/* Swap in the file descriptor record. */ 17569908Smsmith 176124365Simpstatic void 177124365Simpecoff_swap_fdr_in (abfd, ext_copy, intern) 178124365Simp bfd *abfd; 179124365Simp PTR ext_copy; 180124365Simp FDR *intern; 181124365Simp{ 182124365Simp struct fdr_ext ext[1]; 183124365Simp 184124365Simp *ext = *(struct fdr_ext *) ext_copy; 185124365Simp 186124365Simp intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr); 18769908Smsmith intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss); 18869908Smsmith#ifdef ECOFF_64 18969908Smsmith if (intern->rss == 0xffffffff) 190124365Simp intern->rss = -1; 191124365Simp#endif 192124365Simp intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase); 193124365Simp intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs); 194124365Simp intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase); 195124365Simp intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym); 196124365Simp intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase); 197124365Simp intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline); 198124365Simp intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase); 199124365Simp intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt); 200124365Simp#ifdef ECOFF_32 201124365Simp intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst); 20269783Smsmith intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd); 20369783Smsmith#endif 20469783Smsmith#ifdef ECOFF_64 20569783Smsmith intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst); 20669783Smsmith intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd); 20769783Smsmith#endif 208124365Simp intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase); 209124365Simp intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux); 21069783Smsmith intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase); 21169783Smsmith intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd); 21269783Smsmith 21369783Smsmith /* now the fun stuff... */ 21469783Smsmith if (bfd_header_big_endian (abfd)) { 21569783Smsmith intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG) 21669783Smsmith >> FDR_BITS1_LANG_SH_BIG; 21769783Smsmith intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG); 21869783Smsmith intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG); 21969783Smsmith intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG); 22069783Smsmith intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG) 22169783Smsmith >> FDR_BITS2_GLEVEL_SH_BIG; 22269783Smsmith } else { 223102441Sjhb intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE) 22469783Smsmith >> FDR_BITS1_LANG_SH_LITTLE; 225103042Sjhb intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE); 226102441Sjhb intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE); 227102441Sjhb intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE); 228102441Sjhb intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE) 229102441Sjhb >> FDR_BITS2_GLEVEL_SH_LITTLE; 230102441Sjhb } 231102441Sjhb intern->reserved = 0; 232102441Sjhb 23369783Smsmith intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset); 234103016Sjhb intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine); 23569783Smsmith 23669783Smsmith#ifdef TEST 23769783Smsmith if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 23869783Smsmith abort(); 23969783Smsmith#endif 24069783Smsmith} 24169783Smsmith 24269783Smsmith/* Swap out the file descriptor record. */ 243102441Sjhb 24469783Smsmithstatic void 24569783Smsmithecoff_swap_fdr_out (abfd, intern_copy, ext_ptr) 24669783Smsmith bfd *abfd; 24769783Smsmith const FDR *intern_copy; 24869783Smsmith PTR ext_ptr; 24969783Smsmith{ 25069783Smsmith struct fdr_ext *ext = (struct fdr_ext *) ext_ptr; 25169783Smsmith FDR intern[1]; 25269783Smsmith 25369783Smsmith *intern = *intern_copy; /* Make it reasonable to do in-place. */ 25469783Smsmith 25569783Smsmith ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr); 256102441Sjhb bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss); 25769783Smsmith bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase); 25869783Smsmith ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs); 25969783Smsmith bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase); 26069783Smsmith bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym); 26169783Smsmith bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase); 26269783Smsmith bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline); 26369783Smsmith bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase); 26469783Smsmith bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt); 26569783Smsmith#ifdef ECOFF_32 26669783Smsmith bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst); 26769783Smsmith bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd); 26869783Smsmith#endif 26969783Smsmith#ifdef ECOFF_64 270107546Simp bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst); 271107546Simp bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd); 272107546Simp#endif 273107546Simp bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase); 274107546Simp bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux); 275124365Simp bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase); 276107546Simp bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd); 277107546Simp 278107546Simp /* now the fun stuff... */ 279107546Simp if (bfd_header_big_endian (abfd)) { 280107546Simp ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG) 281107546Simp & FDR_BITS1_LANG_BIG) 282107546Simp | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0) 283107546Simp | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0) 284124365Simp | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0)); 285107546Simp ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG) 286107546Simp & FDR_BITS2_GLEVEL_BIG); 287107546Simp ext->f_bits2[1] = 0; 288107546Simp ext->f_bits2[2] = 0; 289107546Simp } else { 290107546Simp ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE) 291107546Simp & FDR_BITS1_LANG_LITTLE) 292107546Simp | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0) 293124365Simp | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0) 294107546Simp | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0)); 295107546Simp ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE) 296107546Simp & FDR_BITS2_GLEVEL_LITTLE); 29769783Smsmith ext->f_bits2[1] = 0; 29869783Smsmith ext->f_bits2[2] = 0; 29969783Smsmith } 300102441Sjhb 30169783Smsmith ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset); 30269783Smsmith ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine); 30369783Smsmith 304124365Simp#ifdef TEST 305124365Simp if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 30669783Smsmith abort(); 30769783Smsmith#endif 30869783Smsmith} 30969783Smsmith 31069783Smsmith#ifndef MPW_C 31169783Smsmith 312107546Simp/* Swap in the procedure descriptor record. */ 313124365Simp 314124365Simpstatic void 315124365Simpecoff_swap_pdr_in (abfd, ext_copy, intern) 316124365Simp bfd *abfd; 317124365Simp PTR ext_copy; 318124365Simp PDR *intern; 319124365Simp{ 320124365Simp struct pdr_ext ext[1]; 321124365Simp 322124365Simp *ext = *(struct pdr_ext *) ext_copy; 323106844Smdodd 324124365Simp memset ((PTR) intern, 0, sizeof (*intern)); 325128058Simp 326124365Simp intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr); 327124365Simp intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym); 328124365Simp intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline); 329124365Simp intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask); 330124641Simp intern->regoffset = bfd_h_get_signed_32 (abfd, 331106844Smdodd (bfd_byte *)ext->p_regoffset); 332124365Simp intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt); 333124365Simp intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask); 334124365Simp intern->fregoffset = bfd_h_get_signed_32 (abfd, 335124365Simp (bfd_byte *)ext->p_fregoffset); 336124365Simp intern->frameoffset = bfd_h_get_signed_32 (abfd, 337124365Simp (bfd_byte *)ext->p_frameoffset); 338124365Simp intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg); 339124365Simp intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg); 340124365Simp intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow); 341124365Simp intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh); 342124365Simp intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset); 343124365Simp 344124365Simp#ifdef ECOFF_64 345124365Simp intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue); 346124365Simp if (bfd_header_big_endian (abfd)) 347124365Simp { 348124365Simp intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG); 34969783Smsmith intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG); 35069783Smsmith intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_BIG); 351107546Simp intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG) 352107546Simp << PDR_BITS1_RESERVED_SH_LEFT_BIG) 353124365Simp | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG) 354107546Simp >> PDR_BITS2_RESERVED_SH_BIG)); 355124365Simp } 356124365Simp else 357124365Simp { 358124365Simp intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE); 359124365Simp intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE); 360124365Simp intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_LITTLE); 361124365Simp intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE) 362124365Simp >> PDR_BITS1_RESERVED_SH_LITTLE) 363124365Simp | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE) 364124365Simp << PDR_BITS2_RESERVED_SH_LEFT_LITTLE)); 365124365Simp } 366124365Simp intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff); 367124365Simp#endif 368124365Simp 369124365Simp#ifdef TEST 370124365Simp if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 371124365Simp abort(); 372124365Simp#endif 373124365Simp} 374124365Simp 375124365Simp/* Swap out the procedure descriptor record. */ 376124365Simp 377124365Simpstatic void 378107546Simpecoff_swap_pdr_out (abfd, intern_copy, ext_ptr) 379107546Simp bfd *abfd; 380124365Simp const PDR *intern_copy; 381128058Simp PTR ext_ptr; 382124365Simp{ 383124365Simp struct pdr_ext *ext = (struct pdr_ext *) ext_ptr; 384124365Simp PDR intern[1]; 385124365Simp 386124365Simp *intern = *intern_copy; /* Make it reasonable to do in-place. */ 387124365Simp 388124365Simp ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr); 389124365Simp bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym); 390124365Simp bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline); 391124365Simp bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask); 392124365Simp bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset); 393124365Simp bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt); 394124641Simp bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask); 395106844Smdodd bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset); 396124365Simp bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset); 397124365Simp bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg); 398124365Simp bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg); 399124365Simp bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow); 400124365Simp bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh); 401124365Simp ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset); 402124365Simp 403124365Simp#ifdef ECOFF_64 404124365Simp bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue); 405124365Simp if (bfd_header_big_endian (abfd)) 406124365Simp { 407124365Simp ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0) 408124365Simp | (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0) 409124365Simp | (intern->prof ? PDR_BITS1_PROF_BIG : 0) 410124365Simp | ((intern->reserved 411124365Simp >> PDR_BITS1_RESERVED_SH_LEFT_BIG) 412124365Simp & PDR_BITS1_RESERVED_BIG)); 413124365Simp ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG) 414124365Simp & PDR_BITS2_RESERVED_BIG); 41569908Smsmith } 41669783Smsmith else 417124365Simp { 41869783Smsmith ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0) 419124365Simp | (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0) 420124365Simp | (intern->prof ? PDR_BITS1_PROF_LITTLE : 0) 421124365Simp | ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE) 422124365Simp & PDR_BITS1_RESERVED_LITTLE)); 42369783Smsmith ext->p_bits2[0] = ((intern->reserved >> 42469783Smsmith PDR_BITS2_RESERVED_SH_LEFT_LITTLE) 42569783Smsmith & PDR_BITS2_RESERVED_LITTLE); 42669783Smsmith } 42769783Smsmith bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff); 428102441Sjhb#endif 42969783Smsmith 43069783Smsmith#ifdef TEST 43169908Smsmith if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 43269783Smsmith abort(); 43369783Smsmith#endif 43469783Smsmith} 43569783Smsmith 43669783Smsmith#else /* MPW_C */ 437119266Simp/* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't 43869783Smsmith corrupt itself and then freak out. */ 43969783Smsmith/* Swap in the procedure descriptor record. */ 44069783Smsmith 44169783Smsmithstatic void 44269783Smsmithecoff_swap_pdr_in (abfd, ext_copy, intern) 443102441Sjhb bfd *abfd; 444119266Simp PTR ext_copy; 44569783Smsmith PDR *intern; 44669783Smsmith{ 44769783Smsmith struct pdr_ext ext[1]; 44869783Smsmith 44969783Smsmith *ext = *(struct pdr_ext *) ext_copy; 45069783Smsmith 45169783Smsmith intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr); 452109229Sbenno intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym); 45369783Smsmith intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline); 45469783Smsmith intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask); 45569783Smsmith intern->regoffset = bfd_h_get_signed_32 (abfd, 45669783Smsmith (bfd_byte *)ext->p_regoffset); 45769783Smsmith intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt); 45869783Smsmith intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask); 45969783Smsmith intern->fregoffset = bfd_h_get_signed_32 (abfd, 46069783Smsmith (bfd_byte *)ext->p_fregoffset); 46169783Smsmith intern->frameoffset = bfd_h_get_signed_32 (abfd, 46269783Smsmith (bfd_byte *)ext->p_frameoffset); 46369783Smsmith intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg); 46469783Smsmith intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg); 46569783Smsmith intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow); 46669783Smsmith intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh); 46769783Smsmith intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset); 46869783Smsmith 46969783Smsmith#ifdef TEST 470115234Sticso if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 47169783Smsmith abort(); 47269783Smsmith#endif 47369783Smsmith} 47469783Smsmith 47569783Smsmith/* Swap out the procedure descriptor record. */ 47669783Smsmith 47769783Smsmithstatic void 47890554Smsmithecoff_swap_pdr_out (abfd, intern_copy, ext_ptr) 479102977Sjhb bfd *abfd; 480102977Sjhb const PDR *intern_copy; 48190554Smsmith PTR ext_ptr; 48269783Smsmith{ 48369783Smsmith struct pdr_ext *ext = (struct pdr_ext *) ext_ptr; 484107172Sjhb PDR intern[1]; 485107172Sjhb 486107172Sjhb *intern = *intern_copy; /* Make it reasonable to do in-place. */ 487107172Sjhb 488107172Sjhb ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr); 489107172Sjhb bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym); 490107172Sjhb bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline); 491119266Simp bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask); 492107172Sjhb bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset); 493119266Simp bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt); 494107172Sjhb bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask); 495107172Sjhb bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset); 496107248Sjhb bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset); 497107172Sjhb bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg); 498107172Sjhb bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg); 499107172Sjhb bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow); 500107172Sjhb bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh); 501107172Sjhb ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset); 502107172Sjhb 503107172Sjhb#ifdef TEST 504107172Sjhb if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 505107172Sjhb abort(); 506107172Sjhb#endif 507107172Sjhb} 508107172Sjhb#endif /* MPW_C */ 509107172Sjhb 510107172Sjhb/* Swap in a symbol record. */ 511107172Sjhb 512107172Sjhbstatic void 513107172Sjhbecoff_swap_sym_in (abfd, ext_copy, intern) 514107172Sjhb bfd *abfd; 515107172Sjhb PTR ext_copy; 516107172Sjhb SYMR *intern; 517107172Sjhb{ 518107172Sjhb struct sym_ext ext[1]; 519107172Sjhb 520107172Sjhb *ext = *(struct sym_ext *) ext_copy; 521107172Sjhb 522107172Sjhb intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss); 523107172Sjhb intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value); 524107172Sjhb 525107172Sjhb /* now the fun stuff... */ 526107172Sjhb if (bfd_header_big_endian (abfd)) { 527107248Sjhb intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG) 528107172Sjhb >> SYM_BITS1_ST_SH_BIG; 529107172Sjhb intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG) 530107172Sjhb << SYM_BITS1_SC_SH_LEFT_BIG) 531107248Sjhb | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG) 532107172Sjhb >> SYM_BITS2_SC_SH_BIG); 533107172Sjhb intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG); 534107172Sjhb intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG) 535107248Sjhb << SYM_BITS2_INDEX_SH_LEFT_BIG) 536107172Sjhb | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG) 537107172Sjhb | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG); 538107172Sjhb } else { 539107248Sjhb intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE) 540107172Sjhb >> SYM_BITS1_ST_SH_LITTLE; 541107172Sjhb intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE) 542107172Sjhb >> SYM_BITS1_SC_SH_LITTLE) 543107172Sjhb | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE) 544107172Sjhb << SYM_BITS2_SC_SH_LEFT_LITTLE); 545107172Sjhb intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE); 546107172Sjhb intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE) 547107172Sjhb >> SYM_BITS2_INDEX_SH_LITTLE) 548107172Sjhb | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE) 549107172Sjhb | ((unsigned int) ext->s_bits4[0] 550107172Sjhb << SYM_BITS4_INDEX_SH_LEFT_LITTLE); 551107172Sjhb } 552107172Sjhb 553107172Sjhb#ifdef TEST 554107172Sjhb if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 555107172Sjhb abort(); 556107172Sjhb#endif 557107172Sjhb} 558107172Sjhb 559107172Sjhb/* Swap out a symbol record. */ 560107172Sjhb 561107172Sjhbstatic void 562107172Sjhbecoff_swap_sym_out (abfd, intern_copy, ext_ptr) 563107172Sjhb bfd *abfd; 564107172Sjhb const SYMR *intern_copy; 565 PTR ext_ptr; 566{ 567 struct sym_ext *ext = (struct sym_ext *) ext_ptr; 568 SYMR intern[1]; 569 570 *intern = *intern_copy; /* Make it reasonable to do in-place. */ 571 572 bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss); 573 ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value); 574 575 /* now the fun stuff... */ 576 if (bfd_header_big_endian (abfd)) { 577 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG) 578 & SYM_BITS1_ST_BIG) 579 | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG) 580 & SYM_BITS1_SC_BIG)); 581 ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG) 582 & SYM_BITS2_SC_BIG) 583 | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0) 584 | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG) 585 & SYM_BITS2_INDEX_BIG)); 586 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff; 587 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff; 588 } else { 589 ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE) 590 & SYM_BITS1_ST_LITTLE) 591 | ((intern->sc << SYM_BITS1_SC_SH_LITTLE) 592 & SYM_BITS1_SC_LITTLE)); 593 ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE) 594 & SYM_BITS2_SC_LITTLE) 595 | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0) 596 | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE) 597 & SYM_BITS2_INDEX_LITTLE)); 598 ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff; 599 ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff; 600 } 601 602#ifdef TEST 603 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 604 abort(); 605#endif 606} 607 608/* Swap in an external symbol record. */ 609 610static void 611ecoff_swap_ext_in (abfd, ext_copy, intern) 612 bfd *abfd; 613 PTR ext_copy; 614 EXTR *intern; 615{ 616 struct ext_ext ext[1]; 617 618 *ext = *(struct ext_ext *) ext_copy; 619 620 /* now the fun stuff... */ 621 if (bfd_header_big_endian (abfd)) { 622 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG); 623 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG); 624 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG); 625 } else { 626 intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE); 627 intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE); 628 intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE); 629 } 630 intern->reserved = 0; 631 632#ifdef ECOFF_32 633 intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd); 634#endif 635#ifdef ECOFF_64 636 intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd); 637#endif 638 639 ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym); 640 641#ifdef TEST 642 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 643 abort(); 644#endif 645} 646 647/* Swap out an external symbol record. */ 648 649static void 650ecoff_swap_ext_out (abfd, intern_copy, ext_ptr) 651 bfd *abfd; 652 const EXTR *intern_copy; 653 PTR ext_ptr; 654{ 655 struct ext_ext *ext = (struct ext_ext *) ext_ptr; 656 EXTR intern[1]; 657 658 *intern = *intern_copy; /* Make it reasonable to do in-place. */ 659 660 /* now the fun stuff... */ 661 if (bfd_header_big_endian (abfd)) { 662 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0) 663 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0) 664 | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0)); 665 ext->es_bits2[0] = 0; 666#ifdef ECOFF_64 667 ext->es_bits2[1] = 0; 668 ext->es_bits2[2] = 0; 669#endif 670 } else { 671 ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0) 672 | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0) 673 | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0)); 674 ext->es_bits2[0] = 0; 675#ifdef ECOFF_64 676 ext->es_bits2[1] = 0; 677 ext->es_bits2[2] = 0; 678#endif 679 } 680 681#ifdef ECOFF_32 682 bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd); 683#endif 684#ifdef ECOFF_64 685 bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd); 686#endif 687 688 ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym); 689 690#ifdef TEST 691 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 692 abort(); 693#endif 694} 695 696/* Swap in a relative file descriptor. */ 697 698static void 699ecoff_swap_rfd_in (abfd, ext_ptr, intern) 700 bfd *abfd; 701 PTR ext_ptr; 702 RFDT *intern; 703{ 704 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr; 705 706 *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd); 707 708#ifdef TEST 709 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 710 abort(); 711#endif 712} 713 714/* Swap out a relative file descriptor. */ 715 716static void 717ecoff_swap_rfd_out (abfd, intern, ext_ptr) 718 bfd *abfd; 719 const RFDT *intern; 720 PTR ext_ptr; 721{ 722 struct rfd_ext *ext = (struct rfd_ext *) ext_ptr; 723 724 bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd); 725 726#ifdef TEST 727 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 728 abort(); 729#endif 730} 731 732/* Swap in an optimization symbol. */ 733 734static void 735ecoff_swap_opt_in (abfd, ext_copy, intern) 736 bfd *abfd; 737 PTR ext_copy; 738 OPTR *intern; 739{ 740 struct opt_ext ext[1]; 741 742 *ext = *(struct opt_ext *) ext_copy; 743 744 if (bfd_header_big_endian (abfd)) 745 { 746 intern->ot = ext->o_bits1[0]; 747 intern->value = (((unsigned int) ext->o_bits2[0] 748 << OPT_BITS2_VALUE_SH_LEFT_BIG) 749 | ((unsigned int) ext->o_bits3[0] 750 << OPT_BITS2_VALUE_SH_LEFT_BIG) 751 | ((unsigned int) ext->o_bits4[0] 752 << OPT_BITS2_VALUE_SH_LEFT_BIG)); 753 } 754 else 755 { 756 intern->ot = ext->o_bits1[0]; 757 intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE) 758 | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE) 759 | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)); 760 } 761 762 _bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd), 763 &ext->o_rndx, &intern->rndx); 764 765 intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset); 766 767#ifdef TEST 768 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 769 abort(); 770#endif 771} 772 773/* Swap out an optimization symbol. */ 774 775static void 776ecoff_swap_opt_out (abfd, intern_copy, ext_ptr) 777 bfd *abfd; 778 const OPTR *intern_copy; 779 PTR ext_ptr; 780{ 781 struct opt_ext *ext = (struct opt_ext *) ext_ptr; 782 OPTR intern[1]; 783 784 *intern = *intern_copy; /* Make it reasonable to do in-place. */ 785 786 if (bfd_header_big_endian (abfd)) 787 { 788 ext->o_bits1[0] = intern->ot; 789 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG; 790 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG; 791 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG; 792 } 793 else 794 { 795 ext->o_bits1[0] = intern->ot; 796 ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE; 797 ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE; 798 ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE; 799 } 800 801 _bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd), 802 &intern->rndx, &ext->o_rndx); 803 804 bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset); 805 806#ifdef TEST 807 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 808 abort(); 809#endif 810} 811 812/* Swap in a dense number. */ 813 814static void 815ecoff_swap_dnr_in (abfd, ext_copy, intern) 816 bfd *abfd; 817 PTR ext_copy; 818 DNR *intern; 819{ 820 struct dnr_ext ext[1]; 821 822 *ext = *(struct dnr_ext *) ext_copy; 823 824 intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd); 825 intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index); 826 827#ifdef TEST 828 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 829 abort(); 830#endif 831} 832 833/* Swap out a dense number. */ 834 835static void 836ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr) 837 bfd *abfd; 838 const DNR *intern_copy; 839 PTR ext_ptr; 840{ 841 struct dnr_ext *ext = (struct dnr_ext *) ext_ptr; 842 DNR intern[1]; 843 844 *intern = *intern_copy; /* Make it reasonable to do in-place. */ 845 846 bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd); 847 bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index); 848 849#ifdef TEST 850 if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) 851 abort(); 852#endif 853} 854