1 /* BFD back-end for IBM RS/6000 "XCOFF64" files.
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_ldsymbol_name
88 PARAMS ((bfd
*, struct xcoff_loader_info
*, struct internal_ldsym
*,
90 static void _bfd_xcoff64_swap_sym_in
PARAMS ((bfd
*, PTR
, PTR
));
91 static unsigned int _bfd_xcoff64_swap_sym_out
PARAMS ((bfd
*, PTR
, PTR
));
92 static void _bfd_xcoff64_swap_aux_in
93 PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
94 static unsigned int _bfd_xcoff64_swap_aux_out
95 PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
96 extern boolean _bfd_xcoff_mkobject
PARAMS ((bfd
*));
97 extern boolean _bfd_xcoff_copy_private_bfd_data
PARAMS ((bfd
*, bfd
*));
98 extern boolean _bfd_xcoff_is_local_label_name
PARAMS ((bfd
*, const char *));
99 extern void xcoff64_rtype2howto
100 PARAMS ((arelent
*, struct internal_reloc
*));
101 extern reloc_howto_type
* xcoff64_reloc_type_lookup
102 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
103 extern boolean _bfd_xcoff_slurp_armap
PARAMS ((bfd
*));
104 extern PTR _bfd_xcoff_read_ar_hdr
PARAMS ((bfd
*));
105 extern bfd
*_bfd_xcoff_openr_next_archived_file
PARAMS ((bfd
*, bfd
*));
106 extern int _bfd_xcoff_generic_stat_arch_elt
PARAMS ((bfd
*, struct stat
*));
107 extern boolean _bfd_xcoff_write_armap
108 PARAMS ((bfd
*, unsigned int, struct orl
*, unsigned int, int));
109 extern boolean _bfd_xcoff_write_archive_contents
PARAMS ((bfd
*));
110 extern int _bfd_xcoff_sizeof_headers
PARAMS ((bfd
*, boolean
));
111 extern void _bfd_xcoff_swap_sym_in
PARAMS ((bfd
*, PTR
, PTR
));
112 extern unsigned int _bfd_xcoff_swap_sym_out
PARAMS ((bfd
*, PTR
, PTR
));
113 extern void _bfd_xcoff_swap_aux_in
114 PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
115 extern unsigned int _bfd_xcoff_swap_aux_out
116 PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
117 static void xcoff64_swap_ldhdr_in
118 PARAMS ((bfd
*, const PTR
, struct internal_ldhdr
*));
119 static void xcoff64_swap_ldhdr_out
120 PARAMS ((bfd
*, const struct internal_ldhdr
*, PTR d
));
121 static void xcoff64_swap_ldsym_in
122 PARAMS ((bfd
*, const PTR
, struct internal_ldsym
*));
123 static void xcoff64_swap_ldsym_out
124 PARAMS ((bfd
*, const struct internal_ldsym
*, PTR d
));
125 static void xcoff64_swap_ldrel_in
126 PARAMS ((bfd
*, const PTR
, struct internal_ldrel
*));
127 static void xcoff64_swap_ldrel_out
128 PARAMS ((bfd
*, const struct internal_ldrel
*, PTR d
));
129 static boolean xcoff64_write_object_contents
PARAMS ((bfd
*));
130 static boolean xcoff64_ppc_relocate_section
131 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
132 struct internal_reloc
*, struct internal_syment
*,
133 asection
**sections
));
134 static boolean xcoff64_slurp_armap
PARAMS ((bfd
*));
135 static const bfd_target
*xcoff64_archive_p
PARAMS ((bfd
*));
136 static bfd
*xcoff64_openr_next_archived_file
PARAMS ((bfd
*, bfd
*));
137 static int xcoff64_sizeof_headers
PARAMS ((bfd
*, boolean
));
138 static asection
*xcoff64_create_csect_from_smclas
139 PARAMS ((bfd
*, union internal_auxent
*, const char *));
140 static boolean xcoff64_is_lineno_count_overflow
PARAMS ((bfd
*, bfd_vma
));
141 static boolean xcoff64_is_reloc_count_overflow
PARAMS ((bfd
*, bfd_vma
));
142 static bfd_vma xcoff64_loader_symbol_offset
143 PARAMS ((bfd
*, struct internal_ldhdr
*));
144 static bfd_vma xcoff64_loader_reloc_offset
145 PARAMS ((bfd
*, struct internal_ldhdr
*));
147 /* coffcode.h needs these to be defined */
148 /* Internalcoff.h and coffcode.h modify themselves based on these flags. */
150 #define RS6000COFF_C 1
152 #define SELECT_RELOC(internal, howto) \
154 internal.r_type = howto->type; \
156 ((howto->complain_on_overflow == complain_overflow_signed \
159 | (howto->bitsize - 1)); \
162 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
163 #define COFF_LONG_FILENAMES
164 #define NO_COFF_SYMBOLS
165 #define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst)
166 #define coff_mkobject _bfd_xcoff_mkobject
167 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
168 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
169 #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
171 extern const bfd_target
* rs6000coff_core_p ();
172 extern boolean
rs6000coff_core_file_matches_executable_p ();
173 extern char *rs6000coff_core_file_failing_command
PARAMS ((bfd
*abfd
));
174 extern int rs6000coff_core_file_failing_signal
PARAMS ((bfd
*abfd
));
175 #define CORE_FILE_P rs6000coff_core_p
176 #define coff_core_file_failing_command \
177 rs6000coff_core_file_failing_command
178 #define coff_core_file_failing_signal \
179 rs6000coff_core_file_failing_signal
180 #define coff_core_file_matches_executable_p \
181 rs6000coff_core_file_matches_executable_p
183 #define CORE_FILE_P _bfd_dummy_target
184 #define coff_core_file_failing_command \
185 _bfd_nocore_core_file_failing_command
186 #define coff_core_file_failing_signal \
187 _bfd_nocore_core_file_failing_signal
188 #define coff_core_file_matches_executable_p \
189 _bfd_nocore_core_file_matches_executable_p
191 #define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
192 #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
193 #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
194 #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
197 #include "coffcode.h"
199 /* For XCOFF64, the effective width of symndx changes depending on
200 whether we are the first entry. Sigh. */
202 _bfd_xcoff64_swap_lineno_in (abfd
, ext1
, in1
)
207 LINENO
*ext
= (LINENO
*) ext1
;
208 struct internal_lineno
*in
= (struct internal_lineno
*) in1
;
210 in
->l_lnno
= H_GET_32 (abfd
, (ext
->l_lnno
));
212 in
->l_addr
.l_symndx
= H_GET_32 (abfd
, ext
->l_addr
.l_symndx
);
214 in
->l_addr
.l_paddr
= H_GET_64 (abfd
, ext
->l_addr
.l_paddr
);
218 _bfd_xcoff64_swap_lineno_out (abfd
, inp
, outp
)
223 struct internal_lineno
*in
= (struct internal_lineno
*) inp
;
224 struct external_lineno
*ext
= (struct external_lineno
*) outp
;
226 H_PUT_32 (abfd
, in
->l_addr
.l_symndx
, ext
->l_addr
.l_symndx
);
227 H_PUT_32 (abfd
, in
->l_lnno
, (ext
->l_lnno
));
230 H_PUT_32 (abfd
, in
->l_addr
.l_symndx
, ext
->l_addr
.l_symndx
);
232 H_PUT_64 (abfd
, in
->l_addr
.l_paddr
, ext
->l_addr
.l_paddr
);
234 return bfd_coff_linesz (abfd
);
238 _bfd_xcoff64_swap_sym_in (abfd
, ext1
, in1
)
243 struct external_syment
*ext
= (struct external_syment
*) ext1
;
244 struct internal_syment
*in
= (struct internal_syment
*) in1
;
246 in
->_n
._n_n
._n_zeroes
= 0;
247 in
->_n
._n_n
._n_offset
= H_GET_32 (abfd
, ext
->e_offset
);
248 in
->n_value
= H_GET_64 (abfd
, ext
->e_value
);
249 in
->n_scnum
= H_GET_16 (abfd
, ext
->e_scnum
);
250 in
->n_type
= H_GET_16 (abfd
, ext
->e_type
);
251 in
->n_sclass
= H_GET_8 (abfd
, ext
->e_sclass
);
252 in
->n_numaux
= H_GET_8 (abfd
, ext
->e_numaux
);
256 _bfd_xcoff64_swap_sym_out (abfd
, inp
, extp
)
261 struct internal_syment
*in
= (struct internal_syment
*) inp
;
262 struct external_syment
*ext
= (struct external_syment
*) extp
;
264 H_PUT_32 (abfd
, in
->_n
._n_n
._n_offset
, ext
->e_offset
);
265 H_PUT_64 (abfd
, in
->n_value
, ext
->e_value
);
266 H_PUT_16 (abfd
, in
->n_scnum
, ext
->e_scnum
);
267 H_PUT_16 (abfd
, in
->n_type
, ext
->e_type
);
268 H_PUT_8 (abfd
, in
->n_sclass
, ext
->e_sclass
);
269 H_PUT_8 (abfd
, in
->n_numaux
, ext
->e_numaux
);
270 return bfd_coff_symesz (abfd
);
274 _bfd_xcoff64_swap_aux_in (abfd
, ext1
, type
, class, indx
, numaux
, in1
)
283 union external_auxent
*ext
= (union external_auxent
*) ext1
;
284 union internal_auxent
*in
= (union internal_auxent
*) in1
;
289 if (ext
->x_file
.x_n
.x_zeroes
== 0)
291 in
->x_file
.x_n
.x_zeroes
= 0;
292 in
->x_file
.x_n
.x_offset
= H_GET_32 (abfd
, ext
->x_file
.x_n
.x_offset
);
296 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_fname
, FILNMLEN
);
300 /* RS/6000 "csect" auxents */
303 if (indx
+ 1 == numaux
)
305 bfd_signed_vma h
= 0;
308 h
= H_GET_S32 (abfd
, ext
->x_csect
.x_scnlen_hi
);
309 l
= H_GET_32 (abfd
, ext
->x_csect
.x_scnlen_lo
);
311 in
->x_csect
.x_scnlen
.l
= h
<< 32 | (l
& 0xffffffff);
313 in
->x_csect
.x_parmhash
= H_GET_32 (abfd
, ext
->x_csect
.x_parmhash
);
314 in
->x_csect
.x_snhash
= H_GET_16 (abfd
, ext
->x_csect
.x_snhash
);
315 /* We don't have to hack bitfields in x_smtyp because it's
316 defined by shifts-and-ands, which are equivalent on all
318 in
->x_csect
.x_smtyp
= H_GET_8 (abfd
, ext
->x_csect
.x_smtyp
);
319 in
->x_csect
.x_smclas
= H_GET_8 (abfd
, ext
->x_csect
.x_smclas
);
329 /* PE defines some extra fields; we zero them out for
331 in
->x_scn
.x_checksum
= 0;
332 in
->x_scn
.x_associated
= 0;
333 in
->x_scn
.x_comdat
= 0;
340 if (class == C_BLOCK
|| class == C_FCN
|| ISFCN (type
) || ISTAG (class))
342 in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
343 = H_GET_64 (abfd
, ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
344 in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
345 = H_GET_32 (abfd
, ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
349 in
->x_sym
.x_misc
.x_fsize
350 = H_GET_32 (abfd
, ext
->x_sym
.x_fcnary
.x_fcn
.x_fsize
);
354 in
->x_sym
.x_misc
.x_lnsz
.x_lnno
355 = H_GET_32 (abfd
, ext
->x_sym
.x_fcnary
.x_lnsz
.x_lnno
);
356 in
->x_sym
.x_misc
.x_lnsz
.x_size
357 = H_GET_16 (abfd
, ext
->x_sym
.x_fcnary
.x_lnsz
.x_size
);
364 _bfd_xcoff64_swap_aux_out (abfd
, inp
, type
, class, indx
, numaux
, extp
)
369 int indx ATTRIBUTE_UNUSED
;
370 int numaux ATTRIBUTE_UNUSED
;
373 union internal_auxent
*in
= (union internal_auxent
*) inp
;
374 union external_auxent
*ext
= (union external_auxent
*) extp
;
376 memset ((PTR
) ext
, 0, bfd_coff_auxesz (abfd
));
380 if (ext
->x_file
.x_n
.x_zeroes
== 0)
382 H_PUT_32 (abfd
, 0, ext
->x_file
.x_n
.x_zeroes
);
383 H_PUT_32 (abfd
, in
->x_file
.x_n
.x_offset
, ext
->x_file
.x_n
.x_offset
);
387 memcpy (ext
->x_file
.x_fname
, in
->x_file
.x_fname
, FILNMLEN
);
389 H_PUT_8 (abfd
, _AUX_FILE
, ext
->x_auxtype
.x_auxtype
);
392 /* RS/6000 "csect" auxents */
395 if (indx
+ 1 == numaux
)
399 temp
= in
->x_csect
.x_scnlen
.l
& 0xffffffff;
400 H_PUT_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_lo
);
401 temp
= in
->x_csect
.x_scnlen
.l
>> 32;
402 H_PUT_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_hi
);
403 H_PUT_32 (abfd
, in
->x_csect
.x_parmhash
, ext
->x_csect
.x_parmhash
);
404 H_PUT_16 (abfd
, in
->x_csect
.x_snhash
, ext
->x_csect
.x_snhash
);
405 /* We don't have to hack bitfields in x_smtyp because it's
406 defined by shifts-and-ands, which are equivalent on all
408 H_PUT_8 (abfd
, in
->x_csect
.x_smtyp
, ext
->x_csect
.x_smtyp
);
409 H_PUT_8 (abfd
, in
->x_csect
.x_smclas
, ext
->x_csect
.x_smclas
);
410 H_PUT_8 (abfd
, _AUX_CSECT
, ext
->x_auxtype
.x_auxtype
);
425 if (class == C_BLOCK
|| class == C_FCN
|| ISFCN (type
) || ISTAG (class))
427 H_PUT_64 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
,
428 ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
429 H_PUT_8 (abfd
, _AUX_FCN
,
430 ext
->x_auxtype
.x_auxtype
);
431 H_PUT_32 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
,
432 ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
436 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_fsize
,
437 ext
->x_sym
.x_fcnary
.x_fcn
.x_fsize
);
441 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_lnno
,
442 ext
->x_sym
.x_fcnary
.x_lnsz
.x_lnno
);
443 H_PUT_16 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_size
,
444 ext
->x_sym
.x_fcnary
.x_lnsz
.x_size
);
449 return bfd_coff_auxesz (abfd
);
453 _bfd_xcoff64_put_symbol_name (bfd
*abfd
, struct bfd_strtab_hash
*strtab
,
454 struct internal_syment
*sym
,
461 if ((abfd
->flags
& BFD_TRADITIONAL_FORMAT
) != 0)
464 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
466 if (indx
== (bfd_size_type
) -1)
469 sym
->_n
._n_n
._n_zeroes
= 0;
470 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
476 _bfd_xcoff64_put_ldsymbol_name (abfd
, ldinfo
, ldsym
, name
)
477 bfd
*abfd ATTRIBUTE_UNUSED
;
478 struct xcoff_loader_info
*ldinfo
;
479 struct internal_ldsym
*ldsym
;
486 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
)
488 bfd_size_type newalc
;
489 bfd_byte
*newstrings
;
491 newalc
= ldinfo
->string_alc
* 2;
494 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
497 newstrings
= ((bfd_byte
*)
498 bfd_realloc ((PTR
) ldinfo
->strings
, newalc
));
499 if (newstrings
== NULL
)
501 ldinfo
->failed
= true;
504 ldinfo
->string_alc
= newalc
;
505 ldinfo
->strings
= newstrings
;
508 bfd_put_16 (ldinfo
->output_bfd
, (bfd_vma
) (len
+ 1),
509 ldinfo
->strings
+ ldinfo
->string_size
);
510 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
511 ldsym
->_l
._l_l
._l_zeroes
= 0;
512 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
513 ldinfo
->string_size
+= len
+ 3;
518 /* Routines to swap information in the XCOFF .loader section. If we
519 ever need to write an XCOFF loader, this stuff will need to be
520 moved to another file shared by the linker (which XCOFF calls the
521 ``binder'') and the loader. */
523 /* Swap in the ldhdr structure. */
526 xcoff64_swap_ldhdr_in (abfd
, s
, dst
)
529 struct internal_ldhdr
*dst
;
531 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
533 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
534 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
535 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
536 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
537 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
538 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
539 dst
->l_impoff
= bfd_get_64 (abfd
, src
->l_impoff
);
540 dst
->l_stoff
= bfd_get_64 (abfd
, src
->l_stoff
);
541 dst
->l_symoff
= bfd_get_64 (abfd
, src
->l_symoff
);
542 dst
->l_rldoff
= bfd_get_64 (abfd
, src
->l_rldoff
);
545 /* Swap out the ldhdr structure. */
548 xcoff64_swap_ldhdr_out (abfd
, src
, d
)
550 const struct internal_ldhdr
*src
;
553 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
555 bfd_put_32 (abfd
, (bfd_vma
) src
->l_version
, dst
->l_version
);
556 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
557 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
558 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
559 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
560 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
561 bfd_put_64 (abfd
, src
->l_impoff
, dst
->l_impoff
);
562 bfd_put_64 (abfd
, src
->l_stoff
, dst
->l_stoff
);
563 bfd_put_64 (abfd
, src
->l_symoff
, dst
->l_symoff
);
564 bfd_put_64 (abfd
, src
->l_rldoff
, dst
->l_rldoff
);
567 /* Swap in the ldsym structure. */
570 xcoff64_swap_ldsym_in (abfd
, s
, dst
)
573 struct internal_ldsym
*dst
;
575 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
576 /* XCOFF64 does not use l_zeroes like XCOFF32
577 Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
578 as an offset into the loader symbol table. */
579 dst
->_l
._l_l
._l_zeroes
= 0;
580 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->l_offset
);
581 dst
->l_value
= bfd_get_64 (abfd
, src
->l_value
);
582 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
583 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
584 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
585 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
586 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
589 /* Swap out the ldsym structure. */
592 xcoff64_swap_ldsym_out (abfd
, src
, d
)
594 const struct internal_ldsym
*src
;
597 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
599 bfd_put_64 (abfd
, src
->l_value
, dst
->l_value
);
600 bfd_put_32 (abfd
, (bfd_vma
) src
->_l
._l_l
._l_offset
, dst
->l_offset
);
601 bfd_put_16 (abfd
, (bfd_vma
) src
->l_scnum
, dst
->l_scnum
);
602 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
603 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
604 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
605 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
608 /* Swap in the ldrel structure. */
611 xcoff64_swap_ldrel_in (abfd
, s
, dst
)
614 struct internal_ldrel
*dst
;
616 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
618 dst
->l_vaddr
= bfd_get_64 (abfd
, src
->l_vaddr
);
619 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
620 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
621 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
624 /* Swap out the ldrel structure. */
627 xcoff64_swap_ldrel_out (abfd
, src
, d
)
629 const struct internal_ldrel
*src
;
632 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
634 bfd_put_64 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
635 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rtype
, dst
->l_rtype
);
636 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rsecnm
, dst
->l_rsecnm
);
637 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
641 xcoff64_write_object_contents (abfd
)
645 boolean hasrelocs
= false;
646 boolean haslinno
= false;
649 file_ptr lineno_base
;
651 unsigned long reloc_size
= 0;
652 unsigned long lnno_size
= 0;
653 boolean long_section_names
;
654 asection
*text_sec
= ((void *) 0);
655 asection
*data_sec
= ((void *) 0);
656 asection
*bss_sec
= ((void *) 0);
657 struct internal_filehdr internal_f
;
658 struct internal_aouthdr internal_a
;
660 bfd_set_error (bfd_error_system_call
);
662 if (abfd
->output_has_begun
== false)
664 if (! bfd_coff_compute_section_file_positions (abfd
))
668 /* Work out the size of the reloc and linno areas */
669 reloc_base
= obj_relocbase (abfd
);
671 for (current
= abfd
->sections
; current
!= NULL
; current
= current
->next
)
672 reloc_size
+= current
->reloc_count
* bfd_coff_relsz (abfd
);
674 lineno_base
= reloc_base
+ reloc_size
;
676 /* Make a pass through the symbol table to count line number entries and
677 put them into the correct asections */
678 lnno_size
= coff_count_linenumbers (abfd
) * bfd_coff_linesz (abfd
);
680 sym_base
= lineno_base
+ lnno_size
;
682 /* Indicate in each section->line_filepos its actual file address */
683 for (current
= abfd
->sections
; current
!= NULL
; current
= current
->next
)
685 if (current
->lineno_count
)
687 current
->line_filepos
= lineno_base
;
688 current
->moving_line_filepos
= lineno_base
;
689 lineno_base
+= current
->lineno_count
* bfd_coff_linesz (abfd
);
693 current
->line_filepos
= 0;
696 if (current
->reloc_count
)
698 current
->rel_filepos
= reloc_base
;
699 reloc_base
+= current
->reloc_count
* bfd_coff_relsz (abfd
);
703 current
->rel_filepos
= 0;
707 if ((abfd
->flags
& EXEC_P
) != 0)
709 scn_base
= bfd_coff_filhsz (abfd
) + bfd_coff_aoutsz (abfd
);
710 internal_f
.f_opthdr
= bfd_coff_aoutsz (abfd
);
714 scn_base
= bfd_coff_filhsz (abfd
);
715 internal_f
.f_opthdr
= 0;
718 internal_f
.f_nscns
= 0;
720 if (bfd_seek (abfd
, scn_base
, SEEK_SET
) != 0)
723 long_section_names
= false;
724 for (current
= abfd
->sections
; current
!= NULL
; current
= current
->next
)
726 struct internal_scnhdr section
;
727 struct external_scnhdr buff
;
728 bfd_size_type amount
;
730 internal_f
.f_nscns
++;
732 strncpy (section
.s_name
, current
->name
, SCNNMLEN
);
734 section
.s_vaddr
= current
->vma
;
735 section
.s_paddr
= current
->lma
;
736 section
.s_size
= current
->_raw_size
;
738 /* If this section has no size or is unloadable then the scnptr
740 if (current
->_raw_size
== 0
741 || (current
->flags
& (SEC_LOAD
| SEC_HAS_CONTENTS
)) == 0)
743 section
.s_scnptr
= 0;
747 section
.s_scnptr
= current
->filepos
;
750 section
.s_relptr
= current
->rel_filepos
;
751 section
.s_lnnoptr
= current
->line_filepos
;
752 section
.s_nreloc
= current
->reloc_count
;
754 section
.s_nlnno
= current
->lineno_count
;
755 if (current
->reloc_count
!= 0)
757 if (current
->lineno_count
!= 0)
760 section
.s_flags
= sec_to_styp_flags (current
->name
, current
->flags
);
762 if (!strcmp (current
->name
, _TEXT
))
766 else if (!strcmp (current
->name
, _DATA
))
770 else if (!strcmp (current
->name
, _BSS
))
775 amount
= bfd_coff_scnhsz (abfd
);
776 if (bfd_coff_swap_scnhdr_out (abfd
, §ion
, &buff
) == 0
777 || bfd_bwrite ((PTR
) (&buff
), amount
, abfd
) != amount
)
781 internal_f
.f_timdat
= 0;
783 internal_f
.f_flags
= 0;
786 internal_f
.f_flags
|= F_RELFLG
;
788 internal_f
.f_flags
|= F_LNNO
;
789 if (abfd
->flags
& EXEC_P
)
790 internal_f
.f_flags
|= F_EXEC
;
792 /* FIXME: this is wrong for PPC_PE! */
793 if (bfd_little_endian (abfd
))
794 internal_f
.f_flags
|= F_AR32WR
;
796 internal_f
.f_flags
|= F_AR32W
;
798 if ((abfd
->flags
& DYNAMIC
) != 0)
799 internal_f
.f_flags
|= F_SHROBJ
;
800 if (bfd_get_section_by_name (abfd
, _LOADER
) != NULL
)
801 internal_f
.f_flags
|= F_DYNLOAD
;
803 memset (&internal_a
, 0, sizeof internal_a
);
806 /* This can only be called from the xcoff64 backend so the magic #
807 must be for xcoff64. */
808 internal_f
.f_magic
= 0757;
810 internal_a
.magic
= (abfd
->flags
& D_PAGED
) ? RS6K_AOUTHDR_ZMAGIC
:
811 (abfd
->flags
& WP_TEXT
) ? RS6K_AOUTHDR_NMAGIC
:
814 /* FIXME: Does anybody ever set this to another value? */
815 internal_a
.vstamp
= 0;
817 /* Now should write relocs, strings, syms */
818 obj_sym_filepos (abfd
) = sym_base
;
820 internal_f
.f_symptr
= 0;
821 internal_f
.f_nsyms
= 0;
823 /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
824 backend linker, and obj_raw_syment_count is not valid until after
825 coff_write_symbols is called. */
826 if (bfd_get_symcount (abfd
) != 0)
830 if (!coff_renumber_symbols (abfd
, &firstundef
))
832 coff_mangle_symbols (abfd
);
833 if (! coff_write_symbols (abfd
))
835 if (! coff_write_linenumbers (abfd
))
837 if (! coff_write_relocs (abfd
, firstundef
))
840 internal_f
.f_symptr
= sym_base
;
841 internal_f
.f_nsyms
= bfd_get_symcount (abfd
);
843 else if (obj_raw_syment_count (abfd
) != 0)
845 internal_f
.f_symptr
= sym_base
;
847 /* AIX appears to require that F_RELFLG not be set if there are
848 local symbols but no relocations. */
849 internal_f
.f_flags
&=~ F_RELFLG
;
853 internal_f
.f_flags
|= F_LSYMS
;
858 internal_a
.tsize
= bfd_get_section_size_before_reloc (text_sec
);
859 internal_a
.text_start
= internal_a
.tsize
? text_sec
->vma
: 0;
864 internal_a
.dsize
= bfd_get_section_size_before_reloc (data_sec
);
865 internal_a
.data_start
= internal_a
.dsize
? data_sec
->vma
: 0;
870 internal_a
.bsize
= bfd_get_section_size_before_reloc (bss_sec
);
871 if (internal_a
.bsize
&& bss_sec
->vma
< internal_a
.data_start
)
872 internal_a
.data_start
= bss_sec
->vma
;
875 internal_a
.entry
= bfd_get_start_address (abfd
);
876 internal_f
.f_nsyms
= obj_raw_syment_count (abfd
);
878 if (xcoff_data (abfd
)->full_aouthdr
)
881 asection
*loader_sec
;
883 internal_a
.vstamp
= 1;
885 internal_a
.o_snentry
= xcoff_data (abfd
)->snentry
;
886 if (internal_a
.o_snentry
== 0)
887 internal_a
.entry
= (bfd_vma
) -1;
889 if (text_sec
!= NULL
)
891 internal_a
.o_sntext
= text_sec
->target_index
;
892 internal_a
.o_algntext
= bfd_get_section_alignment (abfd
, text_sec
);
896 internal_a
.o_sntext
= 0;
897 internal_a
.o_algntext
= 0;
900 if (data_sec
!= NULL
)
902 internal_a
.o_sndata
= data_sec
->target_index
;
903 internal_a
.o_algndata
= bfd_get_section_alignment (abfd
, data_sec
);
907 internal_a
.o_sndata
= 0;
908 internal_a
.o_algndata
= 0;
911 loader_sec
= bfd_get_section_by_name (abfd
, ".loader");
912 if (loader_sec
!= NULL
)
913 internal_a
.o_snloader
= loader_sec
->target_index
;
915 internal_a
.o_snloader
= 0;
917 internal_a
.o_snbss
= bss_sec
->target_index
;
919 internal_a
.o_snbss
= 0;
921 toc
= xcoff_data (abfd
)->toc
;
922 internal_a
.o_toc
= toc
;
923 internal_a
.o_sntoc
= xcoff_data (abfd
)->sntoc
;
925 internal_a
.o_modtype
= xcoff_data (abfd
)->modtype
;
926 if (xcoff_data (abfd
)->cputype
!= -1)
927 internal_a
.o_cputype
= xcoff_data (abfd
)->cputype
;
930 switch (bfd_get_arch (abfd
))
932 case bfd_arch_rs6000
:
933 internal_a
.o_cputype
= 4;
935 case bfd_arch_powerpc
:
936 if (bfd_get_mach (abfd
) == 0)
937 internal_a
.o_cputype
= 3;
939 internal_a
.o_cputype
= 1;
945 internal_a
.o_maxstack
= xcoff_data (abfd
)->maxstack
;
946 internal_a
.o_maxdata
= xcoff_data (abfd
)->maxdata
;
949 if (bfd_seek (abfd
, (file_ptr
) 0, 0) != 0)
954 bfd_size_type amount
= bfd_coff_filhsz (abfd
);
956 buff
= bfd_malloc (amount
);
960 bfd_coff_swap_filehdr_out (abfd
, (PTR
) &internal_f
, (PTR
) buff
);
961 amount
= bfd_bwrite ((PTR
) buff
, amount
, abfd
);
965 if (amount
!= bfd_coff_filhsz (abfd
))
969 if (abfd
->flags
& EXEC_P
)
972 bfd_size_type amount
= bfd_coff_aoutsz (abfd
);
974 buff
= bfd_malloc (amount
);
978 bfd_coff_swap_aouthdr_out (abfd
, (PTR
) & internal_a
, (PTR
) buff
);
979 amount
= bfd_bwrite ((PTR
) buff
, amount
, abfd
);
983 if (amount
!= bfd_coff_aoutsz (abfd
))
990 /* This is the relocation function for the RS/6000/POWER/PowerPC.
991 This is currently the only processor which uses XCOFF; I hope that
992 will never change. */
995 xcoff64_ppc_relocate_section (output_bfd
, info
, input_bfd
,
996 input_section
, contents
, relocs
, syms
,
999 struct bfd_link_info
*info
;
1001 asection
*input_section
;
1003 struct internal_reloc
*relocs
;
1004 struct internal_syment
*syms
;
1005 asection
**sections
;
1007 struct internal_reloc
*rel
;
1008 struct internal_reloc
*relend
;
1011 relend
= rel
+ input_section
->reloc_count
;
1012 for (; rel
< relend
; rel
++)
1015 struct xcoff_link_hash_entry
*h
;
1016 struct internal_syment
*sym
;
1019 struct reloc_howto_struct howto
;
1020 bfd_reloc_status_type rstat
;
1022 /* Relocation type R_REF is a special relocation type which is
1023 merely used to prevent garbage collection from occurring for
1024 the csect including the symbol which it references. */
1025 if (rel
->r_type
== R_REF
)
1028 symndx
= rel
->r_symndx
;
1038 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
1039 sym
= syms
+ symndx
;
1040 addend
= - sym
->n_value
;
1043 /* We build the howto information on the fly. */
1045 howto
.type
= rel
->r_type
;
1046 howto
.rightshift
= 0;
1048 howto
.bitsize
= (rel
->r_size
& 0x3f) + 1;
1049 howto
.pc_relative
= false;
1051 if ((rel
->r_size
& 0x80) != 0)
1052 howto
.complain_on_overflow
= complain_overflow_signed
;
1054 howto
.complain_on_overflow
= complain_overflow_bitfield
;
1055 howto
.special_function
= NULL
;
1056 howto
.name
= "internal";
1057 howto
.partial_inplace
= true;
1059 if (howto
.bitsize
== 64)
1061 howto
.src_mask
= howto
.dst_mask
= MINUS_ONE
;
1063 else if (howto
.bitsize
== 32)
1065 howto
.src_mask
= howto
.dst_mask
= 0xffffffff;
1069 howto
.src_mask
= howto
.dst_mask
= (1 << howto
.bitsize
) - 1;
1070 if (howto
.bitsize
== 16)
1073 howto
.pcrel_offset
= false;
1083 sec
= bfd_abs_section_ptr
;
1088 sec
= sections
[symndx
];
1089 /* Hack to make sure we use the right TOC anchor value
1090 if this reloc is against the TOC anchor. */
1091 if (sec
->name
[3] == '0'
1092 && strcmp (sec
->name
, ".tc0") == 0)
1093 val
= xcoff_data (output_bfd
)->toc
;
1095 val
= (sec
->output_section
->vma
1096 + sec
->output_offset
1105 if (h
->root
.type
== bfd_link_hash_defined
1106 || h
->root
.type
== bfd_link_hash_defweak
)
1110 sec
= h
->root
.u
.def
.section
;
1111 val
= (h
->root
.u
.def
.value
1112 + sec
->output_section
->vma
1113 + sec
->output_offset
);
1116 else if (h
->root
.type
== bfd_link_hash_common
)
1120 sec
= h
->root
.u
.c
.p
->section
;
1121 val
= (sec
->output_section
->vma
1122 + sec
->output_offset
);
1124 else if ((h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
1125 || (h
->flags
& XCOFF_IMPORT
) != 0)
1127 /* Every symbol in a shared object is defined somewhere. */
1130 else if (! info
->relocateable
)
1132 if (! ((*info
->callbacks
->undefined_symbol
)
1133 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
1134 rel
->r_vaddr
- input_section
->vma
, true)))
1137 /* Don't try to process the reloc. It can't help, and
1138 it may generate another error. */
1143 /* I took the relocation type definitions from two documents:
1144 the PowerPC AIX Version 4 Application Binary Interface, First
1145 Edition (April 1992), and the PowerOpen ABI, Big-Endian
1146 32-Bit Hardware Implementation (June 30, 1994). Differences
1147 between the documents are noted below. */
1149 switch (rel
->r_type
)
1154 /* These relocs are defined by the PowerPC ABI to be
1155 relative branches which use half of the difference
1156 between the symbol and the program counter. I can't
1157 quite figure out when this is useful. These relocs are
1158 not defined by the PowerOpen ABI. */
1160 (*_bfd_error_handler
)
1161 (_("%s: unsupported relocation type 0x%02x"),
1162 bfd_archive_filename (input_bfd
), (unsigned int) rel
->r_type
);
1163 bfd_set_error (bfd_error_bad_value
);
1166 /* Simple positive relocation. */
1169 /* Simple negative relocation. */
1173 /* Simple PC relative relocation. */
1174 howto
.pc_relative
= true;
1177 /* TOC relative relocation. The value in the instruction in
1178 the input file is the offset from the input file TOC to
1179 the desired location. We want the offset from the final
1180 TOC to the desired location. We have:
1185 so we must change insn by on - in.
1188 /* Global linkage relocation. The value of this relocation
1189 is the address of the entry in the TOC section. */
1191 /* Local object TOC address. I can't figure out the
1192 difference between this and case R_GL. */
1194 /* TOC relative relocation. A TOC relative load instruction
1195 which may be changed to a load address instruction.
1196 FIXME: We don't currently implement this optimization. */
1198 /* TOC relative relocation. This is a TOC relative load
1199 address instruction which may be changed to a load
1200 instruction. FIXME: I don't know if this is the correct
1202 if (h
!= NULL
&& h
->smclas
!= XMC_TD
)
1204 if (h
->toc_section
== NULL
)
1206 (*_bfd_error_handler
)
1207 (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
1208 bfd_archive_filename (input_bfd
), rel
->r_vaddr
,
1209 h
->root
.root
.string
);
1210 bfd_set_error (bfd_error_bad_value
);
1214 BFD_ASSERT ((h
->flags
& XCOFF_SET_TOC
) == 0);
1215 val
= (h
->toc_section
->output_section
->vma
1216 + h
->toc_section
->output_offset
);
1219 val
= ((val
- xcoff_data (output_bfd
)->toc
)
1220 - (sym
->n_value
- xcoff_data (input_bfd
)->toc
));
1225 /* Absolute branch. We don't want to mess with the lower
1226 two bits of the instruction. */
1228 /* The PowerPC ABI defines this as an absolute call which
1229 may be modified to become a relative call. The PowerOpen
1230 ABI does not define this relocation type. */
1232 /* Absolute branch which may be modified to become a
1235 /* The PowerPC ABI defines this as an absolute branch to a
1236 fixed address which may be modified to an absolute branch
1237 to a symbol. The PowerOpen ABI does not define this
1240 /* The PowerPC ABI defines this as an absolute branch to a
1241 fixed address which may be modified to a relative branch.
1242 The PowerOpen ABI does not define this relocation type. */
1243 howto
.src_mask
&= ~3;
1244 howto
.dst_mask
= howto
.src_mask
;
1247 /* Relative branch. We don't want to mess with the lower
1248 two bits of the instruction. */
1250 /* The PowerPC ABI defines this as a relative call which may
1251 be modified to become an absolute call. The PowerOpen
1252 ABI does not define this relocation type. */
1254 /* A relative branch which may be modified to become an
1255 absolute branch. FIXME: We don't implement this,
1256 although we should for symbols of storage mapping class
1258 howto
.pc_relative
= true;
1259 howto
.src_mask
&= ~3;
1260 howto
.dst_mask
= howto
.src_mask
;
1262 howto
.complain_on_overflow
= complain_overflow_bitfield
;
1265 /* The PowerPC AIX ABI describes this as a load which may be
1266 changed to a load address. The PowerOpen ABI says this
1267 is the same as case R_POS. */
1270 /* The PowerPC AIX ABI describes this as a load address
1271 which may be changed to a load. The PowerOpen ABI says
1272 this is the same as R_POS. */
1276 /* If we see an R_BR or R_RBR reloc which is jumping to global
1277 linkage code, and it is followed by an appropriate cror nop
1278 instruction, we replace the cror with ld r2,40(r1). This
1279 restores the TOC after the glink code. Contrariwise, if the
1280 call is followed by a ld r2,40(r1), but the call is not
1281 going to global linkage code, we can replace the load with a
1283 if ((rel
->r_type
== R_BR
|| rel
->r_type
== R_RBR
)
1285 && h
->root
.type
== bfd_link_hash_defined
1286 && (rel
->r_vaddr
- input_section
->vma
+ 8
1287 <= input_section
->_cooked_size
))
1292 pnext
= contents
+ (rel
->r_vaddr
- input_section
->vma
) + 4;
1293 next
= bfd_get_32 (input_bfd
, pnext
);
1296 /* The _ptrgl function is magic. It is used by the AIX
1297 * compiler to call a function through a pointer.
1299 * special case XMC_GL, global linkage
1301 if (h
->smclas
== XMC_GL
1302 || strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
1304 if (next
== 0x4def7b82 /* cror 15,15,15 */
1305 || next
== 0x4ffffb82 /* cror 31,31,31 */
1306 || next
== 0x60000000 /* ori r0,r0,0 */)
1307 bfd_put_32 (input_bfd
, (bfd_vma
) 0xe8410028 /* ld r2,40(r1) */,
1312 if (next
== 0xe8410028 /* ld r2,40(r1) */)
1313 bfd_put_32 (input_bfd
, (bfd_vma
) 0x60000000 /* ori r0,r0,0 */,
1318 /* A PC relative reloc includes the section address. */
1319 if (howto
.pc_relative
)
1320 addend
+= input_section
->vma
;
1322 rstat
= _bfd_final_link_relocate (&howto
, input_bfd
, input_section
,
1324 rel
->r_vaddr
- input_section
->vma
,
1333 case bfd_reloc_overflow
:
1336 char buf
[SYMNMLEN
+ 1];
1337 char howto_name
[10];
1342 name
= h
->root
.root
.string
;
1345 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
1349 sprintf (howto_name
, "0x%02x", rel
->r_type
);
1351 if (! ((*info
->callbacks
->reloc_overflow
)
1352 (info
, name
, howto_name
, (bfd_vma
) 0, input_bfd
,
1353 input_section
, rel
->r_vaddr
- input_section
->vma
)))
1364 /* The XCOFF reloc table. Actually, XCOFF relocations specify the
1365 bitsize and whether they are signed or not, along with a
1366 conventional type. This table is for the types, which are used for
1367 different algorithms for putting in the reloc. Many of these
1368 relocs need special_function entries, which I have not written. */
1371 reloc_howto_type xcoff64_howto_table
[] =
1373 /* Standard 64 bit relocation. */
1374 HOWTO (0, /* type */
1376 4, /* size (0 = byte, 1 = short, 2 = long) */
1378 false, /* pc_relative */
1380 complain_overflow_bitfield
, /* complain_on_overflow */
1381 0, /* special_function */
1383 true, /* partial_inplace */
1384 MINUS_ONE
, /* src_mask */
1385 MINUS_ONE
, /* dst_mask */
1386 false), /* pcrel_offset */
1388 /* 64 bit relocation, but store negative value. */
1389 HOWTO (1, /* type */
1391 -4, /* size (0 = byte, 1 = short, 2 = long) */
1393 false, /* pc_relative */
1395 complain_overflow_bitfield
, /* complain_on_overflow */
1396 0, /* special_function */
1398 true, /* partial_inplace */
1399 MINUS_ONE
, /* src_mask */
1400 MINUS_ONE
, /* dst_mask */
1401 false), /* pcrel_offset */
1403 /* 32 bit PC relative relocation. */
1404 HOWTO (2, /* type */
1406 2, /* size (0 = byte, 1 = short, 2 = long) */
1408 true, /* pc_relative */
1410 complain_overflow_signed
, /* complain_on_overflow */
1411 0, /* special_function */
1413 true, /* partial_inplace */
1414 0xffffffff, /* src_mask */
1415 0xffffffff, /* dst_mask */
1416 false), /* pcrel_offset */
1418 /* 16 bit TOC relative relocation. */
1419 HOWTO (3, /* type */
1421 1, /* size (0 = byte, 1 = short, 2 = long) */
1423 false, /* pc_relative */
1425 complain_overflow_bitfield
, /* complain_on_overflow */
1426 0, /* special_function */
1428 true, /* partial_inplace */
1429 0xffff, /* src_mask */
1430 0xffff, /* dst_mask */
1431 false), /* pcrel_offset */
1433 /* I don't really know what this is. */
1434 HOWTO (4, /* type */
1436 2, /* size (0 = byte, 1 = short, 2 = long) */
1438 false, /* pc_relative */
1440 complain_overflow_bitfield
, /* complain_on_overflow */
1441 0, /* special_function */
1443 true, /* partial_inplace */
1444 0xffffffff, /* src_mask */
1445 0xffffffff, /* dst_mask */
1446 false), /* pcrel_offset */
1448 /* External TOC relative symbol. */
1449 HOWTO (5, /* type */
1451 2, /* size (0 = byte, 1 = short, 2 = long) */
1453 false, /* pc_relative */
1455 complain_overflow_bitfield
, /* complain_on_overflow */
1456 0, /* special_function */
1458 true, /* partial_inplace */
1459 0xffff, /* src_mask */
1460 0xffff, /* dst_mask */
1461 false), /* pcrel_offset */
1463 /* Local TOC relative symbol. */
1464 HOWTO (6, /* type */
1466 2, /* size (0 = byte, 1 = short, 2 = long) */
1468 false, /* pc_relative */
1470 complain_overflow_bitfield
, /* complain_on_overflow */
1471 0, /* special_function */
1473 true, /* partial_inplace */
1474 0xffff, /* src_mask */
1475 0xffff, /* dst_mask */
1476 false), /* pcrel_offset */
1480 /* Non modifiable absolute branch. */
1481 HOWTO (8, /* type */
1483 2, /* size (0 = byte, 1 = short, 2 = long) */
1485 false, /* pc_relative */
1487 complain_overflow_bitfield
, /* complain_on_overflow */
1488 0, /* special_function */
1490 true, /* partial_inplace */
1491 0x3fffffc, /* src_mask */
1492 0x3fffffc, /* dst_mask */
1493 false), /* pcrel_offset */
1497 /* Non modifiable relative branch. */
1498 HOWTO (0xa, /* type */
1500 2, /* size (0 = byte, 1 = short, 2 = long) */
1502 true, /* pc_relative */
1504 complain_overflow_signed
, /* complain_on_overflow */
1505 0, /* special_function */
1507 true, /* partial_inplace */
1508 0x3fffffc, /* src_mask */
1509 0x3fffffc, /* dst_mask */
1510 false), /* pcrel_offset */
1514 /* Indirect load. */
1515 HOWTO (0xc, /* type */
1517 2, /* size (0 = byte, 1 = short, 2 = long) */
1519 false, /* pc_relative */
1521 complain_overflow_bitfield
, /* complain_on_overflow */
1522 0, /* special_function */
1524 true, /* partial_inplace */
1525 0xffff, /* src_mask */
1526 0xffff, /* dst_mask */
1527 false), /* pcrel_offset */
1530 HOWTO (0xd, /* type */
1532 2, /* size (0 = byte, 1 = short, 2 = long) */
1534 false, /* pc_relative */
1536 complain_overflow_bitfield
, /* complain_on_overflow */
1537 0, /* special_function */
1539 true, /* partial_inplace */
1540 0xffff, /* src_mask */
1541 0xffff, /* dst_mask */
1542 false), /* pcrel_offset */
1546 /* Non-relocating reference. */
1547 HOWTO (0xf, /* type */
1549 2, /* size (0 = byte, 1 = short, 2 = long) */
1551 false, /* pc_relative */
1553 complain_overflow_bitfield
, /* complain_on_overflow */
1554 0, /* special_function */
1556 false, /* partial_inplace */
1559 false), /* pcrel_offset */
1564 /* TOC relative indirect load. */
1565 HOWTO (0x12, /* type */
1567 2, /* size (0 = byte, 1 = short, 2 = long) */
1569 false, /* pc_relative */
1571 complain_overflow_bitfield
, /* complain_on_overflow */
1572 0, /* special_function */
1574 true, /* partial_inplace */
1575 0xffff, /* src_mask */
1576 0xffff, /* dst_mask */
1577 false), /* pcrel_offset */
1579 /* TOC relative load address. */
1580 HOWTO (0x13, /* type */
1582 2, /* size (0 = byte, 1 = short, 2 = long) */
1584 false, /* pc_relative */
1586 complain_overflow_bitfield
, /* complain_on_overflow */
1587 0, /* special_function */
1588 "R_TRLA", /* name */
1589 true, /* partial_inplace */
1590 0xffff, /* src_mask */
1591 0xffff, /* dst_mask */
1592 false), /* pcrel_offset */
1594 /* Modifiable relative branch. */
1595 HOWTO (0x14, /* type */
1597 2, /* size (0 = byte, 1 = short, 2 = long) */
1599 false, /* pc_relative */
1601 complain_overflow_bitfield
, /* complain_on_overflow */
1602 0, /* special_function */
1603 "R_RRTBI", /* name */
1604 true, /* partial_inplace */
1605 0xffffffff, /* src_mask */
1606 0xffffffff, /* dst_mask */
1607 false), /* pcrel_offset */
1609 /* Modifiable absolute branch. */
1610 HOWTO (0x15, /* type */
1612 2, /* size (0 = byte, 1 = short, 2 = long) */
1614 false, /* pc_relative */
1616 complain_overflow_bitfield
, /* complain_on_overflow */
1617 0, /* special_function */
1618 "R_RRTBA", /* name */
1619 true, /* partial_inplace */
1620 0xffffffff, /* src_mask */
1621 0xffffffff, /* dst_mask */
1622 false), /* pcrel_offset */
1624 /* Modifiable call absolute indirect. */
1625 HOWTO (0x16, /* type */
1627 2, /* size (0 = byte, 1 = short, 2 = long) */
1629 false, /* pc_relative */
1631 complain_overflow_bitfield
, /* complain_on_overflow */
1632 0, /* special_function */
1634 true, /* partial_inplace */
1635 0xffff, /* src_mask */
1636 0xffff, /* dst_mask */
1637 false), /* pcrel_offset */
1639 /* Modifiable call relative. */
1640 HOWTO (0x17, /* type */
1642 2, /* size (0 = byte, 1 = short, 2 = long) */
1644 false, /* pc_relative */
1646 complain_overflow_bitfield
, /* complain_on_overflow */
1647 0, /* special_function */
1648 "R_CREL", /* name */
1649 true, /* partial_inplace */
1650 0xffff, /* src_mask */
1651 0xffff, /* dst_mask */
1652 false), /* pcrel_offset */
1654 /* Modifiable branch absolute. */
1655 HOWTO (0x18, /* type */
1657 2, /* size (0 = byte, 1 = short, 2 = long) */
1659 false, /* pc_relative */
1661 complain_overflow_bitfield
, /* complain_on_overflow */
1662 0, /* special_function */
1664 true, /* partial_inplace */
1665 0xffff, /* src_mask */
1666 0xffff, /* dst_mask */
1667 false), /* pcrel_offset */
1669 /* Modifiable branch absolute. */
1670 HOWTO (0x19, /* type */
1672 2, /* size (0 = byte, 1 = short, 2 = long) */
1674 false, /* pc_relative */
1676 complain_overflow_bitfield
, /* complain_on_overflow */
1677 0, /* special_function */
1678 "R_RBAC", /* name */
1679 true, /* partial_inplace */
1680 0xffff, /* src_mask */
1681 0xffff, /* dst_mask */
1682 false), /* pcrel_offset */
1684 /* Modifiable branch relative. */
1685 HOWTO (0x1a, /* type */
1687 2, /* size (0 = byte, 1 = short, 2 = long) */
1689 false, /* pc_relative */
1691 complain_overflow_signed
, /* complain_on_overflow */
1692 0, /* special_function */
1694 true, /* partial_inplace */
1695 0xffff, /* src_mask */
1696 0xffff, /* dst_mask */
1697 false), /* pcrel_offset */
1699 /* Modifiable branch absolute. */
1700 HOWTO (0x1b, /* type */
1702 2, /* size (0 = byte, 1 = short, 2 = long) */
1704 false, /* pc_relative */
1706 complain_overflow_bitfield
, /* complain_on_overflow */
1707 0, /* special_function */
1708 "R_RBRC", /* name */
1709 true, /* partial_inplace */
1710 0xffff, /* src_mask */
1711 0xffff, /* dst_mask */
1712 false), /* pcrel_offset */
1714 HOWTO (0, /* type */
1716 4, /* size (0 = byte, 1 = short, 2 = long) */
1718 false, /* pc_relative */
1720 complain_overflow_bitfield
, /* complain_on_overflow */
1721 0, /* special_function */
1723 true, /* partial_inplace */
1724 MINUS_ONE
, /* src_mask */
1725 MINUS_ONE
, /* dst_mask */
1726 false) /* pcrel_offset */
1730 xcoff64_rtype2howto (relent
, internal
)
1732 struct internal_reloc
*internal
;
1734 relent
->howto
= xcoff64_howto_table
+ internal
->r_type
;
1736 /* Check for relocs we don't know of. */
1737 if (internal
->r_type
1738 >= sizeof (xcoff64_howto_table
) / sizeof (xcoff64_howto_table
[0]))
1740 if (internal
->r_type
!= relent
->howto
->type
)
1743 /* The r_size field of an XCOFF reloc encodes the bitsize of the
1744 relocation, as well as indicating whether it is signed or not.
1745 Doublecheck that the relocation information gathered from the
1746 type matches this information. The bitsize is not significant
1747 for R_REF relocs. */
1748 if (relent
->howto
->dst_mask
!= 0
1749 && (relent
->howto
->bitsize
1750 != ((unsigned int) internal
->r_size
& 0x3f) + 1))
1753 if ((internal
->r_size
& 0x80) != 0
1754 ? (relent
->howto
->complain_on_overflow
!= complain_overflow_signed
)
1755 : (relent
->howto
->complain_on_overflow
!= complain_overflow_bitfield
))
1761 xcoff64_reloc_type_lookup (abfd
, code
)
1762 bfd
*abfd ATTRIBUTE_UNUSED
;
1763 bfd_reloc_code_real_type code
;
1767 case BFD_RELOC_PPC_B26
:
1768 return &xcoff64_howto_table
[0xa];
1769 case BFD_RELOC_PPC_BA26
:
1770 return &xcoff64_howto_table
[8];
1771 case BFD_RELOC_PPC_TOC16
:
1772 return &xcoff64_howto_table
[3];
1774 case BFD_RELOC_CTOR
:
1775 return &xcoff64_howto_table
[0];
1777 return &xcoff64_howto_table
[0x1c];
1785 /* Read in the armap of an XCOFF archive. */
1788 xcoff64_slurp_armap (abfd
)
1793 bfd_size_type sz
, amt
;
1794 bfd_byte
*contents
, *cend
;
1800 /* This is for the new format. */
1801 struct xcoff_ar_hdr_big hdr
;
1803 if (xcoff_ardata (abfd
) == NULL
)
1805 bfd_has_map (abfd
) = false;
1809 off
= strtol (xcoff_ardata_big (abfd
)->symoff64
, (char **) NULL
, 10);
1812 bfd_has_map (abfd
) = false;
1816 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1819 /* The symbol table starts with a normal archive header. */
1820 if (bfd_bread ((PTR
) &hdr
, (bfd_size_type
) SIZEOF_AR_HDR_BIG
, abfd
)
1821 != SIZEOF_AR_HDR_BIG
)
1824 /* Skip the name (normally empty). */
1825 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1826 pos
= ((namlen
+ 1) & ~(size_t) 1) + SXCOFFARFMAG
;
1827 if (bfd_seek (abfd
, pos
, SEEK_CUR
) != 0)
1830 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1831 machines) since the field width is 20 and there numbers with more
1832 than 32 bits can be represented. */
1833 sz
= strtol (hdr
.size
, (char **) NULL
, 10);
1835 /* Read in the entire symbol table. */
1836 contents
= (bfd_byte
*) bfd_alloc (abfd
, sz
);
1837 if (contents
== NULL
)
1839 if (bfd_bread ((PTR
) contents
, sz
, abfd
) != sz
)
1842 /* The symbol table starts with an eight byte count. */
1843 c
= H_GET_64 (abfd
, contents
);
1847 bfd_set_error (bfd_error_bad_value
);
1851 amt
*= sizeof (carsym
);
1852 bfd_ardata (abfd
)->symdefs
= (carsym
*) bfd_alloc (abfd
, amt
);
1853 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1856 /* After the count comes a list of eight byte file offsets. */
1857 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1859 ++i
, ++arsym
, p
+= 8)
1860 arsym
->file_offset
= H_GET_64 (abfd
, p
);
1862 /* After the file offsets come null terminated symbol names. */
1863 cend
= contents
+ sz
;
1864 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1866 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1870 bfd_set_error (bfd_error_bad_value
);
1873 arsym
->name
= (char *) p
;
1876 bfd_ardata (abfd
)->symdef_count
= c
;
1877 bfd_has_map (abfd
) = true;
1883 /* See if this is an NEW XCOFF archive. */
1885 static const bfd_target
*
1886 xcoff64_archive_p (abfd
)
1889 char magic
[SXCOFFARMAG
];
1890 /* This is the new format. */
1891 struct xcoff_ar_file_hdr_big hdr
;
1892 bfd_size_type amt
= SXCOFFARMAG
;
1894 if (bfd_bread ((PTR
) magic
, amt
, abfd
) != amt
)
1896 if (bfd_get_error () != bfd_error_system_call
)
1897 bfd_set_error (bfd_error_wrong_format
);
1901 if (strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0)
1903 bfd_set_error (bfd_error_wrong_format
);
1907 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
1908 involves a cast, we can't do it as the left operand of
1910 amt
= sizeof (struct artdata
);
1911 abfd
->tdata
.aout_ar_data
= (struct artdata
*) bfd_zalloc (abfd
, amt
);
1913 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1916 bfd_ardata (abfd
)->cache
= NULL
;
1917 bfd_ardata (abfd
)->archive_head
= NULL
;
1918 bfd_ardata (abfd
)->symdefs
= NULL
;
1919 bfd_ardata (abfd
)->extended_names
= NULL
;
1921 /* Copy over the magic string. */
1922 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1924 /* Now read the rest of the file header. */
1925 if (bfd_bread ((PTR
) &hdr
.memoff
,
1926 (bfd_size_type
) (SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
),
1927 abfd
) != SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
)
1929 if (bfd_get_error () != bfd_error_system_call
)
1930 bfd_set_error (bfd_error_wrong_format
);
1934 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1935 machines) since the field width is 20 and there numbers with more
1936 than 32 bits can be represented. */
1937 bfd_ardata (abfd
)->first_file_filepos
= strtol (hdr
.firstmemoff
,
1938 (char **) NULL
, 10);
1940 amt
= SIZEOF_AR_FILE_HDR_BIG
;
1941 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, amt
);
1942 if (bfd_ardata (abfd
)->tdata
== NULL
)
1945 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1947 if (! xcoff64_slurp_armap (abfd
))
1949 bfd_release (abfd
, bfd_ardata (abfd
));
1950 abfd
->tdata
.aout_ar_data
= (struct artdata
*) NULL
;
1958 /* Open the next element in an XCOFF archive. */
1961 xcoff64_openr_next_archived_file (archive
, last_file
)
1967 if ((xcoff_ardata (archive
) == NULL
)
1968 || ! xcoff_big_format_p (archive
))
1970 bfd_set_error (bfd_error_invalid_operation
);
1974 if (last_file
== NULL
)
1976 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1980 /* XXX These actually have to be a calls to strtoll (at least
1981 on 32-bit machines) since the fields's width is 20 and
1982 there numbers with more than 32 bits can be represented. */
1983 filestart
= strtol (arch_xhdr_big (last_file
)->nextoff
, (char **) NULL
,
1986 /* XXX These actually have to be calls to strtoll (at least on 32-bit
1987 machines) since the fields's width is 20 and there numbers with more
1988 than 32 bits can be represented. */
1990 || filestart
== strtol (xcoff_ardata_big (archive
)->memoff
,
1992 || filestart
== strtol (xcoff_ardata_big (archive
)->symoff
,
1993 (char **) NULL
, 10))
1995 bfd_set_error (bfd_error_no_more_archived_files
);
1999 return _bfd_get_elt_at_filepos (archive
, filestart
);
2002 /* We can't use the usual coff_sizeof_headers routine, because AIX
2003 always uses an a.out header. */
2007 xcoff64_sizeof_headers (abfd
, reloc
)
2009 boolean reloc ATTRIBUTE_UNUSED
;
2013 size
= bfd_coff_filhsz (abfd
);
2015 /* Don't think the small aout header can be used since some of the
2016 old elements have been reordered past the end of the old coff
2019 if (xcoff_data (abfd
)->full_aouthdr
)
2020 size
+= bfd_coff_aoutsz (abfd
);
2022 size
+= abfd
->section_count
* bfd_coff_scnhsz (abfd
);
2029 xcoff64_create_csect_from_smclas (abfd
, aux
, symbol_name
)
2031 union internal_auxent
*aux
;
2032 const char *symbol_name
;
2034 asection
*return_value
= NULL
;
2036 /* Changes from 32 :
2037 .sv == 8, is only for 32 bit programs
2038 .ti == 12 and .tb == 13 are now reserved. */
2039 static const char *names
[19] =
2041 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
2042 NULL
, ".bs", ".ds", ".uc", NULL
, NULL
, NULL
, ".tc0",
2043 ".td", ".sv64", ".sv3264"
2046 if ((19 >= aux
->x_csect
.x_smclas
)
2047 && (NULL
!= names
[aux
->x_csect
.x_smclas
]))
2050 return_value
= bfd_make_section_anyway
2051 (abfd
, names
[aux
->x_csect
.x_smclas
]);
2056 (*_bfd_error_handler
)
2057 (_("%s: symbol `%s' has unrecognized smclas %d"),
2058 bfd_archive_filename (abfd
), symbol_name
, aux
->x_csect
.x_smclas
);
2059 bfd_set_error (bfd_error_bad_value
);
2062 return return_value
;
2066 xcoff64_is_lineno_count_overflow (abfd
, value
)
2067 bfd
*abfd ATTRIBUTE_UNUSED
;
2068 bfd_vma value ATTRIBUTE_UNUSED
;
2074 xcoff64_is_reloc_count_overflow (abfd
, value
)
2075 bfd
*abfd ATTRIBUTE_UNUSED
;
2076 bfd_vma value ATTRIBUTE_UNUSED
;
2082 xcoff64_loader_symbol_offset (abfd
, ldhdr
)
2083 bfd
*abfd ATTRIBUTE_UNUSED
;
2084 struct internal_ldhdr
*ldhdr
;
2086 return (ldhdr
->l_symoff
);
2090 xcoff64_loader_reloc_offset (abfd
, ldhdr
)
2091 bfd
*abfd ATTRIBUTE_UNUSED
;
2092 struct internal_ldhdr
*ldhdr
;
2094 return (ldhdr
->l_rldoff
);
2097 /* The typical dynamic reloc. */
2099 static reloc_howto_type xcoff64_dynamic_reloc
=
2100 HOWTO (0, /* type */
2102 4, /* size (0 = byte, 1 = short, 2 = long) */
2104 false, /* pc_relative */
2106 complain_overflow_bitfield
, /* complain_on_overflow */
2107 0, /* special_function */
2109 true, /* partial_inplace */
2110 MINUS_ONE
, /* src_mask */
2111 MINUS_ONE
, /* dst_mask */
2112 false); /* pcrel_offset */
2114 static unsigned long xcoff64_glink_code
[10] =
2116 0xe9820000, /* ld r12,0(r2) */
2117 0xf8410028, /* std r2,40(r1) */
2118 0xe80c0000, /* ld r0,0(r12) */
2119 0xe84c0008, /* ld r0,8(r12) */
2120 0x7c0903a6, /* mtctr r0 */
2121 0x4e800420, /* bctr */
2122 0x00000000, /* start of traceback table */
2123 0x000ca000, /* traceback table */
2124 0x00000000, /* traceback table */
2125 0x00000018, /* ??? */
2128 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
2130 { /* COFF backend, defined in libcoff.h */
2131 _bfd_xcoff64_swap_aux_in
, /* _bfd_coff_swap_aux_in */
2132 _bfd_xcoff64_swap_sym_in
, /* _bfd_coff_swap_sym_in */
2133 _bfd_xcoff64_swap_lineno_in
, /* _bfd_coff_swap_lineno_in */
2134 _bfd_xcoff64_swap_aux_out
, /* _bfd_swap_aux_out */
2135 _bfd_xcoff64_swap_sym_out
, /* _bfd_swap_sym_out */
2136 _bfd_xcoff64_swap_lineno_out
, /* _bfd_swap_lineno_out */
2137 coff_swap_reloc_out
, /* _bfd_swap_reloc_out */
2138 coff_swap_filehdr_out
, /* _bfd_swap_filehdr_out */
2139 coff_swap_aouthdr_out
, /* _bfd_swap_aouthdr_out */
2140 coff_swap_scnhdr_out
, /* _bfd_swap_scnhdr_out */
2141 FILHSZ
, /* _bfd_filhsz */
2142 AOUTSZ
, /* _bfd_aoutsz */
2143 SCNHSZ
, /* _bfd_scnhsz */
2144 SYMESZ
, /* _bfd_symesz */
2145 AUXESZ
, /* _bfd_auxesz */
2146 RELSZ
, /* _bfd_relsz */
2147 LINESZ
, /* _bfd_linesz */
2148 FILNMLEN
, /* _bfd_filnmlen */
2149 true, /* _bfd_coff_long_filenames */
2150 false, /* _bfd_coff_long_section_names */
2151 (3), /* _bfd_coff_default_section_alignment_power */
2152 true, /* _bfd_coff_force_symnames_in_strings */
2153 4, /* _bfd_coff_debug_string_prefix_length */
2154 coff_swap_filehdr_in
, /* _bfd_coff_swap_filehdr_in */
2155 coff_swap_aouthdr_in
, /* _bfd_swap_aouthdr_in */
2156 coff_swap_scnhdr_in
, /* _bfd_swap_scnhdr_in */
2157 coff_swap_reloc_in
, /* _bfd_reloc_in */
2158 coff_bad_format_hook
, /* _bfd_bad_format_hook */
2159 coff_set_arch_mach_hook
, /* _bfd_set_arch_mach_hook */
2160 coff_mkobject_hook
, /* _bfd_mkobject_hook */
2161 styp_to_sec_flags
, /* _bfd_syp_to_sec_flags */
2162 coff_set_alignment_hook
, /* _bfd_set_alignment_hook */
2163 coff_slurp_symbol_table
, /* _bfd_coff_slurp_symbol_table */
2164 symname_in_debug_hook
, /* _coff_symname_in_debug_hook */
2165 coff_pointerize_aux_hook
, /* _bfd_coff_pointerize_aux_hook */
2166 coff_print_aux
, /* bfd_coff_print_aux */
2167 dummy_reloc16_extra_cases
, /* _bfd_coff_reloc16_extra_cases */
2168 dummy_reloc16_estimate
, /* _bfd_coff_reloc16_estimate */
2169 NULL
, /* bfd_coff_sym_is_global */
2170 /* _bfd_coff_compute_section_file_positions */
2171 coff_compute_section_file_positions
,
2172 NULL
, /* _bfd_coff_start_final_link */
2173 xcoff64_ppc_relocate_section
, /* _bfd_coff_relocate_section */
2174 coff_rtype_to_howto
, /* _bfd_coff_rtype_to_howto */
2175 NULL
, /* _bfd_coff_addust_symndx */
2176 _bfd_generic_link_add_one_symbol
, /* _bfd_coff_add_one_symbol */
2177 coff_link_output_has_begun
, /* _bfd_coff_link_output_has_begun */
2178 coff_final_link_postscript
/* _bfd_coff_final_link_postscript */
2181 0x01EF, /* magic number */
2182 bfd_arch_powerpc
, /* architecture */
2183 bfd_mach_ppc_620
, /* machine */
2185 /* function pointers to xcoff specific swap routines */
2186 xcoff64_swap_ldhdr_in
, /* _xcoff_swap_ldhdr_in */
2187 xcoff64_swap_ldhdr_out
, /* _xcoff_swap_ldhdr_out */
2188 xcoff64_swap_ldsym_in
, /* _xcoff_swap_ldsym_in */
2189 xcoff64_swap_ldsym_out
, /* _xcoff_swap_ldsym_out */
2190 xcoff64_swap_ldrel_in
, /* _xcoff_swap_ldrel_in */
2191 xcoff64_swap_ldrel_out
, /* _xcoff_swap_ldrel_out */
2194 LDHDRSZ
, /* _xcoff_ldhdrsz */
2195 LDSYMSZ
, /* _xcoff_ldsymsz */
2196 LDRELSZ
, /* _xcoff_ldrelsz */
2197 24, /* _xcoff_function_descriptor_size */
2198 0, /* _xcoff_small_aout_header_size */
2200 2, /* _xcoff_ldhdr_version */
2202 /* xcoff vs xcoff64 putting symbol names */
2203 _bfd_xcoff64_put_symbol_name
, /* _xcoff_put_symbol_name */
2204 _bfd_xcoff64_put_ldsymbol_name
, /* _xcoff_put_ldsymbol_name */
2206 /* dynamic reloc howto */
2207 &xcoff64_dynamic_reloc
,
2209 xcoff64_create_csect_from_smclas
,
2211 /* lineno and reloc count overflow */
2212 xcoff64_is_lineno_count_overflow
,
2213 xcoff64_is_reloc_count_overflow
,
2215 xcoff64_loader_symbol_offset
,
2216 xcoff64_loader_reloc_offset
,
2219 &xcoff64_glink_code
[0],
2220 40, /* _xcoff_glink_size */
2224 /* The transfer vector that leads the outside world to all of the above. */
2225 const bfd_target rs6000coff64_vec
=
2228 bfd_target_xcoff_flavour
,
2229 BFD_ENDIAN_BIG
, /* data byte order is big */
2230 BFD_ENDIAN_BIG
, /* header byte order is big */
2232 (HAS_RELOC
| EXEC_P
| /* object flags */
2233 HAS_LINENO
| HAS_DEBUG
| DYNAMIC
|
2234 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
2236 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
2237 0, /* leading char */
2238 '/', /* ar_pad_char */
2239 15, /* ar_max_namelen??? FIXMEmgo */
2242 bfd_getb64
, /* bfd_getx64 */
2243 bfd_getb_signed_64
, /* bfd_getx_signed_64 */
2244 bfd_putb64
, /* bfd_putx64 */
2245 bfd_getb32
, /* bfd_getx32 */
2246 bfd_getb_signed_32
, /* bfd_getx_signed_32 */
2247 bfd_putb32
, /* bfd_putx32 */
2248 bfd_getb16
, /* bfd_getx16 */
2249 bfd_getb_signed_16
, /* bfd_getx_signed_16 */
2250 bfd_putb16
, /* bfd_putx16 */
2253 bfd_getb64
, /* bfd_h_getx64 */
2254 bfd_getb_signed_64
, /* bfd_h_getx_signed_64 */
2255 bfd_putb64
, /* bfd_h_putx64 */
2256 bfd_getb32
, /* bfd_h_getx32 */
2257 bfd_getb_signed_32
, /* bfd_h_getx_signed_32 */
2258 bfd_putb32
, /* bfd_h_putx32 */
2259 bfd_getb16
, /* bfd_h_getx16 */
2260 bfd_getb_signed_16
, /* bfd_h_getx_signed_16 */
2261 bfd_putb16
, /* bfd_h_putx16 */
2263 { /* bfd_check_format */
2270 { /* bfd_set_format */
2273 _bfd_generic_mkarchive
,
2277 {/* bfd_write_contents */
2279 xcoff64_write_object_contents
,
2280 _bfd_xcoff_write_archive_contents
,
2285 bfd_true
, /* _close_and_cleanup */
2286 bfd_true
, /* _bfd_free_cached_info */
2287 coff_new_section_hook
, /* _new_section_hook */
2288 _bfd_generic_get_section_contents
, /* _bfd_get_section_contents */
2289 /* _bfd_get_section_contents_in_window */
2290 _bfd_generic_get_section_contents_in_window
,
2293 _bfd_xcoff_copy_private_bfd_data
, /* _bfd_copy_private_bfd */
2294 /* _bfd_merge_private_bfd_data */
2295 ((boolean (*) (bfd
*, bfd
*)) bfd_true
),
2296 /* _bfd_copy_pivate_section_data */
2297 ((boolean (*) (bfd
*, asection
*, bfd
*, asection
*)) bfd_true
),
2298 /* _bfd_copy_private_symbol_data */
2299 ((boolean (*) (bfd
*, asymbol
*, bfd
*, asymbol
*)) bfd_true
),
2300 ((boolean (*) (bfd
*, flagword
)) bfd_true
), /* _bfd_set_private_flags */
2301 ((boolean (*) (bfd
*, void * )) bfd_true
), /* _bfd_print_private_bfd_data */
2304 coff_core_file_failing_command
, /* _core_file_failing_command */
2305 coff_core_file_failing_signal
, /* _core_file_failing_signal */
2306 /* _core_file_matches_executable_p */
2307 coff_core_file_matches_executable_p
,
2310 xcoff64_slurp_armap
, /* _slurp_armap */
2311 /* XCOFF archives do not have
2312 anything which corresponds to
2313 an extended name table. */
2314 bfd_false
, /* _slurp_extended_name_table */
2315 /* _construct_extended_name_table */
2316 ((boolean (*) (bfd
*, char **, bfd_size_type
*, const char **)) bfd_false
),
2317 bfd_dont_truncate_arname
, /* _truncate_arname */
2318 _bfd_xcoff_write_armap
, /* _write_armap */
2319 _bfd_xcoff_read_ar_hdr
, /* _read_ar_hdr */
2320 xcoff64_openr_next_archived_file
, /* _openr_next_archived_file */
2321 _bfd_generic_get_elt_at_index
, /* _get_elt_at_index */
2322 _bfd_xcoff_generic_stat_arch_elt
, /* _generic_dtat_arch_elt */
2323 /* XCOFF archives do not have
2325 bfd_true
, /* _update_armap_timestamp */
2328 coff_get_symtab_upper_bound
, /* _get_symtab_upper_bound */
2329 coff_get_symtab
, /* _get_symtab */
2330 coff_make_empty_symbol
, /* _make_empty_symbol */
2331 coff_print_symbol
, /* _print_symbol */
2332 coff_get_symbol_info
, /* _get_symbol_info */
2333 _bfd_xcoff_is_local_label_name
, /* _bfd_is_local_label_name */
2334 coff_get_lineno
, /* _get_lineno */
2335 coff_find_nearest_line
, /* _find_nearest_line */
2336 coff_bfd_make_debug_symbol
, /* _bfd_make_debug_symbol */
2337 _bfd_generic_read_minisymbols
, /* _read_minisymbols */
2338 _bfd_generic_minisymbol_to_symbol
, /* _minsymbol_to_symbol */
2341 coff_get_reloc_upper_bound
, /* _get_reloc_upper_bound */
2342 coff_canonicalize_reloc
, /* _cononicalize_reloc */
2343 xcoff64_reloc_type_lookup
, /* _bfd_reloc_type_lookup */
2346 coff_set_arch_mach
, /* _set_arch_mach */
2347 coff_set_section_contents
, /* _set_section_contents */
2350 xcoff64_sizeof_headers
, /* _sizeof_headers */
2351 /* _bfd_get_relocated_section_contents */
2352 bfd_generic_get_relocated_section_contents
,
2353 bfd_generic_relax_section
, /* _bfd_relax_section */
2354 _bfd_xcoff_bfd_link_hash_table_create
, /* _bfd_link_hash_table_create */
2355 _bfd_xcoff_bfd_link_add_symbols
, /* _bfd_link_add_symbols */
2356 _bfd_xcoff_bfd_final_link
, /* _bfd_filnal_link */
2357 _bfd_generic_link_split_section
, /* _bfd_link_split_section */
2358 bfd_generic_gc_sections
, /* _bfd_gc_sections */
2359 bfd_generic_merge_sections
, /* _bfd_merge_sections */
2362 /* _get_dynamic_symtab_upper_bound */
2363 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
2364 _bfd_xcoff_canonicalize_dynamic_symtab
, /* _cononicalize_dynamic_symtab */
2365 _bfd_xcoff_get_dynamic_reloc_upper_bound
,/* _get_dynamic_reloc_upper_bound */
2366 _bfd_xcoff_canonicalize_dynamic_reloc
, /* _cononicalize_dynamic_reloc */
2368 /* Opposite endian version, none exists */
2372 (void *) &bfd_xcoff_backend_data
,