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