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 #include "bfd.h"
00028 #include "sysdep.h"
00029 #include "bfdlink.h"
00030 #include "libbfd.h"
00031 #include "coff/internal.h"
00032 #include "coff/xcoff.h"
00033 #include "coff/rs6k64.h"
00034 #include "libcoff.h"
00035 #include "libxcoff.h"
00036
00037 #define GET_FILEHDR_SYMPTR H_GET_64
00038 #define PUT_FILEHDR_SYMPTR H_PUT_64
00039 #define GET_AOUTHDR_DATA_START H_GET_64
00040 #define PUT_AOUTHDR_DATA_START H_PUT_64
00041 #define GET_AOUTHDR_TEXT_START H_GET_64
00042 #define PUT_AOUTHDR_TEXT_START H_PUT_64
00043 #define GET_AOUTHDR_TSIZE H_GET_64
00044 #define PUT_AOUTHDR_TSIZE H_PUT_64
00045 #define GET_AOUTHDR_DSIZE H_GET_64
00046 #define PUT_AOUTHDR_DSIZE H_PUT_64
00047 #define GET_AOUTHDR_BSIZE H_GET_64
00048 #define PUT_AOUTHDR_BSIZE H_PUT_64
00049 #define GET_AOUTHDR_ENTRY H_GET_64
00050 #define PUT_AOUTHDR_ENTRY H_PUT_64
00051 #define GET_SCNHDR_PADDR H_GET_64
00052 #define PUT_SCNHDR_PADDR H_PUT_64
00053 #define GET_SCNHDR_VADDR H_GET_64
00054 #define PUT_SCNHDR_VADDR H_PUT_64
00055 #define GET_SCNHDR_SIZE H_GET_64
00056 #define PUT_SCNHDR_SIZE H_PUT_64
00057 #define GET_SCNHDR_SCNPTR H_GET_64
00058 #define PUT_SCNHDR_SCNPTR H_PUT_64
00059 #define GET_SCNHDR_RELPTR H_GET_64
00060 #define PUT_SCNHDR_RELPTR H_PUT_64
00061 #define GET_SCNHDR_LNNOPTR H_GET_64
00062 #define PUT_SCNHDR_LNNOPTR H_PUT_64
00063 #define GET_SCNHDR_NRELOC H_GET_32
00064 #define MAX_SCNHDR_NRELOC 0xffffffff
00065 #define PUT_SCNHDR_NRELOC H_PUT_32
00066 #define GET_SCNHDR_NLNNO H_GET_32
00067 #define MAX_SCNHDR_NLNNO 0xffffffff
00068 #define PUT_SCNHDR_NLNNO H_PUT_32
00069 #define GET_RELOC_VADDR H_GET_64
00070 #define PUT_RELOC_VADDR H_PUT_64
00071
00072 #define COFF_FORCE_SYMBOLS_IN_STRINGS
00073 #define COFF_DEBUG_STRING_WIDE_PREFIX
00074
00075
00076 #define COFF_ADJUST_SCNHDR_OUT_POST(ABFD, INT, EXT) \
00077 do \
00078 { \
00079 memset (((SCNHDR *) EXT)->s_pad, 0, \
00080 sizeof (((SCNHDR *) EXT)->s_pad)); \
00081 } \
00082 while (0)
00083
00084 #define NO_COFF_LINENOS
00085
00086 #define coff_SWAP_lineno_in _bfd_xcoff64_swap_lineno_in
00087 #define coff_SWAP_lineno_out _bfd_xcoff64_swap_lineno_out
00088
00089 static void _bfd_xcoff64_swap_lineno_in
00090 PARAMS ((bfd *, PTR, PTR));
00091 static unsigned int _bfd_xcoff64_swap_lineno_out
00092 PARAMS ((bfd *, PTR, PTR));
00093 static bfd_boolean _bfd_xcoff64_put_symbol_name
00094 PARAMS ((bfd *, struct bfd_strtab_hash *, struct internal_syment *,
00095 const char *));
00096 static bfd_boolean _bfd_xcoff64_put_ldsymbol_name
00097 PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
00098 const char *));
00099 static void _bfd_xcoff64_swap_sym_in
00100 PARAMS ((bfd *, PTR, PTR));
00101 static unsigned int _bfd_xcoff64_swap_sym_out
00102 PARAMS ((bfd *, PTR, PTR));
00103 static void _bfd_xcoff64_swap_aux_in
00104 PARAMS ((bfd *, PTR, int, int, int, int, PTR));
00105 static unsigned int _bfd_xcoff64_swap_aux_out
00106 PARAMS ((bfd *, PTR, int, int, int, int, PTR));
00107 static void xcoff64_swap_reloc_in
00108 PARAMS ((bfd *, PTR, PTR));
00109 static unsigned int xcoff64_swap_reloc_out
00110 PARAMS ((bfd *, PTR, PTR));
00111 extern bfd_boolean _bfd_xcoff_mkobject
00112 PARAMS ((bfd *));
00113 extern bfd_boolean _bfd_xcoff_copy_private_bfd_data
00114 PARAMS ((bfd *, bfd *));
00115 extern bfd_boolean _bfd_xcoff_is_local_label_name
00116 PARAMS ((bfd *, const char *));
00117 extern void xcoff64_rtype2howto
00118 PARAMS ((arelent *, struct internal_reloc *));
00119 extern reloc_howto_type * xcoff64_reloc_type_lookup
00120 PARAMS ((bfd *, bfd_reloc_code_real_type));
00121 extern bfd_boolean _bfd_xcoff_slurp_armap
00122 PARAMS ((bfd *));
00123 extern PTR _bfd_xcoff_read_ar_hdr
00124 PARAMS ((bfd *));
00125 extern bfd *_bfd_xcoff_openr_next_archived_file
00126 PARAMS ((bfd *, bfd *));
00127 extern int _bfd_xcoff_stat_arch_elt
00128 PARAMS ((bfd *, struct stat *));
00129 extern bfd_boolean _bfd_xcoff_write_armap
00130 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
00131 extern bfd_boolean _bfd_xcoff_write_archive_contents
00132 PARAMS ((bfd *));
00133 extern int _bfd_xcoff_sizeof_headers
00134 PARAMS ((bfd *, bfd_boolean));
00135 extern void _bfd_xcoff_swap_sym_in
00136 PARAMS ((bfd *, PTR, PTR));
00137 extern unsigned int _bfd_xcoff_swap_sym_out
00138 PARAMS ((bfd *, PTR, PTR));
00139 extern void _bfd_xcoff_swap_aux_in
00140 PARAMS ((bfd *, PTR, int, int, int, int, PTR));
00141 extern unsigned int _bfd_xcoff_swap_aux_out
00142 PARAMS ((bfd *, PTR, int, int, int, int, PTR));
00143 static void xcoff64_swap_ldhdr_in
00144 PARAMS ((bfd *, const PTR, struct internal_ldhdr *));
00145 static void xcoff64_swap_ldhdr_out
00146 PARAMS ((bfd *, const struct internal_ldhdr *, PTR d));
00147 static void xcoff64_swap_ldsym_in
00148 PARAMS ((bfd *, const PTR, struct internal_ldsym *));
00149 static void xcoff64_swap_ldsym_out
00150 PARAMS ((bfd *, const struct internal_ldsym *, PTR d));
00151 static void xcoff64_swap_ldrel_in
00152 PARAMS ((bfd *, const PTR, struct internal_ldrel *));
00153 static void xcoff64_swap_ldrel_out
00154 PARAMS ((bfd *, const struct internal_ldrel *, PTR d));
00155 static bfd_boolean xcoff64_write_object_contents
00156 PARAMS ((bfd *));
00157 static bfd_boolean xcoff64_ppc_relocate_section
00158 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
00159 struct internal_reloc *, struct internal_syment *,
00160 asection **));
00161 static bfd_boolean xcoff64_slurp_armap
00162 PARAMS ((bfd *));
00163 static const bfd_target *xcoff64_archive_p
00164 PARAMS ((bfd *));
00165 static bfd *xcoff64_openr_next_archived_file
00166 PARAMS ((bfd *, bfd *));
00167 static int xcoff64_sizeof_headers
00168 PARAMS ((bfd *, bfd_boolean));
00169 static asection *xcoff64_create_csect_from_smclas
00170 PARAMS ((bfd *, union internal_auxent *, const char *));
00171 static bfd_boolean xcoff64_is_lineno_count_overflow
00172 PARAMS ((bfd *, bfd_vma));
00173 static bfd_boolean xcoff64_is_reloc_count_overflow
00174 PARAMS ((bfd *, bfd_vma));
00175 static bfd_vma xcoff64_loader_symbol_offset
00176 PARAMS ((bfd *, struct internal_ldhdr *));
00177 static bfd_vma xcoff64_loader_reloc_offset
00178 PARAMS ((bfd *, struct internal_ldhdr *));
00179 static bfd_boolean xcoff64_generate_rtinit
00180 PARAMS ((bfd *, const char *, const char *, bfd_boolean));
00181 static bfd_boolean xcoff64_bad_format_hook
00182 PARAMS ((bfd *, PTR ));
00183
00184
00185 static bfd_boolean xcoff64_reloc_type_br
00186 PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
00187
00188 bfd_boolean (*xcoff64_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
00189 PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)) =
00190 {
00191 xcoff_reloc_type_pos,
00192 xcoff_reloc_type_neg,
00193 xcoff_reloc_type_rel,
00194 xcoff_reloc_type_toc,
00195 xcoff_reloc_type_fail,
00196 xcoff_reloc_type_toc,
00197 xcoff_reloc_type_toc,
00198 xcoff_reloc_type_fail,
00199 xcoff_reloc_type_ba,
00200 xcoff_reloc_type_fail,
00201 xcoff64_reloc_type_br,
00202 xcoff_reloc_type_fail,
00203 xcoff_reloc_type_pos,
00204 xcoff_reloc_type_pos,
00205 xcoff_reloc_type_fail,
00206 xcoff_reloc_type_noop,
00207 xcoff_reloc_type_fail,
00208 xcoff_reloc_type_fail,
00209 xcoff_reloc_type_toc,
00210 xcoff_reloc_type_toc,
00211 xcoff_reloc_type_fail,
00212 xcoff_reloc_type_fail,
00213 xcoff_reloc_type_ba,
00214 xcoff_reloc_type_crel,
00215 xcoff_reloc_type_ba,
00216 xcoff_reloc_type_ba,
00217 xcoff64_reloc_type_br,
00218 xcoff_reloc_type_ba,
00219 };
00220
00221
00222
00223 #define XCOFF64
00224 #define RS6000COFF_C 1
00225
00226 #define SELECT_RELOC(internal, howto) \
00227 { \
00228 internal.r_type = howto->type; \
00229 internal.r_size = \
00230 ((howto->complain_on_overflow == complain_overflow_signed \
00231 ? 0x80 \
00232 : 0) \
00233 | (howto->bitsize - 1)); \
00234 }
00235
00236 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
00237 #define COFF_LONG_FILENAMES
00238 #define NO_COFF_SYMBOLS
00239 #define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst)
00240 #define coff_mkobject _bfd_xcoff_mkobject
00241 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
00242 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
00243 #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
00244 #ifdef AIX_CORE
00245 extern const bfd_target * rs6000coff_core_p
00246 PARAMS ((bfd *abfd));
00247 extern bfd_boolean rs6000coff_core_file_matches_executable_p
00248 PARAMS ((bfd *cbfd, bfd *ebfd));
00249 extern char *rs6000coff_core_file_failing_command
00250 PARAMS ((bfd *abfd));
00251 extern int rs6000coff_core_file_failing_signal
00252 PARAMS ((bfd *abfd));
00253 #define CORE_FILE_P rs6000coff_core_p
00254 #define coff_core_file_failing_command \
00255 rs6000coff_core_file_failing_command
00256 #define coff_core_file_failing_signal \
00257 rs6000coff_core_file_failing_signal
00258 #define coff_core_file_matches_executable_p \
00259 rs6000coff_core_file_matches_executable_p
00260 #else
00261 #define CORE_FILE_P _bfd_dummy_target
00262 #define coff_core_file_failing_command \
00263 _bfd_nocore_core_file_failing_command
00264 #define coff_core_file_failing_signal \
00265 _bfd_nocore_core_file_failing_signal
00266 #define coff_core_file_matches_executable_p \
00267 _bfd_nocore_core_file_matches_executable_p
00268 #endif
00269 #define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
00270 #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
00271 #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
00272 #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
00273 #define coff_swap_reloc_in xcoff64_swap_reloc_in
00274 #define coff_swap_reloc_out xcoff64_swap_reloc_out
00275 #define NO_COFF_RELOCS
00276
00277 #include "coffcode.h"
00278
00279
00280
00281 static void
00282 _bfd_xcoff64_swap_lineno_in (abfd, ext1, in1)
00283 bfd *abfd;
00284 PTR ext1;
00285 PTR in1;
00286 {
00287 LINENO *ext = (LINENO *) ext1;
00288 struct internal_lineno *in = (struct internal_lineno *) in1;
00289
00290 in->l_lnno = H_GET_32 (abfd, (ext->l_lnno));
00291 if (in->l_lnno == 0)
00292 in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
00293 else
00294 in->l_addr.l_paddr = H_GET_64 (abfd, ext->l_addr.l_paddr);
00295 }
00296
00297 static unsigned int
00298 _bfd_xcoff64_swap_lineno_out (abfd, inp, outp)
00299 bfd *abfd;
00300 PTR inp;
00301 PTR outp;
00302 {
00303 struct internal_lineno *in = (struct internal_lineno *) inp;
00304 struct external_lineno *ext = (struct external_lineno *) outp;
00305
00306 H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
00307 H_PUT_32 (abfd, in->l_lnno, (ext->l_lnno));
00308
00309 if (in->l_lnno == 0)
00310 H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
00311 else
00312 H_PUT_64 (abfd, in->l_addr.l_paddr, ext->l_addr.l_paddr);
00313
00314 return bfd_coff_linesz (abfd);
00315 }
00316
00317 static void
00318 _bfd_xcoff64_swap_sym_in (abfd, ext1, in1)
00319 bfd *abfd;
00320 PTR ext1;
00321 PTR in1;
00322 {
00323 struct external_syment *ext = (struct external_syment *) ext1;
00324 struct internal_syment *in = (struct internal_syment *) in1;
00325
00326 in->_n._n_n._n_zeroes = 0;
00327 in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e_offset);
00328 in->n_value = H_GET_64 (abfd, ext->e_value);
00329 in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
00330 in->n_type = H_GET_16 (abfd, ext->e_type);
00331 in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
00332 in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
00333 }
00334
00335 static unsigned int
00336 _bfd_xcoff64_swap_sym_out (abfd, inp, extp)
00337 bfd *abfd;
00338 PTR inp;
00339 PTR extp;
00340 {
00341 struct internal_syment *in = (struct internal_syment *) inp;
00342 struct external_syment *ext = (struct external_syment *) extp;
00343
00344 H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e_offset);
00345 H_PUT_64 (abfd, in->n_value, ext->e_value);
00346 H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
00347 H_PUT_16 (abfd, in->n_type, ext->e_type);
00348 H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
00349 H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
00350 return bfd_coff_symesz (abfd);
00351 }
00352
00353 static void
00354 _bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
00355 bfd *abfd;
00356 PTR ext1;
00357 int type;
00358 int class;
00359 int indx;
00360 int numaux;
00361 PTR in1;
00362 {
00363 union external_auxent *ext = (union external_auxent *) ext1;
00364 union internal_auxent *in = (union internal_auxent *) in1;
00365
00366 switch (class)
00367 {
00368 case C_FILE:
00369 if (ext->x_file.x_n.x_zeroes[0] == 0)
00370 {
00371 in->x_file.x_n.x_zeroes = 0;
00372 in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
00373 }
00374 else
00375 {
00376 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
00377 }
00378 goto end;
00379
00380
00381 case C_EXT:
00382 case C_HIDEXT:
00383 if (indx + 1 == numaux)
00384 {
00385 bfd_signed_vma h = 0;
00386 bfd_vma l = 0;
00387
00388 h = H_GET_S32 (abfd, ext->x_csect.x_scnlen_hi);
00389 l = H_GET_32 (abfd, ext->x_csect.x_scnlen_lo);
00390
00391 in->x_csect.x_scnlen.l = h << 32 | (l & 0xffffffff);
00392
00393 in->x_csect.x_parmhash = H_GET_32 (abfd, ext->x_csect.x_parmhash);
00394 in->x_csect.x_snhash = H_GET_16 (abfd, ext->x_csect.x_snhash);
00395
00396
00397
00398 in->x_csect.x_smtyp = H_GET_8 (abfd, ext->x_csect.x_smtyp);
00399 in->x_csect.x_smclas = H_GET_8 (abfd, ext->x_csect.x_smclas);
00400 goto end;
00401 }
00402 break;
00403
00404 case C_STAT:
00405 case C_LEAFSTAT:
00406 case C_HIDDEN:
00407 if (type == T_NULL)
00408 {
00409
00410
00411 in->x_scn.x_checksum = 0;
00412 in->x_scn.x_associated = 0;
00413 in->x_scn.x_comdat = 0;
00414
00415 goto end;
00416 }
00417 break;
00418 }
00419
00420 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
00421 {
00422 in->x_sym.x_fcnary.x_fcn.x_lnnoptr
00423 = H_GET_64 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
00424 in->x_sym.x_fcnary.x_fcn.x_endndx.l
00425 = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx);
00426 }
00427 if (ISFCN (type))
00428 {
00429 in->x_sym.x_misc.x_fsize
00430 = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_fsize);
00431 }
00432 else
00433 {
00434 in->x_sym.x_misc.x_lnsz.x_lnno
00435 = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_lnno);
00436 in->x_sym.x_misc.x_lnsz.x_size
00437 = H_GET_16 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_size);
00438 }
00439
00440 end: ;
00441 }
00442
00443 static unsigned int
00444 _bfd_xcoff64_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
00445 bfd *abfd;
00446 PTR inp;
00447 int type;
00448 int class;
00449 int indx ATTRIBUTE_UNUSED;
00450 int numaux ATTRIBUTE_UNUSED;
00451 PTR extp;
00452 {
00453 union internal_auxent *in = (union internal_auxent *) inp;
00454 union external_auxent *ext = (union external_auxent *) extp;
00455
00456 memset ((PTR) ext, 0, bfd_coff_auxesz (abfd));
00457 switch (class)
00458 {
00459 case C_FILE:
00460 if (in->x_file.x_n.x_zeroes == 0)
00461 {
00462 H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
00463 H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
00464 }
00465 else
00466 {
00467 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
00468 }
00469 H_PUT_8 (abfd, _AUX_FILE, ext->x_auxtype.x_auxtype);
00470 goto end;
00471
00472
00473 case C_EXT:
00474 case C_HIDEXT:
00475 if (indx + 1 == numaux)
00476 {
00477 bfd_vma temp;
00478
00479 temp = in->x_csect.x_scnlen.l & 0xffffffff;
00480 H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_lo);
00481 temp = in->x_csect.x_scnlen.l >> 32;
00482 H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_hi);
00483 H_PUT_32 (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
00484 H_PUT_16 (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
00485
00486
00487
00488 H_PUT_8 (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
00489 H_PUT_8 (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
00490 H_PUT_8 (abfd, _AUX_CSECT, ext->x_auxtype.x_auxtype);
00491 goto end;
00492 }
00493 break;
00494
00495 case C_STAT:
00496 case C_LEAFSTAT:
00497 case C_HIDDEN:
00498 if (type == T_NULL)
00499 {
00500 goto end;
00501 }
00502 break;
00503 }
00504
00505 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
00506 {
00507 H_PUT_64 (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
00508 ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
00509 H_PUT_8 (abfd, _AUX_FCN,
00510 ext->x_auxtype.x_auxtype);
00511 H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
00512 ext->x_sym.x_fcnary.x_fcn.x_endndx);
00513 }
00514 if (ISFCN (type))
00515 {
00516 H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize,
00517 ext->x_sym.x_fcnary.x_fcn.x_fsize);
00518 }
00519 else
00520 {
00521 H_PUT_32 (abfd, in->x_sym.x_misc.x_lnsz.x_lnno,
00522 ext->x_sym.x_fcnary.x_lnsz.x_lnno);
00523 H_PUT_16 (abfd, in->x_sym.x_misc.x_lnsz.x_size,
00524 ext->x_sym.x_fcnary.x_lnsz.x_size);
00525 }
00526
00527 end:
00528
00529 return bfd_coff_auxesz (abfd);
00530 }
00531
00532 static bfd_boolean
00533 _bfd_xcoff64_put_symbol_name (abfd, strtab, sym, name)
00534 bfd *abfd;
00535 struct bfd_strtab_hash *strtab;
00536 struct internal_syment *sym;
00537 const char *name;
00538 {
00539 bfd_boolean hash;
00540 bfd_size_type indx;
00541
00542 hash = TRUE;
00543
00544 if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
00545 hash = FALSE;
00546
00547 indx = _bfd_stringtab_add (strtab, name, hash, FALSE);
00548
00549 if (indx == (bfd_size_type) -1)
00550 return FALSE;
00551
00552 sym->_n._n_n._n_zeroes = 0;
00553 sym->_n._n_n._n_offset = STRING_SIZE_SIZE + indx;
00554
00555 return TRUE;
00556 }
00557
00558 static bfd_boolean
00559 _bfd_xcoff64_put_ldsymbol_name (abfd, ldinfo, ldsym, name)
00560 bfd *abfd ATTRIBUTE_UNUSED;
00561 struct xcoff_loader_info *ldinfo;
00562 struct internal_ldsym *ldsym;
00563 const char *name;
00564 {
00565 size_t len;
00566 len = strlen (name);
00567
00568 if (ldinfo->string_size + len + 3 > ldinfo->string_alc)
00569 {
00570 bfd_size_type newalc;
00571 char *newstrings;
00572
00573 newalc = ldinfo->string_alc * 2;
00574 if (newalc == 0)
00575 newalc = 32;
00576 while (ldinfo->string_size + len + 3 > newalc)
00577 newalc *= 2;
00578
00579 newstrings = bfd_realloc (ldinfo->strings, newalc);
00580 if (newstrings == NULL)
00581 {
00582 ldinfo->failed = TRUE;
00583 return FALSE;
00584 }
00585 ldinfo->string_alc = newalc;
00586 ldinfo->strings = newstrings;
00587 }
00588
00589 bfd_put_16 (ldinfo->output_bfd, (bfd_vma) (len + 1),
00590 ldinfo->strings + ldinfo->string_size);
00591 strcpy (ldinfo->strings + ldinfo->string_size + 2, name);
00592 ldsym->_l._l_l._l_zeroes = 0;
00593 ldsym->_l._l_l._l_offset = ldinfo->string_size + 2;
00594 ldinfo->string_size += len + 3;
00595
00596 return TRUE;
00597 }
00598
00599
00600
00601
00602
00603
00604
00605
00606 static void
00607 xcoff64_swap_ldhdr_in (abfd, s, dst)
00608 bfd *abfd;
00609 const PTR s;
00610 struct internal_ldhdr *dst;
00611 {
00612 const struct external_ldhdr *src = (const struct external_ldhdr *) s;
00613
00614 dst->l_version = bfd_get_32 (abfd, src->l_version);
00615 dst->l_nsyms = bfd_get_32 (abfd, src->l_nsyms);
00616 dst->l_nreloc = bfd_get_32 (abfd, src->l_nreloc);
00617 dst->l_istlen = bfd_get_32 (abfd, src->l_istlen);
00618 dst->l_nimpid = bfd_get_32 (abfd, src->l_nimpid);
00619 dst->l_stlen = bfd_get_32 (abfd, src->l_stlen);
00620 dst->l_impoff = bfd_get_64 (abfd, src->l_impoff);
00621 dst->l_stoff = bfd_get_64 (abfd, src->l_stoff);
00622 dst->l_symoff = bfd_get_64 (abfd, src->l_symoff);
00623 dst->l_rldoff = bfd_get_64 (abfd, src->l_rldoff);
00624 }
00625
00626
00627
00628 static void
00629 xcoff64_swap_ldhdr_out (abfd, src, d)
00630 bfd *abfd;
00631 const struct internal_ldhdr *src;
00632 PTR d;
00633 {
00634 struct external_ldhdr *dst = (struct external_ldhdr *) d;
00635
00636 bfd_put_32 (abfd, (bfd_vma) src->l_version, dst->l_version);
00637 bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms);
00638 bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc);
00639 bfd_put_32 (abfd, src->l_istlen, dst->l_istlen);
00640 bfd_put_32 (abfd, src->l_nimpid, dst->l_nimpid);
00641 bfd_put_32 (abfd, src->l_stlen, dst->l_stlen);
00642 bfd_put_64 (abfd, src->l_impoff, dst->l_impoff);
00643 bfd_put_64 (abfd, src->l_stoff, dst->l_stoff);
00644 bfd_put_64 (abfd, src->l_symoff, dst->l_symoff);
00645 bfd_put_64 (abfd, src->l_rldoff, dst->l_rldoff);
00646 }
00647
00648
00649
00650 static void
00651 xcoff64_swap_ldsym_in (abfd, s, dst)
00652 bfd *abfd;
00653 const PTR s;
00654 struct internal_ldsym *dst;
00655 {
00656 const struct external_ldsym *src = (const struct external_ldsym *) s;
00657
00658
00659
00660 dst->_l._l_l._l_zeroes = 0;
00661 dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->l_offset);
00662 dst->l_value = bfd_get_64 (abfd, src->l_value);
00663 dst->l_scnum = bfd_get_16 (abfd, src->l_scnum);
00664 dst->l_smtype = bfd_get_8 (abfd, src->l_smtype);
00665 dst->l_smclas = bfd_get_8 (abfd, src->l_smclas);
00666 dst->l_ifile = bfd_get_32 (abfd, src->l_ifile);
00667 dst->l_parm = bfd_get_32 (abfd, src->l_parm);
00668 }
00669
00670
00671
00672 static void
00673 xcoff64_swap_ldsym_out (abfd, src, d)
00674 bfd *abfd;
00675 const struct internal_ldsym *src;
00676 PTR d;
00677 {
00678 struct external_ldsym *dst = (struct external_ldsym *) d;
00679
00680 bfd_put_64 (abfd, src->l_value, dst->l_value);
00681 bfd_put_32 (abfd, (bfd_vma) src->_l._l_l._l_offset, dst->l_offset);
00682 bfd_put_16 (abfd, (bfd_vma) src->l_scnum, dst->l_scnum);
00683 bfd_put_8 (abfd, src->l_smtype, dst->l_smtype);
00684 bfd_put_8 (abfd, src->l_smclas, dst->l_smclas);
00685 bfd_put_32 (abfd, src->l_ifile, dst->l_ifile);
00686 bfd_put_32 (abfd, src->l_parm, dst->l_parm);
00687 }
00688
00689 static void
00690 xcoff64_swap_reloc_in (abfd, s, d)
00691 bfd *abfd;
00692 PTR s;
00693 PTR d;
00694 {
00695 struct external_reloc *src = (struct external_reloc *) s;
00696 struct internal_reloc *dst = (struct internal_reloc *) d;
00697
00698 memset (dst, 0, sizeof (struct internal_reloc));
00699
00700 dst->r_vaddr = bfd_get_64 (abfd, src->r_vaddr);
00701 dst->r_symndx = bfd_get_32 (abfd, src->r_symndx);
00702 dst->r_size = bfd_get_8 (abfd, src->r_size);
00703 dst->r_type = bfd_get_8 (abfd, src->r_type);
00704 }
00705
00706 static unsigned int
00707 xcoff64_swap_reloc_out (abfd, s, d)
00708 bfd *abfd;
00709 PTR s;
00710 PTR d;
00711 {
00712 struct internal_reloc *src = (struct internal_reloc *) s;
00713 struct external_reloc *dst = (struct external_reloc *) d;
00714
00715 bfd_put_64 (abfd, src->r_vaddr, dst->r_vaddr);
00716 bfd_put_32 (abfd, src->r_symndx, dst->r_symndx);
00717 bfd_put_8 (abfd, src->r_type, dst->r_type);
00718 bfd_put_8 (abfd, src->r_size, dst->r_size);
00719
00720 return bfd_coff_relsz (abfd);
00721 }
00722
00723
00724
00725 static void
00726 xcoff64_swap_ldrel_in (abfd, s, dst)
00727 bfd *abfd;
00728 const PTR s;
00729 struct internal_ldrel *dst;
00730 {
00731 const struct external_ldrel *src = (const struct external_ldrel *) s;
00732
00733 dst->l_vaddr = bfd_get_64 (abfd, src->l_vaddr);
00734 dst->l_symndx = bfd_get_32 (abfd, src->l_symndx);
00735 dst->l_rtype = bfd_get_16 (abfd, src->l_rtype);
00736 dst->l_rsecnm = bfd_get_16 (abfd, src->l_rsecnm);
00737 }
00738
00739
00740
00741 static void
00742 xcoff64_swap_ldrel_out (abfd, src, d)
00743 bfd *abfd;
00744 const struct internal_ldrel *src;
00745 PTR d;
00746 {
00747 struct external_ldrel *dst = (struct external_ldrel *) d;
00748
00749 bfd_put_64 (abfd, src->l_vaddr, dst->l_vaddr);
00750 bfd_put_16 (abfd, (bfd_vma) src->l_rtype, dst->l_rtype);
00751 bfd_put_16 (abfd, (bfd_vma) src->l_rsecnm, dst->l_rsecnm);
00752 bfd_put_32 (abfd, src->l_symndx, dst->l_symndx);
00753 }
00754
00755 static bfd_boolean
00756 xcoff64_write_object_contents (abfd)
00757 bfd *abfd;
00758 {
00759 asection *current;
00760 bfd_boolean hasrelocs = FALSE;
00761 bfd_boolean haslinno = FALSE;
00762 file_ptr scn_base;
00763 file_ptr reloc_base;
00764 file_ptr lineno_base;
00765 file_ptr sym_base;
00766 unsigned long reloc_size = 0;
00767 unsigned long lnno_size = 0;
00768 bfd_boolean long_section_names;
00769 asection *text_sec = ((void *) 0);
00770 asection *data_sec = ((void *) 0);
00771 asection *bss_sec = ((void *) 0);
00772 struct internal_filehdr internal_f;
00773 struct internal_aouthdr internal_a;
00774
00775 bfd_set_error (bfd_error_system_call);
00776
00777 if (! abfd->output_has_begun)
00778 {
00779 if (! bfd_coff_compute_section_file_positions (abfd))
00780 return FALSE;
00781 }
00782
00783
00784 reloc_base = obj_relocbase (abfd);
00785
00786 for (current = abfd->sections; current != NULL; current = current->next)
00787 reloc_size += current->reloc_count * bfd_coff_relsz (abfd);
00788
00789 lineno_base = reloc_base + reloc_size;
00790
00791
00792
00793 lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd);
00794
00795 sym_base = lineno_base + lnno_size;
00796
00797
00798 for (current = abfd->sections; current != NULL; current = current->next)
00799 {
00800 if (current->lineno_count)
00801 {
00802 current->line_filepos = lineno_base;
00803 current->moving_line_filepos = lineno_base;
00804 lineno_base += current->lineno_count * bfd_coff_linesz (abfd);
00805 }
00806 else
00807 {
00808 current->line_filepos = 0;
00809 }
00810
00811 if (current->reloc_count)
00812 {
00813 current->rel_filepos = reloc_base;
00814 reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
00815 }
00816 else
00817 {
00818 current->rel_filepos = 0;
00819 }
00820 }
00821
00822 if ((abfd->flags & EXEC_P) != 0)
00823 {
00824 scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
00825 internal_f.f_opthdr = bfd_coff_aoutsz (abfd);
00826 }
00827 else
00828 {
00829 scn_base = bfd_coff_filhsz (abfd);
00830 internal_f.f_opthdr = 0;
00831 }
00832
00833 internal_f.f_nscns = 0;
00834
00835 if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
00836 return FALSE;
00837
00838 long_section_names = FALSE;
00839 for (current = abfd->sections; current != NULL; current = current->next)
00840 {
00841 struct internal_scnhdr section;
00842 struct external_scnhdr buff;
00843 bfd_size_type amount;
00844
00845 internal_f.f_nscns++;
00846
00847 strncpy (section.s_name, current->name, SCNNMLEN);
00848
00849 section.s_vaddr = current->vma;
00850 section.s_paddr = current->lma;
00851 section.s_size = current->size;
00852
00853
00854
00855 if (current->size == 0
00856 || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
00857 {
00858 section.s_scnptr = 0;
00859 }
00860 else
00861 {
00862 section.s_scnptr = current->filepos;
00863 }
00864
00865 section.s_relptr = current->rel_filepos;
00866 section.s_lnnoptr = current->line_filepos;
00867 section.s_nreloc = current->reloc_count;
00868
00869 section.s_nlnno = current->lineno_count;
00870 if (current->reloc_count != 0)
00871 hasrelocs = TRUE;
00872 if (current->lineno_count != 0)
00873 haslinno = TRUE;
00874
00875 section.s_flags = sec_to_styp_flags (current->name, current->flags);
00876
00877 if (!strcmp (current->name, _TEXT))
00878 {
00879 text_sec = current;
00880 }
00881 else if (!strcmp (current->name, _DATA))
00882 {
00883 data_sec = current;
00884 }
00885 else if (!strcmp (current->name, _BSS))
00886 {
00887 bss_sec = current;
00888 }
00889
00890 amount = bfd_coff_scnhsz (abfd);
00891 if (bfd_coff_swap_scnhdr_out (abfd, §ion, &buff) == 0
00892 || bfd_bwrite ((PTR) (&buff), amount, abfd) != amount)
00893 return FALSE;
00894 }
00895
00896 internal_f.f_timdat = 0;
00897
00898 internal_f.f_flags = 0;
00899
00900 if (!hasrelocs)
00901 internal_f.f_flags |= F_RELFLG;
00902 if (!haslinno)
00903 internal_f.f_flags |= F_LNNO;
00904 if (abfd->flags & EXEC_P)
00905 internal_f.f_flags |= F_EXEC;
00906
00907
00908 if (bfd_little_endian (abfd))
00909 internal_f.f_flags |= F_AR32WR;
00910 else
00911 internal_f.f_flags |= F_AR32W;
00912
00913 if ((abfd->flags & DYNAMIC) != 0)
00914 internal_f.f_flags |= F_SHROBJ;
00915 if (bfd_get_section_by_name (abfd, _LOADER) != NULL)
00916 internal_f.f_flags |= F_DYNLOAD;
00917
00918 memset (&internal_a, 0, sizeof internal_a);
00919
00920 internal_f.f_magic = bfd_xcoff_magic_number (abfd);
00921 internal_a.magic = (abfd->flags & D_PAGED
00922 ? RS6K_AOUTHDR_ZMAGIC
00923 : (abfd->flags & WP_TEXT
00924 ? RS6K_AOUTHDR_NMAGIC
00925 : RS6K_AOUTHDR_OMAGIC));
00926
00927
00928 internal_a.vstamp = 0;
00929
00930
00931 obj_sym_filepos (abfd) = sym_base;
00932
00933 internal_f.f_symptr = 0;
00934 internal_f.f_nsyms = 0;
00935
00936
00937
00938
00939 if (bfd_get_symcount (abfd) != 0)
00940 {
00941 int firstundef;
00942
00943 if (!coff_renumber_symbols (abfd, &firstundef))
00944 return FALSE;
00945 coff_mangle_symbols (abfd);
00946 if (! coff_write_symbols (abfd))
00947 return FALSE;
00948 if (! coff_write_linenumbers (abfd))
00949 return FALSE;
00950 if (! coff_write_relocs (abfd, firstundef))
00951 return FALSE;
00952
00953 internal_f.f_symptr = sym_base;
00954 internal_f.f_nsyms = bfd_get_symcount (abfd);
00955 }
00956 else if (obj_raw_syment_count (abfd) != 0)
00957 {
00958 internal_f.f_symptr = sym_base;
00959
00960
00961
00962 internal_f.f_flags &=~ F_RELFLG;
00963 }
00964 else
00965 {
00966 internal_f.f_flags |= F_LSYMS;
00967 }
00968
00969 if (text_sec)
00970 {
00971 internal_a.tsize = text_sec->size;
00972 internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
00973 }
00974
00975 if (data_sec)
00976 {
00977 internal_a.dsize = data_sec->size;
00978 internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
00979 }
00980
00981 if (bss_sec)
00982 {
00983 internal_a.bsize = bss_sec->size;
00984 if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
00985 internal_a.data_start = bss_sec->vma;
00986 }
00987
00988 internal_a.entry = bfd_get_start_address (abfd);
00989 internal_f.f_nsyms = obj_raw_syment_count (abfd);
00990
00991 if (xcoff_data (abfd)->full_aouthdr)
00992 {
00993 bfd_vma toc;
00994 asection *loader_sec;
00995
00996 internal_a.vstamp = 1;
00997
00998 internal_a.o_snentry = xcoff_data (abfd)->snentry;
00999 if (internal_a.o_snentry == 0)
01000 internal_a.entry = (bfd_vma) -1;
01001
01002 if (text_sec != NULL)
01003 {
01004 internal_a.o_sntext = text_sec->target_index;
01005 internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec);
01006 }
01007 else
01008 {
01009 internal_a.o_sntext = 0;
01010 internal_a.o_algntext = 0;
01011 }
01012
01013 if (data_sec != NULL)
01014 {
01015 internal_a.o_sndata = data_sec->target_index;
01016 internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
01017 }
01018 else
01019 {
01020 internal_a.o_sndata = 0;
01021 internal_a.o_algndata = 0;
01022 }
01023
01024 loader_sec = bfd_get_section_by_name (abfd, ".loader");
01025 if (loader_sec != NULL)
01026 internal_a.o_snloader = loader_sec->target_index;
01027 else
01028 internal_a.o_snloader = 0;
01029 if (bss_sec != NULL)
01030 internal_a.o_snbss = bss_sec->target_index;
01031 else
01032 internal_a.o_snbss = 0;
01033
01034 toc = xcoff_data (abfd)->toc;
01035 internal_a.o_toc = toc;
01036 internal_a.o_sntoc = xcoff_data (abfd)->sntoc;
01037
01038 internal_a.o_modtype = xcoff_data (abfd)->modtype;
01039 if (xcoff_data (abfd)->cputype != -1)
01040 internal_a.o_cputype = xcoff_data (abfd)->cputype;
01041 else
01042 {
01043 switch (bfd_get_arch (abfd))
01044 {
01045 case bfd_arch_rs6000:
01046 internal_a.o_cputype = 4;
01047 break;
01048 case bfd_arch_powerpc:
01049 if (bfd_get_mach (abfd) == bfd_mach_ppc)
01050 internal_a.o_cputype = 3;
01051 else
01052 internal_a.o_cputype = 1;
01053 break;
01054 default:
01055 abort ();
01056 }
01057 }
01058 internal_a.o_maxstack = xcoff_data (abfd)->maxstack;
01059 internal_a.o_maxdata = xcoff_data (abfd)->maxdata;
01060 }
01061
01062 if (bfd_seek (abfd, (file_ptr) 0, 0) != 0)
01063 return FALSE;
01064
01065 {
01066 char * buff;
01067 bfd_size_type amount = bfd_coff_filhsz (abfd);
01068
01069 buff = bfd_malloc (amount);
01070 if (buff == NULL)
01071 return FALSE;
01072
01073 bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, (PTR) buff);
01074 amount = bfd_bwrite ((PTR) buff, amount, abfd);
01075
01076 free (buff);
01077
01078 if (amount != bfd_coff_filhsz (abfd))
01079 return FALSE;
01080 }
01081
01082 if (abfd->flags & EXEC_P)
01083 {
01084 char * buff;
01085 bfd_size_type amount = bfd_coff_aoutsz (abfd);
01086
01087 buff = bfd_malloc (amount);
01088 if (buff == NULL)
01089 return FALSE;
01090
01091 bfd_coff_swap_aouthdr_out (abfd, (PTR) &internal_a, (PTR) buff);
01092 amount = bfd_bwrite ((PTR) buff, amount, abfd);
01093
01094 free (buff);
01095
01096 if (amount != bfd_coff_aoutsz (abfd))
01097 return FALSE;
01098 }
01099
01100 return TRUE;
01101 }
01102
01103 static bfd_boolean
01104 xcoff64_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto,
01105 val, addend, relocation, contents)
01106 bfd *input_bfd;
01107 asection *input_section;
01108 bfd *output_bfd ATTRIBUTE_UNUSED;
01109 struct internal_reloc *rel;
01110 struct internal_syment *sym ATTRIBUTE_UNUSED;
01111 struct reloc_howto_struct *howto;
01112 bfd_vma val;
01113 bfd_vma addend;
01114 bfd_vma *relocation;
01115 bfd_byte *contents;
01116 {
01117 struct xcoff_link_hash_entry *h;
01118
01119 if (0 > rel->r_symndx)
01120 return FALSE;
01121
01122 h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];
01123
01124
01125
01126
01127
01128
01129
01130
01131 if (NULL != h
01132 && bfd_link_hash_defined == h->root.type
01133 && rel->r_vaddr - input_section->vma + 8 <= input_section->size)
01134 {
01135 bfd_byte *pnext;
01136 unsigned long next;
01137
01138 pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
01139 next = bfd_get_32 (input_bfd, pnext);
01140
01141
01142
01143 if (h->smclas == XMC_GL || strcmp (h->root.root.string, "._ptrgl") == 0)
01144 {
01145 if (next == 0x4def7b82
01146 || next == 0x4ffffb82
01147 || next == 0x60000000)
01148 bfd_put_32 (input_bfd, 0xe8410028, pnext);
01149 }
01150 else
01151 {
01152 if (next == 0xe8410028)
01153 bfd_put_32 (input_bfd, 0x60000000, pnext);
01154 }
01155 }
01156 else if (NULL != h && bfd_link_hash_undefined == h->root.type)
01157 {
01158
01159
01160
01161
01162
01163
01164 howto->complain_on_overflow = complain_overflow_dont;
01165 }
01166
01167 howto->pc_relative = TRUE;
01168 howto->src_mask &= ~3;
01169 howto->dst_mask = howto->src_mask;
01170
01171
01172 addend += input_section->vma;
01173
01174 *relocation = val + addend;
01175 *relocation -= (input_section->output_section->vma
01176 + input_section->output_offset);
01177 return TRUE;
01178 }
01179
01180
01181
01182
01183 bfd_boolean
01184 xcoff64_ppc_relocate_section (output_bfd, info, input_bfd,
01185 input_section, contents, relocs, syms,
01186 sections)
01187 bfd *output_bfd;
01188 struct bfd_link_info *info;
01189 bfd *input_bfd;
01190 asection *input_section;
01191 bfd_byte *contents;
01192 struct internal_reloc *relocs;
01193 struct internal_syment *syms;
01194 asection **sections;
01195 {
01196 struct internal_reloc *rel;
01197 struct internal_reloc *relend;
01198
01199 rel = relocs;
01200 relend = rel + input_section->reloc_count;
01201 for (; rel < relend; rel++)
01202 {
01203 long symndx;
01204 struct xcoff_link_hash_entry *h;
01205 struct internal_syment *sym;
01206 bfd_vma addend;
01207 bfd_vma val;
01208 struct reloc_howto_struct howto;
01209 bfd_vma relocation;
01210 bfd_vma value_to_relocate;
01211 bfd_vma address;
01212 bfd_byte *location;
01213
01214
01215
01216
01217 if (rel->r_type == R_REF)
01218 continue;
01219
01220
01221 howto.type = rel->r_type;
01222 howto.rightshift = 0;
01223 howto.bitsize = (rel->r_size & 0x3f) + 1;
01224 howto.size = howto.bitsize > 16 ? (howto.bitsize > 32 ? 4 : 2) : 1;
01225 howto.pc_relative = FALSE;
01226 howto.bitpos = 0;
01227 howto.complain_on_overflow = (rel->r_size & 0x80
01228 ? complain_overflow_signed
01229 : complain_overflow_bitfield);
01230 howto.special_function = NULL;
01231 howto.name = "internal";
01232 howto.partial_inplace = TRUE;
01233 howto.src_mask = howto.dst_mask = N_ONES (howto.bitsize);
01234 howto.pcrel_offset = FALSE;
01235
01236
01237 val = 0;
01238 addend = 0;
01239 h = NULL;
01240 sym = NULL;
01241 symndx = rel->r_symndx;
01242
01243 if (-1 != symndx)
01244 {
01245 asection *sec;
01246
01247 h = obj_xcoff_sym_hashes (input_bfd)[symndx];
01248 sym = syms + symndx;
01249 addend = - sym->n_value;
01250
01251 if (NULL == h)
01252 {
01253 sec = sections[symndx];
01254
01255
01256 if (sec->name[3] == '0'
01257 && strcmp (sec->name, ".tc0") == 0)
01258 val = xcoff_data (output_bfd)->toc;
01259 else
01260 val = (sec->output_section->vma
01261 + sec->output_offset
01262 + sym->n_value
01263 - sec->vma);
01264 }
01265 else
01266 {
01267 if (h->root.type == bfd_link_hash_defined
01268 || h->root.type == bfd_link_hash_defweak)
01269 {
01270 sec = h->root.u.def.section;
01271 val = (h->root.u.def.value
01272 + sec->output_section->vma
01273 + sec->output_offset);
01274 }
01275 else if (h->root.type == bfd_link_hash_common)
01276 {
01277 sec = h->root.u.c.p->section;
01278 val = (sec->output_section->vma
01279 + sec->output_offset);
01280 }
01281 else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT)))
01282 && ! info->relocatable)
01283 {
01284 if (! ((*info->callbacks->undefined_symbol)
01285 (info, h->root.root.string, input_bfd, input_section,
01286 rel->r_vaddr - input_section->vma, TRUE)))
01287 return FALSE;
01288
01289
01290
01291 continue;
01292 }
01293 }
01294 }
01295
01296 if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION
01297 || !((*xcoff64_calculate_relocation[rel->r_type])
01298 (input_bfd, input_section, output_bfd, rel, sym, &howto, val,
01299 addend, &relocation, contents)))
01300 return FALSE;
01301
01302
01303 address = rel->r_vaddr - input_section->vma;
01304 location = contents + address;
01305
01306 if (address > input_section->size)
01307 abort ();
01308
01309
01310 if (1 == howto.size)
01311 value_to_relocate = bfd_get_16 (input_bfd, location);
01312 else if (2 == howto.size)
01313 value_to_relocate = bfd_get_32 (input_bfd, location);
01314 else
01315 value_to_relocate = bfd_get_64 (input_bfd, location);
01316
01317
01318
01319
01320
01321
01322
01323
01324 if ((unsigned int) howto.complain_on_overflow
01325 >= XCOFF_MAX_COMPLAIN_OVERFLOW)
01326 abort ();
01327
01328 if (((*xcoff_complain_overflow[howto.complain_on_overflow])
01329 (input_bfd, value_to_relocate, relocation, &howto)))
01330 {
01331 const char *name;
01332 char buf[SYMNMLEN + 1];
01333 char reloc_type_name[10];
01334
01335 if (symndx == -1)
01336 {
01337 name = "*ABS*";
01338 }
01339 else if (h != NULL)
01340 {
01341 name = NULL;
01342 }
01343 else
01344 {
01345 name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
01346 if (name == NULL)
01347 name = "UNKNOWN";
01348 }
01349 sprintf (reloc_type_name, "0x%02x", rel->r_type);
01350
01351 if (! ((*info->callbacks->reloc_overflow)
01352 (info, (h ? &h->root : NULL), name, reloc_type_name,
01353 (bfd_vma) 0, input_bfd, input_section,
01354 rel->r_vaddr - input_section->vma)))
01355 return FALSE;
01356 }
01357
01358
01359 value_to_relocate = ((value_to_relocate & ~howto.dst_mask)
01360 | (((value_to_relocate & howto.src_mask)
01361 + relocation) & howto.dst_mask));
01362
01363
01364 if (1 == howto.size)
01365 bfd_put_16 (input_bfd, value_to_relocate, location);
01366 else if (2 == howto.size)
01367 bfd_put_32 (input_bfd, value_to_relocate, location);
01368 else
01369 bfd_put_64 (input_bfd, value_to_relocate, location);
01370
01371 }
01372 return TRUE;
01373 }
01374
01375
01376
01377
01378
01379
01380
01381
01382 reloc_howto_type xcoff64_howto_table[] =
01383 {
01384
01385 HOWTO (R_POS,
01386 0,
01387 4,
01388 64,
01389 FALSE,
01390 0,
01391 complain_overflow_bitfield,
01392 0,
01393 "R_POS_64",
01394 TRUE,
01395 MINUS_ONE,
01396 MINUS_ONE,
01397 FALSE),
01398
01399
01400 HOWTO (R_NEG,
01401 0,
01402 -4,
01403 64,
01404 FALSE,
01405 0,
01406 complain_overflow_bitfield,
01407 0,
01408 "R_NEG",
01409 TRUE,
01410 MINUS_ONE,
01411 MINUS_ONE,
01412 FALSE),
01413
01414
01415 HOWTO (R_REL,
01416 0,
01417 2,
01418 32,
01419 TRUE,
01420 0,
01421 complain_overflow_signed,
01422 0,
01423 "R_REL",
01424 TRUE,
01425 0xffffffff,
01426 0xffffffff,
01427 FALSE),
01428
01429
01430 HOWTO (R_TOC,
01431 0,
01432 1,
01433 16,
01434 FALSE,
01435 0,
01436 complain_overflow_bitfield,
01437 0,
01438 "R_TOC",
01439 TRUE,
01440 0xffff,
01441 0xffff,
01442 FALSE),
01443
01444
01445 HOWTO (R_RTB,
01446 1,
01447 2,
01448 32,
01449 FALSE,
01450 0,
01451 complain_overflow_bitfield,
01452 0,
01453 "R_RTB",
01454 TRUE,
01455 0xffffffff,
01456 0xffffffff,
01457 FALSE),
01458
01459
01460 HOWTO (R_GL,
01461 0,
01462 1,
01463 16,
01464 FALSE,
01465 0,
01466 complain_overflow_bitfield,
01467 0,
01468 "R_GL",
01469 TRUE,
01470 0xffff,
01471 0xffff,
01472 FALSE),
01473
01474
01475 HOWTO (R_TCL,
01476 0,
01477 1,
01478 16,
01479 FALSE,
01480 0,
01481 complain_overflow_bitfield,
01482 0,
01483 "R_TCL",
01484 TRUE,
01485 0xffff,
01486 0xffff,
01487 FALSE),
01488
01489 EMPTY_HOWTO (7),
01490
01491
01492 HOWTO (R_BA,
01493 0,
01494 2,
01495 26,
01496 FALSE,
01497 0,
01498 complain_overflow_bitfield,
01499 0,
01500 "R_BA_26",
01501 TRUE,
01502 0x03fffffc,
01503 0x03fffffc,
01504 FALSE),
01505
01506 EMPTY_HOWTO (9),
01507
01508
01509 HOWTO (R_BR,
01510 0,
01511 2,
01512 26,
01513 TRUE,
01514 0,
01515 complain_overflow_signed,
01516 0,
01517 "R_BR",
01518 TRUE,
01519 0x03fffffc,
01520 0x03fffffc,
01521 FALSE),
01522
01523 EMPTY_HOWTO (0xb),
01524
01525
01526 HOWTO (R_RL,
01527 0,
01528 1,
01529 16,
01530 FALSE,
01531 0,
01532 complain_overflow_bitfield,
01533 0,
01534 "R_RL",
01535 TRUE,
01536 0xffff,
01537 0xffff,
01538 FALSE),
01539
01540
01541 HOWTO (R_RLA,
01542 0,
01543 1,
01544 16,
01545 FALSE,
01546 0,
01547 complain_overflow_bitfield,
01548 0,
01549 "R_RLA",
01550 TRUE,
01551 0xffff,
01552 0xffff,
01553 FALSE),
01554
01555 EMPTY_HOWTO (0xe),
01556
01557
01558 HOWTO (R_REF,
01559 0,
01560 2,
01561 32,
01562 FALSE,
01563 0,
01564 complain_overflow_dont,
01565 0,
01566 "R_REF",
01567 FALSE,
01568 0,
01569 0,
01570 FALSE),
01571
01572 EMPTY_HOWTO (0x10),
01573 EMPTY_HOWTO (0x11),
01574
01575
01576 HOWTO (R_TRL,
01577 0,
01578 1,
01579 16,
01580 FALSE,
01581 0,
01582 complain_overflow_bitfield,
01583 0,
01584 "R_TRL",
01585 TRUE,
01586 0xffff,
01587 0xffff,
01588 FALSE),
01589
01590
01591 HOWTO (R_TRLA,
01592 0,
01593 1,
01594 16,
01595 FALSE,
01596 0,
01597 complain_overflow_bitfield,
01598 0,
01599 "R_TRLA",
01600 TRUE,
01601 0xffff,
01602 0xffff,
01603 FALSE),
01604
01605
01606 HOWTO (R_RRTBI,
01607 1,
01608 2,
01609 32,
01610 FALSE,
01611 0,
01612 complain_overflow_bitfield,
01613 0,
01614 "R_RRTBI",
01615 TRUE,
01616 0xffffffff,
01617 0xffffffff,
01618 FALSE),
01619
01620
01621 HOWTO (R_RRTBA,
01622 1,
01623 2,
01624 32,
01625 FALSE,
01626 0,
01627 complain_overflow_bitfield,
01628 0,
01629 "R_RRTBA",
01630 TRUE,
01631 0xffffffff,
01632 0xffffffff,
01633 FALSE),
01634
01635
01636 HOWTO (R_CAI,
01637 0,
01638 1,
01639 16,
01640 FALSE,
01641 0,
01642 complain_overflow_bitfield,
01643 0,
01644 "R_CAI",
01645 TRUE,
01646 0xffff,
01647 0xffff,
01648 FALSE),
01649
01650
01651 HOWTO (R_CREL,
01652 0,
01653 1,
01654 16,
01655 FALSE,
01656 0,
01657 complain_overflow_bitfield,
01658 0,
01659 "R_CREL",
01660 TRUE,
01661 0xffff,
01662 0xffff,
01663 FALSE),
01664
01665
01666 HOWTO (R_RBA,
01667 0,
01668 2,
01669 26,
01670 FALSE,
01671 0,
01672 complain_overflow_bitfield,
01673 0,
01674 "R_RBA",
01675 TRUE,
01676 0x03fffffc,
01677 0x03fffffc,
01678 FALSE),
01679
01680
01681 HOWTO (R_RBAC,
01682 0,
01683 2,
01684 32,
01685 FALSE,
01686 0,
01687 complain_overflow_bitfield,
01688 0,
01689 "R_RBAC",
01690 TRUE,
01691 0xffffffff,
01692 0xffffffff,
01693 FALSE),
01694
01695
01696 HOWTO (R_RBR,
01697 0,
01698 2,
01699 26,
01700 FALSE,
01701 0,
01702 complain_overflow_signed,
01703 0,
01704 "R_RBR_26",
01705 TRUE,
01706 0x03fffffc,
01707 0x03fffffc,
01708 FALSE),
01709
01710
01711 HOWTO (R_RBRC,
01712 0,
01713 1,
01714 16,
01715 FALSE,
01716 0,
01717 complain_overflow_bitfield,
01718 0,
01719 "R_RBRC",
01720 TRUE,
01721 0xffff,
01722 0xffff,
01723 FALSE),
01724
01725 HOWTO (R_POS,
01726 0,
01727 2,
01728 32,
01729 FALSE,
01730 0,
01731 complain_overflow_bitfield,
01732 0,
01733 "R_POS_32",
01734 TRUE,
01735 0xffffffff,
01736 0xffffffff,
01737 FALSE),
01738
01739
01740 HOWTO (R_BA,
01741 0,
01742 1,
01743 16,
01744 FALSE,
01745 0,
01746 complain_overflow_bitfield,
01747 0,
01748 "R_BA_16",
01749 TRUE,
01750 0xfffc,
01751 0xfffc,
01752 FALSE),
01753
01754
01755 HOWTO (R_RBR,
01756 0,
01757 1,
01758 16,
01759 FALSE,
01760 0,
01761 complain_overflow_signed,
01762 0,
01763 "R_RBR_16",
01764 TRUE,
01765 0xffff,
01766 0xffff,
01767 FALSE),
01768
01769
01770 HOWTO (R_RBA,
01771 0,
01772 1,
01773 16,
01774 FALSE,
01775 0,
01776 complain_overflow_bitfield,
01777 0,
01778 "R_RBA_16",
01779 TRUE,
01780 0xffff,
01781 0xffff,
01782 FALSE),
01783
01784 };
01785
01786 void
01787 xcoff64_rtype2howto (relent, internal)
01788 arelent *relent;
01789 struct internal_reloc *internal;
01790 {
01791 if (internal->r_type > R_RBRC)
01792 abort ();
01793
01794
01795 relent->howto = &xcoff64_howto_table[internal->r_type];
01796
01797
01798 if (15 == (internal->r_size & 0x3f))
01799 {
01800 if (R_BA == internal->r_type)
01801 relent->howto = &xcoff64_howto_table[0x1d];
01802 else if (R_RBR == internal->r_type)
01803 relent->howto = &xcoff64_howto_table[0x1e];
01804 else if (R_RBA == internal->r_type)
01805 relent->howto = &xcoff64_howto_table[0x1f];
01806 }
01807
01808 else if (31 == (internal->r_size & 0x3f))
01809 {
01810 if (R_POS == internal->r_type)
01811 relent->howto = &xcoff64_howto_table[0x1c];
01812 }
01813
01814
01815
01816
01817
01818
01819 if (relent->howto->dst_mask != 0
01820 && (relent->howto->bitsize
01821 != ((unsigned int) internal->r_size & 0x3f) + 1))
01822 abort ();
01823 }
01824
01825 reloc_howto_type *
01826 xcoff64_reloc_type_lookup (abfd, code)
01827 bfd *abfd ATTRIBUTE_UNUSED;
01828 bfd_reloc_code_real_type code;
01829 {
01830 switch (code)
01831 {
01832 case BFD_RELOC_PPC_B26:
01833 return &xcoff64_howto_table[0xa];
01834 case BFD_RELOC_PPC_BA16:
01835 return &xcoff64_howto_table[0x1d];
01836 case BFD_RELOC_PPC_BA26:
01837 return &xcoff64_howto_table[8];
01838 case BFD_RELOC_PPC_TOC16:
01839 return &xcoff64_howto_table[3];
01840 case BFD_RELOC_32:
01841 case BFD_RELOC_CTOR:
01842 return &xcoff64_howto_table[0x1c];
01843 case BFD_RELOC_64:
01844 return &xcoff64_howto_table[0];
01845 default:
01846 return NULL;
01847 }
01848 }
01849
01850
01851
01852 static bfd_boolean
01853 xcoff64_slurp_armap (abfd)
01854 bfd *abfd;
01855 {
01856 file_ptr off;
01857 size_t namlen;
01858 bfd_size_type sz, amt;
01859 bfd_byte *contents, *cend;
01860 bfd_vma c, i;
01861 carsym *arsym;
01862 bfd_byte *p;
01863 file_ptr pos;
01864
01865
01866 struct xcoff_ar_hdr_big hdr;
01867
01868 if (xcoff_ardata (abfd) == NULL)
01869 {
01870 bfd_has_map (abfd) = FALSE;
01871 return TRUE;
01872 }
01873
01874 off = bfd_scan_vma (xcoff_ardata_big (abfd)->symoff64,
01875 (const char **) NULL, 10);
01876 if (off == 0)
01877 {
01878 bfd_has_map (abfd) = FALSE;
01879 return TRUE;
01880 }
01881
01882 if (bfd_seek (abfd, off, SEEK_SET) != 0)
01883 return FALSE;
01884
01885
01886 if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
01887 != SIZEOF_AR_HDR_BIG)
01888 return FALSE;
01889
01890
01891 namlen = strtol (hdr.namlen, (char **) NULL, 10);
01892 pos = ((namlen + 1) & ~(size_t) 1) + SXCOFFARFMAG;
01893 if (bfd_seek (abfd, pos, SEEK_CUR) != 0)
01894 return FALSE;
01895
01896 sz = bfd_scan_vma (hdr.size, (const char **) NULL, 10);
01897
01898
01899 contents = (bfd_byte *) bfd_alloc (abfd, sz);
01900 if (contents == NULL)
01901 return FALSE;
01902 if (bfd_bread ((PTR) contents, sz, abfd) != sz)
01903 return FALSE;
01904
01905
01906 c = H_GET_64 (abfd, contents);
01907
01908 if (c * 8 >= sz)
01909 {
01910 bfd_set_error (bfd_error_bad_value);
01911 return FALSE;
01912 }
01913 amt = c;
01914 amt *= sizeof (carsym);
01915 bfd_ardata (abfd)->symdefs = (carsym *) bfd_alloc (abfd, amt);
01916 if (bfd_ardata (abfd)->symdefs == NULL)
01917 return FALSE;
01918
01919
01920 for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8;
01921 i < c;
01922 ++i, ++arsym, p += 8)
01923 arsym->file_offset = H_GET_64 (abfd, p);
01924
01925
01926 cend = contents + sz;
01927 for (i = 0, arsym = bfd_ardata (abfd)->symdefs;
01928 i < c;
01929 ++i, ++arsym, p += strlen ((char *) p) + 1)
01930 {
01931 if (p >= cend)
01932 {
01933 bfd_set_error (bfd_error_bad_value);
01934 return FALSE;
01935 }
01936 arsym->name = (char *) p;
01937 }
01938
01939 bfd_ardata (abfd)->symdef_count = c;
01940 bfd_has_map (abfd) = TRUE;
01941
01942 return TRUE;
01943 }
01944
01945
01946
01947
01948 static const bfd_target *
01949 xcoff64_archive_p (abfd)
01950 bfd *abfd;
01951 {
01952 struct artdata *tdata_hold;
01953 char magic[SXCOFFARMAG];
01954
01955 struct xcoff_ar_file_hdr_big hdr;
01956 bfd_size_type amt = SXCOFFARMAG;
01957
01958 if (bfd_bread ((PTR) magic, amt, abfd) != amt)
01959 {
01960 if (bfd_get_error () != bfd_error_system_call)
01961 bfd_set_error (bfd_error_wrong_format);
01962 return NULL;
01963 }
01964
01965 if (strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0)
01966 {
01967 bfd_set_error (bfd_error_wrong_format);
01968 return NULL;
01969 }
01970
01971
01972 memcpy (hdr.magic, magic, SXCOFFARMAG);
01973
01974
01975 amt = SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG;
01976 if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt)
01977 {
01978 if (bfd_get_error () != bfd_error_system_call)
01979 bfd_set_error (bfd_error_wrong_format);
01980 return NULL;
01981 }
01982
01983 tdata_hold = bfd_ardata (abfd);
01984
01985 amt = sizeof (struct artdata);
01986 bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt);
01987 if (bfd_ardata (abfd) == (struct artdata *) NULL)
01988 goto error_ret_restore;
01989
01990 bfd_ardata (abfd)->cache = NULL;
01991 bfd_ardata (abfd)->archive_head = NULL;
01992 bfd_ardata (abfd)->symdefs = NULL;
01993 bfd_ardata (abfd)->extended_names = NULL;
01994 bfd_ardata (abfd)->first_file_filepos = bfd_scan_vma (hdr.firstmemoff,
01995 (const char **) NULL,
01996 10);
01997
01998 amt = SIZEOF_AR_FILE_HDR_BIG;
01999 bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
02000 if (bfd_ardata (abfd)->tdata == NULL)
02001 goto error_ret;
02002
02003 memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG);
02004
02005 if (! xcoff64_slurp_armap (abfd))
02006 {
02007 error_ret:
02008 bfd_release (abfd, bfd_ardata (abfd));
02009 error_ret_restore:
02010 bfd_ardata (abfd) = tdata_hold;
02011 return NULL;
02012 }
02013
02014 return abfd->xvec;
02015 }
02016
02017
02018
02019
02020 static bfd *
02021 xcoff64_openr_next_archived_file (archive, last_file)
02022 bfd *archive;
02023 bfd *last_file;
02024 {
02025 bfd_vma filestart;
02026
02027 if ((xcoff_ardata (archive) == NULL)
02028 || ! xcoff_big_format_p (archive))
02029 {
02030 bfd_set_error (bfd_error_invalid_operation);
02031 return NULL;
02032 }
02033
02034 if (last_file == NULL)
02035 {
02036 filestart = bfd_ardata (archive)->first_file_filepos;
02037 }
02038 else
02039 {
02040 filestart = bfd_scan_vma (arch_xhdr_big (last_file)->nextoff,
02041 (const char **) NULL, 10);
02042 }
02043
02044 if (filestart == 0
02045 || filestart == bfd_scan_vma (xcoff_ardata_big (archive)->memoff,
02046 (const char **) NULL, 10)
02047 || filestart == bfd_scan_vma (xcoff_ardata_big (archive)->symoff,
02048 (const char **) NULL, 10))
02049 {
02050 bfd_set_error (bfd_error_no_more_archived_files);
02051 return NULL;
02052 }
02053
02054 return _bfd_get_elt_at_filepos (archive, (file_ptr) filestart);
02055 }
02056
02057
02058
02059
02060 static int
02061 xcoff64_sizeof_headers (abfd, reloc)
02062 bfd *abfd;
02063 bfd_boolean reloc ATTRIBUTE_UNUSED;
02064 {
02065 int size;
02066
02067 size = bfd_coff_filhsz (abfd);
02068
02069
02070
02071
02072
02073 if (xcoff_data (abfd)->full_aouthdr)
02074 size += bfd_coff_aoutsz (abfd);
02075
02076 size += abfd->section_count * bfd_coff_scnhsz (abfd);
02077 return size;
02078 }
02079
02080
02081
02082 static asection *
02083 xcoff64_create_csect_from_smclas (abfd, aux, symbol_name)
02084 bfd *abfd;
02085 union internal_auxent *aux;
02086 const char *symbol_name;
02087 {
02088 asection *return_value = NULL;
02089
02090
02091
02092
02093 static const char *names[19] =
02094 {
02095 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
02096 NULL, ".bs", ".ds", ".uc", NULL, NULL, NULL, ".tc0",
02097 ".td", ".sv64", ".sv3264"
02098 };
02099
02100 if ((19 >= aux->x_csect.x_smclas)
02101 && (NULL != names[aux->x_csect.x_smclas]))
02102 {
02103
02104 return_value = bfd_make_section_anyway
02105 (abfd, names[aux->x_csect.x_smclas]);
02106
02107 }
02108 else
02109 {
02110 (*_bfd_error_handler)
02111 (_("%B: symbol `%s' has unrecognized smclas %d"),
02112 abfd, symbol_name, aux->x_csect.x_smclas);
02113 bfd_set_error (bfd_error_bad_value);
02114 }
02115
02116 return return_value;
02117 }
02118
02119 static bfd_boolean
02120 xcoff64_is_lineno_count_overflow (abfd, value)
02121 bfd *abfd ATTRIBUTE_UNUSED;
02122 bfd_vma value ATTRIBUTE_UNUSED;
02123 {
02124 return FALSE;
02125 }
02126
02127 static bfd_boolean
02128 xcoff64_is_reloc_count_overflow (abfd, value)
02129 bfd *abfd ATTRIBUTE_UNUSED;
02130 bfd_vma value ATTRIBUTE_UNUSED;
02131 {
02132 return FALSE;
02133 }
02134
02135 static bfd_vma
02136 xcoff64_loader_symbol_offset (abfd, ldhdr)
02137 bfd *abfd ATTRIBUTE_UNUSED;
02138 struct internal_ldhdr *ldhdr;
02139 {
02140 return (ldhdr->l_symoff);
02141 }
02142
02143 static bfd_vma
02144 xcoff64_loader_reloc_offset (abfd, ldhdr)
02145 bfd *abfd ATTRIBUTE_UNUSED;
02146 struct internal_ldhdr *ldhdr;
02147 {
02148 return (ldhdr->l_rldoff);
02149 }
02150
02151 static bfd_boolean
02152 xcoff64_bad_format_hook (abfd, filehdr)
02153 bfd * abfd;
02154 PTR filehdr;
02155 {
02156 struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
02157
02158
02159 if (bfd_get_flavour (abfd) != bfd_target_xcoff_flavour)
02160 return FALSE;
02161
02162 if (bfd_xcoff_magic_number (abfd) != internal_f->f_magic)
02163 return FALSE;
02164
02165 return TRUE;
02166 }
02167
02168 static bfd_boolean
02169 xcoff64_generate_rtinit (abfd, init, fini, rtld)
02170 bfd *abfd;
02171 const char *init;
02172 const char *fini;
02173 bfd_boolean rtld;
02174 {
02175 bfd_byte filehdr_ext[FILHSZ];
02176 bfd_byte scnhdr_ext[SCNHSZ * 3];
02177 bfd_byte syment_ext[SYMESZ * 10];
02178 bfd_byte reloc_ext[RELSZ * 3];
02179 bfd_byte *data_buffer;
02180 bfd_size_type data_buffer_size;
02181 bfd_byte *string_table, *st_tmp;
02182 bfd_size_type string_table_size;
02183 bfd_vma val;
02184 size_t initsz, finisz;
02185 struct internal_filehdr filehdr;
02186 struct internal_scnhdr text_scnhdr;
02187 struct internal_scnhdr data_scnhdr;
02188 struct internal_scnhdr bss_scnhdr;
02189 struct internal_syment syment;
02190 union internal_auxent auxent;
02191 struct internal_reloc reloc;
02192
02193 char *text_name = ".text";
02194 char *data_name = ".data";
02195 char *bss_name = ".bss";
02196 char *rtinit_name = "__rtinit";
02197 char *rtld_name = "__rtld";
02198
02199 if (! bfd_xcoff_rtinit_size (abfd))
02200 return FALSE;
02201
02202 initsz = (init == NULL ? 0 : 1 + strlen (init));
02203 finisz = (fini == NULL ? 0 : 1 + strlen (fini));
02204
02205
02206 memset (filehdr_ext, 0, FILHSZ);
02207 memset (&filehdr, 0, sizeof (struct internal_filehdr));
02208 filehdr.f_magic = bfd_xcoff_magic_number (abfd);
02209 filehdr.f_nscns = 3;
02210 filehdr.f_timdat = 0;
02211 filehdr.f_nsyms = 0;
02212 filehdr.f_symptr = 0;
02213 filehdr.f_opthdr = 0;
02214 filehdr.f_flags = 0;
02215
02216
02217 memset (scnhdr_ext, 0, 3 * SCNHSZ);
02218
02219
02220 memset (&text_scnhdr, 0, sizeof (struct internal_scnhdr));
02221 memcpy (text_scnhdr.s_name, text_name, strlen (text_name));
02222 text_scnhdr.s_paddr = 0;
02223 text_scnhdr.s_vaddr = 0;
02224 text_scnhdr.s_size = 0;
02225 text_scnhdr.s_scnptr = 0;
02226 text_scnhdr.s_relptr = 0;
02227 text_scnhdr.s_lnnoptr = 0;
02228 text_scnhdr.s_nreloc = 0;
02229 text_scnhdr.s_nlnno = 0;
02230 text_scnhdr.s_flags = STYP_TEXT;
02231
02232
02233 memset (&data_scnhdr, 0, sizeof (struct internal_scnhdr));
02234 memcpy (data_scnhdr.s_name, data_name, strlen (data_name));
02235 data_scnhdr.s_paddr = 0;
02236 data_scnhdr.s_vaddr = 0;
02237 data_scnhdr.s_size = 0;
02238 data_scnhdr.s_scnptr = FILHSZ + 3 * SCNHSZ;
02239 data_scnhdr.s_relptr = 0;
02240 data_scnhdr.s_lnnoptr = 0;
02241 data_scnhdr.s_nreloc = 0;
02242 data_scnhdr.s_nlnno = 0;
02243 data_scnhdr.s_flags = STYP_DATA;
02244
02245
02246 memset (&bss_scnhdr, 0, sizeof (struct internal_scnhdr));
02247 memcpy (bss_scnhdr.s_name, bss_name, strlen (bss_name));
02248 bss_scnhdr.s_paddr = 0;
02249 bss_scnhdr.s_vaddr = 0;
02250 bss_scnhdr.s_size = 0;
02251 bss_scnhdr.s_scnptr = 0;
02252 bss_scnhdr.s_relptr = 0;
02253 bss_scnhdr.s_lnnoptr = 0;
02254 bss_scnhdr.s_nreloc = 0;
02255 bss_scnhdr.s_nlnno = 0;
02256 bss_scnhdr.s_flags = STYP_BSS;
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284 data_buffer_size = 0x0058 + initsz + finisz;
02285 data_buffer_size = (data_buffer_size + 7) &~ (bfd_size_type) 7;
02286 data_buffer = NULL;
02287 data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size);
02288 if (data_buffer == NULL)
02289 return FALSE;
02290
02291 if (initsz)
02292 {
02293 val = 0x18;
02294 bfd_put_32 (abfd, val, &data_buffer[0x08]);
02295 val = 0x58;
02296 bfd_put_32 (abfd, val, &data_buffer[0x20]);
02297 memcpy (&data_buffer[val], init, initsz);
02298 }
02299
02300 if (finisz)
02301 {
02302 val = 0x38;
02303 bfd_put_32 (abfd, val, &data_buffer[0x0C]);
02304 val = 0x58 + initsz;
02305 bfd_put_32 (abfd, val, &data_buffer[0x40]);
02306 memcpy (&data_buffer[val], fini, finisz);
02307 }
02308
02309 val = 0x10;
02310 bfd_put_32 (abfd, val, &data_buffer[0x10]);
02311 data_scnhdr.s_size = data_buffer_size;
02312 bss_scnhdr.s_paddr = bss_scnhdr.s_vaddr = data_scnhdr.s_size;
02313
02314
02315 string_table_size = 4;
02316 string_table_size += strlen (data_name) + 1;
02317 string_table_size += strlen (rtinit_name) + 1;
02318 string_table_size += initsz;
02319 string_table_size += finisz;
02320 if (rtld)
02321 string_table_size += strlen (rtld_name) + 1;
02322
02323 string_table = (bfd_byte *) bfd_zmalloc (string_table_size);
02324 if (string_table == NULL)
02325 return FALSE;
02326
02327 val = string_table_size;
02328 bfd_put_32 (abfd, val, &string_table[0]);
02329 st_tmp = string_table + 4;
02330
02331
02332
02333
02334
02335
02336
02337 memset (syment_ext, 0, 10 * SYMESZ);
02338 memset (reloc_ext, 0, 3 * RELSZ);
02339
02340
02341 memset (&syment, 0, sizeof (struct internal_syment));
02342 memset (&auxent, 0, sizeof (union internal_auxent));
02343
02344 syment._n._n_n._n_offset = st_tmp - string_table;
02345 memcpy (st_tmp, data_name, strlen (data_name));
02346 st_tmp += strlen (data_name) + 1;
02347
02348 syment.n_scnum = 2;
02349 syment.n_sclass = C_HIDEXT;
02350 syment.n_numaux = 1;
02351 auxent.x_csect.x_scnlen.l = data_buffer_size;
02352 auxent.x_csect.x_smtyp = 3 << 3 | XTY_SD;
02353 auxent.x_csect.x_smclas = XMC_RW;
02354 bfd_coff_swap_sym_out (abfd, &syment,
02355 &syment_ext[filehdr.f_nsyms * SYMESZ]);
02356 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
02357 syment.n_numaux,
02358 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
02359 filehdr.f_nsyms += 2;
02360
02361
02362 memset (&syment, 0, sizeof (struct internal_syment));
02363 memset (&auxent, 0, sizeof (union internal_auxent));
02364 syment._n._n_n._n_offset = st_tmp - string_table;
02365 memcpy (st_tmp, rtinit_name, strlen (rtinit_name));
02366 st_tmp += strlen (rtinit_name) + 1;
02367
02368 syment.n_scnum = 2;
02369 syment.n_sclass = C_EXT;
02370 syment.n_numaux = 1;
02371 auxent.x_csect.x_smtyp = XTY_LD;
02372 auxent.x_csect.x_smclas = XMC_RW;
02373 bfd_coff_swap_sym_out (abfd, &syment,
02374 &syment_ext[filehdr.f_nsyms * SYMESZ]);
02375 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
02376 syment.n_numaux,
02377 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
02378 filehdr.f_nsyms += 2;
02379
02380
02381 if (initsz)
02382 {
02383 memset (&syment, 0, sizeof (struct internal_syment));
02384 memset (&auxent, 0, sizeof (union internal_auxent));
02385
02386 syment._n._n_n._n_offset = st_tmp - string_table;
02387 memcpy (st_tmp, init, initsz);
02388 st_tmp += initsz;
02389
02390 syment.n_sclass = C_EXT;
02391 syment.n_numaux = 1;
02392 bfd_coff_swap_sym_out (abfd, &syment,
02393 &syment_ext[filehdr.f_nsyms * SYMESZ]);
02394 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
02395 syment.n_numaux,
02396 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
02397
02398 memset (&reloc, 0, sizeof (struct internal_reloc));
02399 reloc.r_vaddr = 0x0018;
02400 reloc.r_symndx = filehdr.f_nsyms;
02401 reloc.r_type = R_POS;
02402 reloc.r_size = 63;
02403 bfd_coff_swap_reloc_out (abfd, &reloc, &reloc_ext[0]);
02404
02405 filehdr.f_nsyms += 2;
02406 data_scnhdr.s_nreloc += 1;
02407 }
02408
02409
02410 if (finisz)
02411 {
02412 memset (&syment, 0, sizeof (struct internal_syment));
02413 memset (&auxent, 0, sizeof (union internal_auxent));
02414
02415 syment._n._n_n._n_offset = st_tmp - string_table;
02416 memcpy (st_tmp, fini, finisz);
02417 st_tmp += finisz;
02418
02419 syment.n_sclass = C_EXT;
02420 syment.n_numaux = 1;
02421 bfd_coff_swap_sym_out (abfd, &syment,
02422 &syment_ext[filehdr.f_nsyms * SYMESZ]);
02423 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
02424 syment.n_numaux,
02425 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
02426
02427
02428 memset (&reloc, 0, sizeof (struct internal_reloc));
02429 reloc.r_vaddr = 0x0038;
02430 reloc.r_symndx = filehdr.f_nsyms;
02431 reloc.r_type = R_POS;
02432 reloc.r_size = 63;
02433 bfd_coff_swap_reloc_out (abfd, &reloc,
02434 &reloc_ext[data_scnhdr.s_nreloc * RELSZ]);
02435
02436 filehdr.f_nsyms += 2;
02437 data_scnhdr.s_nreloc += 1;
02438 }
02439
02440 if (rtld)
02441 {
02442 memset (&syment, 0, sizeof (struct internal_syment));
02443 memset (&auxent, 0, sizeof (union internal_auxent));
02444
02445 syment._n._n_n._n_offset = st_tmp - string_table;
02446 memcpy (st_tmp, rtld_name, strlen (rtld_name));
02447 st_tmp += strlen (rtld_name) + 1;
02448
02449 syment.n_sclass = C_EXT;
02450 syment.n_numaux = 1;
02451 bfd_coff_swap_sym_out (abfd, &syment,
02452 &syment_ext[filehdr.f_nsyms * SYMESZ]);
02453 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
02454 syment.n_numaux,
02455 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
02456
02457
02458 memset (&reloc, 0, sizeof (struct internal_reloc));
02459 reloc.r_vaddr = 0x0000;
02460 reloc.r_symndx = filehdr.f_nsyms;
02461 reloc.r_type = R_POS;
02462 reloc.r_size = 63;
02463 bfd_coff_swap_reloc_out (abfd, &reloc,
02464 &reloc_ext[data_scnhdr.s_nreloc * RELSZ]);
02465
02466 filehdr.f_nsyms += 2;
02467 data_scnhdr.s_nreloc += 1;
02468
02469 bss_scnhdr.s_size = 0;
02470 }
02471
02472 data_scnhdr.s_relptr = data_scnhdr.s_scnptr + data_buffer_size;
02473 filehdr.f_symptr = data_scnhdr.s_relptr + data_scnhdr.s_nreloc * RELSZ;
02474
02475 bfd_coff_swap_filehdr_out (abfd, &filehdr, filehdr_ext);
02476 bfd_bwrite (filehdr_ext, FILHSZ, abfd);
02477 bfd_coff_swap_scnhdr_out (abfd, &text_scnhdr, &scnhdr_ext[SCNHSZ * 0]);
02478 bfd_coff_swap_scnhdr_out (abfd, &data_scnhdr, &scnhdr_ext[SCNHSZ * 1]);
02479 bfd_coff_swap_scnhdr_out (abfd, &bss_scnhdr, &scnhdr_ext[SCNHSZ * 2]);
02480 bfd_bwrite (scnhdr_ext, 3 * SCNHSZ, abfd);
02481 bfd_bwrite (data_buffer, data_buffer_size, abfd);
02482 bfd_bwrite (reloc_ext, data_scnhdr.s_nreloc * RELSZ, abfd);
02483 bfd_bwrite (syment_ext, filehdr.f_nsyms * SYMESZ, abfd);
02484 bfd_bwrite (string_table, string_table_size, abfd);
02485
02486 free (data_buffer);
02487 data_buffer = NULL;
02488
02489 return TRUE;
02490 }
02491
02492
02493
02494 static reloc_howto_type xcoff64_dynamic_reloc =
02495 HOWTO (0,
02496 0,
02497 4,
02498 64,
02499 FALSE,
02500 0,
02501 complain_overflow_bitfield,
02502 0,
02503 "R_POS",
02504 TRUE,
02505 MINUS_ONE,
02506 MINUS_ONE,
02507 FALSE);
02508
02509 static unsigned long xcoff64_glink_code[10] =
02510 {
02511 0xe9820000,
02512 0xf8410028,
02513 0xe80c0000,
02514 0xe84c0008,
02515 0x7c0903a6,
02516 0x4e800420,
02517 0x00000000,
02518 0x000ca000,
02519 0x00000000,
02520 0x00000018,
02521 };
02522
02523 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
02524 {
02525 {
02526 _bfd_xcoff64_swap_aux_in,
02527 _bfd_xcoff64_swap_sym_in,
02528 _bfd_xcoff64_swap_lineno_in,
02529 _bfd_xcoff64_swap_aux_out,
02530 _bfd_xcoff64_swap_sym_out,
02531 _bfd_xcoff64_swap_lineno_out,
02532 xcoff64_swap_reloc_out,
02533 coff_swap_filehdr_out,
02534 coff_swap_aouthdr_out,
02535 coff_swap_scnhdr_out,
02536 FILHSZ,
02537 AOUTSZ,
02538 SCNHSZ,
02539 SYMESZ,
02540 AUXESZ,
02541 RELSZ,
02542 LINESZ,
02543 FILNMLEN,
02544 TRUE,
02545 FALSE,
02546 3,
02547 TRUE,
02548 4,
02549 coff_swap_filehdr_in,
02550 coff_swap_aouthdr_in,
02551 coff_swap_scnhdr_in,
02552 xcoff64_swap_reloc_in,
02553 xcoff64_bad_format_hook,
02554 coff_set_arch_mach_hook,
02555 coff_mkobject_hook,
02556 styp_to_sec_flags,
02557 coff_set_alignment_hook,
02558 coff_slurp_symbol_table,
02559 symname_in_debug_hook,
02560 coff_pointerize_aux_hook,
02561 coff_print_aux,
02562 dummy_reloc16_extra_cases,
02563 dummy_reloc16_estimate,
02564 NULL,
02565 coff_compute_section_file_positions,
02566 NULL,
02567 xcoff64_ppc_relocate_section,
02568 coff_rtype_to_howto,
02569 NULL,
02570 _bfd_generic_link_add_one_symbol,
02571 coff_link_output_has_begun,
02572 coff_final_link_postscript
02573 },
02574
02575 0x01EF,
02576 bfd_arch_powerpc,
02577 bfd_mach_ppc_620,
02578
02579
02580 xcoff64_swap_ldhdr_in,
02581 xcoff64_swap_ldhdr_out,
02582 xcoff64_swap_ldsym_in,
02583 xcoff64_swap_ldsym_out,
02584 xcoff64_swap_ldrel_in,
02585 xcoff64_swap_ldrel_out,
02586
02587
02588 LDHDRSZ,
02589 LDSYMSZ,
02590 LDRELSZ,
02591 24,
02592 0,
02593
02594
02595 2,
02596
02597 _bfd_xcoff64_put_symbol_name,
02598 _bfd_xcoff64_put_ldsymbol_name,
02599 &xcoff64_dynamic_reloc,
02600 xcoff64_create_csect_from_smclas,
02601
02602
02603 xcoff64_is_lineno_count_overflow,
02604 xcoff64_is_reloc_count_overflow,
02605
02606 xcoff64_loader_symbol_offset,
02607 xcoff64_loader_reloc_offset,
02608
02609
02610 &xcoff64_glink_code[0],
02611 40,
02612
02613
02614 88,
02615 xcoff64_generate_rtinit,
02616 };
02617
02618
02619 const bfd_target rs6000coff64_vec =
02620 {
02621 "aixcoff64-rs6000",
02622 bfd_target_xcoff_flavour,
02623 BFD_ENDIAN_BIG,
02624 BFD_ENDIAN_BIG,
02625
02626 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC
02627 | HAS_SYMS | HAS_LOCALS | WP_TEXT),
02628
02629 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA,
02630 0,
02631 '/',
02632 15,
02633
02634
02635 bfd_getb64,
02636 bfd_getb_signed_64,
02637 bfd_putb64,
02638 bfd_getb32,
02639 bfd_getb_signed_32,
02640 bfd_putb32,
02641 bfd_getb16,
02642 bfd_getb_signed_16,
02643 bfd_putb16,
02644
02645
02646 bfd_getb64,
02647 bfd_getb_signed_64,
02648 bfd_putb64,
02649 bfd_getb32,
02650 bfd_getb_signed_32,
02651 bfd_putb32,
02652 bfd_getb16,
02653 bfd_getb_signed_16,
02654 bfd_putb16,
02655
02656 {
02657 _bfd_dummy_target,
02658 coff_object_p,
02659 xcoff64_archive_p,
02660 CORE_FILE_P
02661 },
02662
02663 {
02664 bfd_false,
02665 coff_mkobject,
02666 _bfd_generic_mkarchive,
02667 bfd_false
02668 },
02669
02670 {
02671 bfd_false,
02672 xcoff64_write_object_contents,
02673 _bfd_xcoff_write_archive_contents,
02674 bfd_false
02675 },
02676
02677
02678 bfd_true,
02679 bfd_true,
02680 coff_new_section_hook,
02681 _bfd_generic_get_section_contents,
02682 _bfd_generic_get_section_contents_in_window,
02683
02684
02685 _bfd_xcoff_copy_private_bfd_data,
02686 ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
02687 ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
02688 ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
02689 ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
02690 ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
02691 ((bfd_boolean (*) (bfd *, void * )) bfd_true),
02692
02693
02694 coff_core_file_failing_command,
02695 coff_core_file_failing_signal,
02696 coff_core_file_matches_executable_p,
02697
02698
02699 xcoff64_slurp_armap,
02700 bfd_false,
02701 ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
02702 bfd_dont_truncate_arname,
02703 _bfd_xcoff_write_armap,
02704 _bfd_xcoff_read_ar_hdr,
02705 xcoff64_openr_next_archived_file,
02706 _bfd_generic_get_elt_at_index,
02707 _bfd_xcoff_stat_arch_elt,
02708 bfd_true,
02709
02710
02711 coff_get_symtab_upper_bound,
02712 coff_canonicalize_symtab,
02713 coff_make_empty_symbol,
02714 coff_print_symbol,
02715 coff_get_symbol_info,
02716 _bfd_xcoff_is_local_label_name,
02717 coff_bfd_is_target_special_symbol,
02718 coff_get_lineno,
02719 coff_find_nearest_line,
02720 coff_bfd_make_debug_symbol,
02721 _bfd_generic_read_minisymbols,
02722 _bfd_generic_minisymbol_to_symbol,
02723
02724
02725 coff_get_reloc_upper_bound,
02726 coff_canonicalize_reloc,
02727 xcoff64_reloc_type_lookup,
02728
02729
02730 coff_set_arch_mach,
02731 coff_set_section_contents,
02732
02733
02734 xcoff64_sizeof_headers,
02735 bfd_generic_get_relocated_section_contents,
02736 bfd_generic_relax_section,
02737 _bfd_xcoff_bfd_link_hash_table_create,
02738 _bfd_generic_link_hash_table_free,
02739 _bfd_xcoff_bfd_link_add_symbols,
02740 _bfd_generic_link_just_syms,
02741 _bfd_xcoff_bfd_final_link,
02742 _bfd_generic_link_split_section,
02743 bfd_generic_gc_sections,
02744 bfd_generic_merge_sections,
02745 bfd_generic_is_group_section,
02746 bfd_generic_discard_group,
02747 _bfd_generic_section_already_linked,
02748
02749
02750 _bfd_xcoff_get_dynamic_symtab_upper_bound,
02751 _bfd_xcoff_canonicalize_dynamic_symtab,
02752 _bfd_nodynamic_get_synthetic_symtab,
02753 _bfd_xcoff_get_dynamic_reloc_upper_bound,
02754 _bfd_xcoff_canonicalize_dynamic_reloc,
02755
02756
02757 NULL,
02758
02759 (void *) &bfd_xcoff_backend_data,
02760 };
02761
02762 extern const bfd_target *xcoff64_core_p
02763 PARAMS ((bfd *));
02764 extern bfd_boolean xcoff64_core_file_matches_executable_p
02765 PARAMS ((bfd *, bfd *));
02766 extern char *xcoff64_core_file_failing_command
02767 PARAMS ((bfd *));
02768 extern int xcoff64_core_file_failing_signal
02769 PARAMS ((bfd *));
02770
02771
02772 static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data =
02773 {
02774 {
02775 _bfd_xcoff64_swap_aux_in,
02776 _bfd_xcoff64_swap_sym_in,
02777 _bfd_xcoff64_swap_lineno_in,
02778 _bfd_xcoff64_swap_aux_out,
02779 _bfd_xcoff64_swap_sym_out,
02780 _bfd_xcoff64_swap_lineno_out,
02781 xcoff64_swap_reloc_out,
02782 coff_swap_filehdr_out,
02783 coff_swap_aouthdr_out,
02784 coff_swap_scnhdr_out,
02785 FILHSZ,
02786 AOUTSZ,
02787 SCNHSZ,
02788 SYMESZ,
02789 AUXESZ,
02790 RELSZ,
02791 LINESZ,
02792 FILNMLEN,
02793 TRUE,
02794 FALSE,
02795 3,
02796 TRUE,
02797 4,
02798 coff_swap_filehdr_in,
02799 coff_swap_aouthdr_in,
02800 coff_swap_scnhdr_in,
02801 xcoff64_swap_reloc_in,
02802 xcoff64_bad_format_hook,
02803 coff_set_arch_mach_hook,
02804 coff_mkobject_hook,
02805 styp_to_sec_flags,
02806 coff_set_alignment_hook,
02807 coff_slurp_symbol_table,
02808 symname_in_debug_hook,
02809 coff_pointerize_aux_hook,
02810 coff_print_aux,
02811 dummy_reloc16_extra_cases,
02812 dummy_reloc16_estimate,
02813 NULL,
02814 coff_compute_section_file_positions,
02815 NULL,
02816 xcoff64_ppc_relocate_section,
02817 coff_rtype_to_howto,
02818 NULL,
02819 _bfd_generic_link_add_one_symbol,
02820 coff_link_output_has_begun,
02821 coff_final_link_postscript
02822 },
02823
02824 U64_TOCMAGIC,
02825 bfd_arch_powerpc,
02826 bfd_mach_ppc_620,
02827
02828
02829 xcoff64_swap_ldhdr_in,
02830 xcoff64_swap_ldhdr_out,
02831 xcoff64_swap_ldsym_in,
02832 xcoff64_swap_ldsym_out,
02833 xcoff64_swap_ldrel_in,
02834 xcoff64_swap_ldrel_out,
02835
02836
02837 LDHDRSZ,
02838 LDSYMSZ,
02839 LDRELSZ,
02840 24,
02841 0,
02842
02843 2,
02844
02845 _bfd_xcoff64_put_symbol_name,
02846 _bfd_xcoff64_put_ldsymbol_name,
02847 &xcoff64_dynamic_reloc,
02848 xcoff64_create_csect_from_smclas,
02849
02850
02851 xcoff64_is_lineno_count_overflow,
02852 xcoff64_is_reloc_count_overflow,
02853
02854 xcoff64_loader_symbol_offset,
02855 xcoff64_loader_reloc_offset,
02856
02857
02858 &xcoff64_glink_code[0],
02859 40,
02860
02861
02862 88,
02863 xcoff64_generate_rtinit,
02864 };
02865
02866
02867 const bfd_target aix5coff64_vec =
02868 {
02869 "aix5coff64-rs6000",
02870 bfd_target_xcoff_flavour,
02871 BFD_ENDIAN_BIG,
02872 BFD_ENDIAN_BIG,
02873
02874 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC
02875 | HAS_SYMS | HAS_LOCALS | WP_TEXT),
02876
02877 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA,
02878 0,
02879 '/',
02880 15,
02881
02882
02883 bfd_getb64,
02884 bfd_getb_signed_64,
02885 bfd_putb64,
02886 bfd_getb32,
02887 bfd_getb_signed_32,
02888 bfd_putb32,
02889 bfd_getb16,
02890 bfd_getb_signed_16,
02891 bfd_putb16,
02892
02893
02894 bfd_getb64,
02895 bfd_getb_signed_64,
02896 bfd_putb64,
02897 bfd_getb32,
02898 bfd_getb_signed_32,
02899 bfd_putb32,
02900 bfd_getb16,
02901 bfd_getb_signed_16,
02902 bfd_putb16,
02903
02904 {
02905 _bfd_dummy_target,
02906 coff_object_p,
02907 xcoff64_archive_p,
02908 xcoff64_core_p
02909 },
02910
02911 {
02912 bfd_false,
02913 coff_mkobject,
02914 _bfd_generic_mkarchive,
02915 bfd_false
02916 },
02917
02918 {
02919 bfd_false,
02920 xcoff64_write_object_contents,
02921 _bfd_xcoff_write_archive_contents,
02922 bfd_false
02923 },
02924
02925
02926 bfd_true,
02927 bfd_true,
02928 coff_new_section_hook,
02929 _bfd_generic_get_section_contents,
02930 _bfd_generic_get_section_contents_in_window,
02931
02932
02933 _bfd_xcoff_copy_private_bfd_data,
02934 ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
02935 ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
02936 ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
02937 ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
02938 ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
02939 ((bfd_boolean (*) (bfd *, void * )) bfd_true),
02940
02941
02942 xcoff64_core_file_failing_command,
02943 xcoff64_core_file_failing_signal,
02944 xcoff64_core_file_matches_executable_p,
02945
02946
02947 xcoff64_slurp_armap,
02948 bfd_false,
02949 ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
02950 bfd_dont_truncate_arname,
02951 _bfd_xcoff_write_armap,
02952 _bfd_xcoff_read_ar_hdr,
02953 xcoff64_openr_next_archived_file,
02954 _bfd_generic_get_elt_at_index,
02955 _bfd_xcoff_stat_arch_elt,
02956 bfd_true,
02957
02958
02959 coff_get_symtab_upper_bound,
02960 coff_canonicalize_symtab,
02961 coff_make_empty_symbol,
02962 coff_print_symbol,
02963 coff_get_symbol_info,
02964 _bfd_xcoff_is_local_label_name,
02965 coff_bfd_is_target_special_symbol,
02966 coff_get_lineno,
02967 coff_find_nearest_line,
02968 coff_bfd_make_debug_symbol,
02969 _bfd_generic_read_minisymbols,
02970 _bfd_generic_minisymbol_to_symbol,
02971
02972
02973 coff_get_reloc_upper_bound,
02974 coff_canonicalize_reloc,
02975 xcoff64_reloc_type_lookup,
02976
02977
02978 coff_set_arch_mach,
02979 coff_set_section_contents,
02980
02981
02982 xcoff64_sizeof_headers,
02983 bfd_generic_get_relocated_section_contents,
02984 bfd_generic_relax_section,
02985 _bfd_xcoff_bfd_link_hash_table_create,
02986 _bfd_generic_link_hash_table_free,
02987 _bfd_xcoff_bfd_link_add_symbols,
02988 _bfd_generic_link_just_syms,
02989 _bfd_xcoff_bfd_final_link,
02990 _bfd_generic_link_split_section,
02991 bfd_generic_gc_sections,
02992 bfd_generic_merge_sections,
02993 bfd_generic_is_group_section,
02994 bfd_generic_discard_group,
02995 _bfd_generic_section_already_linked,
02996
02997
02998 _bfd_xcoff_get_dynamic_symtab_upper_bound,
02999 _bfd_xcoff_canonicalize_dynamic_symtab,
03000 _bfd_nodynamic_get_synthetic_symtab,
03001 _bfd_xcoff_get_dynamic_reloc_upper_bound,
03002 _bfd_xcoff_canonicalize_dynamic_reloc,
03003
03004
03005 NULL,
03006
03007 (void *) & bfd_xcoff_aix5_backend_data,
03008 };