1 /* BFD back-end for IBM RS/6000 "XCOFF64" files.
2 Copyright 2000, 2001, 2002
3 Free Software Foundation, Inc.
4 Written Clinton Popetz.
5 Contributed by Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27 #include "coff/internal.h"
28 #include "coff/xcoff.h"
29 #include "coff/rs6k64.h"
33 #define GET_FILEHDR_SYMPTR H_GET_64
34 #define PUT_FILEHDR_SYMPTR H_PUT_64
35 #define GET_AOUTHDR_DATA_START H_GET_64
36 #define PUT_AOUTHDR_DATA_START H_PUT_64
37 #define GET_AOUTHDR_TEXT_START H_GET_64
38 #define PUT_AOUTHDR_TEXT_START H_PUT_64
39 #define GET_AOUTHDR_TSIZE H_GET_64
40 #define PUT_AOUTHDR_TSIZE H_PUT_64
41 #define GET_AOUTHDR_DSIZE H_GET_64
42 #define PUT_AOUTHDR_DSIZE H_PUT_64
43 #define GET_AOUTHDR_BSIZE H_GET_64
44 #define PUT_AOUTHDR_BSIZE H_PUT_64
45 #define GET_AOUTHDR_ENTRY H_GET_64
46 #define PUT_AOUTHDR_ENTRY H_PUT_64
47 #define GET_SCNHDR_PADDR H_GET_64
48 #define PUT_SCNHDR_PADDR H_PUT_64
49 #define GET_SCNHDR_VADDR H_GET_64
50 #define PUT_SCNHDR_VADDR H_PUT_64
51 #define GET_SCNHDR_SIZE H_GET_64
52 #define PUT_SCNHDR_SIZE H_PUT_64
53 #define GET_SCNHDR_SCNPTR H_GET_64
54 #define PUT_SCNHDR_SCNPTR H_PUT_64
55 #define GET_SCNHDR_RELPTR H_GET_64
56 #define PUT_SCNHDR_RELPTR H_PUT_64
57 #define GET_SCNHDR_LNNOPTR H_GET_64
58 #define PUT_SCNHDR_LNNOPTR H_PUT_64
59 #define GET_SCNHDR_NRELOC H_GET_32
60 #define MAX_SCNHDR_NRELOC 0xffffffff
61 #define PUT_SCNHDR_NRELOC H_PUT_32
62 #define GET_SCNHDR_NLNNO H_GET_32
63 #define MAX_SCNHDR_NLNNO 0xffffffff
64 #define PUT_SCNHDR_NLNNO H_PUT_32
65 #define GET_RELOC_VADDR H_GET_64
66 #define PUT_RELOC_VADDR H_PUT_64
68 #define COFF_FORCE_SYMBOLS_IN_STRINGS
69 #define COFF_DEBUG_STRING_WIDE_PREFIX
72 #define COFF_ADJUST_SCNHDR_OUT_POST(ABFD, INT, EXT) \
75 memset (((SCNHDR *) EXT)->s_pad, 0, \
76 sizeof (((SCNHDR *) EXT)->s_pad)); \
80 #define NO_COFF_LINENOS
82 #define coff_SWAP_lineno_in _bfd_xcoff64_swap_lineno_in
83 #define coff_SWAP_lineno_out _bfd_xcoff64_swap_lineno_out
85 static void _bfd_xcoff64_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
86 static unsigned int _bfd_xcoff64_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
87 static boolean _bfd_xcoff64_put_symbol_name
88 PARAMS ((bfd *, struct bfd_strtab_hash *, struct internal_syment *,
90 static boolean _bfd_xcoff64_put_ldsymbol_name
91 PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
93 static void _bfd_xcoff64_swap_sym_in PARAMS ((bfd *, PTR, PTR));
94 static unsigned int _bfd_xcoff64_swap_sym_out PARAMS ((bfd *, PTR, PTR));
95 static void _bfd_xcoff64_swap_aux_in
96 PARAMS ((bfd *, PTR, int, int, int, int, PTR));
97 static unsigned int _bfd_xcoff64_swap_aux_out
98 PARAMS ((bfd *, PTR, int, int, int, int, PTR));
99 static void xcoff64_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
100 static unsigned int xcoff64_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
101 extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *));
102 extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
103 extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *));
104 extern void xcoff64_rtype2howto
105 PARAMS ((arelent *, struct internal_reloc *));
106 extern reloc_howto_type * xcoff64_reloc_type_lookup
107 PARAMS ((bfd *, bfd_reloc_code_real_type));
108 extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *));
109 extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));
110 extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
111 extern int _bfd_xcoff_stat_arch_elt PARAMS ((bfd *, struct stat *));
112 extern boolean _bfd_xcoff_write_armap
113 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
114 extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));
115 extern int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean));
116 extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
117 extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
118 extern void _bfd_xcoff_swap_aux_in
119 PARAMS ((bfd *, PTR, int, int, int, int, PTR));
120 extern unsigned int _bfd_xcoff_swap_aux_out
121 PARAMS ((bfd *, PTR, int, int, int, int, PTR));
122 static void xcoff64_swap_ldhdr_in
123 PARAMS ((bfd *, const PTR, struct internal_ldhdr *));
124 static void xcoff64_swap_ldhdr_out
125 PARAMS ((bfd *, const struct internal_ldhdr *, PTR d));
126 static void xcoff64_swap_ldsym_in
127 PARAMS ((bfd *, const PTR, struct internal_ldsym *));
128 static void xcoff64_swap_ldsym_out
129 PARAMS ((bfd *, const struct internal_ldsym *, PTR d));
130 static void xcoff64_swap_ldrel_in
131 PARAMS ((bfd *, const PTR, struct internal_ldrel *));
132 static void xcoff64_swap_ldrel_out
133 PARAMS ((bfd *, const struct internal_ldrel *, PTR d));
134 static boolean xcoff64_write_object_contents PARAMS ((bfd *));
135 static boolean xcoff64_ppc_relocate_section
136 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
137 struct internal_reloc *, struct internal_syment *,
139 static boolean xcoff64_slurp_armap PARAMS ((bfd *));
140 static const bfd_target *xcoff64_archive_p PARAMS ((bfd *));
141 static bfd *xcoff64_openr_next_archived_file PARAMS ((bfd *, bfd *));
142 static int xcoff64_sizeof_headers PARAMS ((bfd *, boolean));
143 static asection *xcoff64_create_csect_from_smclas
144 PARAMS ((bfd *, union internal_auxent *, const char *));
145 static boolean xcoff64_is_lineno_count_overflow PARAMS ((bfd *, bfd_vma));
146 static boolean xcoff64_is_reloc_count_overflow PARAMS ((bfd *, bfd_vma));
147 static bfd_vma xcoff64_loader_symbol_offset
148 PARAMS ((bfd *, struct internal_ldhdr *));
149 static bfd_vma xcoff64_loader_reloc_offset
150 PARAMS ((bfd *, struct internal_ldhdr *));
151 static boolean xcoff64_generate_rtinit
152 PARAMS ((bfd *, const char *, const char *, boolean));
153 static boolean xcoff64_bad_format_hook PARAMS ((bfd *, PTR ));
155 /* coffcode.h needs these to be defined. */
156 /* Internalcoff.h and coffcode.h modify themselves based on these flags. */
158 #define RS6000COFF_C 1
160 #define SELECT_RELOC(internal, howto) \
162 internal.r_type = howto->type; \
164 ((howto->complain_on_overflow == complain_overflow_signed \
167 | (howto->bitsize - 1)); \
170 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
171 #define COFF_LONG_FILENAMES
172 #define NO_COFF_SYMBOLS
173 #define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst)
174 #define coff_mkobject _bfd_xcoff_mkobject
175 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
176 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
177 #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
179 extern const bfd_target * rs6000coff_core_p PARAMS ((bfd *abfd));
180 extern boolean rs6000coff_core_file_matches_executable_p
181 PARAMS((bfd *cbfd, bfd *ebfd));
182 extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
183 extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
184 #define CORE_FILE_P rs6000coff_core_p
185 #define coff_core_file_failing_command \
186 rs6000coff_core_file_failing_command
187 #define coff_core_file_failing_signal \
188 rs6000coff_core_file_failing_signal
189 #define coff_core_file_matches_executable_p \
190 rs6000coff_core_file_matches_executable_p
192 #define CORE_FILE_P _bfd_dummy_target
193 #define coff_core_file_failing_command \
194 _bfd_nocore_core_file_failing_command
195 #define coff_core_file_failing_signal \
196 _bfd_nocore_core_file_failing_signal
197 #define coff_core_file_matches_executable_p \
198 _bfd_nocore_core_file_matches_executable_p
200 #define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
201 #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
202 #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
203 #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
204 #define coff_swap_reloc_in xcoff64_swap_reloc_in
205 #define coff_swap_reloc_out xcoff64_swap_reloc_out
206 #define NO_COFF_RELOCS
208 #include "coffcode.h"
210 /* For XCOFF64, the effective width of symndx changes depending on
211 whether we are the first entry. Sigh. */
213 _bfd_xcoff64_swap_lineno_in (abfd, ext1, in1)
218 LINENO *ext = (LINENO *) ext1;
219 struct internal_lineno *in = (struct internal_lineno *) in1;
221 in->l_lnno = H_GET_32 (abfd, (ext->l_lnno));
223 in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
225 in->l_addr.l_paddr = H_GET_64 (abfd, ext->l_addr.l_paddr);
229 _bfd_xcoff64_swap_lineno_out (abfd, inp, outp)
234 struct internal_lineno *in = (struct internal_lineno *) inp;
235 struct external_lineno *ext = (struct external_lineno *) outp;
237 H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
238 H_PUT_32 (abfd, in->l_lnno, (ext->l_lnno));
241 H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
243 H_PUT_64 (abfd, in->l_addr.l_paddr, ext->l_addr.l_paddr);
245 return bfd_coff_linesz (abfd);
249 _bfd_xcoff64_swap_sym_in (abfd, ext1, in1)
254 struct external_syment *ext = (struct external_syment *) ext1;
255 struct internal_syment *in = (struct internal_syment *) in1;
257 in->_n._n_n._n_zeroes = 0;
258 in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e_offset);
259 in->n_value = H_GET_64 (abfd, ext->e_value);
260 in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
261 in->n_type = H_GET_16 (abfd, ext->e_type);
262 in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
263 in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
267 _bfd_xcoff64_swap_sym_out (abfd, inp, extp)
272 struct internal_syment *in = (struct internal_syment *) inp;
273 struct external_syment *ext = (struct external_syment *) extp;
275 H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e_offset);
276 H_PUT_64 (abfd, in->n_value, ext->e_value);
277 H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
278 H_PUT_16 (abfd, in->n_type, ext->e_type);
279 H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
280 H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
281 return bfd_coff_symesz (abfd);
285 _bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
294 union external_auxent *ext = (union external_auxent *) ext1;
295 union internal_auxent *in = (union internal_auxent *) in1;
300 if (ext->x_file.x_n.x_zeroes[0] == 0)
302 in->x_file.x_n.x_zeroes = 0;
303 in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
307 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
311 /* RS/6000 "csect" auxents */
314 if (indx + 1 == numaux)
316 bfd_signed_vma h = 0;
319 h = H_GET_S32 (abfd, ext->x_csect.x_scnlen_hi);
320 l = H_GET_32 (abfd, ext->x_csect.x_scnlen_lo);
322 in->x_csect.x_scnlen.l = h << 32 | (l & 0xffffffff);
324 in->x_csect.x_parmhash = H_GET_32 (abfd, ext->x_csect.x_parmhash);
325 in->x_csect.x_snhash = H_GET_16 (abfd, ext->x_csect.x_snhash);
326 /* We don't have to hack bitfields in x_smtyp because it's
327 defined by shifts-and-ands, which are equivalent on all
329 in->x_csect.x_smtyp = H_GET_8 (abfd, ext->x_csect.x_smtyp);
330 in->x_csect.x_smclas = H_GET_8 (abfd, ext->x_csect.x_smclas);
340 /* PE defines some extra fields; we zero them out for
342 in->x_scn.x_checksum = 0;
343 in->x_scn.x_associated = 0;
344 in->x_scn.x_comdat = 0;
351 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
353 in->x_sym.x_fcnary.x_fcn.x_lnnoptr
354 = H_GET_64 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
355 in->x_sym.x_fcnary.x_fcn.x_endndx.l
356 = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx);
360 in->x_sym.x_misc.x_fsize
361 = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_fsize);
365 in->x_sym.x_misc.x_lnsz.x_lnno
366 = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_lnno);
367 in->x_sym.x_misc.x_lnsz.x_size
368 = H_GET_16 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_size);
375 _bfd_xcoff64_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
380 int indx ATTRIBUTE_UNUSED;
381 int numaux ATTRIBUTE_UNUSED;
384 union internal_auxent *in = (union internal_auxent *) inp;
385 union external_auxent *ext = (union external_auxent *) extp;
387 memset ((PTR) ext, 0, bfd_coff_auxesz (abfd));
391 if (ext->x_file.x_n.x_zeroes == 0)
393 H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
394 H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
398 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
400 H_PUT_8 (abfd, _AUX_FILE, ext->x_auxtype.x_auxtype);
403 /* RS/6000 "csect" auxents */
406 if (indx + 1 == numaux)
410 temp = in->x_csect.x_scnlen.l & 0xffffffff;
411 H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_lo);
412 temp = in->x_csect.x_scnlen.l >> 32;
413 H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_hi);
414 H_PUT_32 (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
415 H_PUT_16 (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
416 /* We don't have to hack bitfields in x_smtyp because it's
417 defined by shifts-and-ands, which are equivalent on all
419 H_PUT_8 (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
420 H_PUT_8 (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
421 H_PUT_8 (abfd, _AUX_CSECT, ext->x_auxtype.x_auxtype);
436 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
438 H_PUT_64 (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
439 ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
440 H_PUT_8 (abfd, _AUX_FCN,
441 ext->x_auxtype.x_auxtype);
442 H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
443 ext->x_sym.x_fcnary.x_fcn.x_endndx);
447 H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize,
448 ext->x_sym.x_fcnary.x_fcn.x_fsize);
452 H_PUT_32 (abfd, in->x_sym.x_misc.x_lnsz.x_lnno,
453 ext->x_sym.x_fcnary.x_lnsz.x_lnno);
454 H_PUT_16 (abfd, in->x_sym.x_misc.x_lnsz.x_size,
455 ext->x_sym.x_fcnary.x_lnsz.x_size);
460 return bfd_coff_auxesz (abfd);
464 _bfd_xcoff64_put_symbol_name (abfd, strtab, sym, name)
466 struct bfd_strtab_hash *strtab;
467 struct internal_syment *sym;
475 if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
478 indx = _bfd_stringtab_add (strtab, name, hash, false);
480 if (indx == (bfd_size_type) -1)
483 sym->_n._n_n._n_zeroes = 0;
484 sym->_n._n_n._n_offset = STRING_SIZE_SIZE + indx;
490 _bfd_xcoff64_put_ldsymbol_name (abfd, ldinfo, ldsym, name)
491 bfd *abfd ATTRIBUTE_UNUSED;
492 struct xcoff_loader_info *ldinfo;
493 struct internal_ldsym *ldsym;
499 if (ldinfo->string_size + len + 3 > ldinfo->string_alc)
501 bfd_size_type newalc;
502 bfd_byte *newstrings;
504 newalc = ldinfo->string_alc * 2;
507 while (ldinfo->string_size + len + 3 > newalc)
510 newstrings = ((bfd_byte *)
511 bfd_realloc ((PTR) ldinfo->strings, newalc));
512 if (newstrings == NULL)
514 ldinfo->failed = true;
517 ldinfo->string_alc = newalc;
518 ldinfo->strings = newstrings;
521 bfd_put_16 (ldinfo->output_bfd, (bfd_vma) (len + 1),
522 ldinfo->strings + ldinfo->string_size);
523 strcpy (ldinfo->strings + ldinfo->string_size + 2, name);
524 ldsym->_l._l_l._l_zeroes = 0;
525 ldsym->_l._l_l._l_offset = ldinfo->string_size + 2;
526 ldinfo->string_size += len + 3;
531 /* Routines to swap information in the XCOFF .loader section. If we
532 ever need to write an XCOFF loader, this stuff will need to be
533 moved to another file shared by the linker (which XCOFF calls the
534 ``binder'') and the loader. */
536 /* Swap in the ldhdr structure. */
539 xcoff64_swap_ldhdr_in (abfd, s, dst)
542 struct internal_ldhdr *dst;
544 const struct external_ldhdr *src = (const struct external_ldhdr *) s;
546 dst->l_version = bfd_get_32 (abfd, src->l_version);
547 dst->l_nsyms = bfd_get_32 (abfd, src->l_nsyms);
548 dst->l_nreloc = bfd_get_32 (abfd, src->l_nreloc);
549 dst->l_istlen = bfd_get_32 (abfd, src->l_istlen);
550 dst->l_nimpid = bfd_get_32 (abfd, src->l_nimpid);
551 dst->l_stlen = bfd_get_32 (abfd, src->l_stlen);
552 dst->l_impoff = bfd_get_64 (abfd, src->l_impoff);
553 dst->l_stoff = bfd_get_64 (abfd, src->l_stoff);
554 dst->l_symoff = bfd_get_64 (abfd, src->l_symoff);
555 dst->l_rldoff = bfd_get_64 (abfd, src->l_rldoff);
558 /* Swap out the ldhdr structure. */
561 xcoff64_swap_ldhdr_out (abfd, src, d)
563 const struct internal_ldhdr *src;
566 struct external_ldhdr *dst = (struct external_ldhdr *) d;
568 bfd_put_32 (abfd, (bfd_vma) src->l_version, dst->l_version);
569 bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms);
570 bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc);
571 bfd_put_32 (abfd, src->l_istlen, dst->l_istlen);
572 bfd_put_32 (abfd, src->l_nimpid, dst->l_nimpid);
573 bfd_put_32 (abfd, src->l_stlen, dst->l_stlen);
574 bfd_put_64 (abfd, src->l_impoff, dst->l_impoff);
575 bfd_put_64 (abfd, src->l_stoff, dst->l_stoff);
576 bfd_put_64 (abfd, src->l_symoff, dst->l_symoff);
577 bfd_put_64 (abfd, src->l_rldoff, dst->l_rldoff);
580 /* Swap in the ldsym structure. */
583 xcoff64_swap_ldsym_in (abfd, s, dst)
586 struct internal_ldsym *dst;
588 const struct external_ldsym *src = (const struct external_ldsym *) s;
589 /* XCOFF64 does not use l_zeroes like XCOFF32
590 Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
591 as an offset into the loader symbol table. */
592 dst->_l._l_l._l_zeroes = 0;
593 dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->l_offset);
594 dst->l_value = bfd_get_64 (abfd, src->l_value);
595 dst->l_scnum = bfd_get_16 (abfd, src->l_scnum);
596 dst->l_smtype = bfd_get_8 (abfd, src->l_smtype);
597 dst->l_smclas = bfd_get_8 (abfd, src->l_smclas);
598 dst->l_ifile = bfd_get_32 (abfd, src->l_ifile);
599 dst->l_parm = bfd_get_32 (abfd, src->l_parm);
602 /* Swap out the ldsym structure. */
605 xcoff64_swap_ldsym_out (abfd, src, d)
607 const struct internal_ldsym *src;
610 struct external_ldsym *dst = (struct external_ldsym *) d;
612 bfd_put_64 (abfd, src->l_value, dst->l_value);
613 bfd_put_32 (abfd, (bfd_vma) src->_l._l_l._l_offset, dst->l_offset);
614 bfd_put_16 (abfd, (bfd_vma) src->l_scnum, dst->l_scnum);
615 bfd_put_8 (abfd, src->l_smtype, dst->l_smtype);
616 bfd_put_8 (abfd, src->l_smclas, dst->l_smclas);
617 bfd_put_32 (abfd, src->l_ifile, dst->l_ifile);
618 bfd_put_32 (abfd, src->l_parm, dst->l_parm);
622 xcoff64_swap_reloc_in (abfd, s, d)
627 struct external_reloc *src = (struct external_reloc *) s;
628 struct internal_reloc *dst = (struct internal_reloc *) d;
630 memset (dst, 0, sizeof (struct internal_reloc));
632 dst->r_vaddr = bfd_get_64 (abfd, src->r_vaddr);
633 dst->r_symndx = bfd_get_32 (abfd, src->r_symndx);
634 dst->r_size = bfd_get_8 (abfd, src->r_size);
635 dst->r_type = bfd_get_8 (abfd, src->r_type);
639 xcoff64_swap_reloc_out (abfd, s, d)
644 struct internal_reloc *src = (struct internal_reloc *) s;
645 struct external_reloc *dst = (struct external_reloc *) d;
647 bfd_put_64 (abfd, src->r_vaddr, dst->r_vaddr);
648 bfd_put_32 (abfd, src->r_symndx, dst->r_symndx);
649 bfd_put_8 (abfd, src->r_type, dst->r_type);
650 bfd_put_8 (abfd, src->r_size, dst->r_size);
652 return bfd_coff_relsz (abfd);
655 /* Swap in the ldrel structure. */
658 xcoff64_swap_ldrel_in (abfd, s, dst)
661 struct internal_ldrel *dst;
663 const struct external_ldrel *src = (const struct external_ldrel *) s;
665 dst->l_vaddr = bfd_get_64 (abfd, src->l_vaddr);
666 dst->l_symndx = bfd_get_32 (abfd, src->l_symndx);
667 dst->l_rtype = bfd_get_16 (abfd, src->l_rtype);
668 dst->l_rsecnm = bfd_get_16 (abfd, src->l_rsecnm);
671 /* Swap out the ldrel structure. */
674 xcoff64_swap_ldrel_out (abfd, src, d)
676 const struct internal_ldrel *src;
679 struct external_ldrel *dst = (struct external_ldrel *) d;
681 bfd_put_64 (abfd, src->l_vaddr, dst->l_vaddr);
682 bfd_put_16 (abfd, (bfd_vma) src->l_rtype, dst->l_rtype);
683 bfd_put_16 (abfd, (bfd_vma) src->l_rsecnm, dst->l_rsecnm);
684 bfd_put_32 (abfd, src->l_symndx, dst->l_symndx);
688 xcoff64_write_object_contents (abfd)
692 boolean hasrelocs = false;
693 boolean haslinno = false;
696 file_ptr lineno_base;
698 unsigned long reloc_size = 0;
699 unsigned long lnno_size = 0;
700 boolean long_section_names;
701 asection *text_sec = ((void *) 0);
702 asection *data_sec = ((void *) 0);
703 asection *bss_sec = ((void *) 0);
704 struct internal_filehdr internal_f;
705 struct internal_aouthdr internal_a;
707 bfd_set_error (bfd_error_system_call);
709 if (abfd->output_has_begun == false)
711 if (! bfd_coff_compute_section_file_positions (abfd))
715 /* Work out the size of the reloc and linno areas. */
716 reloc_base = obj_relocbase (abfd);
718 for (current = abfd->sections; current != NULL; current = current->next)
719 reloc_size += current->reloc_count * bfd_coff_relsz (abfd);
721 lineno_base = reloc_base + reloc_size;
723 /* Make a pass through the symbol table to count line number entries and
724 put them into the correct asections. */
725 lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd);
727 sym_base = lineno_base + lnno_size;
729 /* Indicate in each section->line_filepos its actual file address. */
730 for (current = abfd->sections; current != NULL; current = current->next)
732 if (current->lineno_count)
734 current->line_filepos = lineno_base;
735 current->moving_line_filepos = lineno_base;
736 lineno_base += current->lineno_count * bfd_coff_linesz (abfd);
740 current->line_filepos = 0;
743 if (current->reloc_count)
745 current->rel_filepos = reloc_base;
746 reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
750 current->rel_filepos = 0;
754 if ((abfd->flags & EXEC_P) != 0)
756 scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
757 internal_f.f_opthdr = bfd_coff_aoutsz (abfd);
761 scn_base = bfd_coff_filhsz (abfd);
762 internal_f.f_opthdr = 0;
765 internal_f.f_nscns = 0;
767 if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
770 long_section_names = false;
771 for (current = abfd->sections; current != NULL; current = current->next)
773 struct internal_scnhdr section;
774 struct external_scnhdr buff;
775 bfd_size_type amount;
777 internal_f.f_nscns++;
779 strncpy (section.s_name, current->name, SCNNMLEN);
781 section.s_vaddr = current->vma;
782 section.s_paddr = current->lma;
783 section.s_size = current->_raw_size;
785 /* If this section has no size or is unloadable then the scnptr
787 if (current->_raw_size == 0
788 || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
790 section.s_scnptr = 0;
794 section.s_scnptr = current->filepos;
797 section.s_relptr = current->rel_filepos;
798 section.s_lnnoptr = current->line_filepos;
799 section.s_nreloc = current->reloc_count;
801 section.s_nlnno = current->lineno_count;
802 if (current->reloc_count != 0)
804 if (current->lineno_count != 0)
807 section.s_flags = sec_to_styp_flags (current->name, current->flags);
809 if (!strcmp (current->name, _TEXT))
813 else if (!strcmp (current->name, _DATA))
817 else if (!strcmp (current->name, _BSS))
822 amount = bfd_coff_scnhsz (abfd);
823 if (bfd_coff_swap_scnhdr_out (abfd, §ion, &buff) == 0
824 || bfd_bwrite ((PTR) (&buff), amount, abfd) != amount)
828 internal_f.f_timdat = 0;
830 internal_f.f_flags = 0;
833 internal_f.f_flags |= F_RELFLG;
835 internal_f.f_flags |= F_LNNO;
836 if (abfd->flags & EXEC_P)
837 internal_f.f_flags |= F_EXEC;
839 /* FIXME: this is wrong for PPC_PE! */
840 if (bfd_little_endian (abfd))
841 internal_f.f_flags |= F_AR32WR;
843 internal_f.f_flags |= F_AR32W;
845 if ((abfd->flags & DYNAMIC) != 0)
846 internal_f.f_flags |= F_SHROBJ;
847 if (bfd_get_section_by_name (abfd, _LOADER) != NULL)
848 internal_f.f_flags |= F_DYNLOAD;
850 memset (&internal_a, 0, sizeof internal_a);
852 internal_f.f_magic = bfd_xcoff_magic_number (abfd);
853 internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :
854 (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC :
857 /* FIXME: Does anybody ever set this to another value? */
858 internal_a.vstamp = 0;
860 /* Now should write relocs, strings, syms. */
861 obj_sym_filepos (abfd) = sym_base;
863 internal_f.f_symptr = 0;
864 internal_f.f_nsyms = 0;
866 /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
867 backend linker, and obj_raw_syment_count is not valid until after
868 coff_write_symbols is called. */
869 if (bfd_get_symcount (abfd) != 0)
873 if (!coff_renumber_symbols (abfd, &firstundef))
875 coff_mangle_symbols (abfd);
876 if (! coff_write_symbols (abfd))
878 if (! coff_write_linenumbers (abfd))
880 if (! coff_write_relocs (abfd, firstundef))
883 internal_f.f_symptr = sym_base;
884 internal_f.f_nsyms = bfd_get_symcount (abfd);
886 else if (obj_raw_syment_count (abfd) != 0)
888 internal_f.f_symptr = sym_base;
890 /* AIX appears to require that F_RELFLG not be set if there are
891 local symbols but no relocations. */
892 internal_f.f_flags &=~ F_RELFLG;
896 internal_f.f_flags |= F_LSYMS;
901 internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
902 internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
907 internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
908 internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
913 internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
914 if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
915 internal_a.data_start = bss_sec->vma;
918 internal_a.entry = bfd_get_start_address (abfd);
919 internal_f.f_nsyms = obj_raw_syment_count (abfd);
921 if (xcoff_data (abfd)->full_aouthdr)
924 asection *loader_sec;
926 internal_a.vstamp = 1;
928 internal_a.o_snentry = xcoff_data (abfd)->snentry;
929 if (internal_a.o_snentry == 0)
930 internal_a.entry = (bfd_vma) -1;
932 if (text_sec != NULL)
934 internal_a.o_sntext = text_sec->target_index;
935 internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec);
939 internal_a.o_sntext = 0;
940 internal_a.o_algntext = 0;
943 if (data_sec != NULL)
945 internal_a.o_sndata = data_sec->target_index;
946 internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
950 internal_a.o_sndata = 0;
951 internal_a.o_algndata = 0;
954 loader_sec = bfd_get_section_by_name (abfd, ".loader");
955 if (loader_sec != NULL)
956 internal_a.o_snloader = loader_sec->target_index;
958 internal_a.o_snloader = 0;
960 internal_a.o_snbss = bss_sec->target_index;
962 internal_a.o_snbss = 0;
964 toc = xcoff_data (abfd)->toc;
965 internal_a.o_toc = toc;
966 internal_a.o_sntoc = xcoff_data (abfd)->sntoc;
968 internal_a.o_modtype = xcoff_data (abfd)->modtype;
969 if (xcoff_data (abfd)->cputype != -1)
970 internal_a.o_cputype = xcoff_data (abfd)->cputype;
973 switch (bfd_get_arch (abfd))
975 case bfd_arch_rs6000:
976 internal_a.o_cputype = 4;
978 case bfd_arch_powerpc:
979 if (bfd_get_mach (abfd) == 0)
980 internal_a.o_cputype = 3;
982 internal_a.o_cputype = 1;
988 internal_a.o_maxstack = xcoff_data (abfd)->maxstack;
989 internal_a.o_maxdata = xcoff_data (abfd)->maxdata;
992 if (bfd_seek (abfd, (file_ptr) 0, 0) != 0)
997 bfd_size_type amount = bfd_coff_filhsz (abfd);
999 buff = bfd_malloc (amount);
1003 bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, (PTR) buff);
1004 amount = bfd_bwrite ((PTR) buff, amount, abfd);
1008 if (amount != bfd_coff_filhsz (abfd))
1012 if (abfd->flags & EXEC_P)
1015 bfd_size_type amount = bfd_coff_aoutsz (abfd);
1017 buff = bfd_malloc (amount);
1021 bfd_coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) buff);
1022 amount = bfd_bwrite ((PTR) buff, amount, abfd);
1026 if (amount != bfd_coff_aoutsz (abfd))
1033 /* This is the relocation function for the PowerPC64.
1034 See xcoff_ppc_relocation_section for more information. */
1037 xcoff64_ppc_relocate_section (output_bfd, info, input_bfd,
1038 input_section, contents, relocs, syms,
1041 struct bfd_link_info *info;
1043 asection *input_section;
1045 struct internal_reloc *relocs;
1046 struct internal_syment *syms;
1047 asection **sections;
1049 struct internal_reloc *rel;
1050 struct internal_reloc *relend;
1053 relend = rel + input_section->reloc_count;
1054 for (; rel < relend; rel++)
1057 struct xcoff_link_hash_entry *h;
1058 struct internal_syment *sym;
1061 struct reloc_howto_struct howto;
1063 bfd_vma value_to_relocate;
1067 /* Relocation type R_REF is a special relocation type which is
1068 merely used to prevent garbage collection from occurring for
1069 the csect including the symbol which it references. */
1070 if (rel->r_type == R_REF)
1074 howto.type = rel->r_type;
1075 howto.rightshift = 0;
1076 howto.bitsize = (rel->r_size & 0x3f) + 1;
1077 howto.size = howto.bitsize > 16 ? (howto.bitsize > 32 ? 4 : 2) : 1;
1078 howto.pc_relative = false;
1080 howto.complain_on_overflow = rel->r_size & 0x80 ?
1081 complain_overflow_signed : complain_overflow_bitfield;
1082 howto.special_function = NULL;
1083 howto.name = "internal";
1084 howto.partial_inplace = true;
1085 howto.src_mask = howto.dst_mask = N_ONES(howto.bitsize);
1086 howto.pcrel_offset = false;
1093 symndx = rel->r_symndx;
1099 h = obj_xcoff_sym_hashes (input_bfd)[symndx];
1100 sym = syms + symndx;
1101 addend = - sym->n_value;
1105 sec = sections[symndx];
1106 /* Hack to make sure we use the right TOC anchor value
1107 if this reloc is against the TOC anchor. */
1108 if (sec->name[3] == '0'
1109 && strcmp (sec->name, ".tc0") == 0)
1110 val = xcoff_data (output_bfd)->toc;
1112 val = (sec->output_section->vma
1113 + sec->output_offset
1119 if (h->root.type == bfd_link_hash_defined
1120 || h->root.type == bfd_link_hash_defweak)
1122 sec = h->root.u.def.section;
1123 val = (h->root.u.def.value
1124 + sec->output_section->vma
1125 + sec->output_offset);
1127 else if (h->root.type == bfd_link_hash_common)
1129 sec = h->root.u.c.p->section;
1130 val = (sec->output_section->vma
1131 + sec->output_offset);
1133 else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT)))
1134 && ! info->relocateable)
1136 if (! ((*info->callbacks->undefined_symbol)
1137 (info, h->root.root.string, input_bfd, input_section,
1138 rel->r_vaddr - input_section->vma, true)))
1141 /* Don't try to process the reloc. It can't help, and
1142 it may generate another error. */
1148 if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION
1149 || (false == xcoff_calculate_relocation[rel->r_type]
1150 (input_bfd, input_section, output_bfd, rel, sym, &howto, val,
1151 addend, &relocation, contents)))
1155 address = rel->r_vaddr - input_section->vma;
1156 location = contents + address;
1158 if (address > input_section->_raw_size)
1161 /* Get the value we are going to relocate. */
1162 if (1 == howto.size)
1163 value_to_relocate = bfd_get_16 (input_bfd, location);
1164 else if (2 == howto.size)
1165 value_to_relocate = bfd_get_32 (input_bfd, location);
1167 value_to_relocate = bfd_get_64 (input_bfd, location);
1171 FIXME: We may drop bits during the addition
1172 which we don't check for. We must either check at every single
1173 operation, which would be tedious, or we must do the computations
1174 in a type larger than bfd_vma, which would be inefficient. */
1176 if ((unsigned int) howto.complain_on_overflow >=
1177 XCOFF_MAX_COMPLAIN_OVERFLOW)
1180 if ((true == xcoff_complain_overflow[howto.complain_on_overflow]
1181 (input_bfd, value_to_relocate, relocation, &howto)))
1184 char buf[SYMNMLEN + 1];
1185 char reloc_type_name[10];
1193 name = h->root.root.string;
1197 name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
1201 sprintf (reloc_type_name, "0x%02x", rel->r_type);
1203 if (! ((*info->callbacks->reloc_overflow)
1204 (info, name, reloc_type_name, (bfd_vma) 0, input_bfd,
1205 input_section, rel->r_vaddr - input_section->vma)))
1209 /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */
1210 value_to_relocate = ((value_to_relocate & ~howto.dst_mask) |
1211 (((value_to_relocate & howto.src_mask) +
1212 relocation) & howto.dst_mask));
1214 /* Put the value back in the object file. */
1215 if (1 == howto.size)
1216 bfd_put_16 (input_bfd, value_to_relocate, location);
1217 else if (2 == howto.size)
1218 bfd_put_32 (input_bfd, value_to_relocate, location);
1220 bfd_put_64 (input_bfd, value_to_relocate, location);
1227 /* The XCOFF reloc table. Actually, XCOFF relocations specify the
1228 bitsize and whether they are signed or not, along with a
1229 conventional type. This table is for the types, which are used for
1230 different algorithms for putting in the reloc. Many of these
1231 relocs need special_function entries, which I have not written. */
1233 reloc_howto_type xcoff64_howto_table[] =
1235 /* Standard 64 bit relocation. */
1236 HOWTO (R_POS, /* type */
1238 4, /* size (0 = byte, 1 = short, 2 = long) */
1240 false, /* pc_relative */
1242 complain_overflow_bitfield, /* complain_on_overflow */
1243 0, /* special_function */
1244 "R_POS_64", /* name */
1245 true, /* partial_inplace */
1246 MINUS_ONE, /* src_mask */
1247 MINUS_ONE, /* dst_mask */
1248 false), /* pcrel_offset */
1250 /* 64 bit relocation, but store negative value. */
1251 HOWTO (R_NEG, /* type */
1253 -4, /* size (0 = byte, 1 = short, 2 = long) */
1255 false, /* pc_relative */
1257 complain_overflow_bitfield, /* complain_on_overflow */
1258 0, /* special_function */
1260 true, /* partial_inplace */
1261 MINUS_ONE, /* src_mask */
1262 MINUS_ONE, /* dst_mask */
1263 false), /* pcrel_offset */
1265 /* 32 bit PC relative relocation. */
1266 HOWTO (R_REL, /* type */
1268 2, /* size (0 = byte, 1 = short, 2 = long) */
1270 true, /* pc_relative */
1272 complain_overflow_signed, /* complain_on_overflow */
1273 0, /* special_function */
1275 true, /* partial_inplace */
1276 0xffffffff, /* src_mask */
1277 0xffffffff, /* dst_mask */
1278 false), /* pcrel_offset */
1280 /* 16 bit TOC relative relocation. */
1281 HOWTO (R_TOC, /* type */
1283 1, /* size (0 = byte, 1 = short, 2 = long) */
1285 false, /* pc_relative */
1287 complain_overflow_bitfield, /* complain_on_overflow */
1288 0, /* special_function */
1290 true, /* partial_inplace */
1291 0xffff, /* src_mask */
1292 0xffff, /* dst_mask */
1293 false), /* pcrel_offset */
1295 /* I don't really know what this is. */
1296 HOWTO (R_RTB, /* type */
1298 2, /* size (0 = byte, 1 = short, 2 = long) */
1300 false, /* pc_relative */
1302 complain_overflow_bitfield, /* complain_on_overflow */
1303 0, /* special_function */
1305 true, /* partial_inplace */
1306 0xffffffff, /* src_mask */
1307 0xffffffff, /* dst_mask */
1308 false), /* pcrel_offset */
1310 /* External TOC relative symbol. */
1311 HOWTO (R_GL, /* type */
1313 2, /* size (0 = byte, 1 = short, 2 = long) */
1315 false, /* pc_relative */
1317 complain_overflow_bitfield, /* complain_on_overflow */
1318 0, /* special_function */
1320 true, /* partial_inplace */
1321 0xffff, /* src_mask */
1322 0xffff, /* dst_mask */
1323 false), /* pcrel_offset */
1325 /* Local TOC relative symbol. */
1326 HOWTO (R_TCL, /* type */
1328 2, /* size (0 = byte, 1 = short, 2 = long) */
1330 false, /* pc_relative */
1332 complain_overflow_bitfield, /* complain_on_overflow */
1333 0, /* special_function */
1335 true, /* partial_inplace */
1336 0xffff, /* src_mask */
1337 0xffff, /* dst_mask */
1338 false), /* pcrel_offset */
1342 /* Non modifiable absolute branch. */
1343 HOWTO (R_BA, /* type */
1345 2, /* size (0 = byte, 1 = short, 2 = long) */
1347 false, /* pc_relative */
1349 complain_overflow_bitfield, /* complain_on_overflow */
1350 0, /* special_function */
1351 "R_BA_26", /* name */
1352 true, /* partial_inplace */
1353 0x3fffffc, /* src_mask */
1354 0x3fffffc, /* dst_mask */
1355 false), /* pcrel_offset */
1359 /* Non modifiable relative branch. */
1360 HOWTO (R_BR, /* type */
1362 2, /* size (0 = byte, 1 = short, 2 = long) */
1364 true, /* pc_relative */
1366 complain_overflow_signed, /* complain_on_overflow */
1367 0, /* special_function */
1369 true, /* partial_inplace */
1370 0x3fffffc, /* src_mask */
1371 0x3fffffc, /* dst_mask */
1372 false), /* pcrel_offset */
1376 /* Indirect load. */
1377 HOWTO (R_RL, /* type */
1379 2, /* size (0 = byte, 1 = short, 2 = long) */
1381 false, /* pc_relative */
1383 complain_overflow_bitfield, /* complain_on_overflow */
1384 0, /* special_function */
1386 true, /* partial_inplace */
1387 0xffff, /* src_mask */
1388 0xffff, /* dst_mask */
1389 false), /* pcrel_offset */
1392 HOWTO (R_RLA, /* type */
1394 2, /* size (0 = byte, 1 = short, 2 = long) */
1396 false, /* pc_relative */
1398 complain_overflow_bitfield, /* complain_on_overflow */
1399 0, /* special_function */
1401 true, /* partial_inplace */
1402 0xffff, /* src_mask */
1403 0xffff, /* dst_mask */
1404 false), /* pcrel_offset */
1408 /* Non-relocating reference. */
1409 HOWTO (R_REF, /* type */
1411 2, /* size (0 = byte, 1 = short, 2 = long) */
1413 false, /* pc_relative */
1415 complain_overflow_bitfield, /* complain_on_overflow */
1416 0, /* special_function */
1418 false, /* partial_inplace */
1421 false), /* pcrel_offset */
1426 /* TOC relative indirect load. */
1427 HOWTO (R_TRL, /* type */
1429 2, /* size (0 = byte, 1 = short, 2 = long) */
1431 false, /* pc_relative */
1433 complain_overflow_bitfield, /* complain_on_overflow */
1434 0, /* special_function */
1436 true, /* partial_inplace */
1437 0xffff, /* src_mask */
1438 0xffff, /* dst_mask */
1439 false), /* pcrel_offset */
1441 /* TOC relative load address. */
1442 HOWTO (R_TRLA, /* type */
1444 2, /* size (0 = byte, 1 = short, 2 = long) */
1446 false, /* pc_relative */
1448 complain_overflow_bitfield, /* complain_on_overflow */
1449 0, /* special_function */
1450 "R_TRLA", /* name */
1451 true, /* partial_inplace */
1452 0xffff, /* src_mask */
1453 0xffff, /* dst_mask */
1454 false), /* pcrel_offset */
1456 /* Modifiable relative branch. */
1457 HOWTO (R_RRTBI, /* type */
1459 2, /* size (0 = byte, 1 = short, 2 = long) */
1461 false, /* pc_relative */
1463 complain_overflow_bitfield, /* complain_on_overflow */
1464 0, /* special_function */
1465 "R_RRTBI", /* name */
1466 true, /* partial_inplace */
1467 0xffffffff, /* src_mask */
1468 0xffffffff, /* dst_mask */
1469 false), /* pcrel_offset */
1471 /* Modifiable absolute branch. */
1472 HOWTO (R_RRTBA, /* type */
1474 2, /* size (0 = byte, 1 = short, 2 = long) */
1476 false, /* pc_relative */
1478 complain_overflow_bitfield, /* complain_on_overflow */
1479 0, /* special_function */
1480 "R_RRTBA", /* name */
1481 true, /* partial_inplace */
1482 0xffffffff, /* src_mask */
1483 0xffffffff, /* dst_mask */
1484 false), /* pcrel_offset */
1486 /* Modifiable call absolute indirect. */
1487 HOWTO (R_CAI, /* type */
1489 2, /* size (0 = byte, 1 = short, 2 = long) */
1491 false, /* pc_relative */
1493 complain_overflow_bitfield, /* complain_on_overflow */
1494 0, /* special_function */
1496 true, /* partial_inplace */
1497 0xffff, /* src_mask */
1498 0xffff, /* dst_mask */
1499 false), /* pcrel_offset */
1501 /* Modifiable call relative. */
1502 HOWTO (R_CREL, /* type */
1504 2, /* size (0 = byte, 1 = short, 2 = long) */
1506 false, /* pc_relative */
1508 complain_overflow_bitfield, /* complain_on_overflow */
1509 0, /* special_function */
1510 "R_CREL", /* name */
1511 true, /* partial_inplace */
1512 0xffff, /* src_mask */
1513 0xffff, /* dst_mask */
1514 false), /* pcrel_offset */
1516 /* Modifiable branch absolute. */
1517 HOWTO (R_RBA, /* type */
1519 2, /* size (0 = byte, 1 = short, 2 = long) */
1521 false, /* pc_relative */
1523 complain_overflow_bitfield, /* complain_on_overflow */
1524 0, /* special_function */
1526 true, /* partial_inplace */
1527 0xffff, /* src_mask */
1528 0xffff, /* dst_mask */
1529 false), /* pcrel_offset */
1531 /* Modifiable branch absolute. */
1532 HOWTO (R_RBAC, /* type */
1534 2, /* size (0 = byte, 1 = short, 2 = long) */
1536 false, /* pc_relative */
1538 complain_overflow_bitfield, /* complain_on_overflow */
1539 0, /* special_function */
1540 "R_RBAC", /* name */
1541 true, /* partial_inplace */
1542 0xffff, /* src_mask */
1543 0xffff, /* dst_mask */
1544 false), /* pcrel_offset */
1546 /* Modifiable branch relative. */
1547 HOWTO (R_RBR, /* type */
1549 2, /* size (0 = byte, 1 = short, 2 = long) */
1551 false, /* pc_relative */
1553 complain_overflow_signed, /* complain_on_overflow */
1554 0, /* special_function */
1555 "R_RBR_26", /* name */
1556 true, /* partial_inplace */
1557 0xffff, /* src_mask */
1558 0xffff, /* dst_mask */
1559 false), /* pcrel_offset */
1561 /* Modifiable branch absolute. */
1562 HOWTO (R_RBRC, /* type */
1564 2, /* size (0 = byte, 1 = short, 2 = long) */
1566 false, /* pc_relative */
1568 complain_overflow_bitfield, /* complain_on_overflow */
1569 0, /* special_function */
1570 "R_RBRC", /* name */
1571 true, /* partial_inplace */
1572 0xffff, /* src_mask */
1573 0xffff, /* dst_mask */
1574 false), /* pcrel_offset */
1576 HOWTO (R_POS, /* type */
1578 2, /* size (0 = byte, 1 = short, 2 = long) */
1580 false, /* pc_relative */
1582 complain_overflow_bitfield, /* complain_on_overflow */
1583 0, /* special_function */
1584 "R_POS_32", /* name */
1585 true, /* partial_inplace */
1586 0xffffffff, /* src_mask */
1587 0xffffffff, /* dst_mask */
1588 false), /* pcrel_offset */
1590 /* 16 bit Non modifiable absolute branch. */
1591 HOWTO (R_BA, /* type */
1593 1, /* size (0 = byte, 1 = short, 2 = long) */
1595 false, /* pc_relative */
1597 complain_overflow_bitfield, /* complain_on_overflow */
1598 0, /* special_function */
1599 "R_BA_16", /* name */
1600 true, /* partial_inplace */
1601 0xfffc, /* src_mask */
1602 0xfffc, /* dst_mask */
1603 false), /* pcrel_offset */
1605 /* Modifiable branch relative. */
1606 HOWTO (R_RBR, /* type */
1608 1, /* size (0 = byte, 1 = short, 2 = long) */
1610 false, /* pc_relative */
1612 complain_overflow_signed, /* complain_on_overflow */
1613 0, /* special_function */
1614 "R_RBR_16", /* name */
1615 true, /* partial_inplace */
1616 0xffff, /* src_mask */
1617 0xffff, /* dst_mask */
1618 false), /* pcrel_offset */
1622 xcoff64_rtype2howto (relent, internal)
1624 struct internal_reloc *internal;
1626 if (internal->r_type > R_RBRC)
1629 /* Default howto layout works most of the time */
1630 relent->howto = &xcoff64_howto_table[internal->r_type];
1632 /* Special case some 16 bit reoloc */
1633 if (15 == (internal->r_size & 0x3f))
1635 if (R_BA == internal->r_type)
1636 relent->howto = &xcoff64_howto_table[0x1d];
1637 else if (R_RBR == internal->r_type)
1638 relent->howto = &xcoff64_howto_table[0x1e];
1640 /* Special case 32 bit */
1641 else if (31 == (internal->r_size & 0x3f))
1643 if (R_POS == internal->r_type)
1644 relent->howto = &xcoff64_howto_table[0x1c];
1647 /* The r_size field of an XCOFF reloc encodes the bitsize of the
1648 relocation, as well as indicating whether it is signed or not.
1649 Doublecheck that the relocation information gathered from the
1650 type matches this information. The bitsize is not significant
1651 for R_REF relocs. */
1652 if (relent->howto->dst_mask != 0
1653 && (relent->howto->bitsize
1654 != ((unsigned int) internal->r_size & 0x3f) + 1))
1657 /* Put a meaningful value in addend */
1658 relent->addend = (internal->r_size & 0x80) ? - internal->r_vaddr
1659 : internal->r_vaddr;
1663 xcoff64_reloc_type_lookup (abfd, code)
1664 bfd *abfd ATTRIBUTE_UNUSED;
1665 bfd_reloc_code_real_type code;
1669 case BFD_RELOC_PPC_B26:
1670 return &xcoff64_howto_table[0xa];
1671 case BFD_RELOC_PPC_BA16:
1672 return &xcoff64_howto_table[0x1d];
1673 case BFD_RELOC_PPC_BA26:
1674 return &xcoff64_howto_table[8];
1675 case BFD_RELOC_PPC_TOC16:
1676 return &xcoff64_howto_table[3];
1678 case BFD_RELOC_CTOR:
1679 return &xcoff64_howto_table[0x1c];
1681 return &xcoff64_howto_table[0];
1687 /* Read in the armap of an XCOFF archive. */
1690 xcoff64_slurp_armap (abfd)
1695 bfd_size_type sz, amt;
1696 bfd_byte *contents, *cend;
1702 /* This is for the new format. */
1703 struct xcoff_ar_hdr_big hdr;
1705 if (xcoff_ardata (abfd) == NULL)
1707 bfd_has_map (abfd) = false;
1711 off = strtol (xcoff_ardata_big (abfd)->symoff64, (char **) NULL, 10);
1714 bfd_has_map (abfd) = false;
1718 if (bfd_seek (abfd, off, SEEK_SET) != 0)
1721 /* The symbol table starts with a normal archive header. */
1722 if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
1723 != SIZEOF_AR_HDR_BIG)
1726 /* Skip the name (normally empty). */
1727 namlen = strtol (hdr.namlen, (char **) NULL, 10);
1728 pos = ((namlen + 1) & ~(size_t) 1) + SXCOFFARFMAG;
1729 if (bfd_seek (abfd, pos, SEEK_CUR) != 0)
1732 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1733 machines) since the field width is 20 and there numbers with more
1734 than 32 bits can be represented. */
1735 sz = strtol (hdr.size, (char **) NULL, 10);
1737 /* Read in the entire symbol table. */
1738 contents = (bfd_byte *) bfd_alloc (abfd, sz);
1739 if (contents == NULL)
1741 if (bfd_bread ((PTR) contents, sz, abfd) != sz)
1744 /* The symbol table starts with an eight byte count. */
1745 c = H_GET_64 (abfd, contents);
1749 bfd_set_error (bfd_error_bad_value);
1753 amt *= sizeof (carsym);
1754 bfd_ardata (abfd)->symdefs = (carsym *) bfd_alloc (abfd, amt);
1755 if (bfd_ardata (abfd)->symdefs == NULL)
1758 /* After the count comes a list of eight byte file offsets. */
1759 for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8;
1761 ++i, ++arsym, p += 8)
1762 arsym->file_offset = H_GET_64 (abfd, p);
1764 /* After the file offsets come null terminated symbol names. */
1765 cend = contents + sz;
1766 for (i = 0, arsym = bfd_ardata (abfd)->symdefs;
1768 ++i, ++arsym, p += strlen ((char *) p) + 1)
1772 bfd_set_error (bfd_error_bad_value);
1775 arsym->name = (char *) p;
1778 bfd_ardata (abfd)->symdef_count = c;
1779 bfd_has_map (abfd) = true;
1785 /* See if this is an NEW XCOFF archive. */
1787 static const bfd_target *
1788 xcoff64_archive_p (abfd)
1791 char magic[SXCOFFARMAG];
1792 /* This is the new format. */
1793 struct xcoff_ar_file_hdr_big hdr;
1794 bfd_size_type amt = SXCOFFARMAG;
1796 if (bfd_bread ((PTR) magic, amt, abfd) != amt)
1798 if (bfd_get_error () != bfd_error_system_call)
1799 bfd_set_error (bfd_error_wrong_format);
1803 if (strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0)
1805 bfd_set_error (bfd_error_wrong_format);
1809 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
1810 involves a cast, we can't do it as the left operand of
1812 amt = sizeof (struct artdata);
1813 abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);
1815 if (bfd_ardata (abfd) == (struct artdata *) NULL)
1818 bfd_ardata (abfd)->cache = NULL;
1819 bfd_ardata (abfd)->archive_head = NULL;
1820 bfd_ardata (abfd)->symdefs = NULL;
1821 bfd_ardata (abfd)->extended_names = NULL;
1823 /* Copy over the magic string. */
1824 memcpy (hdr.magic, magic, SXCOFFARMAG);
1826 /* Now read the rest of the file header. */
1827 if (bfd_bread ((PTR) &hdr.memoff,
1828 (bfd_size_type) (SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG),
1829 abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG)
1831 if (bfd_get_error () != bfd_error_system_call)
1832 bfd_set_error (bfd_error_wrong_format);
1836 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1837 machines) since the field width is 20 and there numbers with more
1838 than 32 bits can be represented. */
1839 bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
1840 (char **) NULL, 10);
1842 amt = SIZEOF_AR_FILE_HDR_BIG;
1843 bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
1844 if (bfd_ardata (abfd)->tdata == NULL)
1847 memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG);
1849 if (! xcoff64_slurp_armap (abfd))
1851 bfd_release (abfd, bfd_ardata (abfd));
1852 abfd->tdata.aout_ar_data = (struct artdata *) NULL;
1860 /* Open the next element in an XCOFF archive. */
1863 xcoff64_openr_next_archived_file (archive, last_file)
1869 if ((xcoff_ardata (archive) == NULL)
1870 || ! xcoff_big_format_p (archive))
1872 bfd_set_error (bfd_error_invalid_operation);
1876 if (last_file == NULL)
1878 filestart = bfd_ardata (archive)->first_file_filepos;
1882 /* XXX These actually have to be a calls to strtoll (at least
1883 on 32-bit machines) since the fields's width is 20 and
1884 there numbers with more than 32 bits can be represented. */
1885 filestart = strtol (arch_xhdr_big (last_file)->nextoff, (char **) NULL,
1888 /* XXX These actually have to be calls to strtoll (at least on 32-bit
1889 machines) since the fields's width is 20 and there numbers with more
1890 than 32 bits can be represented. */
1892 || filestart == strtol (xcoff_ardata_big (archive)->memoff,
1894 || filestart == strtol (xcoff_ardata_big (archive)->symoff,
1895 (char **) NULL, 10))
1897 bfd_set_error (bfd_error_no_more_archived_files);
1901 return _bfd_get_elt_at_filepos (archive, filestart);
1904 /* We can't use the usual coff_sizeof_headers routine, because AIX
1905 always uses an a.out header. */
1909 xcoff64_sizeof_headers (abfd, reloc)
1911 boolean reloc ATTRIBUTE_UNUSED;
1915 size = bfd_coff_filhsz (abfd);
1917 /* Don't think the small aout header can be used since some of the
1918 old elements have been reordered past the end of the old coff
1921 if (xcoff_data (abfd)->full_aouthdr)
1922 size += bfd_coff_aoutsz (abfd);
1924 size += abfd->section_count * bfd_coff_scnhsz (abfd);
1931 xcoff64_create_csect_from_smclas (abfd, aux, symbol_name)
1933 union internal_auxent *aux;
1934 const char *symbol_name;
1936 asection *return_value = NULL;
1938 /* Changes from 32 :
1939 .sv == 8, is only for 32 bit programs
1940 .ti == 12 and .tb == 13 are now reserved. */
1941 static const char *names[19] =
1943 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
1944 NULL, ".bs", ".ds", ".uc", NULL, NULL, NULL, ".tc0",
1945 ".td", ".sv64", ".sv3264"
1948 if ((19 >= aux->x_csect.x_smclas)
1949 && (NULL != names[aux->x_csect.x_smclas]))
1952 return_value = bfd_make_section_anyway
1953 (abfd, names[aux->x_csect.x_smclas]);
1958 (*_bfd_error_handler)
1959 (_("%s: symbol `%s' has unrecognized smclas %d"),
1960 bfd_archive_filename (abfd), symbol_name, aux->x_csect.x_smclas);
1961 bfd_set_error (bfd_error_bad_value);
1964 return return_value;
1968 xcoff64_is_lineno_count_overflow (abfd, value)
1969 bfd *abfd ATTRIBUTE_UNUSED;
1970 bfd_vma value ATTRIBUTE_UNUSED;
1976 xcoff64_is_reloc_count_overflow (abfd, value)
1977 bfd *abfd ATTRIBUTE_UNUSED;
1978 bfd_vma value ATTRIBUTE_UNUSED;
1984 xcoff64_loader_symbol_offset (abfd, ldhdr)
1985 bfd *abfd ATTRIBUTE_UNUSED;
1986 struct internal_ldhdr *ldhdr;
1988 return (ldhdr->l_symoff);
1992 xcoff64_loader_reloc_offset (abfd, ldhdr)
1993 bfd *abfd ATTRIBUTE_UNUSED;
1994 struct internal_ldhdr *ldhdr;
1996 return (ldhdr->l_rldoff);
2000 xcoff64_bad_format_hook (abfd, filehdr)
2004 struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2006 /* Check flavor first. */
2007 if (bfd_get_flavour (abfd) != bfd_target_xcoff_flavour)
2010 if (bfd_xcoff_magic_number (abfd) != internal_f->f_magic)
2017 xcoff64_generate_rtinit (abfd, init, fini, rtld)
2023 bfd_byte filehdr_ext[FILHSZ];
2024 bfd_byte scnhdr_ext[SCNHSZ * 3];
2025 bfd_byte syment_ext[SYMESZ * 10];
2026 bfd_byte reloc_ext[RELSZ * 3];
2027 bfd_byte *data_buffer;
2028 bfd_size_type data_buffer_size;
2029 bfd_byte *string_table, *st_tmp;
2030 bfd_size_type string_table_size;
2032 size_t initsz, finisz;
2033 struct internal_filehdr filehdr;
2034 struct internal_scnhdr text_scnhdr;
2035 struct internal_scnhdr data_scnhdr;
2036 struct internal_scnhdr bss_scnhdr;
2037 struct internal_syment syment;
2038 union internal_auxent auxent;
2039 struct internal_reloc reloc;
2041 char *text_name = ".text";
2042 char *data_name = ".data";
2043 char *bss_name = ".bss";
2044 char *rtinit_name = "__rtinit";
2045 char *rtld_name = "__rtld";
2047 if (! bfd_xcoff_rtinit_size (abfd))
2050 initsz = (init == NULL ? 0 : 1 + strlen (init));
2051 finisz = (fini == NULL ? 0 : 1 + strlen (fini));
2054 memset (filehdr_ext, 0, FILHSZ);
2055 memset (&filehdr, 0, sizeof (struct internal_filehdr));
2056 filehdr.f_magic = bfd_xcoff_magic_number (abfd);
2057 filehdr.f_nscns = 3;
2058 filehdr.f_timdat = 0;
2059 filehdr.f_nsyms = 0; /* at least 6, no more than 8 */
2060 filehdr.f_symptr = 0; /* set below */
2061 filehdr.f_opthdr = 0;
2062 filehdr.f_flags = 0;
2064 /* Section headers. */
2065 memset (scnhdr_ext, 0, 3 * SCNHSZ);
2068 memset (&text_scnhdr, 0, sizeof (struct internal_scnhdr));
2069 memcpy (text_scnhdr.s_name, text_name, strlen (text_name));
2070 text_scnhdr.s_paddr = 0;
2071 text_scnhdr.s_vaddr = 0;
2072 text_scnhdr.s_size = 0;
2073 text_scnhdr.s_scnptr = 0;
2074 text_scnhdr.s_relptr = 0;
2075 text_scnhdr.s_lnnoptr = 0;
2076 text_scnhdr.s_nreloc = 0;
2077 text_scnhdr.s_nlnno = 0;
2078 text_scnhdr.s_flags = STYP_TEXT;
2081 memset (&data_scnhdr, 0, sizeof (struct internal_scnhdr));
2082 memcpy (data_scnhdr.s_name, data_name, strlen (data_name));
2083 data_scnhdr.s_paddr = 0;
2084 data_scnhdr.s_vaddr = 0;
2085 data_scnhdr.s_size = 0; /* set below */
2086 data_scnhdr.s_scnptr = FILHSZ + 3 * SCNHSZ;
2087 data_scnhdr.s_relptr = 0; /* set below */
2088 data_scnhdr.s_lnnoptr = 0;
2089 data_scnhdr.s_nreloc = 0; /* either 1 or 2 */
2090 data_scnhdr.s_nlnno = 0;
2091 data_scnhdr.s_flags = STYP_DATA;
2094 memset (&bss_scnhdr, 0, sizeof (struct internal_scnhdr));
2095 memcpy (bss_scnhdr.s_name, bss_name, strlen (bss_name));
2096 bss_scnhdr.s_paddr = 0; /* set below */
2097 bss_scnhdr.s_vaddr = 0; /* set below */
2098 bss_scnhdr.s_size = 0; /* set below */
2099 bss_scnhdr.s_scnptr = 0;
2100 bss_scnhdr.s_relptr = 0;
2101 bss_scnhdr.s_lnnoptr = 0;
2102 bss_scnhdr.s_nreloc = 0;
2103 bss_scnhdr.s_nlnno = 0;
2104 bss_scnhdr.s_flags = STYP_BSS;
2107 0x0000 0x00000000 : rtl
2109 0x0008 0x00000018 : offset to init, or 0
2110 0x000C 0x00000038 : offset to fini, or 0
2111 0x0010 0x00000010 : size of descriptor
2112 0x0014 0x00000000 : pad
2113 0x0018 0x00000000 : init, needs a reloc
2115 0x0020 0x00000058 : offset to init name
2116 0x0024 0x00000000 : flags, padded to a word
2117 0x0028 0x00000000 : empty init
2121 0x0038 0x00000000 : fini, needs a reloc
2123 0x0040 0x00000??? : offset to fini name
2124 0x0044 0x00000000 : flags, padded to a word
2125 0x0048 0x00000000 : empty fini
2130 0x0058 + initsz fini name */
2132 data_buffer_size = 0x0058 + initsz + finisz;
2133 data_buffer_size += (data_buffer_size & 7) ? 8 - (data_buffer_size & 7) : 0;
2135 data_buffer = (bfd_byte *)bfd_malloc (data_buffer_size);
2136 if (data_buffer == NULL)
2139 memset (data_buffer, 0, data_buffer_size);
2144 bfd_put_32 (abfd, val, &data_buffer[0x08]);
2146 bfd_put_32 (abfd, val, &data_buffer[0x20]);
2147 memcpy (&data_buffer[val], init, initsz);
2153 bfd_put_32 (abfd, val, &data_buffer[0x0C]);
2154 val = 0x58 + initsz;
2155 bfd_put_32 (abfd, val, &data_buffer[0x40]);
2156 memcpy (&data_buffer[val], fini, finisz);
2160 bfd_put_32 (abfd, val, &data_buffer[0x10]);
2161 data_scnhdr.s_size = data_buffer_size;
2162 bss_scnhdr.s_paddr = bss_scnhdr.s_vaddr = data_scnhdr.s_size;
2165 string_table_size = 4;
2166 string_table_size += strlen (data_name) + 1;
2167 string_table_size += strlen (rtinit_name) + 1;
2168 string_table_size += initsz;
2169 string_table_size += finisz;
2171 string_table_size += strlen (rtld_name) + 1;
2173 string_table = (bfd_byte *)bfd_malloc (string_table_size);
2174 memset (string_table, 0, string_table_size);
2175 val = string_table_size;
2176 bfd_put_32 (abfd, val, &string_table[0]);
2177 st_tmp = string_table + 4;
2185 memset (syment_ext, 0, 10 * SYMESZ);
2186 memset (reloc_ext, 0, 3 * RELSZ);
2189 memset (&syment, 0, sizeof (struct internal_syment));
2190 memset (&auxent, 0, sizeof (union internal_auxent));
2192 syment._n._n_n._n_offset = st_tmp - string_table;
2193 memcpy (st_tmp, data_name, strlen (data_name));
2194 st_tmp += strlen (data_name) + 1;
2197 syment.n_sclass = C_HIDEXT;
2198 syment.n_numaux = 1;
2199 auxent.x_csect.x_scnlen.l = data_buffer_size;
2200 auxent.x_csect.x_smtyp = 3 << 3 | XTY_SD;
2201 auxent.x_csect.x_smclas = XMC_RW;
2202 bfd_coff_swap_sym_out (abfd, &syment,
2203 &syment_ext[filehdr.f_nsyms * SYMESZ]);
2204 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2206 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2207 filehdr.f_nsyms += 2;
2210 memset (&syment, 0, sizeof (struct internal_syment));
2211 memset (&auxent, 0, sizeof (union internal_auxent));
2212 syment._n._n_n._n_offset = st_tmp - string_table;
2213 memcpy (st_tmp, rtinit_name, strlen (rtinit_name));
2214 st_tmp += strlen (rtinit_name) + 1;
2217 syment.n_sclass = C_EXT;
2218 syment.n_numaux = 1;
2219 auxent.x_csect.x_smtyp = XTY_LD;
2220 auxent.x_csect.x_smclas = XMC_RW;
2221 bfd_coff_swap_sym_out (abfd, &syment,
2222 &syment_ext[filehdr.f_nsyms * SYMESZ]);
2223 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2225 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2226 filehdr.f_nsyms += 2;
2231 memset (&syment, 0, sizeof (struct internal_syment));
2232 memset (&auxent, 0, sizeof (union internal_auxent));
2234 syment._n._n_n._n_offset = st_tmp - string_table;
2235 memcpy (st_tmp, init, initsz);
2238 syment.n_sclass = C_EXT;
2239 syment.n_numaux = 1;
2240 bfd_coff_swap_sym_out (abfd, &syment,
2241 &syment_ext[filehdr.f_nsyms * SYMESZ]);
2242 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2244 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2246 memset (&reloc, 0, sizeof (struct internal_reloc));
2247 reloc.r_vaddr = 0x0018;
2248 reloc.r_symndx = filehdr.f_nsyms;
2249 reloc.r_type = R_POS;
2251 bfd_coff_swap_reloc_out (abfd, &reloc, &reloc_ext[0]);
2253 filehdr.f_nsyms += 2;
2254 data_scnhdr.s_nreloc += 1;
2260 memset (&syment, 0, sizeof (struct internal_syment));
2261 memset (&auxent, 0, sizeof (union internal_auxent));
2263 syment._n._n_n._n_offset = st_tmp - string_table;
2264 memcpy (st_tmp, fini, finisz);
2267 syment.n_sclass = C_EXT;
2268 syment.n_numaux = 1;
2269 bfd_coff_swap_sym_out (abfd, &syment,
2270 &syment_ext[filehdr.f_nsyms * SYMESZ]);
2271 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2273 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2276 memset (&reloc, 0, sizeof (struct internal_reloc));
2277 reloc.r_vaddr = 0x0038;
2278 reloc.r_symndx = filehdr.f_nsyms;
2279 reloc.r_type = R_POS;
2281 bfd_coff_swap_reloc_out (abfd, &reloc,
2282 &reloc_ext[data_scnhdr.s_nreloc * RELSZ]);
2284 filehdr.f_nsyms += 2;
2285 data_scnhdr.s_nreloc += 1;
2290 memset (&syment, 0, sizeof (struct internal_syment));
2291 memset (&auxent, 0, sizeof (union internal_auxent));
2293 syment._n._n_n._n_offset = st_tmp - string_table;
2294 memcpy (st_tmp, rtld_name, strlen (rtld_name));
2295 st_tmp += strlen (rtld_name) + 1;
2297 syment.n_sclass = C_EXT;
2298 syment.n_numaux = 1;
2299 bfd_coff_swap_sym_out (abfd, &syment,
2300 &syment_ext[filehdr.f_nsyms * SYMESZ]);
2301 bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2303 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2306 memset (&reloc, 0, sizeof (struct internal_reloc));
2307 reloc.r_vaddr = 0x0000;
2308 reloc.r_symndx = filehdr.f_nsyms;
2309 reloc.r_type = R_POS;
2311 bfd_coff_swap_reloc_out (abfd, &reloc,
2312 &reloc_ext[data_scnhdr.s_nreloc * RELSZ]);
2314 filehdr.f_nsyms += 2;
2315 data_scnhdr.s_nreloc += 1;
2317 bss_scnhdr.s_size = 0;
2320 data_scnhdr.s_relptr = data_scnhdr.s_scnptr + data_buffer_size;
2321 filehdr.f_symptr = data_scnhdr.s_relptr + data_scnhdr.s_nreloc * RELSZ;
2323 bfd_coff_swap_filehdr_out (abfd, &filehdr, filehdr_ext);
2324 bfd_bwrite (filehdr_ext, FILHSZ, abfd);
2325 bfd_coff_swap_scnhdr_out (abfd, &text_scnhdr, &scnhdr_ext[SCNHSZ * 0]);
2326 bfd_coff_swap_scnhdr_out (abfd, &data_scnhdr, &scnhdr_ext[SCNHSZ * 1]);
2327 bfd_coff_swap_scnhdr_out (abfd, &bss_scnhdr, &scnhdr_ext[SCNHSZ * 2]);
2328 bfd_bwrite (scnhdr_ext, 3 * SCNHSZ, abfd);
2329 bfd_bwrite (data_buffer, data_buffer_size, abfd);
2330 bfd_bwrite (reloc_ext, data_scnhdr.s_nreloc * RELSZ, abfd);
2331 bfd_bwrite (syment_ext, filehdr.f_nsyms * SYMESZ, abfd);
2332 bfd_bwrite (string_table, string_table_size, abfd);
2340 /* The typical dynamic reloc. */
2342 static reloc_howto_type xcoff64_dynamic_reloc =
2343 HOWTO (0, /* type */
2345 4, /* size (0 = byte, 1 = short, 2 = long) */
2347 false, /* pc_relative */
2349 complain_overflow_bitfield, /* complain_on_overflow */
2350 0, /* special_function */
2352 true, /* partial_inplace */
2353 MINUS_ONE, /* src_mask */
2354 MINUS_ONE, /* dst_mask */
2355 false); /* pcrel_offset */
2357 static unsigned long xcoff64_glink_code[10] =
2359 0xe9820000, /* ld r12,0(r2) */
2360 0xf8410028, /* std r2,40(r1) */
2361 0xe80c0000, /* ld r0,0(r12) */
2362 0xe84c0008, /* ld r0,8(r12) */
2363 0x7c0903a6, /* mtctr r0 */
2364 0x4e800420, /* bctr */
2365 0x00000000, /* start of traceback table */
2366 0x000ca000, /* traceback table */
2367 0x00000000, /* traceback table */
2368 0x00000018, /* ??? */
2371 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
2373 { /* COFF backend, defined in libcoff.h. */
2374 _bfd_xcoff64_swap_aux_in, /* _bfd_coff_swap_aux_in */
2375 _bfd_xcoff64_swap_sym_in, /* _bfd_coff_swap_sym_in */
2376 _bfd_xcoff64_swap_lineno_in, /* _bfd_coff_swap_lineno_in */
2377 _bfd_xcoff64_swap_aux_out, /* _bfd_swap_aux_out */
2378 _bfd_xcoff64_swap_sym_out, /* _bfd_swap_sym_out */
2379 _bfd_xcoff64_swap_lineno_out, /* _bfd_swap_lineno_out */
2380 xcoff64_swap_reloc_out, /* _bfd_swap_reloc_out */
2381 coff_swap_filehdr_out, /* _bfd_swap_filehdr_out */
2382 coff_swap_aouthdr_out, /* _bfd_swap_aouthdr_out */
2383 coff_swap_scnhdr_out, /* _bfd_swap_scnhdr_out */
2384 FILHSZ, /* _bfd_filhsz */
2385 AOUTSZ, /* _bfd_aoutsz */
2386 SCNHSZ, /* _bfd_scnhsz */
2387 SYMESZ, /* _bfd_symesz */
2388 AUXESZ, /* _bfd_auxesz */
2389 RELSZ, /* _bfd_relsz */
2390 LINESZ, /* _bfd_linesz */
2391 FILNMLEN, /* _bfd_filnmlen */
2392 true, /* _bfd_coff_long_filenames */
2393 false, /* _bfd_coff_long_section_names */
2394 (3), /* _bfd_coff_default_section_alignment_power */
2395 true, /* _bfd_coff_force_symnames_in_strings */
2396 4, /* _bfd_coff_debug_string_prefix_length */
2397 coff_swap_filehdr_in, /* _bfd_coff_swap_filehdr_in */
2398 coff_swap_aouthdr_in, /* _bfd_swap_aouthdr_in */
2399 coff_swap_scnhdr_in, /* _bfd_swap_scnhdr_in */
2400 xcoff64_swap_reloc_in, /* _bfd_reloc_in */
2401 xcoff64_bad_format_hook, /* _bfd_bad_format_hook */
2402 coff_set_arch_mach_hook, /* _bfd_set_arch_mach_hook */
2403 coff_mkobject_hook, /* _bfd_mkobject_hook */
2404 styp_to_sec_flags, /* _bfd_syp_to_sec_flags */
2405 coff_set_alignment_hook, /* _bfd_set_alignment_hook */
2406 coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */
2407 symname_in_debug_hook, /* _coff_symname_in_debug_hook */
2408 coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */
2409 coff_print_aux, /* bfd_coff_print_aux */
2410 dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */
2411 dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */
2412 NULL, /* bfd_coff_sym_is_global */
2413 /* _bfd_coff_compute_section_file_positions */
2414 coff_compute_section_file_positions,
2415 NULL , /* _bfd_coff_start_final_link */
2416 xcoff64_ppc_relocate_section, /* _bfd_coff_relocate_section */
2417 coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */
2418 NULL , /* _bfd_coff_addust_symndx */
2419 _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */
2420 coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */
2421 coff_final_link_postscript /* _bfd_coff_final_link_postscript */
2424 0x01EF, /* magic number */
2425 bfd_arch_powerpc, /* architecture */
2426 bfd_mach_ppc_620, /* machine */
2428 /* Function pointers to xcoff specific swap routines. */
2429 xcoff64_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */
2430 xcoff64_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */
2431 xcoff64_swap_ldsym_in, /* _xcoff_swap_ldsym_in */
2432 xcoff64_swap_ldsym_out, /* _xcoff_swap_ldsym_out */
2433 xcoff64_swap_ldrel_in, /* _xcoff_swap_ldrel_in */
2434 xcoff64_swap_ldrel_out, /* _xcoff_swap_ldrel_out */
2437 LDHDRSZ, /* _xcoff_ldhdrsz */
2438 LDSYMSZ, /* _xcoff_ldsymsz */
2439 LDRELSZ, /* _xcoff_ldrelsz */
2440 24, /* _xcoff_function_descriptor_size */
2441 0, /* _xcoff_small_aout_header_size */
2444 2, /* _xcoff_ldhdr_version */
2446 /* xcoff vs xcoff64 putting symbol names. */
2447 _bfd_xcoff64_put_symbol_name, /* _xcoff_put_symbol_name */
2448 _bfd_xcoff64_put_ldsymbol_name, /* _xcoff_put_ldsymbol_name */
2450 /* Dynamic reloc howto. */
2451 &xcoff64_dynamic_reloc,
2453 xcoff64_create_csect_from_smclas,
2455 /* Lineno and reloc count overflow. */
2456 xcoff64_is_lineno_count_overflow,
2457 xcoff64_is_reloc_count_overflow,
2459 xcoff64_loader_symbol_offset,
2460 xcoff64_loader_reloc_offset,
2463 &xcoff64_glink_code[0],
2464 40, /* _xcoff_glink_size */
2467 88, /* _xcoff_rtinit_size */
2468 xcoff64_generate_rtinit, /* _xcoff_generate_rtinit */
2471 /* The transfer vector that leads the outside world to all of the above. */
2472 const bfd_target rs6000coff64_vec =
2475 bfd_target_xcoff_flavour,
2476 BFD_ENDIAN_BIG, /* data byte order is big */
2477 BFD_ENDIAN_BIG, /* header byte order is big */
2479 (HAS_RELOC | EXEC_P | /* object flags */
2480 HAS_LINENO | HAS_DEBUG | DYNAMIC |
2481 HAS_SYMS | HAS_LOCALS | WP_TEXT),
2483 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
2484 0, /* leading char */
2485 '/', /* ar_pad_char */
2486 15, /* ar_max_namelen??? FIXMEmgo */
2489 bfd_getb64, /* bfd_getx64 */
2490 bfd_getb_signed_64, /* bfd_getx_signed_64 */
2491 bfd_putb64, /* bfd_putx64 */
2492 bfd_getb32, /* bfd_getx32 */
2493 bfd_getb_signed_32, /* bfd_getx_signed_32 */
2494 bfd_putb32, /* bfd_putx32 */
2495 bfd_getb16, /* bfd_getx16 */
2496 bfd_getb_signed_16, /* bfd_getx_signed_16 */
2497 bfd_putb16, /* bfd_putx16 */
2500 bfd_getb64, /* bfd_h_getx64 */
2501 bfd_getb_signed_64, /* bfd_h_getx_signed_64 */
2502 bfd_putb64, /* bfd_h_putx64 */
2503 bfd_getb32, /* bfd_h_getx32 */
2504 bfd_getb_signed_32, /* bfd_h_getx_signed_32 */
2505 bfd_putb32, /* bfd_h_putx32 */
2506 bfd_getb16, /* bfd_h_getx16 */
2507 bfd_getb_signed_16, /* bfd_h_getx_signed_16 */
2508 bfd_putb16, /* bfd_h_putx16 */
2510 { /* bfd_check_format */
2517 { /* bfd_set_format */
2520 _bfd_generic_mkarchive,
2524 {/* bfd_write_contents */
2526 xcoff64_write_object_contents,
2527 _bfd_xcoff_write_archive_contents,
2532 bfd_true, /* _close_and_cleanup */
2533 bfd_true, /* _bfd_free_cached_info */
2534 coff_new_section_hook, /* _new_section_hook */
2535 _bfd_generic_get_section_contents, /* _bfd_get_section_contents */
2536 /* _bfd_get_section_contents_in_window */
2537 _bfd_generic_get_section_contents_in_window,
2540 _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */
2541 /* _bfd_merge_private_bfd_data */
2542 ((boolean (*) (bfd *, bfd *)) bfd_true),
2543 /* _bfd_copy_pivate_section_data */
2544 ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
2545 /* _bfd_copy_private_symbol_data */
2546 ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
2547 ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */
2548 ((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */
2551 coff_core_file_failing_command, /* _core_file_failing_command */
2552 coff_core_file_failing_signal, /* _core_file_failing_signal */
2553 coff_core_file_matches_executable_p, /* _core_file_matches_executable_p */
2556 xcoff64_slurp_armap, /* _slurp_armap */
2557 /* XCOFF archives do not have anything which corresponds to an
2558 extended name table. */
2559 bfd_false, /* _slurp_extended_name_table */
2560 /* _construct_extended_name_table */
2561 ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
2562 bfd_dont_truncate_arname, /* _truncate_arname */
2563 _bfd_xcoff_write_armap, /* _write_armap */
2564 _bfd_xcoff_read_ar_hdr, /* _read_ar_hdr */
2565 xcoff64_openr_next_archived_file, /* _openr_next_archived_file */
2566 _bfd_generic_get_elt_at_index, /* _get_elt_at_index */
2567 _bfd_xcoff_stat_arch_elt, /* _generic_stat_arch_elt */
2568 /* XCOFF archives do not have a timestamp. */
2569 bfd_true, /* _update_armap_timestamp */
2572 coff_get_symtab_upper_bound, /* _get_symtab_upper_bound */
2573 coff_get_symtab, /* _get_symtab */
2574 coff_make_empty_symbol, /* _make_empty_symbol */
2575 coff_print_symbol, /* _print_symbol */
2576 coff_get_symbol_info, /* _get_symbol_info */
2577 _bfd_xcoff_is_local_label_name, /* _bfd_is_local_label_name */
2578 coff_get_lineno, /* _get_lineno */
2579 coff_find_nearest_line, /* _find_nearest_line */
2580 coff_bfd_make_debug_symbol, /* _bfd_make_debug_symbol */
2581 _bfd_generic_read_minisymbols, /* _read_minisymbols */
2582 _bfd_generic_minisymbol_to_symbol, /* _minsymbol_to_symbol */
2585 coff_get_reloc_upper_bound, /* _get_reloc_upper_bound */
2586 coff_canonicalize_reloc, /* _cononicalize_reloc */
2587 xcoff64_reloc_type_lookup, /* _bfd_reloc_type_lookup */
2590 coff_set_arch_mach, /* _set_arch_mach */
2591 coff_set_section_contents, /* _set_section_contents */
2594 xcoff64_sizeof_headers, /* _sizeof_headers */
2595 /* _bfd_get_relocated_section_contents */
2596 bfd_generic_get_relocated_section_contents,
2597 bfd_generic_relax_section, /* _bfd_relax_section */
2598 _bfd_xcoff_bfd_link_hash_table_create,/* _bfd_link_hash_table_create */
2599 _bfd_generic_link_hash_table_free, /* _bfd_link_hash_table_free */
2600 _bfd_xcoff_bfd_link_add_symbols, /* _bfd_link_add_symbols */
2601 _bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */
2602 _bfd_generic_link_split_section, /* _bfd_link_split_section */
2603 bfd_generic_gc_sections, /* _bfd_gc_sections */
2604 bfd_generic_merge_sections, /* _bfd_merge_sections */
2607 /* _get_dynamic_symtab_upper_bound */
2608 _bfd_xcoff_get_dynamic_symtab_upper_bound,
2609 _bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */
2610 _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */
2611 _bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */
2613 /* Opposite endian version, none exists */
2617 (void *) &bfd_xcoff_backend_data,
2620 extern const bfd_target *xcoff64_core_p PARAMS ((bfd *));
2621 extern boolean xcoff64_core_file_matches_executable_p PARAMS((bfd *, bfd *));
2622 extern char *xcoff64_core_file_failing_command PARAMS ((bfd *));
2623 extern int xcoff64_core_file_failing_signal PARAMS ((bfd *));
2626 static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data =
2628 { /* COFF backend, defined in libcoff.h. */
2629 _bfd_xcoff64_swap_aux_in, /* _bfd_coff_swap_aux_in */
2630 _bfd_xcoff64_swap_sym_in, /* _bfd_coff_swap_sym_in */
2631 _bfd_xcoff64_swap_lineno_in, /* _bfd_coff_swap_lineno_in */
2632 _bfd_xcoff64_swap_aux_out, /* _bfd_swap_aux_out */
2633 _bfd_xcoff64_swap_sym_out, /* _bfd_swap_sym_out */
2634 _bfd_xcoff64_swap_lineno_out, /* _bfd_swap_lineno_out */
2635 xcoff64_swap_reloc_out, /* _bfd_swap_reloc_out */
2636 coff_swap_filehdr_out, /* _bfd_swap_filehdr_out */
2637 coff_swap_aouthdr_out, /* _bfd_swap_aouthdr_out */
2638 coff_swap_scnhdr_out, /* _bfd_swap_scnhdr_out */
2639 FILHSZ, /* _bfd_filhsz */
2640 AOUTSZ, /* _bfd_aoutsz */
2641 SCNHSZ, /* _bfd_scnhsz */
2642 SYMESZ, /* _bfd_symesz */
2643 AUXESZ, /* _bfd_auxesz */
2644 RELSZ, /* _bfd_relsz */
2645 LINESZ, /* _bfd_linesz */
2646 FILNMLEN, /* _bfd_filnmlen */
2647 true, /* _bfd_coff_long_filenames */
2648 false, /* _bfd_coff_long_section_names */
2649 (3), /* _bfd_coff_default_section_alignment_power */
2650 true, /* _bfd_coff_force_symnames_in_strings */
2651 4, /* _bfd_coff_debug_string_prefix_length */
2652 coff_swap_filehdr_in, /* _bfd_coff_swap_filehdr_in */
2653 coff_swap_aouthdr_in, /* _bfd_swap_aouthdr_in */
2654 coff_swap_scnhdr_in, /* _bfd_swap_scnhdr_in */
2655 xcoff64_swap_reloc_in, /* _bfd_reloc_in */
2656 xcoff64_bad_format_hook, /* _bfd_bad_format_hook */
2657 coff_set_arch_mach_hook, /* _bfd_set_arch_mach_hook */
2658 coff_mkobject_hook, /* _bfd_mkobject_hook */
2659 styp_to_sec_flags, /* _bfd_syp_to_sec_flags */
2660 coff_set_alignment_hook, /* _bfd_set_alignment_hook */
2661 coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */
2662 symname_in_debug_hook, /* _coff_symname_in_debug_hook */
2663 coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */
2664 coff_print_aux, /* bfd_coff_print_aux */
2665 dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */
2666 dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */
2667 NULL, /* bfd_coff_sym_is_global */
2668 /* _bfd_coff_compute_section_file_positions */
2669 coff_compute_section_file_positions,
2670 NULL , /* _bfd_coff_start_final_link */
2671 xcoff64_ppc_relocate_section, /* _bfd_coff_relocate_section */
2672 coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */
2673 NULL , /* _bfd_coff_addust_symndx */
2674 _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */
2675 coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */
2676 coff_final_link_postscript /* _bfd_coff_final_link_postscript */
2679 U64_TOCMAGIC, /* magic number */
2680 bfd_arch_powerpc, /* architecture */
2681 bfd_mach_ppc_620, /* machine */
2683 /* Function pointers to xcoff specific swap routines. */
2684 xcoff64_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */
2685 xcoff64_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */
2686 xcoff64_swap_ldsym_in, /* _xcoff_swap_ldsym_in */
2687 xcoff64_swap_ldsym_out, /* _xcoff_swap_ldsym_out */
2688 xcoff64_swap_ldrel_in, /* _xcoff_swap_ldrel_in */
2689 xcoff64_swap_ldrel_out, /* _xcoff_swap_ldrel_out */
2692 LDHDRSZ, /* _xcoff_ldhdrsz */
2693 LDSYMSZ, /* _xcoff_ldsymsz */
2694 LDRELSZ, /* _xcoff_ldrelsz */
2695 24, /* _xcoff_function_descriptor_size */
2696 0, /* _xcoff_small_aout_header_size */
2698 2, /* _xcoff_ldhdr_version */
2700 _bfd_xcoff64_put_symbol_name, /* _xcoff_put_symbol_name */
2701 _bfd_xcoff64_put_ldsymbol_name, /* _xcoff_put_ldsymbol_name */
2703 /* Dynamic reloc howto. */
2704 &xcoff64_dynamic_reloc,
2705 xcoff64_create_csect_from_smclas,
2707 /* Lineno and reloc count overflow. */
2708 xcoff64_is_lineno_count_overflow,
2709 xcoff64_is_reloc_count_overflow,
2711 xcoff64_loader_symbol_offset,
2712 xcoff64_loader_reloc_offset,
2715 &xcoff64_glink_code[0],
2716 40, /* _xcoff_glink_size */
2719 88, /* _xcoff_rtinit_size */
2720 xcoff64_generate_rtinit, /* _xcoff_generate_rtinit */
2723 /* The transfer vector that leads the outside world to all of the above. */
2724 const bfd_target aix5coff64_vec =
2726 "aix5coff64-rs6000",
2727 bfd_target_xcoff_flavour,
2728 BFD_ENDIAN_BIG, /* data byte order is big */
2729 BFD_ENDIAN_BIG, /* header byte order is big */
2731 (HAS_RELOC | EXEC_P | /* object flags */
2732 HAS_LINENO | HAS_DEBUG | DYNAMIC |
2733 HAS_SYMS | HAS_LOCALS | WP_TEXT),
2735 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
2736 0, /* leading char */
2737 '/', /* ar_pad_char */
2738 15, /* ar_max_namelen??? FIXMEmgo */
2741 bfd_getb64, /* bfd_getx64 */
2742 bfd_getb_signed_64, /* bfd_getx_signed_64 */
2743 bfd_putb64, /* bfd_putx64 */
2744 bfd_getb32, /* bfd_getx32 */
2745 bfd_getb_signed_32, /* bfd_getx_signed_32 */
2746 bfd_putb32, /* bfd_putx32 */
2747 bfd_getb16, /* bfd_getx16 */
2748 bfd_getb_signed_16, /* bfd_getx_signed_16 */
2749 bfd_putb16, /* bfd_putx16 */
2752 bfd_getb64, /* bfd_h_getx64 */
2753 bfd_getb_signed_64, /* bfd_h_getx_signed_64 */
2754 bfd_putb64, /* bfd_h_putx64 */
2755 bfd_getb32, /* bfd_h_getx32 */
2756 bfd_getb_signed_32, /* bfd_h_getx_signed_32 */
2757 bfd_putb32, /* bfd_h_putx32 */
2758 bfd_getb16, /* bfd_h_getx16 */
2759 bfd_getb_signed_16, /* bfd_h_getx_signed_16 */
2760 bfd_putb16, /* bfd_h_putx16 */
2762 { /* bfd_check_format */
2769 { /* bfd_set_format */
2772 _bfd_generic_mkarchive,
2776 {/* bfd_write_contents */
2778 xcoff64_write_object_contents,
2779 _bfd_xcoff_write_archive_contents,
2784 bfd_true, /* _close_and_cleanup */
2785 bfd_true, /* _bfd_free_cached_info */
2786 coff_new_section_hook, /* _new_section_hook */
2787 _bfd_generic_get_section_contents, /* _bfd_get_section_contents */
2788 /* _bfd_get_section_contents_in_window */
2789 _bfd_generic_get_section_contents_in_window,
2792 _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */
2793 /* _bfd_merge_private_bfd_data */
2794 ((boolean (*) (bfd *, bfd *)) bfd_true),
2795 /* _bfd_copy_pivate_section_data */
2796 ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
2797 /* _bfd_copy_private_symbol_data */
2798 ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
2799 ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */
2800 ((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */
2803 xcoff64_core_file_failing_command, /* _core_file_failing_command */
2804 xcoff64_core_file_failing_signal, /* _core_file_failing_signal */
2805 xcoff64_core_file_matches_executable_p, /* _core_file_matches_executable_p */
2808 xcoff64_slurp_armap, /* _slurp_armap */
2809 /* XCOFF archives do not have anything which corresponds to an
2810 extended name table. */
2811 bfd_false, /* _slurp_extended_name_table */
2812 /* _construct_extended_name_table */
2813 ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
2814 bfd_dont_truncate_arname, /* _truncate_arname */
2815 _bfd_xcoff_write_armap, /* _write_armap */
2816 _bfd_xcoff_read_ar_hdr, /* _read_ar_hdr */
2817 xcoff64_openr_next_archived_file, /* _openr_next_archived_file */
2818 _bfd_generic_get_elt_at_index, /* _get_elt_at_index */
2819 _bfd_xcoff_stat_arch_elt, /* _generic_stat_arch_elt */
2820 /* XCOFF archives do not have a timestamp. */
2821 bfd_true, /* _update_armap_timestamp */
2824 coff_get_symtab_upper_bound, /* _get_symtab_upper_bound */
2825 coff_get_symtab, /* _get_symtab */
2826 coff_make_empty_symbol, /* _make_empty_symbol */
2827 coff_print_symbol, /* _print_symbol */
2828 coff_get_symbol_info, /* _get_symbol_info */
2829 _bfd_xcoff_is_local_label_name, /* _bfd_is_local_label_name */
2830 coff_get_lineno, /* _get_lineno */
2831 coff_find_nearest_line, /* _find_nearest_line */
2832 coff_bfd_make_debug_symbol, /* _bfd_make_debug_symbol */
2833 _bfd_generic_read_minisymbols, /* _read_minisymbols */
2834 _bfd_generic_minisymbol_to_symbol, /* _minsymbol_to_symbol */
2837 coff_get_reloc_upper_bound, /* _get_reloc_upper_bound */
2838 coff_canonicalize_reloc, /* _cononicalize_reloc */
2839 xcoff64_reloc_type_lookup, /* _bfd_reloc_type_lookup */
2842 coff_set_arch_mach, /* _set_arch_mach */
2843 coff_set_section_contents, /* _set_section_contents */
2846 xcoff64_sizeof_headers, /* _sizeof_headers */
2847 /* _bfd_get_relocated_section_contents */
2848 bfd_generic_get_relocated_section_contents,
2849 bfd_generic_relax_section, /* _bfd_relax_section */
2850 _bfd_xcoff_bfd_link_hash_table_create,/* _bfd_link_hash_table_create */
2851 _bfd_generic_link_hash_table_free, /* _bfd_link_hash_table_free */
2852 _bfd_xcoff_bfd_link_add_symbols, /* _bfd_link_add_symbols */
2853 _bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */
2854 _bfd_generic_link_split_section, /* _bfd_link_split_section */
2855 bfd_generic_gc_sections, /* _bfd_gc_sections */
2856 bfd_generic_merge_sections, /* _bfd_merge_sections */
2859 /* _get_dynamic_symtab_upper_bound */
2860 _bfd_xcoff_get_dynamic_symtab_upper_bound,
2861 _bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */
2862 _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */
2863 _bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */
2865 /* Opposite endian version, none exists. */
2869 (void *) & bfd_xcoff_aix5_backend_data,