00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef GET_FCN_LNNOPTR
00032 #define GET_FCN_LNNOPTR(abfd, ext) \
00033 H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
00034 #endif
00035
00036 #ifndef GET_FCN_ENDNDX
00037 #define GET_FCN_ENDNDX(abfd, ext) \
00038 H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx)
00039 #endif
00040
00041 #ifndef PUT_FCN_LNNOPTR
00042 #define PUT_FCN_LNNOPTR(abfd, in, ext) \
00043 H_PUT_32 (abfd, in, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
00044 #endif
00045 #ifndef PUT_FCN_ENDNDX
00046 #define PUT_FCN_ENDNDX(abfd, in, ext) \
00047 H_PUT_32 (abfd, in, ext->x_sym.x_fcnary.x_fcn.x_endndx)
00048 #endif
00049 #ifndef GET_LNSZ_LNNO
00050 #define GET_LNSZ_LNNO(abfd, ext) \
00051 H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_lnno)
00052 #endif
00053 #ifndef GET_LNSZ_SIZE
00054 #define GET_LNSZ_SIZE(abfd, ext) \
00055 H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size)
00056 #endif
00057 #ifndef PUT_LNSZ_LNNO
00058 #define PUT_LNSZ_LNNO(abfd, in, ext) \
00059 H_PUT_16 (abfd, in, ext->x_sym.x_misc.x_lnsz.x_lnno)
00060 #endif
00061 #ifndef PUT_LNSZ_SIZE
00062 #define PUT_LNSZ_SIZE(abfd, in, ext) \
00063 H_PUT_16 (abfd, in, ext->x_sym.x_misc.x_lnsz.x_size)
00064 #endif
00065 #ifndef GET_SCN_SCNLEN
00066 #define GET_SCN_SCNLEN(abfd, ext) \
00067 H_GET_32 (abfd, ext->x_scn.x_scnlen)
00068 #endif
00069 #ifndef GET_SCN_NRELOC
00070 #define GET_SCN_NRELOC(abfd, ext) \
00071 H_GET_16 (abfd, ext->x_scn.x_nreloc)
00072 #endif
00073 #ifndef GET_SCN_NLINNO
00074 #define GET_SCN_NLINNO(abfd, ext) \
00075 H_GET_16 (abfd, ext->x_scn.x_nlinno)
00076 #endif
00077 #ifndef PUT_SCN_SCNLEN
00078 #define PUT_SCN_SCNLEN(abfd, in, ext) \
00079 H_PUT_32 (abfd, in, ext->x_scn.x_scnlen)
00080 #endif
00081 #ifndef PUT_SCN_NRELOC
00082 #define PUT_SCN_NRELOC(abfd, in, ext) \
00083 H_PUT_16 (abfd, in, ext->x_scn.x_nreloc)
00084 #endif
00085 #ifndef PUT_SCN_NLINNO
00086 #define PUT_SCN_NLINNO(abfd, in, ext) \
00087 H_PUT_16 (abfd, in, ext->x_scn.x_nlinno)
00088 #endif
00089 #ifndef GET_LINENO_LNNO
00090 #define GET_LINENO_LNNO(abfd, ext) \
00091 H_GET_16 (abfd, ext->l_lnno);
00092 #endif
00093 #ifndef PUT_LINENO_LNNO
00094 #define PUT_LINENO_LNNO(abfd, val, ext) \
00095 H_PUT_16 (abfd, val, ext->l_lnno);
00096 #endif
00097
00098
00099 #ifndef GET_FILEHDR_SYMPTR
00100 #define GET_FILEHDR_SYMPTR H_GET_32
00101 #endif
00102 #ifndef PUT_FILEHDR_SYMPTR
00103 #define PUT_FILEHDR_SYMPTR H_PUT_32
00104 #endif
00105
00106
00107 #ifndef GET_AOUTHDR_TSIZE
00108 #define GET_AOUTHDR_TSIZE H_GET_32
00109 #endif
00110 #ifndef PUT_AOUTHDR_TSIZE
00111 #define PUT_AOUTHDR_TSIZE H_PUT_32
00112 #endif
00113 #ifndef GET_AOUTHDR_DSIZE
00114 #define GET_AOUTHDR_DSIZE H_GET_32
00115 #endif
00116 #ifndef PUT_AOUTHDR_DSIZE
00117 #define PUT_AOUTHDR_DSIZE H_PUT_32
00118 #endif
00119 #ifndef GET_AOUTHDR_BSIZE
00120 #define GET_AOUTHDR_BSIZE H_GET_32
00121 #endif
00122 #ifndef PUT_AOUTHDR_BSIZE
00123 #define PUT_AOUTHDR_BSIZE H_PUT_32
00124 #endif
00125 #ifndef GET_AOUTHDR_ENTRY
00126 #define GET_AOUTHDR_ENTRY H_GET_32
00127 #endif
00128 #ifndef PUT_AOUTHDR_ENTRY
00129 #define PUT_AOUTHDR_ENTRY H_PUT_32
00130 #endif
00131 #ifndef GET_AOUTHDR_TEXT_START
00132 #define GET_AOUTHDR_TEXT_START H_GET_32
00133 #endif
00134 #ifndef PUT_AOUTHDR_TEXT_START
00135 #define PUT_AOUTHDR_TEXT_START H_PUT_32
00136 #endif
00137 #ifndef GET_AOUTHDR_DATA_START
00138 #define GET_AOUTHDR_DATA_START H_GET_32
00139 #endif
00140 #ifndef PUT_AOUTHDR_DATA_START
00141 #define PUT_AOUTHDR_DATA_START H_PUT_32
00142 #endif
00143
00144
00145 #ifndef GET_SCNHDR_PADDR
00146 #define GET_SCNHDR_PADDR H_GET_32
00147 #endif
00148 #ifndef PUT_SCNHDR_PADDR
00149 #define PUT_SCNHDR_PADDR H_PUT_32
00150 #endif
00151 #ifndef GET_SCNHDR_VADDR
00152 #define GET_SCNHDR_VADDR H_GET_32
00153 #endif
00154 #ifndef PUT_SCNHDR_VADDR
00155 #define PUT_SCNHDR_VADDR H_PUT_32
00156 #endif
00157 #ifndef GET_SCNHDR_SIZE
00158 #define GET_SCNHDR_SIZE H_GET_32
00159 #endif
00160 #ifndef PUT_SCNHDR_SIZE
00161 #define PUT_SCNHDR_SIZE H_PUT_32
00162 #endif
00163 #ifndef GET_SCNHDR_SCNPTR
00164 #define GET_SCNHDR_SCNPTR H_GET_32
00165 #endif
00166 #ifndef PUT_SCNHDR_SCNPTR
00167 #define PUT_SCNHDR_SCNPTR H_PUT_32
00168 #endif
00169 #ifndef GET_SCNHDR_RELPTR
00170 #define GET_SCNHDR_RELPTR H_GET_32
00171 #endif
00172 #ifndef PUT_SCNHDR_RELPTR
00173 #define PUT_SCNHDR_RELPTR H_PUT_32
00174 #endif
00175 #ifndef GET_SCNHDR_LNNOPTR
00176 #define GET_SCNHDR_LNNOPTR H_GET_32
00177 #endif
00178 #ifndef PUT_SCNHDR_LNNOPTR
00179 #define PUT_SCNHDR_LNNOPTR H_PUT_32
00180 #endif
00181 #ifndef GET_SCNHDR_NRELOC
00182 #define GET_SCNHDR_NRELOC H_GET_16
00183 #endif
00184 #ifndef MAX_SCNHDR_NRELOC
00185 #define MAX_SCNHDR_NRELOC 0xffff
00186 #endif
00187 #ifndef PUT_SCNHDR_NRELOC
00188 #define PUT_SCNHDR_NRELOC H_PUT_16
00189 #endif
00190 #ifndef GET_SCNHDR_NLNNO
00191 #define GET_SCNHDR_NLNNO H_GET_16
00192 #endif
00193 #ifndef MAX_SCNHDR_NLNNO
00194 #define MAX_SCNHDR_NLNNO 0xffff
00195 #endif
00196 #ifndef PUT_SCNHDR_NLNNO
00197 #define PUT_SCNHDR_NLNNO H_PUT_16
00198 #endif
00199 #ifndef GET_SCNHDR_FLAGS
00200 #define GET_SCNHDR_FLAGS H_GET_32
00201 #endif
00202 #ifndef PUT_SCNHDR_FLAGS
00203 #define PUT_SCNHDR_FLAGS H_PUT_32
00204 #endif
00205
00206 #ifndef GET_RELOC_VADDR
00207 #define GET_RELOC_VADDR H_GET_32
00208 #endif
00209 #ifndef PUT_RELOC_VADDR
00210 #define PUT_RELOC_VADDR H_PUT_32
00211 #endif
00212
00213 static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
00214 static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
00215 static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
00216 static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
00217 static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
00218 static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR));
00219 #ifndef NO_COFF_RELOCS
00220 static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
00221 static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
00222 #endif
00223 #ifndef NO_COFF_SYMBOLS
00224 static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
00225 static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
00226 static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
00227 static unsigned int coff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
00228 #endif
00229 #ifndef NO_COFF_LINENOS
00230 static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
00231 static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
00232 #endif
00233
00234 #ifndef NO_COFF_RELOCS
00235
00236 static void
00237 coff_swap_reloc_in (abfd, src, dst)
00238 bfd *abfd;
00239 PTR src;
00240 PTR dst;
00241 {
00242 RELOC *reloc_src = (RELOC *) src;
00243 struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
00244
00245 reloc_dst->r_vaddr = GET_RELOC_VADDR (abfd, reloc_src->r_vaddr);
00246 reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx);
00247 reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type);
00248
00249 #ifdef SWAP_IN_RELOC_OFFSET
00250 reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset);
00251 #endif
00252 }
00253
00254 static unsigned int
00255 coff_swap_reloc_out (abfd, src, dst)
00256 bfd *abfd;
00257 PTR src;
00258 PTR dst;
00259 {
00260 struct internal_reloc *reloc_src = (struct internal_reloc *) src;
00261 struct external_reloc *reloc_dst = (struct external_reloc *) dst;
00262 PUT_RELOC_VADDR (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
00263 H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
00264 H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);
00265
00266 #ifdef SWAP_OUT_RELOC_OFFSET
00267 SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset);
00268 #endif
00269 #ifdef SWAP_OUT_RELOC_EXTRA
00270 SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst);
00271 #endif
00272
00273 return bfd_coff_relsz (abfd);
00274 }
00275
00276 #endif
00277
00278 static void
00279 coff_swap_filehdr_in (abfd, src, dst)
00280 bfd *abfd;
00281 PTR src;
00282 PTR dst;
00283 {
00284 FILHDR *filehdr_src = (FILHDR *) src;
00285 struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
00286
00287 #ifdef COFF_ADJUST_FILEHDR_IN_PRE
00288 COFF_ADJUST_FILEHDR_IN_PRE (abfd, src, dst);
00289 #endif
00290 filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic);
00291 filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns);
00292 filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat);
00293 filehdr_dst->f_symptr = GET_FILEHDR_SYMPTR (abfd, filehdr_src->f_symptr);
00294 filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms);
00295 filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src->f_opthdr);
00296 filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags);
00297 #ifdef TIC80_TARGET_ID
00298 filehdr_dst->f_target_id = H_GET_16 (abfd, filehdr_src->f_target_id);
00299 #endif
00300
00301 #ifdef COFF_ADJUST_FILEHDR_IN_POST
00302 COFF_ADJUST_FILEHDR_IN_POST (abfd, src, dst);
00303 #endif
00304 }
00305
00306 static unsigned int
00307 coff_swap_filehdr_out (abfd, in, out)
00308 bfd *abfd;
00309 PTR in;
00310 PTR out;
00311 {
00312 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
00313 FILHDR *filehdr_out = (FILHDR *) out;
00314
00315 #ifdef COFF_ADJUST_FILEHDR_OUT_PRE
00316 COFF_ADJUST_FILEHDR_OUT_PRE (abfd, in, out);
00317 #endif
00318 H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
00319 H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
00320 H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
00321 PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
00322 H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
00323 H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
00324 H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
00325 #ifdef TIC80_TARGET_ID
00326 H_PUT_16 (abfd, filehdr_in->f_target_id, filehdr_out->f_target_id);
00327 #endif
00328
00329 #ifdef COFF_ADJUST_FILEHDR_OUT_POST
00330 COFF_ADJUST_FILEHDR_OUT_POST (abfd, in, out);
00331 #endif
00332 return bfd_coff_filhsz (abfd);
00333 }
00334
00335 #ifndef NO_COFF_SYMBOLS
00336
00337 static void
00338 coff_swap_sym_in (abfd, ext1, in1)
00339 bfd *abfd;
00340 PTR ext1;
00341 PTR in1;
00342 {
00343 SYMENT *ext = (SYMENT *) ext1;
00344 struct internal_syment *in = (struct internal_syment *) in1;
00345
00346 if (ext->e.e_name[0] == 0)
00347 {
00348 in->_n._n_n._n_zeroes = 0;
00349 in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
00350 }
00351 else
00352 {
00353 #if SYMNMLEN != E_SYMNMLEN
00354 -> Error, we need to cope with truncating or extending SYMNMLEN!;
00355 #else
00356 memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
00357 #endif
00358 }
00359 in->n_value = H_GET_32 (abfd, ext->e_value);
00360 in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
00361 if (sizeof (ext->e_type) == 2)
00362 {
00363 in->n_type = H_GET_16 (abfd, ext->e_type);
00364 }
00365 else
00366 {
00367 in->n_type = H_GET_32 (abfd, ext->e_type);
00368 }
00369 in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
00370 in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
00371 #ifdef COFF_ADJUST_SYM_IN_POST
00372 COFF_ADJUST_SYM_IN_POST (abfd, ext1, in1);
00373 #endif
00374 }
00375
00376 static unsigned int
00377 coff_swap_sym_out (abfd, inp, extp)
00378 bfd *abfd;
00379 PTR inp;
00380 PTR extp;
00381 {
00382 struct internal_syment *in = (struct internal_syment *) inp;
00383 SYMENT *ext =(SYMENT *) extp;
00384
00385 #ifdef COFF_ADJUST_SYM_OUT_PRE
00386 COFF_ADJUST_SYM_OUT_PRE (abfd, inp, extp);
00387 #endif
00388
00389 if (in->_n._n_name[0] == 0)
00390 {
00391 H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
00392 H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
00393 }
00394 else
00395 {
00396 #if SYMNMLEN != E_SYMNMLEN
00397 -> Error, we need to cope with truncating or extending SYMNMLEN!;
00398 #else
00399 memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
00400 #endif
00401 }
00402
00403 H_PUT_32 (abfd, in->n_value, ext->e_value);
00404 H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
00405
00406 if (sizeof (ext->e_type) == 2)
00407 {
00408 H_PUT_16 (abfd, in->n_type, ext->e_type);
00409 }
00410 else
00411 {
00412 H_PUT_32 (abfd, in->n_type, ext->e_type);
00413 }
00414
00415 H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
00416 H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
00417
00418 #ifdef COFF_ADJUST_SYM_OUT_POST
00419 COFF_ADJUST_SYM_OUT_POST (abfd, inp, extp);
00420 #endif
00421
00422 return SYMESZ;
00423 }
00424
00425 static void
00426 coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
00427 bfd *abfd;
00428 PTR ext1;
00429 int type;
00430 int class;
00431 int indx;
00432 int numaux;
00433 PTR in1;
00434 {
00435 AUXENT *ext = (AUXENT *) ext1;
00436 union internal_auxent *in = (union internal_auxent *) in1;
00437
00438 #ifdef COFF_ADJUST_AUX_IN_PRE
00439 COFF_ADJUST_AUX_IN_PRE (abfd, ext1, type, class, indx, numaux, in1);
00440 #endif
00441
00442 switch (class)
00443 {
00444 case C_FILE:
00445 if (ext->x_file.x_fname[0] == 0)
00446 {
00447 in->x_file.x_n.x_zeroes = 0;
00448 in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
00449 }
00450 else
00451 {
00452 #if FILNMLEN != E_FILNMLEN
00453 -> Error, we need to cope with truncating or extending FILNMLEN!;
00454 #else
00455 if (numaux > 1)
00456 {
00457 if (indx == 0)
00458 memcpy (in->x_file.x_fname, ext->x_file.x_fname,
00459 numaux * sizeof (AUXENT));
00460 }
00461 else
00462 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
00463 #endif
00464 }
00465 goto end;
00466
00467 case C_STAT:
00468 #ifdef C_LEAFSTAT
00469 case C_LEAFSTAT:
00470 #endif
00471 case C_HIDDEN:
00472 if (type == T_NULL)
00473 {
00474 in->x_scn.x_scnlen = GET_SCN_SCNLEN (abfd, ext);
00475 in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext);
00476 in->x_scn.x_nlinno = GET_SCN_NLINNO (abfd, ext);
00477
00478
00479
00480 in->x_scn.x_checksum = 0;
00481 in->x_scn.x_associated = 0;
00482 in->x_scn.x_comdat = 0;
00483
00484 goto end;
00485 }
00486 break;
00487 }
00488
00489 in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
00490 #ifndef NO_TVNDX
00491 in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
00492 #endif
00493
00494 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
00495 {
00496 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
00497 in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
00498 }
00499 else
00500 {
00501 #if DIMNUM != E_DIMNUM
00502 #error we need to cope with truncating or extending DIMNUM
00503 #endif
00504 in->x_sym.x_fcnary.x_ary.x_dimen[0] =
00505 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
00506 in->x_sym.x_fcnary.x_ary.x_dimen[1] =
00507 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
00508 in->x_sym.x_fcnary.x_ary.x_dimen[2] =
00509 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
00510 in->x_sym.x_fcnary.x_ary.x_dimen[3] =
00511 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
00512 }
00513
00514 if (ISFCN (type))
00515 {
00516 in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize);
00517 }
00518 else
00519 {
00520 in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO (abfd, ext);
00521 in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE (abfd, ext);
00522 }
00523
00524 end: ;
00525
00526 #ifdef COFF_ADJUST_AUX_IN_POST
00527 COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1);
00528 #endif
00529 }
00530
00531 static unsigned int
00532 coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
00533 bfd *abfd;
00534 PTR inp;
00535 int type;
00536 int class;
00537 int indx ATTRIBUTE_UNUSED;
00538 int numaux ATTRIBUTE_UNUSED;
00539 PTR extp;
00540 {
00541 union internal_auxent *in = (union internal_auxent *) inp;
00542 AUXENT *ext = (AUXENT *) extp;
00543
00544 #ifdef COFF_ADJUST_AUX_OUT_PRE
00545 COFF_ADJUST_AUX_OUT_PRE (abfd, inp, type, class, indx, numaux, extp);
00546 #endif
00547
00548 memset ((PTR)ext, 0, AUXESZ);
00549
00550 switch (class)
00551 {
00552 case C_FILE:
00553 if (in->x_file.x_fname[0] == 0)
00554 {
00555 H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
00556 H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
00557 }
00558 else
00559 {
00560 #if FILNMLEN != E_FILNMLEN
00561 -> Error, we need to cope with truncating or extending FILNMLEN!;
00562 #else
00563 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
00564 #endif
00565 }
00566 goto end;
00567
00568 case C_STAT:
00569 #ifdef C_LEAFSTAT
00570 case C_LEAFSTAT:
00571 #endif
00572 case C_HIDDEN:
00573 if (type == T_NULL)
00574 {
00575 PUT_SCN_SCNLEN (abfd, in->x_scn.x_scnlen, ext);
00576 PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext);
00577 PUT_SCN_NLINNO (abfd, in->x_scn.x_nlinno, ext);
00578 goto end;
00579 }
00580 break;
00581 }
00582
00583 H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
00584 #ifndef NO_TVNDX
00585 H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
00586 #endif
00587
00588 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
00589 {
00590 PUT_FCN_LNNOPTR (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
00591 PUT_FCN_ENDNDX (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
00592 }
00593 else
00594 {
00595 #if DIMNUM != E_DIMNUM
00596 #error we need to cope with truncating or extending DIMNUM
00597 #endif
00598 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
00599 ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
00600 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
00601 ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
00602 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
00603 ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
00604 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
00605 ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
00606 }
00607
00608 if (ISFCN (type))
00609 H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
00610 else
00611 {
00612 PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
00613 PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
00614 }
00615
00616 end:
00617 #ifdef COFF_ADJUST_AUX_OUT_POST
00618 COFF_ADJUST_AUX_OUT_POST (abfd, inp, type, class, indx, numaux, extp);
00619 #endif
00620 return AUXESZ;
00621 }
00622
00623 #endif
00624
00625 #ifndef NO_COFF_LINENOS
00626
00627 static void
00628 coff_swap_lineno_in (abfd, ext1, in1)
00629 bfd *abfd;
00630 PTR ext1;
00631 PTR in1;
00632 {
00633 LINENO *ext = (LINENO *) ext1;
00634 struct internal_lineno *in = (struct internal_lineno *) in1;
00635
00636 in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
00637 in->l_lnno = GET_LINENO_LNNO (abfd, ext);
00638 }
00639
00640 static unsigned int
00641 coff_swap_lineno_out (abfd, inp, outp)
00642 bfd *abfd;
00643 PTR inp;
00644 PTR outp;
00645 {
00646 struct internal_lineno *in = (struct internal_lineno *) inp;
00647 struct external_lineno *ext = (struct external_lineno *) outp;
00648 H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
00649
00650 PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
00651 return LINESZ;
00652 }
00653
00654 #endif
00655
00656 static void
00657 coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
00658 bfd *abfd;
00659 PTR aouthdr_ext1;
00660 PTR aouthdr_int1;
00661 {
00662 AOUTHDR *aouthdr_ext;
00663 struct internal_aouthdr *aouthdr_int;
00664
00665 aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
00666 aouthdr_int = (struct internal_aouthdr *) aouthdr_int1;
00667 aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic);
00668 aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp);
00669 aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize);
00670 aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize);
00671 aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize);
00672 aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry);
00673 aouthdr_int->text_start =
00674 GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start);
00675 aouthdr_int->data_start =
00676 GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start);
00677
00678 #ifdef I960
00679 aouthdr_int->tagentries = H_GET_32 (abfd, aouthdr_ext->tagentries);
00680 #endif
00681
00682 #ifdef APOLLO_M68
00683 H_PUT_32 (abfd, aouthdr_int->o_inlib, aouthdr_ext->o_inlib);
00684 H_PUT_32 (abfd, aouthdr_int->o_sri, aouthdr_ext->o_sri);
00685 H_PUT_32 (abfd, aouthdr_int->vid[0], aouthdr_ext->vid);
00686 H_PUT_32 (abfd, aouthdr_int->vid[1], aouthdr_ext->vid + 4);
00687 #endif
00688
00689 #ifdef RS6000COFF_C
00690 #ifdef XCOFF64
00691 aouthdr_int->o_toc = H_GET_64 (abfd, aouthdr_ext->o_toc);
00692 #else
00693 aouthdr_int->o_toc = H_GET_32 (abfd, aouthdr_ext->o_toc);
00694 #endif
00695 aouthdr_int->o_snentry = H_GET_16 (abfd, aouthdr_ext->o_snentry);
00696 aouthdr_int->o_sntext = H_GET_16 (abfd, aouthdr_ext->o_sntext);
00697 aouthdr_int->o_sndata = H_GET_16 (abfd, aouthdr_ext->o_sndata);
00698 aouthdr_int->o_sntoc = H_GET_16 (abfd, aouthdr_ext->o_sntoc);
00699 aouthdr_int->o_snloader = H_GET_16 (abfd, aouthdr_ext->o_snloader);
00700 aouthdr_int->o_snbss = H_GET_16 (abfd, aouthdr_ext->o_snbss);
00701 aouthdr_int->o_algntext = H_GET_16 (abfd, aouthdr_ext->o_algntext);
00702 aouthdr_int->o_algndata = H_GET_16 (abfd, aouthdr_ext->o_algndata);
00703 aouthdr_int->o_modtype = H_GET_16 (abfd, aouthdr_ext->o_modtype);
00704 aouthdr_int->o_cputype = H_GET_16 (abfd, aouthdr_ext->o_cputype);
00705 #ifdef XCOFF64
00706 aouthdr_int->o_maxstack = H_GET_64 (abfd, aouthdr_ext->o_maxstack);
00707 aouthdr_int->o_maxdata = H_GET_64 (abfd, aouthdr_ext->o_maxdata);
00708 #else
00709 aouthdr_int->o_maxstack = H_GET_32 (abfd, aouthdr_ext->o_maxstack);
00710 aouthdr_int->o_maxdata = H_GET_32 (abfd, aouthdr_ext->o_maxdata);
00711 #endif
00712 #endif
00713
00714 #ifdef MIPSECOFF
00715 aouthdr_int->bss_start = H_GET_32 (abfd, aouthdr_ext->bss_start);
00716 aouthdr_int->gp_value = H_GET_32 (abfd, aouthdr_ext->gp_value);
00717 aouthdr_int->gprmask = H_GET_32 (abfd, aouthdr_ext->gprmask);
00718 aouthdr_int->cprmask[0] = H_GET_32 (abfd, aouthdr_ext->cprmask[0]);
00719 aouthdr_int->cprmask[1] = H_GET_32 (abfd, aouthdr_ext->cprmask[1]);
00720 aouthdr_int->cprmask[2] = H_GET_32 (abfd, aouthdr_ext->cprmask[2]);
00721 aouthdr_int->cprmask[3] = H_GET_32 (abfd, aouthdr_ext->cprmask[3]);
00722 #endif
00723
00724 #ifdef ALPHAECOFF
00725 aouthdr_int->bss_start = H_GET_64 (abfd, aouthdr_ext->bss_start);
00726 aouthdr_int->gp_value = H_GET_64 (abfd, aouthdr_ext->gp_value);
00727 aouthdr_int->gprmask = H_GET_32 (abfd, aouthdr_ext->gprmask);
00728 aouthdr_int->fprmask = H_GET_32 (abfd, aouthdr_ext->fprmask);
00729 #endif
00730 }
00731
00732 static unsigned int
00733 coff_swap_aouthdr_out (abfd, in, out)
00734 bfd *abfd;
00735 PTR in;
00736 PTR out;
00737 {
00738 struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *) in;
00739 AOUTHDR *aouthdr_out = (AOUTHDR *) out;
00740
00741 H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->magic);
00742 H_PUT_16 (abfd, aouthdr_in->vstamp, aouthdr_out->vstamp);
00743 PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->tsize);
00744 PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->dsize);
00745 PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->bsize);
00746 PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->entry);
00747 PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
00748 aouthdr_out->text_start);
00749 PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
00750 aouthdr_out->data_start);
00751
00752 #ifdef I960
00753 H_PUT_32 (abfd, aouthdr_in->tagentries, aouthdr_out->tagentries);
00754 #endif
00755
00756 #ifdef RS6000COFF_C
00757 #ifdef XCOFF64
00758 H_PUT_64 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
00759 #else
00760 H_PUT_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
00761 #endif
00762 H_PUT_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
00763 H_PUT_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
00764 H_PUT_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
00765 H_PUT_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
00766 H_PUT_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
00767 H_PUT_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
00768 H_PUT_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
00769 H_PUT_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
00770 H_PUT_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
00771 H_PUT_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
00772 #ifdef XCOFF64
00773 H_PUT_64 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
00774 H_PUT_64 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
00775 #else
00776 H_PUT_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
00777 H_PUT_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
00778 #endif
00779 memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
00780 #ifdef XCOFF64
00781 memset (aouthdr_out->o_debugger, 0, sizeof aouthdr_out->o_debugger);
00782 memset (aouthdr_out->o_resv3, 0, sizeof aouthdr_out->o_resv3);
00783 #endif
00784 #endif
00785
00786 #ifdef MIPSECOFF
00787 H_PUT_32 (abfd, aouthdr_in->bss_start, aouthdr_out->bss_start);
00788 H_PUT_32 (abfd, aouthdr_in->gp_value, aouthdr_out->gp_value);
00789 H_PUT_32 (abfd, aouthdr_in->gprmask, aouthdr_out->gprmask);
00790 H_PUT_32 (abfd, aouthdr_in->cprmask[0], aouthdr_out->cprmask[0]);
00791 H_PUT_32 (abfd, aouthdr_in->cprmask[1], aouthdr_out->cprmask[1]);
00792 H_PUT_32 (abfd, aouthdr_in->cprmask[2], aouthdr_out->cprmask[2]);
00793 H_PUT_32 (abfd, aouthdr_in->cprmask[3], aouthdr_out->cprmask[3]);
00794 #endif
00795
00796 #ifdef ALPHAECOFF
00797
00798 H_PUT_16 (abfd, 2, aouthdr_out->bldrev);
00799 H_PUT_16 (abfd, 0, aouthdr_out->padding);
00800 H_PUT_64 (abfd, aouthdr_in->bss_start, aouthdr_out->bss_start);
00801 H_PUT_64 (abfd, aouthdr_in->gp_value, aouthdr_out->gp_value);
00802 H_PUT_32 (abfd, aouthdr_in->gprmask, aouthdr_out->gprmask);
00803 H_PUT_32 (abfd, aouthdr_in->fprmask, aouthdr_out->fprmask);
00804 #endif
00805
00806 return AOUTSZ;
00807 }
00808
00809 static void
00810 coff_swap_scnhdr_in (abfd, ext, in)
00811 bfd *abfd;
00812 PTR ext;
00813 PTR in;
00814 {
00815 SCNHDR *scnhdr_ext = (SCNHDR *) ext;
00816 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
00817
00818 #ifdef COFF_ADJUST_SCNHDR_IN_PRE
00819 COFF_ADJUST_SCNHDR_IN_PRE (abfd, ext, in);
00820 #endif
00821 memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name));
00822
00823 scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr);
00824 scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr);
00825 scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size);
00826
00827 scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr);
00828 scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr);
00829 scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr);
00830 scnhdr_int->s_flags = GET_SCNHDR_FLAGS (abfd, scnhdr_ext->s_flags);
00831 scnhdr_int->s_nreloc = GET_SCNHDR_NRELOC (abfd, scnhdr_ext->s_nreloc);
00832 scnhdr_int->s_nlnno = GET_SCNHDR_NLNNO (abfd, scnhdr_ext->s_nlnno);
00833 #ifdef I960
00834 scnhdr_int->s_align = GET_SCNHDR_ALIGN (abfd, scnhdr_ext->s_align);
00835 #endif
00836 #ifdef COFF_ADJUST_SCNHDR_IN_POST
00837 COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
00838 #endif
00839 }
00840
00841 static unsigned int
00842 coff_swap_scnhdr_out (abfd, in, out)
00843 bfd *abfd;
00844 PTR in;
00845 PTR out;
00846 {
00847 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
00848 SCNHDR *scnhdr_ext = (SCNHDR *) out;
00849 unsigned int ret = bfd_coff_scnhsz (abfd);
00850
00851 #ifdef COFF_ADJUST_SCNHDR_OUT_PRE
00852 COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out);
00853 #endif
00854 memcpy (scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
00855
00856 PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr);
00857 PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr);
00858 PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size, scnhdr_ext->s_size);
00859 PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr);
00860 PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr);
00861 PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr);
00862 PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
00863 #if defined(M88)
00864 H_PUT_32 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
00865 H_PUT_32 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
00866 #else
00867 if (scnhdr_int->s_nlnno <= MAX_SCNHDR_NLNNO)
00868 PUT_SCNHDR_NLNNO (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
00869 else
00870 {
00871 char buf[sizeof (scnhdr_int->s_name) + 1];
00872
00873 memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
00874 buf[sizeof (scnhdr_int->s_name)] = '\0';
00875 (*_bfd_error_handler)
00876 (_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
00877 bfd_get_filename (abfd),
00878 buf, scnhdr_int->s_nlnno);
00879 PUT_SCNHDR_NLNNO (abfd, 0xffff, scnhdr_ext->s_nlnno);
00880 }
00881
00882 if (scnhdr_int->s_nreloc <= MAX_SCNHDR_NRELOC)
00883 PUT_SCNHDR_NRELOC (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
00884 else
00885 {
00886 char buf[sizeof (scnhdr_int->s_name) + 1];
00887
00888 memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
00889 buf[sizeof (scnhdr_int->s_name)] = '\0';
00890 (*_bfd_error_handler) (_("%s: %s: reloc overflow: 0x%lx > 0xffff"),
00891 bfd_get_filename (abfd),
00892 buf, scnhdr_int->s_nreloc);
00893 bfd_set_error (bfd_error_file_truncated);
00894 PUT_SCNHDR_NRELOC (abfd, 0xffff, scnhdr_ext->s_nreloc);
00895 ret = 0;
00896 }
00897 #endif
00898
00899 #ifdef I960
00900 PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, scnhdr_ext->s_align);
00901 #endif
00902 #ifdef COFF_ADJUST_SCNHDR_OUT_POST
00903 COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
00904 #endif
00905 return ret;
00906 }