1 /* BFD back-end for IBM RS/6000 "XCOFF64" files.
2 Copyright (C) 2000-2022 Free Software Foundation, Inc.
3 Written Clinton Popetz.
4 Contributed by Cygnus Support.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, 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
86 (bfd
*, void *, void *);
87 static unsigned int _bfd_xcoff64_swap_lineno_out
88 (bfd
*, void *, void *);
89 static bool _bfd_xcoff64_put_symbol_name
90 (struct bfd_link_info
*, struct bfd_strtab_hash
*,
91 struct internal_syment
*, const char *);
92 static bool _bfd_xcoff64_put_ldsymbol_name
93 (bfd
*, struct xcoff_loader_info
*, struct internal_ldsym
*, const char *);
94 static void _bfd_xcoff64_swap_sym_in
95 (bfd
*, void *, void *);
96 static unsigned int _bfd_xcoff64_swap_sym_out
97 (bfd
*, void *, void *);
98 static void _bfd_xcoff64_swap_aux_in
99 (bfd
*, void *, int, int, int, int, void *);
100 static unsigned int _bfd_xcoff64_swap_aux_out
101 (bfd
*, void *, int, int, int, int, void *);
102 static void xcoff64_swap_reloc_in
103 (bfd
*, void *, void *);
104 static unsigned int xcoff64_swap_reloc_out
105 (bfd
*, void *, void *);
106 extern bool _bfd_xcoff_mkobject
108 extern bool _bfd_xcoff_copy_private_bfd_data
110 extern bool _bfd_xcoff_is_local_label_name
111 (bfd
*, const char *);
112 extern void xcoff64_rtype2howto
113 (arelent
*, struct internal_reloc
*);
114 extern reloc_howto_type
* xcoff64_reloc_type_lookup
115 (bfd
*, bfd_reloc_code_real_type
);
116 extern bool _bfd_xcoff_slurp_armap
118 extern void *_bfd_xcoff_read_ar_hdr
120 extern bfd
*_bfd_xcoff_openr_next_archived_file
122 extern int _bfd_xcoff_stat_arch_elt
123 (bfd
*, struct stat
*);
124 extern bool _bfd_xcoff_write_armap
125 (bfd
*, unsigned int, struct orl
*, unsigned int, int);
126 extern bool _bfd_xcoff_write_archive_contents
128 extern int _bfd_xcoff_sizeof_headers
129 (bfd
*, struct bfd_link_info
*);
130 extern void _bfd_xcoff_swap_sym_in
131 (bfd
*, void *, void *);
132 extern unsigned int _bfd_xcoff_swap_sym_out
133 (bfd
*, void *, void *);
134 extern void _bfd_xcoff_swap_aux_in
135 (bfd
*, void *, int, int, int, int, void *);
136 extern unsigned int _bfd_xcoff_swap_aux_out
137 (bfd
*, void *, int, int, int, int, void *);
138 static void xcoff64_swap_ldhdr_in
139 (bfd
*, const void *, struct internal_ldhdr
*);
140 static void xcoff64_swap_ldhdr_out
141 (bfd
*, const struct internal_ldhdr
*, void *d
);
142 static void xcoff64_swap_ldsym_in
143 (bfd
*, const void *, struct internal_ldsym
*);
144 static void xcoff64_swap_ldsym_out
145 (bfd
*, const struct internal_ldsym
*, void *d
);
146 static void xcoff64_swap_ldrel_in
147 (bfd
*, const void *, struct internal_ldrel
*);
148 static void xcoff64_swap_ldrel_out
149 (bfd
*, const struct internal_ldrel
*, void *d
);
150 static bool xcoff64_ppc_relocate_section
151 (bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
152 struct internal_reloc
*, struct internal_syment
*,
154 static bool xcoff64_slurp_armap
156 static bfd_cleanup xcoff64_archive_p
158 static bfd
*xcoff64_openr_next_archived_file
160 static int xcoff64_sizeof_headers
161 (bfd
*, struct bfd_link_info
*);
162 static asection
*xcoff64_create_csect_from_smclas
163 (bfd
*, union internal_auxent
*, const char *);
164 static bool xcoff64_is_lineno_count_overflow
166 static bool xcoff64_is_reloc_count_overflow
168 static bfd_vma xcoff64_loader_symbol_offset
169 (bfd
*, struct internal_ldhdr
*);
170 static bfd_vma xcoff64_loader_reloc_offset
171 (bfd
*, struct internal_ldhdr
*);
172 static bool xcoff64_generate_rtinit
173 (bfd
*, const char *, const char *, bool);
174 static bool xcoff64_bad_format_hook
177 /* Relocation functions */
178 static xcoff_reloc_function xcoff64_reloc_type_br
;
180 xcoff_reloc_function
*const
181 xcoff64_calculate_relocation
[XCOFF_MAX_CALCULATE_RELOCATION
] =
183 xcoff_reloc_type_pos
, /* R_POS (0x00) */
184 xcoff_reloc_type_neg
, /* R_NEG (0x01) */
185 xcoff_reloc_type_rel
, /* R_REL (0x02) */
186 xcoff_reloc_type_toc
, /* R_TOC (0x03) */
187 xcoff_reloc_type_toc
, /* R_TRL (0x04) */
188 xcoff_reloc_type_toc
, /* R_GL (0x05) */
189 xcoff_reloc_type_toc
, /* R_TCL (0x06) */
190 xcoff_reloc_type_fail
, /* (0x07) */
191 xcoff_reloc_type_ba
, /* R_BA (0x08) */
192 xcoff_reloc_type_fail
, /* (0x09) */
193 xcoff64_reloc_type_br
, /* R_BR (0x0a) */
194 xcoff_reloc_type_fail
, /* (0x0b) */
195 xcoff_reloc_type_pos
, /* R_RL (0x0c) */
196 xcoff_reloc_type_pos
, /* R_RLA (0x0d) */
197 xcoff_reloc_type_fail
, /* (0x0e) */
198 xcoff_reloc_type_noop
, /* R_REF (0x0f) */
199 xcoff_reloc_type_fail
, /* (0x10) */
200 xcoff_reloc_type_fail
, /* (0x11) */
201 xcoff_reloc_type_fail
, /* (0x12) */
202 xcoff_reloc_type_toc
, /* R_TRLA (0x13) */
203 xcoff_reloc_type_fail
, /* R_RRTBI (0x14) */
204 xcoff_reloc_type_fail
, /* R_RRTBA (0x15) */
205 xcoff_reloc_type_ba
, /* R_CAI (0x16) */
206 xcoff_reloc_type_crel
, /* R_CREL (0x17) */
207 xcoff_reloc_type_ba
, /* R_RBA (0x18) */
208 xcoff_reloc_type_ba
, /* R_RBAC (0x19) */
209 xcoff64_reloc_type_br
, /* R_RBR (0x1a) */
210 xcoff_reloc_type_ba
, /* R_RBRC (0x1b) */
211 xcoff_reloc_type_fail
, /* (0x1c) */
212 xcoff_reloc_type_fail
, /* (0x1d) */
213 xcoff_reloc_type_fail
, /* (0x1e) */
214 xcoff_reloc_type_fail
, /* (0x1f) */
215 xcoff_reloc_type_tls
, /* R_TLS (0x20) */
216 xcoff_reloc_type_tls
, /* R_TLS_IE (0x21) */
217 xcoff_reloc_type_tls
, /* R_TLS_LD (0x22) */
218 xcoff_reloc_type_tls
, /* R_TLS_LE (0x23) */
219 xcoff_reloc_type_tls
, /* R_TLSM (0x24) */
220 xcoff_reloc_type_tls
, /* R_TLSML (0x25) */
221 xcoff_reloc_type_fail
, /* (0x26) */
222 xcoff_reloc_type_fail
, /* (0x27) */
223 xcoff_reloc_type_fail
, /* (0x28) */
224 xcoff_reloc_type_fail
, /* (0x29) */
225 xcoff_reloc_type_fail
, /* (0x2a) */
226 xcoff_reloc_type_fail
, /* (0x2b) */
227 xcoff_reloc_type_fail
, /* (0x2c) */
228 xcoff_reloc_type_fail
, /* (0x2d) */
229 xcoff_reloc_type_fail
, /* (0x2e) */
230 xcoff_reloc_type_fail
, /* (0x2f) */
231 xcoff_reloc_type_toc
, /* R_TOCU (0x30) */
232 xcoff_reloc_type_toc
, /* R_TOCL (0x31) */
235 /* coffcode.h needs these to be defined. */
236 /* Internalcoff.h and coffcode.h modify themselves based on these flags. */
238 #define RS6000COFF_C 1
240 #define SELECT_RELOC(internal, howto) \
242 internal.r_type = howto->type; \
244 ((howto->complain_on_overflow == complain_overflow_signed \
247 | (howto->bitsize - 1)); \
250 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
251 #define COFF_LONG_FILENAMES
252 #define NO_COFF_SYMBOLS
253 #define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst)
254 #define coff_mkobject _bfd_xcoff_mkobject
255 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
256 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
257 #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
258 #define coff_bfd_reloc_name_lookup xcoff64_reloc_name_lookup
260 extern bfd_cleanup rs6000coff_core_p
262 extern bool rs6000coff_core_file_matches_executable_p
263 (bfd
*cbfd
, bfd
*ebfd
);
264 extern char *rs6000coff_core_file_failing_command
266 extern int rs6000coff_core_file_failing_signal
268 #define CORE_FILE_P rs6000coff_core_p
269 #define coff_core_file_failing_command \
270 rs6000coff_core_file_failing_command
271 #define coff_core_file_failing_signal \
272 rs6000coff_core_file_failing_signal
273 #define coff_core_file_matches_executable_p \
274 rs6000coff_core_file_matches_executable_p
275 #define coff_core_file_pid \
276 _bfd_nocore_core_file_pid
278 #define CORE_FILE_P _bfd_dummy_target
279 #define coff_core_file_failing_command \
280 _bfd_nocore_core_file_failing_command
281 #define coff_core_file_failing_signal \
282 _bfd_nocore_core_file_failing_signal
283 #define coff_core_file_matches_executable_p \
284 _bfd_nocore_core_file_matches_executable_p
285 #define coff_core_file_pid \
286 _bfd_nocore_core_file_pid
288 #define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
289 #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
290 #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
291 #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
292 #define coff_swap_reloc_in xcoff64_swap_reloc_in
293 #define coff_swap_reloc_out xcoff64_swap_reloc_out
294 #define NO_COFF_RELOCS
296 #ifndef bfd_pe_print_pdata
297 #define bfd_pe_print_pdata NULL
300 #include "coffcode.h"
302 /* For XCOFF64, the effective width of symndx changes depending on
303 whether we are the first entry. Sigh. */
305 _bfd_xcoff64_swap_lineno_in (bfd
*abfd
, void *ext1
, void *in1
)
307 LINENO
*ext
= (LINENO
*) ext1
;
308 struct internal_lineno
*in
= (struct internal_lineno
*) in1
;
310 in
->l_lnno
= H_GET_32 (abfd
, (ext
->l_lnno
));
312 in
->l_addr
.l_symndx
= H_GET_32 (abfd
, ext
->l_addr
.l_symndx
);
314 in
->l_addr
.l_paddr
= H_GET_64 (abfd
, ext
->l_addr
.l_paddr
);
318 _bfd_xcoff64_swap_lineno_out (bfd
*abfd
, void *inp
, void *outp
)
320 struct internal_lineno
*in
= (struct internal_lineno
*) inp
;
321 struct external_lineno
*ext
= (struct external_lineno
*) outp
;
323 H_PUT_32 (abfd
, in
->l_addr
.l_symndx
, ext
->l_addr
.l_symndx
);
324 H_PUT_32 (abfd
, in
->l_lnno
, (ext
->l_lnno
));
327 H_PUT_32 (abfd
, in
->l_addr
.l_symndx
, ext
->l_addr
.l_symndx
);
329 H_PUT_64 (abfd
, in
->l_addr
.l_paddr
, ext
->l_addr
.l_paddr
);
331 return bfd_coff_linesz (abfd
);
335 _bfd_xcoff64_swap_sym_in (bfd
*abfd
, void *ext1
, void *in1
)
337 struct external_syment
*ext
= (struct external_syment
*) ext1
;
338 struct internal_syment
*in
= (struct internal_syment
*) in1
;
340 in
->_n
._n_n
._n_zeroes
= 0;
341 in
->_n
._n_n
._n_offset
= H_GET_32 (abfd
, ext
->e_offset
);
342 in
->n_value
= H_GET_64 (abfd
, ext
->e_value
);
343 in
->n_scnum
= (short) H_GET_16 (abfd
, ext
->e_scnum
);
344 in
->n_type
= H_GET_16 (abfd
, ext
->e_type
);
345 in
->n_sclass
= H_GET_8 (abfd
, ext
->e_sclass
);
346 in
->n_numaux
= H_GET_8 (abfd
, ext
->e_numaux
);
350 _bfd_xcoff64_swap_sym_out (bfd
*abfd
, void *inp
, void *extp
)
352 struct internal_syment
*in
= (struct internal_syment
*) inp
;
353 struct external_syment
*ext
= (struct external_syment
*) extp
;
355 H_PUT_32 (abfd
, in
->_n
._n_n
._n_offset
, ext
->e_offset
);
356 H_PUT_64 (abfd
, in
->n_value
, ext
->e_value
);
357 H_PUT_16 (abfd
, in
->n_scnum
, ext
->e_scnum
);
358 H_PUT_16 (abfd
, in
->n_type
, ext
->e_type
);
359 H_PUT_8 (abfd
, in
->n_sclass
, ext
->e_sclass
);
360 H_PUT_8 (abfd
, in
->n_numaux
, ext
->e_numaux
);
361 return bfd_coff_symesz (abfd
);
365 _bfd_xcoff64_swap_aux_in (bfd
*abfd
, void *ext1
, int type ATTRIBUTE_UNUSED
,
366 int in_class
, int indx
, int numaux
, void *in1
)
368 union external_auxent
*ext
= (union external_auxent
*) ext1
;
369 union internal_auxent
*in
= (union internal_auxent
*) in1
;
370 unsigned char auxtype
;
376 /* xgettext: c-format */
377 (_("%pB: unsupported swap_aux_in for storage class %#x"),
378 abfd
, (unsigned int) in_class
);
379 bfd_set_error (bfd_error_bad_value
);
383 auxtype
= H_GET_8 (abfd
, ext
->x_file
.x_auxtype
);
384 if (auxtype
!= _AUX_FILE
)
387 if (ext
->x_file
.x_n
.x_n
.x_zeroes
[0] == 0)
389 in
->x_file
.x_n
.x_n
.x_zeroes
= 0;
390 in
->x_file
.x_n
.x_n
.x_offset
=
391 H_GET_32 (abfd
, ext
->x_file
.x_n
.x_n
.x_offset
);
394 memcpy (in
->x_file
.x_n
.x_fname
, ext
->x_file
.x_n
.x_fname
, FILNMLEN
);
395 in
->x_file
.x_ftype
= H_GET_8 (abfd
, ext
->x_file
.x_ftype
);
398 /* RS/6000 "csect" auxents.
399 There is always a CSECT auxiliary entry. But functions can
400 have FCN and EXCEPT ones too. In this case, CSECT is always the last
402 For now, we only support FCN types. */
406 if (indx
+ 1 == numaux
)
408 /* C_EXT can have several aux enties. But the _AUX_CSECT is always
410 auxtype
= H_GET_8 (abfd
, ext
->x_csect
.x_auxtype
);
411 if (auxtype
!= _AUX_CSECT
)
414 bfd_vma h
= H_GET_S32 (abfd
, ext
->x_csect
.x_scnlen_hi
);
415 bfd_vma l
= H_GET_32 (abfd
, ext
->x_csect
.x_scnlen_lo
);
417 in
->x_csect
.x_scnlen
.l
= h
<< 32 | (l
& 0xffffffff);
419 in
->x_csect
.x_parmhash
= H_GET_32 (abfd
, ext
->x_csect
.x_parmhash
);
420 in
->x_csect
.x_snhash
= H_GET_16 (abfd
, ext
->x_csect
.x_snhash
);
421 /* We don't have to hack bitfields in x_smtyp because it's
422 defined by shifts-and-ands, which are equivalent on all
424 in
->x_csect
.x_smtyp
= H_GET_8 (abfd
, ext
->x_csect
.x_smtyp
);
425 in
->x_csect
.x_smclas
= H_GET_8 (abfd
, ext
->x_csect
.x_smclas
);
429 /* It can also be a _AUX_EXCEPT entry. But it's not supported
431 auxtype
= H_GET_8 (abfd
, ext
->x_fcn
.x_auxtype
);
432 if (auxtype
!= _AUX_FCN
)
435 in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
436 = H_GET_64 (abfd
, ext
->x_fcn
.x_lnnoptr
);
437 in
->x_sym
.x_misc
.x_fsize
438 = H_GET_32 (abfd
, ext
->x_fcn
.x_fsize
);
439 in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
440 = H_GET_32 (abfd
, ext
->x_fcn
.x_endndx
);
446 /* xgettext: c-format */
447 (_("%pB: C_STAT isn't supported by XCOFF64"),
449 bfd_set_error (bfd_error_bad_value
);
454 auxtype
= H_GET_8 (abfd
, ext
->x_sym
.x_auxtype
);
455 if (auxtype
!= _AUX_SYM
)
458 in
->x_sym
.x_misc
.x_lnsz
.x_lnno
459 = H_GET_32 (abfd
, ext
->x_sym
.x_lnno
);
463 auxtype
= H_GET_8 (abfd
, ext
->x_sect
.x_auxtype
);
464 if (auxtype
!= _AUX_SECT
)
467 in
->x_sect
.x_scnlen
= H_GET_64 (abfd
, ext
->x_sect
.x_scnlen
);
468 in
->x_sect
.x_nreloc
= H_GET_64 (abfd
, ext
->x_sect
.x_nreloc
);
476 /* xgettext: c-format */
477 (_("%pB: wrong auxtype %#x for storage class %#x"),
478 abfd
, auxtype
, (unsigned int) in_class
);
479 bfd_set_error (bfd_error_bad_value
);
485 _bfd_xcoff64_swap_aux_out (bfd
*abfd
, void *inp
, int type ATTRIBUTE_UNUSED
,
486 int in_class
, int indx
, int numaux
, void *extp
)
488 union internal_auxent
*in
= (union internal_auxent
*) inp
;
489 union external_auxent
*ext
= (union external_auxent
*) extp
;
491 memset (ext
, 0, bfd_coff_auxesz (abfd
));
496 /* xgettext: c-format */
497 (_("%pB: unsupported swap_aux_out for storage class %#x"),
498 abfd
, (unsigned int) in_class
);
499 bfd_set_error (bfd_error_bad_value
);
503 if (in
->x_file
.x_n
.x_n
.x_zeroes
== 0)
505 H_PUT_32 (abfd
, 0, ext
->x_file
.x_n
.x_n
.x_zeroes
);
506 H_PUT_32 (abfd
, in
->x_file
.x_n
.x_n
.x_offset
,
507 ext
->x_file
.x_n
.x_n
.x_offset
);
510 memcpy (ext
->x_file
.x_n
.x_fname
, in
->x_file
.x_n
.x_fname
, FILNMLEN
);
511 H_PUT_8 (abfd
, in
->x_file
.x_ftype
, ext
->x_file
.x_ftype
);
512 H_PUT_8 (abfd
, _AUX_FILE
, ext
->x_file
.x_auxtype
);
515 /* RS/6000 "csect" auxents.
516 There is always a CSECT auxiliary entry. But functions can
517 have FCN and EXCEPT ones too. In this case, CSECT is always the last
519 For now, we only support FCN types. */
523 if (indx
+ 1 == numaux
)
527 temp
= in
->x_csect
.x_scnlen
.l
& 0xffffffff;
528 H_PUT_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_lo
);
529 temp
= in
->x_csect
.x_scnlen
.l
>> 32;
530 H_PUT_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_hi
);
531 H_PUT_32 (abfd
, in
->x_csect
.x_parmhash
, ext
->x_csect
.x_parmhash
);
532 H_PUT_16 (abfd
, in
->x_csect
.x_snhash
, ext
->x_csect
.x_snhash
);
533 /* We don't have to hack bitfields in x_smtyp because it's
534 defined by shifts-and-ands, which are equivalent on all
536 H_PUT_8 (abfd
, in
->x_csect
.x_smtyp
, ext
->x_csect
.x_smtyp
);
537 H_PUT_8 (abfd
, in
->x_csect
.x_smclas
, ext
->x_csect
.x_smclas
);
538 H_PUT_8 (abfd
, _AUX_CSECT
, ext
->x_csect
.x_auxtype
);
542 H_PUT_64 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
,
543 ext
->x_fcn
.x_lnnoptr
);
544 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_fsize
, ext
->x_fcn
.x_fsize
);
545 H_PUT_32 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
,
546 ext
->x_fcn
.x_endndx
);
547 H_PUT_8 (abfd
, _AUX_FCN
, ext
->x_csect
.x_auxtype
);
553 /* xgettext: c-format */
554 (_("%pB: C_STAT isn't supported by XCOFF64"),
556 bfd_set_error (bfd_error_bad_value
);
561 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_lnno
, ext
->x_sym
.x_lnno
);
562 H_PUT_8 (abfd
, _AUX_SYM
, ext
->x_sym
.x_auxtype
);
566 H_PUT_64 (abfd
, in
->x_sect
.x_scnlen
, ext
->x_sect
.x_scnlen
);
567 H_PUT_64 (abfd
, in
->x_sect
.x_nreloc
, ext
->x_sect
.x_nreloc
);
568 H_PUT_8 (abfd
, _AUX_SECT
, ext
->x_sect
.x_auxtype
);
572 return bfd_coff_auxesz (abfd
);
576 _bfd_xcoff64_put_symbol_name (struct bfd_link_info
*info
,
577 struct bfd_strtab_hash
*strtab
,
578 struct internal_syment
*sym
,
584 hash
= !info
->traditional_format
;
585 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
587 if (indx
== (bfd_size_type
) -1)
590 sym
->_n
._n_n
._n_zeroes
= 0;
591 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
597 _bfd_xcoff64_put_ldsymbol_name (bfd
*abfd ATTRIBUTE_UNUSED
,
598 struct xcoff_loader_info
*ldinfo
,
599 struct internal_ldsym
*ldsym
,
605 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
)
607 bfd_size_type newalc
;
610 newalc
= ldinfo
->string_alc
* 2;
613 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
616 newstrings
= bfd_realloc (ldinfo
->strings
, newalc
);
617 if (newstrings
== NULL
)
619 ldinfo
->failed
= true;
622 ldinfo
->string_alc
= newalc
;
623 ldinfo
->strings
= newstrings
;
626 bfd_put_16 (ldinfo
->output_bfd
, (bfd_vma
) (len
+ 1),
627 ldinfo
->strings
+ ldinfo
->string_size
);
628 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
629 ldsym
->_l
._l_l
._l_zeroes
= 0;
630 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
631 ldinfo
->string_size
+= len
+ 3;
636 /* Routines to swap information in the XCOFF .loader section. If we
637 ever need to write an XCOFF loader, this stuff will need to be
638 moved to another file shared by the linker (which XCOFF calls the
639 ``binder'') and the loader. */
641 /* Swap in the ldhdr structure. */
644 xcoff64_swap_ldhdr_in (bfd
*abfd
,
646 struct internal_ldhdr
*dst
)
648 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
650 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
651 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
652 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
653 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
654 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
655 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
656 dst
->l_impoff
= bfd_get_64 (abfd
, src
->l_impoff
);
657 dst
->l_stoff
= bfd_get_64 (abfd
, src
->l_stoff
);
658 dst
->l_symoff
= bfd_get_64 (abfd
, src
->l_symoff
);
659 dst
->l_rldoff
= bfd_get_64 (abfd
, src
->l_rldoff
);
662 /* Swap out the ldhdr structure. */
665 xcoff64_swap_ldhdr_out (bfd
*abfd
, const struct internal_ldhdr
*src
, void *d
)
667 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
669 bfd_put_32 (abfd
, (bfd_vma
) src
->l_version
, dst
->l_version
);
670 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
671 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
672 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
673 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
674 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
675 bfd_put_64 (abfd
, src
->l_impoff
, dst
->l_impoff
);
676 bfd_put_64 (abfd
, src
->l_stoff
, dst
->l_stoff
);
677 bfd_put_64 (abfd
, src
->l_symoff
, dst
->l_symoff
);
678 bfd_put_64 (abfd
, src
->l_rldoff
, dst
->l_rldoff
);
681 /* Swap in the ldsym structure. */
684 xcoff64_swap_ldsym_in (bfd
*abfd
, const void *s
, struct internal_ldsym
*dst
)
686 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
687 /* XCOFF64 does not use l_zeroes like XCOFF32
688 Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
689 as an offset into the loader symbol table. */
690 dst
->_l
._l_l
._l_zeroes
= 0;
691 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->l_offset
);
692 dst
->l_value
= bfd_get_64 (abfd
, src
->l_value
);
693 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
694 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
695 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
696 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
697 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
700 /* Swap out the ldsym structure. */
703 xcoff64_swap_ldsym_out (bfd
*abfd
, const struct internal_ldsym
*src
, void *d
)
705 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
707 bfd_put_64 (abfd
, src
->l_value
, dst
->l_value
);
708 bfd_put_32 (abfd
, (bfd_vma
) src
->_l
._l_l
._l_offset
, dst
->l_offset
);
709 bfd_put_16 (abfd
, (bfd_vma
) src
->l_scnum
, dst
->l_scnum
);
710 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
711 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
712 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
713 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
717 xcoff64_swap_reloc_in (bfd
*abfd
, void *s
, void *d
)
719 struct external_reloc
*src
= (struct external_reloc
*) s
;
720 struct internal_reloc
*dst
= (struct internal_reloc
*) d
;
722 memset (dst
, 0, sizeof (struct internal_reloc
));
724 dst
->r_vaddr
= bfd_get_64 (abfd
, src
->r_vaddr
);
725 dst
->r_symndx
= bfd_get_32 (abfd
, src
->r_symndx
);
726 dst
->r_size
= bfd_get_8 (abfd
, src
->r_size
);
727 dst
->r_type
= bfd_get_8 (abfd
, src
->r_type
);
731 xcoff64_swap_reloc_out (bfd
*abfd
, void *s
, void *d
)
733 struct internal_reloc
*src
= (struct internal_reloc
*) s
;
734 struct external_reloc
*dst
= (struct external_reloc
*) d
;
736 bfd_put_64 (abfd
, src
->r_vaddr
, dst
->r_vaddr
);
737 bfd_put_32 (abfd
, src
->r_symndx
, dst
->r_symndx
);
738 bfd_put_8 (abfd
, src
->r_type
, dst
->r_type
);
739 bfd_put_8 (abfd
, src
->r_size
, dst
->r_size
);
741 return bfd_coff_relsz (abfd
);
744 /* Swap in the ldrel structure. */
747 xcoff64_swap_ldrel_in (bfd
*abfd
, const void *s
, struct internal_ldrel
*dst
)
749 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
751 dst
->l_vaddr
= bfd_get_64 (abfd
, src
->l_vaddr
);
752 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
753 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
754 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
757 /* Swap out the ldrel structure. */
760 xcoff64_swap_ldrel_out (bfd
*abfd
, const struct internal_ldrel
*src
, void *d
)
762 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
764 bfd_put_64 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
765 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rtype
, dst
->l_rtype
);
766 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rsecnm
, dst
->l_rsecnm
);
767 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
772 xcoff64_reloc_type_br (bfd
*input_bfd
,
773 asection
*input_section
,
774 bfd
*output_bfd ATTRIBUTE_UNUSED
,
775 struct internal_reloc
*rel
,
776 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
777 struct reloc_howto_struct
*howto
,
783 struct xcoff_link_hash_entry
*h
;
784 bfd_vma section_offset
;
786 if (0 > rel
->r_symndx
)
789 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
790 section_offset
= rel
->r_vaddr
- input_section
->vma
;
792 /* If we see an R_BR or R_RBR reloc which is jumping to global
793 linkage code, and it is followed by an appropriate cror nop
794 instruction, we replace the cror with ld r2,40(r1). This
795 restores the TOC after the glink code. Contrariwise, if the
796 call is followed by a ld r2,40(r1), but the call is not
797 going to global linkage code, we can replace the load with a
800 && (bfd_link_hash_defined
== h
->root
.type
801 || bfd_link_hash_defweak
== h
->root
.type
)
802 && section_offset
+ 8 <= input_section
->size
)
807 pnext
= contents
+ section_offset
+ 4;
808 next
= bfd_get_32 (input_bfd
, pnext
);
810 /* The _ptrgl function is magic. It is used by the AIX compiler to call
811 a function through a pointer. */
812 if (h
->smclas
== XMC_GL
|| strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
814 if (next
== 0x4def7b82 /* cror 15,15,15 */
815 || next
== 0x4ffffb82 /* cror 31,31,31 */
816 || next
== 0x60000000) /* ori r0,r0,0 */
817 bfd_put_32 (input_bfd
, 0xe8410028, pnext
); /* ld r2,40(r1) */
821 if (next
== 0xe8410028) /* ld r2,40(r1) */
822 bfd_put_32 (input_bfd
, 0x60000000, pnext
); /* ori r0,r0,0 */
825 else if (NULL
!= h
&& bfd_link_hash_undefined
== h
->root
.type
)
827 /* Normally, this relocation is against a defined symbol. In the
828 case where this is a partial link and the output section offset
829 is greater than 2^25, the linker will return an invalid error
830 message that the relocation has been truncated. Yes it has been
831 truncated but no it not important. For this case, disable the
832 overflow checking. */
833 howto
->complain_on_overflow
= complain_overflow_dont
;
836 /* The original PC-relative relocation is biased by -r_vaddr, so adding
837 the value below will give the absolute target address. */
838 *relocation
= val
+ addend
+ rel
->r_vaddr
;
840 howto
->src_mask
&= ~3;
841 howto
->dst_mask
= howto
->src_mask
;
844 && (h
->root
.type
== bfd_link_hash_defined
845 || h
->root
.type
== bfd_link_hash_defweak
)
846 && bfd_is_abs_section (h
->root
.u
.def
.section
)
847 && section_offset
+ 4 <= input_section
->size
)
852 /* Turn the relative branch into an absolute one by setting the
854 ptr
= contents
+ section_offset
;
855 insn
= bfd_get_32 (input_bfd
, ptr
);
857 bfd_put_32 (input_bfd
, insn
, ptr
);
859 /* Make the howto absolute too. */
860 howto
->pc_relative
= false;
861 howto
->complain_on_overflow
= complain_overflow_bitfield
;
865 /* Use a PC-relative howto and subtract the instruction's address
866 from the target address we calculated above. */
867 howto
->pc_relative
= true;
868 *relocation
-= (input_section
->output_section
->vma
869 + input_section
->output_offset
877 /* The XCOFF reloc table.
878 Cf xcoff_howto_table comments. */
880 reloc_howto_type xcoff64_howto_table
[] =
882 /* 0x00: Standard 64 bit relocation. */
883 HOWTO (R_POS
, /* type */
885 4, /* size (0 = byte, 1 = short, 2 = long) */
887 false, /* pc_relative */
889 complain_overflow_bitfield
, /* complain_on_overflow */
890 0, /* special_function */
891 "R_POS_64", /* name */
892 true, /* partial_inplace */
893 MINUS_ONE
, /* src_mask */
894 MINUS_ONE
, /* dst_mask */
895 false), /* pcrel_offset */
897 /* 0x01: 64 bit relocation, but store negative value. */
898 HOWTO (R_NEG
, /* type */
900 -4, /* size (0 = byte, 1 = short, 2 = long) */
902 false, /* pc_relative */
904 complain_overflow_bitfield
, /* complain_on_overflow */
905 0, /* special_function */
907 true, /* partial_inplace */
908 MINUS_ONE
, /* src_mask */
909 MINUS_ONE
, /* dst_mask */
910 false), /* pcrel_offset */
912 /* 0x02: 64 bit PC relative relocation. */
913 HOWTO (R_REL
, /* type */
915 4, /* size (0 = byte, 1 = short, 2 = long) */
917 true, /* pc_relative */
919 complain_overflow_signed
, /* complain_on_overflow */
920 0, /* special_function */
922 true, /* partial_inplace */
923 MINUS_ONE
, /* src_mask */
924 MINUS_ONE
, /* dst_mask */
925 false), /* pcrel_offset */
927 /* 0x03: 16 bit TOC relative relocation. */
928 HOWTO (R_TOC
, /* type */
930 1, /* size (0 = byte, 1 = short, 2 = long) */
932 false, /* pc_relative */
934 complain_overflow_bitfield
, /* complain_on_overflow */
935 0, /* special_function */
937 true, /* partial_inplace */
939 0xffff, /* dst_mask */
940 false), /* pcrel_offset */
942 /* 0x04: Same as R_TOC. */
943 HOWTO (R_TRL
, /* type */
945 1, /* size (0 = byte, 1 = short, 2 = long) */
947 false, /* pc_relative */
949 complain_overflow_bitfield
, /* complain_on_overflow */
950 0, /* special_function */
952 true, /* partial_inplace */
954 0xffff, /* dst_mask */
955 false), /* pcrel_offset */
957 /* 0x05: External TOC relative symbol. */
958 HOWTO (R_GL
, /* type */
960 1, /* size (0 = byte, 1 = short, 2 = long) */
962 false, /* pc_relative */
964 complain_overflow_bitfield
, /* complain_on_overflow */
965 0, /* special_function */
967 true, /* partial_inplace */
969 0xffff, /* dst_mask */
970 false), /* pcrel_offset */
972 /* 0x06: Local TOC relative symbol. */
973 HOWTO (R_TCL
, /* type */
975 1, /* size (0 = byte, 1 = short, 2 = long) */
977 false, /* pc_relative */
979 complain_overflow_bitfield
, /* complain_on_overflow */
980 0, /* special_function */
982 true, /* partial_inplace */
984 0xffff, /* dst_mask */
985 false), /* pcrel_offset */
989 /* 0x08: Same as R_RBA. */
990 HOWTO (R_BA
, /* type */
992 2, /* size (0 = byte, 1 = short, 2 = long) */
994 false, /* pc_relative */
996 complain_overflow_bitfield
, /* complain_on_overflow */
997 0, /* special_function */
998 "R_BA_26", /* name */
999 true, /* partial_inplace */
1000 0x03fffffc, /* src_mask */
1001 0x03fffffc, /* dst_mask */
1002 false), /* pcrel_offset */
1006 /* 0x0a: Same as R_RBR. */
1007 HOWTO (R_BR
, /* type */
1009 2, /* size (0 = byte, 1 = short, 2 = long) */
1011 true, /* pc_relative */
1013 complain_overflow_signed
, /* complain_on_overflow */
1014 0, /* special_function */
1016 true, /* partial_inplace */
1017 0x03fffffc, /* src_mask */
1018 0x03fffffc, /* dst_mask */
1019 false), /* pcrel_offset */
1023 /* 0x0c: Same as R_POS. */
1024 HOWTO (R_RL
, /* type */
1026 4, /* size (0 = byte, 1 = short, 2 = long) */
1028 false, /* pc_relative */
1030 complain_overflow_bitfield
, /* complain_on_overflow */
1031 0, /* special_function */
1033 true, /* partial_inplace */
1034 MINUS_ONE
, /* src_mask */
1035 MINUS_ONE
, /* dst_mask */
1036 false), /* pcrel_offset */
1038 /* 0x0d: Same as R_POS. */
1039 HOWTO (R_RLA
, /* type */
1041 4, /* size (0 = byte, 1 = short, 2 = long) */
1043 false, /* pc_relative */
1045 complain_overflow_bitfield
, /* complain_on_overflow */
1046 0, /* special_function */
1048 true, /* partial_inplace */
1049 MINUS_ONE
, /* src_mask */
1050 MINUS_ONE
, /* dst_mask */
1051 false), /* pcrel_offset */
1055 /* 0x0f: Non-relocating reference. Bitsize is 1 so that r_rsize is 0. */
1056 HOWTO (R_REF
, /* type */
1058 0, /* size (0 = byte, 1 = short, 2 = long) */
1060 false, /* pc_relative */
1062 complain_overflow_dont
, /* complain_on_overflow */
1063 0, /* special_function */
1065 false, /* partial_inplace */
1068 false), /* pcrel_offset */
1074 /* 0x13: Same as R_TOC */
1075 HOWTO (R_TRLA
, /* type */
1077 1, /* size (0 = byte, 1 = short, 2 = long) */
1079 false, /* pc_relative */
1081 complain_overflow_bitfield
, /* complain_on_overflow */
1082 0, /* special_function */
1083 "R_TRLA", /* name */
1084 true, /* partial_inplace */
1085 0xffff, /* src_mask */
1086 0xffff, /* dst_mask */
1087 false), /* pcrel_offset */
1089 /* 0x14: Modifiable relative branch. */
1090 HOWTO (R_RRTBI
, /* type */
1092 2, /* size (0 = byte, 1 = short, 2 = long) */
1094 false, /* pc_relative */
1096 complain_overflow_bitfield
, /* complain_on_overflow */
1097 0, /* special_function */
1098 "R_RRTBI", /* name */
1099 true, /* partial_inplace */
1100 0xffffffff, /* src_mask */
1101 0xffffffff, /* dst_mask */
1102 false), /* pcrel_offset */
1104 /* 0x15: Modifiable absolute branch. */
1105 HOWTO (R_RRTBA
, /* type */
1107 2, /* size (0 = byte, 1 = short, 2 = long) */
1109 false, /* pc_relative */
1111 complain_overflow_bitfield
, /* complain_on_overflow */
1112 0, /* special_function */
1113 "R_RRTBA", /* name */
1114 true, /* partial_inplace */
1115 0xffffffff, /* src_mask */
1116 0xffffffff, /* dst_mask */
1117 false), /* pcrel_offset */
1119 /* 0x16: Modifiable call absolute indirect. */
1120 HOWTO (R_CAI
, /* type */
1122 1, /* size (0 = byte, 1 = short, 2 = long) */
1124 false, /* pc_relative */
1126 complain_overflow_bitfield
, /* complain_on_overflow */
1127 0, /* special_function */
1129 true, /* partial_inplace */
1130 0xffff, /* src_mask */
1131 0xffff, /* dst_mask */
1132 false), /* pcrel_offset */
1134 /* 0x17: Modifiable call relative. */
1135 HOWTO (R_CREL
, /* type */
1137 1, /* size (0 = byte, 1 = short, 2 = long) */
1139 false, /* pc_relative */
1141 complain_overflow_bitfield
, /* complain_on_overflow */
1142 0, /* special_function */
1143 "R_CREL", /* name */
1144 true, /* partial_inplace */
1145 0xffff, /* src_mask */
1146 0xffff, /* dst_mask */
1147 false), /* pcrel_offset */
1149 /* 0x18: Modifiable branch absolute. */
1150 HOWTO (R_RBA
, /* type */
1152 2, /* size (0 = byte, 1 = short, 2 = long) */
1154 false, /* pc_relative */
1156 complain_overflow_bitfield
, /* complain_on_overflow */
1157 0, /* special_function */
1159 true, /* partial_inplace */
1160 0x03fffffc, /* src_mask */
1161 0x03fffffc, /* dst_mask */
1162 false), /* pcrel_offset */
1164 /* 0x19: Modifiable branch absolute. */
1165 HOWTO (R_RBAC
, /* type */
1167 2, /* size (0 = byte, 1 = short, 2 = long) */
1169 false, /* pc_relative */
1171 complain_overflow_bitfield
, /* complain_on_overflow */
1172 0, /* special_function */
1173 "R_RBAC", /* name */
1174 true, /* partial_inplace */
1175 0xffffffff, /* src_mask */
1176 0xffffffff, /* dst_mask */
1177 false), /* pcrel_offset */
1179 /* 0x1a: Modifiable branch relative. */
1180 HOWTO (R_RBR
, /* type */
1182 2, /* size (0 = byte, 1 = short, 2 = long) */
1184 false, /* pc_relative */
1186 complain_overflow_signed
, /* complain_on_overflow */
1187 0, /* special_function */
1188 "R_RBR_26", /* name */
1189 true, /* partial_inplace */
1190 0x03fffffc, /* src_mask */
1191 0x03fffffc, /* dst_mask */
1192 false), /* pcrel_offset */
1194 /* 0x1b: Modifiable branch absolute. */
1195 HOWTO (R_RBRC
, /* type */
1197 1, /* size (0 = byte, 1 = short, 2 = long) */
1199 false, /* pc_relative */
1201 complain_overflow_bitfield
, /* complain_on_overflow */
1202 0, /* special_function */
1203 "R_RBRC", /* name */
1204 true, /* partial_inplace */
1205 0xffff, /* src_mask */
1206 0xffff, /* dst_mask */
1207 false), /* pcrel_offset */
1209 /* 0x1c: Standard 32 bit relocation. */
1210 HOWTO (R_POS
, /* type */
1212 2, /* size (0 = byte, 1 = short, 2 = long) */
1214 false, /* pc_relative */
1216 complain_overflow_bitfield
, /* complain_on_overflow */
1217 0, /* special_function */
1218 "R_POS_32", /* name */
1219 true, /* partial_inplace */
1220 0xffffffff, /* src_mask */
1221 0xffffffff, /* dst_mask */
1222 false), /* pcrel_offset */
1224 /* 0x1d: 16 bit Non modifiable absolute branch. */
1225 HOWTO (R_BA
, /* type */
1227 1, /* size (0 = byte, 1 = short, 2 = long) */
1229 false, /* pc_relative */
1231 complain_overflow_bitfield
, /* complain_on_overflow */
1232 0, /* special_function */
1233 "R_BA_16", /* name */
1234 true, /* partial_inplace */
1235 0xfffc, /* src_mask */
1236 0xfffc, /* dst_mask */
1237 false), /* pcrel_offset */
1239 /* 0x1e: Modifiable branch relative. */
1240 HOWTO (R_RBR
, /* type */
1242 1, /* size (0 = byte, 1 = short, 2 = long) */
1244 true, /* pc_relative */
1246 complain_overflow_signed
, /* complain_on_overflow */
1247 0, /* special_function */
1248 "R_RBR_16", /* name */
1249 true, /* partial_inplace */
1250 0xfffc, /* src_mask */
1251 0xfffc, /* dst_mask */
1252 false), /* pcrel_offset */
1254 /* 0x1f: Modifiable branch absolute. */
1255 HOWTO (R_RBA
, /* type */
1257 1, /* size (0 = byte, 1 = short, 2 = long) */
1259 false, /* pc_relative */
1261 complain_overflow_bitfield
, /* complain_on_overflow */
1262 0, /* special_function */
1263 "R_RBA_16", /* name */
1264 true, /* partial_inplace */
1265 0xffff, /* src_mask */
1266 0xffff, /* dst_mask */
1267 false), /* pcrel_offset */
1269 /* 0x20: General-dynamic TLS relocation. */
1270 HOWTO (R_TLS
, /* type */
1272 4, /* size (0 = byte, 1 = short, 2 = long) */
1274 false, /* pc_relative */
1276 complain_overflow_bitfield
, /* complain_on_overflow */
1277 0, /* special_function */
1279 true, /* partial_inplace */
1280 MINUS_ONE
, /* src_mask */
1281 MINUS_ONE
, /* dst_mask */
1282 false), /* pcrel_offset */
1284 /* 0x21: Initial-exec TLS relocation. */
1285 HOWTO (R_TLS_IE
, /* type */
1287 4, /* size (0 = byte, 1 = short, 2 = long) */
1289 false, /* pc_relative */
1291 complain_overflow_bitfield
, /* complain_on_overflow */
1292 0, /* special_function */
1293 "R_TLS_IE", /* name */
1294 true, /* partial_inplace */
1295 MINUS_ONE
, /* src_mask */
1296 MINUS_ONE
, /* dst_mask */
1297 false), /* pcrel_offset */
1299 /* 0x22: Local-dynamic TLS relocation. */
1300 HOWTO (R_TLS_LD
, /* type */
1302 4, /* size (0 = byte, 1 = short, 2 = long) */
1304 false, /* pc_relative */
1306 complain_overflow_bitfield
, /* complain_on_overflow */
1307 0, /* special_function */
1308 "R_TLS_LD", /* name */
1309 true, /* partial_inplace */
1310 MINUS_ONE
, /* src_mask */
1311 MINUS_ONE
, /* dst_mask */
1312 false), /* pcrel_offset */
1314 /* 0x23: Local-exec TLS relocation. */
1315 HOWTO (R_TLS_LE
, /* type */
1317 4, /* size (0 = byte, 1 = short, 2 = long) */
1319 false, /* pc_relative */
1321 complain_overflow_bitfield
, /* complain_on_overflow */
1322 0, /* special_function */
1323 "R_TLS_LE", /* name */
1324 true, /* partial_inplace */
1325 MINUS_ONE
, /* src_mask */
1326 MINUS_ONE
, /* dst_mask */
1327 false), /* pcrel_offset */
1329 /* 0x24: TLS relocation. */
1330 HOWTO (R_TLSM
, /* type */
1332 4, /* size (0 = byte, 1 = short, 2 = long) */
1334 false, /* pc_relative */
1336 complain_overflow_bitfield
, /* complain_on_overflow */
1337 0, /* special_function */
1338 "R_TLSM", /* name */
1339 true, /* partial_inplace */
1340 MINUS_ONE
, /* src_mask */
1341 MINUS_ONE
, /* dst_mask */
1342 false), /* pcrel_offset */
1344 /* 0x25: TLS module relocation. */
1345 HOWTO (R_TLSML
, /* type */
1347 4, /* size (0 = byte, 1 = short, 2 = long) */
1349 false, /* pc_relative */
1351 complain_overflow_bitfield
, /* complain_on_overflow */
1352 0, /* special_function */
1353 "R_TLSML", /* name */
1354 true, /* partial_inplace */
1355 MINUS_ONE
, /* src_mask */
1356 MINUS_ONE
, /* dst_mask */
1357 false), /* pcrel_offset */
1359 /* 0x26: 32 bit relocation, but store negative value. */
1360 HOWTO (R_NEG
, /* type */
1362 -2, /* size (0 = byte, 1 = short, 2 = long) */
1364 false, /* pc_relative */
1366 complain_overflow_bitfield
, /* complain_on_overflow */
1367 0, /* special_function */
1368 "R_NEG_32", /* name */
1369 true, /* partial_inplace */
1370 MINUS_ONE
, /* src_mask */
1371 MINUS_ONE
, /* dst_mask */
1372 false), /* pcrel_offset */
1384 HOWTO (R_TOCU
, /* type */
1385 16, /* rightshift */
1386 1, /* size (0 = byte, 1 = short, 2 = long) */
1388 false, /* pc_relative */
1390 complain_overflow_bitfield
, /* complain_on_overflow */
1391 0, /* special_function */
1392 "R_TOCU", /* name */
1393 true, /* partial_inplace */
1395 0xffff, /* dst_mask */
1396 false), /* pcrel_offset */
1398 /* 0x31: Low-order 16 bit TOC relative relocation. */
1399 HOWTO (R_TOCL
, /* type */
1401 1, /* size (0 = byte, 1 = short, 2 = long) */
1403 false, /* pc_relative */
1405 complain_overflow_dont
, /* complain_on_overflow */
1406 0, /* special_function */
1407 "R_TOCL", /* name */
1408 true, /* partial_inplace */
1410 0xffff, /* dst_mask */
1411 false), /* pcrel_offset */
1416 xcoff64_rtype2howto (arelent
*relent
, struct internal_reloc
*internal
)
1418 if (internal
->r_type
> R_TOCL
)
1421 /* Default howto layout works most of the time */
1422 relent
->howto
= &xcoff64_howto_table
[internal
->r_type
];
1424 /* Special case some 16 bit reloc */
1425 if (15 == (internal
->r_size
& 0x3f))
1427 if (R_BA
== internal
->r_type
)
1428 relent
->howto
= &xcoff64_howto_table
[0x1d];
1429 else if (R_RBR
== internal
->r_type
)
1430 relent
->howto
= &xcoff64_howto_table
[0x1e];
1431 else if (R_RBA
== internal
->r_type
)
1432 relent
->howto
= &xcoff64_howto_table
[0x1f];
1434 /* Special case 32 bit */
1435 else if (31 == (internal
->r_size
& 0x3f))
1437 if (R_POS
== internal
->r_type
)
1438 relent
->howto
= &xcoff64_howto_table
[0x1c];
1440 if (R_NEG
== internal
->r_type
)
1441 relent
->howto
= &xcoff64_howto_table
[0x26];
1444 /* The r_size field of an XCOFF reloc encodes the bitsize of the
1445 relocation, as well as indicating whether it is signed or not.
1446 Doublecheck that the relocation information gathered from the
1447 type matches this information. The bitsize is not significant
1448 for R_REF relocs. */
1449 if (relent
->howto
->dst_mask
!= 0
1450 && (relent
->howto
->bitsize
1451 != ((unsigned int) internal
->r_size
& 0x3f) + 1))
1456 xcoff64_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1457 bfd_reloc_code_real_type code
)
1461 case BFD_RELOC_PPC_B26
:
1462 return &xcoff64_howto_table
[0xa];
1463 case BFD_RELOC_PPC_BA16
:
1464 return &xcoff64_howto_table
[0x1d];
1465 case BFD_RELOC_PPC_BA26
:
1466 return &xcoff64_howto_table
[8];
1467 case BFD_RELOC_PPC_TOC16
:
1468 return &xcoff64_howto_table
[3];
1469 case BFD_RELOC_PPC_TOC16_HI
:
1470 return &xcoff64_howto_table
[0x30];
1471 case BFD_RELOC_PPC_TOC16_LO
:
1472 return &xcoff64_howto_table
[0x31];
1473 case BFD_RELOC_PPC_B16
:
1474 return &xcoff64_howto_table
[0x1e];
1476 case BFD_RELOC_CTOR
:
1477 return &xcoff64_howto_table
[0x1c];
1479 return &xcoff64_howto_table
[0];
1480 case BFD_RELOC_NONE
:
1481 return &xcoff64_howto_table
[0xf];
1482 case BFD_RELOC_PPC_NEG
:
1483 return &xcoff64_howto_table
[0x1];
1484 case BFD_RELOC_PPC64_TLSGD
:
1485 return &xcoff64_howto_table
[0x20];
1486 case BFD_RELOC_PPC64_TLSIE
:
1487 return &xcoff64_howto_table
[0x21];
1488 case BFD_RELOC_PPC64_TLSLD
:
1489 return &xcoff64_howto_table
[0x22];
1490 case BFD_RELOC_PPC64_TLSLE
:
1491 return &xcoff64_howto_table
[0x23];
1492 case BFD_RELOC_PPC64_TLSM
:
1493 return &xcoff64_howto_table
[0x24];
1494 case BFD_RELOC_PPC64_TLSML
:
1495 return &xcoff64_howto_table
[0x25];
1501 static reloc_howto_type
*
1502 xcoff64_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1508 i
< sizeof (xcoff64_howto_table
) / sizeof (xcoff64_howto_table
[0]);
1510 if (xcoff64_howto_table
[i
].name
!= NULL
1511 && strcasecmp (xcoff64_howto_table
[i
].name
, r_name
) == 0)
1512 return &xcoff64_howto_table
[i
];
1517 /* This is the relocation function for the PowerPC64.
1518 See xcoff_ppc_relocation_section for more information. */
1521 xcoff64_ppc_relocate_section (bfd
*output_bfd
,
1522 struct bfd_link_info
*info
,
1524 asection
*input_section
,
1526 struct internal_reloc
*relocs
,
1527 struct internal_syment
*syms
,
1528 asection
**sections
)
1530 struct internal_reloc
*rel
;
1531 struct internal_reloc
*relend
;
1534 relend
= rel
+ input_section
->reloc_count
;
1535 for (; rel
< relend
; rel
++)
1538 struct xcoff_link_hash_entry
*h
;
1539 struct internal_syment
*sym
;
1542 struct reloc_howto_struct howto
;
1544 bfd_vma value_to_relocate
;
1548 /* Relocation type R_REF is a special relocation type which is
1549 merely used to prevent garbage collection from occurring for
1550 the csect including the symbol which it references. */
1551 if (rel
->r_type
== R_REF
)
1554 /* Retrieve default value in HOWTO table and fix up according
1555 to r_size field, if it can be different.
1556 This should be made during relocation reading but the algorithms
1557 are expecting constant howtos. */
1558 memcpy (&howto
, &xcoff64_howto_table
[rel
->r_type
], sizeof (howto
));
1559 if (howto
.bitsize
!= (rel
->r_size
& 0x3f) + 1)
1561 switch (rel
->r_type
)
1565 howto
.bitsize
= (rel
->r_size
& 0x3f) + 1;
1566 howto
.size
= howto
.bitsize
> 16 ? (howto
.bitsize
> 32 ? 4 : 2) : 1;
1567 howto
.src_mask
= howto
.dst_mask
= N_ONES (howto
.bitsize
);
1572 (_("%pB: relocation (%d) at (0x%" BFD_VMA_FMT
"x) has wrong"
1573 " r_rsize (0x%x)\n"),
1574 input_bfd
, rel
->r_type
, rel
->r_vaddr
, rel
->r_size
);
1579 howto
.complain_on_overflow
= (rel
->r_size
& 0x80
1580 ? complain_overflow_signed
1581 : complain_overflow_bitfield
);
1588 symndx
= rel
->r_symndx
;
1594 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
1595 sym
= syms
+ symndx
;
1596 addend
= - sym
->n_value
;
1600 sec
= sections
[symndx
];
1601 /* Hack to make sure we use the right TOC anchor value
1602 if this reloc is against the TOC anchor. */
1603 if (sec
->name
[3] == '0'
1604 && strcmp (sec
->name
, ".tc0") == 0)
1605 val
= xcoff_data (output_bfd
)->toc
;
1607 val
= (sec
->output_section
->vma
1608 + sec
->output_offset
1614 if (info
->unresolved_syms_in_objects
!= RM_IGNORE
1615 && (h
->flags
& XCOFF_WAS_UNDEFINED
) != 0)
1616 info
->callbacks
->undefined_symbol
1617 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
1618 rel
->r_vaddr
- input_section
->vma
,
1619 info
->unresolved_syms_in_objects
== RM_DIAGNOSE
1620 && !info
->warn_unresolved_syms
);
1622 if (h
->root
.type
== bfd_link_hash_defined
1623 || h
->root
.type
== bfd_link_hash_defweak
)
1625 sec
= h
->root
.u
.def
.section
;
1626 val
= (h
->root
.u
.def
.value
1627 + sec
->output_section
->vma
1628 + sec
->output_offset
);
1630 else if (h
->root
.type
== bfd_link_hash_common
)
1632 sec
= h
->root
.u
.c
.p
->section
;
1633 val
= (sec
->output_section
->vma
1634 + sec
->output_offset
);
1638 BFD_ASSERT (bfd_link_relocatable (info
)
1639 || (h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
1640 || (h
->flags
& XCOFF_IMPORT
) != 0);
1645 if (rel
->r_type
>= XCOFF_MAX_CALCULATE_RELOCATION
1646 || !((*xcoff64_calculate_relocation
[rel
->r_type
])
1647 (input_bfd
, input_section
, output_bfd
, rel
, sym
, &howto
, val
,
1648 addend
, &relocation
, contents
)))
1652 address
= rel
->r_vaddr
- input_section
->vma
;
1653 location
= contents
+ address
;
1655 if (address
> input_section
->size
)
1658 /* Get the value we are going to relocate. */
1659 if (1 == howto
.size
)
1660 value_to_relocate
= bfd_get_16 (input_bfd
, location
);
1661 else if (2 == howto
.size
)
1662 value_to_relocate
= bfd_get_32 (input_bfd
, location
);
1664 value_to_relocate
= bfd_get_64 (input_bfd
, location
);
1668 FIXME: We may drop bits during the addition
1669 which we don't check for. We must either check at every single
1670 operation, which would be tedious, or we must do the computations
1671 in a type larger than bfd_vma, which would be inefficient. */
1673 if (((*xcoff_complain_overflow
[howto
.complain_on_overflow
])
1674 (input_bfd
, value_to_relocate
, relocation
, &howto
)))
1677 char buf
[SYMNMLEN
+ 1];
1678 char reloc_type_name
[10];
1690 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
1694 sprintf (reloc_type_name
, "0x%02x", rel
->r_type
);
1696 (*info
->callbacks
->reloc_overflow
)
1697 (info
, (h
? &h
->root
: NULL
), name
, reloc_type_name
,
1698 (bfd_vma
) 0, input_bfd
, input_section
,
1699 rel
->r_vaddr
- input_section
->vma
);
1702 /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */
1703 value_to_relocate
= ((value_to_relocate
& ~howto
.dst_mask
)
1704 | (((value_to_relocate
& howto
.src_mask
)
1705 + relocation
) & howto
.dst_mask
));
1707 /* Put the value back in the object file. */
1708 if (1 == howto
.size
)
1709 bfd_put_16 (input_bfd
, value_to_relocate
, location
);
1710 else if (2 == howto
.size
)
1711 bfd_put_32 (input_bfd
, value_to_relocate
, location
);
1713 bfd_put_64 (input_bfd
, value_to_relocate
, location
);
1720 /* PR 21786: The PE/COFF standard does not require NUL termination for any of
1721 the ASCII fields in the archive headers. So in order to be able to extract
1722 numerical values we provide our own versions of strtol and strtoll which
1723 take a maximum length as an additional parameter. Also - just to save space,
1724 we omit the endptr return parameter, since we know that it is never used. */
1727 _bfd_strntol (const char * nptr
, int base
, unsigned int maxlen
)
1729 char buf
[24]; /* Should be enough. */
1731 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1733 memcpy (buf
, nptr
, maxlen
);
1735 return strtol (buf
, NULL
, base
);
1739 _bfd_strntoll (const char * nptr
, int base
, unsigned int maxlen
)
1741 char buf
[32]; /* Should be enough. */
1743 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1745 memcpy (buf
, nptr
, maxlen
);
1747 return strtoll (buf
, NULL
, base
);
1750 /* Macro to read an ASCII value stored in an archive header field. */
1751 #define GET_VALUE_IN_FIELD(VAR, FIELD, BASE) \
1754 (VAR) = (sizeof (VAR) > sizeof (long) \
1755 ? _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
1756 : _bfd_strntol (FIELD, BASE, sizeof FIELD)); \
1760 /* Read in the armap of an XCOFF archive. */
1763 xcoff64_slurp_armap (bfd
*abfd
)
1767 bfd_size_type sz
, amt
;
1768 bfd_byte
*contents
, *cend
;
1774 /* This is for the new format. */
1775 struct xcoff_ar_hdr_big hdr
;
1777 if (xcoff_ardata (abfd
) == NULL
)
1779 abfd
->has_armap
= false;
1783 off
= bfd_scan_vma (xcoff_ardata_big (abfd
)->symoff64
,
1784 (const char **) NULL
, 10);
1787 abfd
->has_armap
= false;
1791 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1794 /* The symbol table starts with a normal archive header. */
1795 if (bfd_bread (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR_BIG
, abfd
)
1796 != SIZEOF_AR_HDR_BIG
)
1799 /* Skip the name (normally empty). */
1800 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1801 pos
= ((namlen
+ 1) & ~(size_t) 1) + SXCOFFARFMAG
;
1802 if (bfd_seek (abfd
, pos
, SEEK_CUR
) != 0)
1805 sz
= bfd_scan_vma (hdr
.size
, (const char **) NULL
, 10);
1808 bfd_set_error (bfd_error_bad_value
);
1812 /* Read in the entire symbol table. */
1813 contents
= (bfd_byte
*) _bfd_alloc_and_read (abfd
, sz
+ 1, sz
);
1814 if (contents
== NULL
)
1817 /* Ensure strings are NULL terminated so we don't wander off the end
1821 /* The symbol table starts with an eight byte count. */
1822 c
= H_GET_64 (abfd
, contents
);
1826 bfd_set_error (bfd_error_bad_value
);
1830 amt
*= sizeof (carsym
);
1831 bfd_ardata (abfd
)->symdefs
= (carsym
*) bfd_alloc (abfd
, amt
);
1832 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1835 /* After the count comes a list of eight byte file offsets. */
1836 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1838 ++i
, ++arsym
, p
+= 8)
1839 arsym
->file_offset
= H_GET_64 (abfd
, p
);
1841 /* After the file offsets come null terminated symbol names. */
1842 cend
= contents
+ sz
;
1843 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1845 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1849 bfd_set_error (bfd_error_bad_value
);
1852 arsym
->name
= (char *) p
;
1855 bfd_ardata (abfd
)->symdef_count
= c
;
1856 abfd
->has_armap
= true;
1862 /* See if this is an NEW XCOFF archive. */
1865 xcoff64_archive_p (bfd
*abfd
)
1867 struct artdata
*tdata_hold
;
1868 char magic
[SXCOFFARMAG
];
1869 /* This is the new format. */
1870 struct xcoff_ar_file_hdr_big hdr
;
1871 size_t amt
= SXCOFFARMAG
;
1873 if (bfd_bread (magic
, amt
, abfd
) != amt
)
1875 if (bfd_get_error () != bfd_error_system_call
)
1876 bfd_set_error (bfd_error_wrong_format
);
1880 if (strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0)
1882 bfd_set_error (bfd_error_wrong_format
);
1886 /* Copy over the magic string. */
1887 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1889 /* Now read the rest of the file header. */
1890 amt
= SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
;
1891 if (bfd_bread (&hdr
.memoff
, amt
, abfd
) != amt
)
1893 if (bfd_get_error () != bfd_error_system_call
)
1894 bfd_set_error (bfd_error_wrong_format
);
1898 tdata_hold
= bfd_ardata (abfd
);
1900 amt
= sizeof (struct artdata
);
1901 bfd_ardata (abfd
) = (struct artdata
*) bfd_zalloc (abfd
, amt
);
1902 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1903 goto error_ret_restore
;
1905 /* Already cleared by bfd_zalloc above.
1906 bfd_ardata (abfd)->cache = NULL;
1907 bfd_ardata (abfd)->archive_head = NULL;
1908 bfd_ardata (abfd)->symdefs = NULL;
1909 bfd_ardata (abfd)->extended_names = NULL;
1910 bfd_ardata (abfd)->extended_names_size = 0; */
1911 bfd_ardata (abfd
)->first_file_filepos
= bfd_scan_vma (hdr
.firstmemoff
,
1912 (const char **) NULL
,
1915 amt
= SIZEOF_AR_FILE_HDR_BIG
;
1916 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, amt
);
1917 if (bfd_ardata (abfd
)->tdata
== NULL
)
1920 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1922 if (! xcoff64_slurp_armap (abfd
))
1925 bfd_release (abfd
, bfd_ardata (abfd
));
1927 bfd_ardata (abfd
) = tdata_hold
;
1931 return _bfd_no_cleanup
;
1935 /* Open the next element in an XCOFF archive. */
1938 xcoff64_openr_next_archived_file (bfd
*archive
, bfd
*last_file
)
1940 if ((xcoff_ardata (archive
) == NULL
)
1941 || ! xcoff_big_format_p (archive
))
1943 bfd_set_error (bfd_error_invalid_operation
);
1947 return _bfd_xcoff_openr_next_archived_file (archive
, last_file
);
1950 /* We can't use the usual coff_sizeof_headers routine, because AIX
1951 always uses an a.out header. */
1954 xcoff64_sizeof_headers (bfd
*abfd
,
1955 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
1959 size
= bfd_coff_filhsz (abfd
);
1961 /* Don't think the small aout header can be used since some of the
1962 old elements have been reordered past the end of the old coff
1965 if (xcoff_data (abfd
)->full_aouthdr
)
1966 size
+= bfd_coff_aoutsz (abfd
);
1968 size
+= abfd
->section_count
* bfd_coff_scnhsz (abfd
);
1973 xcoff64_create_csect_from_smclas (bfd
*abfd
, union internal_auxent
*aux
,
1974 const char *symbol_name
)
1976 asection
*return_value
= NULL
;
1978 /* Changes from 32 :
1979 .sv == 8, is only for 32 bit programs
1980 .ti == 12 and .tb == 13 are now reserved. */
1981 static const char * const names
[] =
1983 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
1984 NULL
, ".bs", ".ds", ".uc", NULL
, NULL
, NULL
, ".tc0",
1985 ".td", ".sv64", ".sv3264", NULL
, ".tl", ".ul", ".te"
1988 if ((aux
->x_csect
.x_smclas
< ARRAY_SIZE (names
))
1989 && (NULL
!= names
[aux
->x_csect
.x_smclas
]))
1992 return_value
= bfd_make_section_anyway
1993 (abfd
, names
[aux
->x_csect
.x_smclas
]);
1999 /* xgettext: c-format */
2000 (_("%pB: symbol `%s' has unrecognized smclas %d"),
2001 abfd
, symbol_name
, aux
->x_csect
.x_smclas
);
2002 bfd_set_error (bfd_error_bad_value
);
2005 return return_value
;
2009 xcoff64_is_lineno_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
,
2010 bfd_vma value ATTRIBUTE_UNUSED
)
2016 xcoff64_is_reloc_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
,
2017 bfd_vma value ATTRIBUTE_UNUSED
)
2023 xcoff64_loader_symbol_offset (bfd
*abfd ATTRIBUTE_UNUSED
,
2024 struct internal_ldhdr
*ldhdr
)
2026 return (ldhdr
->l_symoff
);
2030 xcoff64_loader_reloc_offset (bfd
*abfd ATTRIBUTE_UNUSED
,
2031 struct internal_ldhdr
*ldhdr
)
2033 return (ldhdr
->l_rldoff
);
2037 xcoff64_bad_format_hook (bfd
* abfd
, void *filehdr
)
2039 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
2041 /* Check flavor first. */
2042 if (bfd_get_flavour (abfd
) != bfd_target_xcoff_flavour
)
2045 if (bfd_xcoff_magic_number (abfd
) != internal_f
->f_magic
)
2052 xcoff64_generate_rtinit (bfd
*abfd
, const char *init
, const char *fini
,
2055 bfd_byte filehdr_ext
[FILHSZ
];
2056 bfd_byte scnhdr_ext
[SCNHSZ
* 3];
2057 bfd_byte syment_ext
[SYMESZ
* 10];
2058 bfd_byte reloc_ext
[RELSZ
* 3];
2059 bfd_byte
*data_buffer
;
2060 bfd_size_type data_buffer_size
;
2061 bfd_byte
*string_table
, *st_tmp
;
2062 bfd_size_type string_table_size
;
2064 size_t initsz
, finisz
;
2065 struct internal_filehdr filehdr
;
2066 struct internal_scnhdr text_scnhdr
;
2067 struct internal_scnhdr data_scnhdr
;
2068 struct internal_scnhdr bss_scnhdr
;
2069 struct internal_syment syment
;
2070 union internal_auxent auxent
;
2071 struct internal_reloc reloc
;
2073 char *text_name
= ".text";
2074 char *data_name
= ".data";
2075 char *bss_name
= ".bss";
2076 char *rtinit_name
= "__rtinit";
2077 char *rtld_name
= "__rtld";
2079 if (! bfd_xcoff_rtinit_size (abfd
))
2082 initsz
= (init
== NULL
? 0 : 1 + strlen (init
));
2083 finisz
= (fini
== NULL
? 0 : 1 + strlen (fini
));
2086 memset (filehdr_ext
, 0, FILHSZ
);
2087 memset (&filehdr
, 0, sizeof (struct internal_filehdr
));
2088 filehdr
.f_magic
= bfd_xcoff_magic_number (abfd
);
2089 filehdr
.f_nscns
= 3;
2090 filehdr
.f_timdat
= 0;
2091 filehdr
.f_nsyms
= 0; /* at least 6, no more than 8 */
2092 filehdr
.f_symptr
= 0; /* set below */
2093 filehdr
.f_opthdr
= 0;
2094 filehdr
.f_flags
= 0;
2096 /* Section headers. */
2097 memset (scnhdr_ext
, 0, 3 * SCNHSZ
);
2100 memset (&text_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2101 memcpy (text_scnhdr
.s_name
, text_name
, strlen (text_name
));
2102 text_scnhdr
.s_paddr
= 0;
2103 text_scnhdr
.s_vaddr
= 0;
2104 text_scnhdr
.s_size
= 0;
2105 text_scnhdr
.s_scnptr
= 0;
2106 text_scnhdr
.s_relptr
= 0;
2107 text_scnhdr
.s_lnnoptr
= 0;
2108 text_scnhdr
.s_nreloc
= 0;
2109 text_scnhdr
.s_nlnno
= 0;
2110 text_scnhdr
.s_flags
= STYP_TEXT
;
2113 memset (&data_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2114 memcpy (data_scnhdr
.s_name
, data_name
, strlen (data_name
));
2115 data_scnhdr
.s_paddr
= 0;
2116 data_scnhdr
.s_vaddr
= 0;
2117 data_scnhdr
.s_size
= 0; /* set below */
2118 data_scnhdr
.s_scnptr
= FILHSZ
+ 3 * SCNHSZ
;
2119 data_scnhdr
.s_relptr
= 0; /* set below */
2120 data_scnhdr
.s_lnnoptr
= 0;
2121 data_scnhdr
.s_nreloc
= 0; /* either 1 or 2 */
2122 data_scnhdr
.s_nlnno
= 0;
2123 data_scnhdr
.s_flags
= STYP_DATA
;
2126 memset (&bss_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2127 memcpy (bss_scnhdr
.s_name
, bss_name
, strlen (bss_name
));
2128 bss_scnhdr
.s_paddr
= 0; /* set below */
2129 bss_scnhdr
.s_vaddr
= 0; /* set below */
2130 bss_scnhdr
.s_size
= 0; /* set below */
2131 bss_scnhdr
.s_scnptr
= 0;
2132 bss_scnhdr
.s_relptr
= 0;
2133 bss_scnhdr
.s_lnnoptr
= 0;
2134 bss_scnhdr
.s_nreloc
= 0;
2135 bss_scnhdr
.s_nlnno
= 0;
2136 bss_scnhdr
.s_flags
= STYP_BSS
;
2139 0x0000 0x00000000 : rtl
2141 0x0008 0x00000018 : offset to init, or 0
2142 0x000C 0x00000038 : offset to fini, or 0
2143 0x0010 0x00000010 : size of descriptor
2144 0x0014 0x00000000 : pad
2145 0x0018 0x00000000 : init, needs a reloc
2147 0x0020 0x00000058 : offset to init name
2148 0x0024 0x00000000 : flags, padded to a word
2149 0x0028 0x00000000 : empty init
2153 0x0038 0x00000000 : fini, needs a reloc
2155 0x0040 0x00000??? : offset to fini name
2156 0x0044 0x00000000 : flags, padded to a word
2157 0x0048 0x00000000 : empty fini
2162 0x0058 + initsz fini name */
2164 data_buffer_size
= 0x0058 + initsz
+ finisz
;
2165 data_buffer_size
= (data_buffer_size
+ 7) &~ (bfd_size_type
) 7;
2167 data_buffer
= (bfd_byte
*) bfd_zmalloc (data_buffer_size
);
2168 if (data_buffer
== NULL
)
2174 bfd_put_32 (abfd
, val
, &data_buffer
[0x08]);
2176 bfd_put_32 (abfd
, val
, &data_buffer
[0x20]);
2177 memcpy (&data_buffer
[val
], init
, initsz
);
2183 bfd_put_32 (abfd
, val
, &data_buffer
[0x0C]);
2184 val
= 0x58 + initsz
;
2185 bfd_put_32 (abfd
, val
, &data_buffer
[0x40]);
2186 memcpy (&data_buffer
[val
], fini
, finisz
);
2190 bfd_put_32 (abfd
, val
, &data_buffer
[0x10]);
2191 data_scnhdr
.s_size
= data_buffer_size
;
2192 bss_scnhdr
.s_paddr
= bss_scnhdr
.s_vaddr
= data_scnhdr
.s_size
;
2195 string_table_size
= 4;
2196 string_table_size
+= strlen (data_name
) + 1;
2197 string_table_size
+= strlen (rtinit_name
) + 1;
2198 string_table_size
+= initsz
;
2199 string_table_size
+= finisz
;
2201 string_table_size
+= strlen (rtld_name
) + 1;
2203 string_table
= (bfd_byte
*) bfd_zmalloc (string_table_size
);
2204 if (string_table
== NULL
)
2207 val
= string_table_size
;
2208 bfd_put_32 (abfd
, val
, &string_table
[0]);
2209 st_tmp
= string_table
+ 4;
2217 memset (syment_ext
, 0, 10 * SYMESZ
);
2218 memset (reloc_ext
, 0, 3 * RELSZ
);
2221 memset (&syment
, 0, sizeof (struct internal_syment
));
2222 memset (&auxent
, 0, sizeof (union internal_auxent
));
2224 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2225 memcpy (st_tmp
, data_name
, strlen (data_name
));
2226 st_tmp
+= strlen (data_name
) + 1;
2229 syment
.n_sclass
= C_HIDEXT
;
2230 syment
.n_numaux
= 1;
2231 auxent
.x_csect
.x_scnlen
.l
= data_buffer_size
;
2232 auxent
.x_csect
.x_smtyp
= 3 << 3 | XTY_SD
;
2233 auxent
.x_csect
.x_smclas
= XMC_RW
;
2234 bfd_coff_swap_sym_out (abfd
, &syment
,
2235 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2236 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2238 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2239 filehdr
.f_nsyms
+= 2;
2242 memset (&syment
, 0, sizeof (struct internal_syment
));
2243 memset (&auxent
, 0, sizeof (union internal_auxent
));
2244 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2245 memcpy (st_tmp
, rtinit_name
, strlen (rtinit_name
));
2246 st_tmp
+= strlen (rtinit_name
) + 1;
2249 syment
.n_sclass
= C_EXT
;
2250 syment
.n_numaux
= 1;
2251 auxent
.x_csect
.x_smtyp
= XTY_LD
;
2252 auxent
.x_csect
.x_smclas
= XMC_RW
;
2253 bfd_coff_swap_sym_out (abfd
, &syment
,
2254 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2255 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2257 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2258 filehdr
.f_nsyms
+= 2;
2263 memset (&syment
, 0, sizeof (struct internal_syment
));
2264 memset (&auxent
, 0, sizeof (union internal_auxent
));
2266 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2267 memcpy (st_tmp
, init
, initsz
);
2270 syment
.n_sclass
= C_EXT
;
2271 syment
.n_numaux
= 1;
2272 bfd_coff_swap_sym_out (abfd
, &syment
,
2273 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2274 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2276 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2278 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2279 reloc
.r_vaddr
= 0x0018;
2280 reloc
.r_symndx
= filehdr
.f_nsyms
;
2281 reloc
.r_type
= R_POS
;
2283 bfd_coff_swap_reloc_out (abfd
, &reloc
, &reloc_ext
[0]);
2285 filehdr
.f_nsyms
+= 2;
2286 data_scnhdr
.s_nreloc
+= 1;
2292 memset (&syment
, 0, sizeof (struct internal_syment
));
2293 memset (&auxent
, 0, sizeof (union internal_auxent
));
2295 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2296 memcpy (st_tmp
, fini
, finisz
);
2299 syment
.n_sclass
= C_EXT
;
2300 syment
.n_numaux
= 1;
2301 bfd_coff_swap_sym_out (abfd
, &syment
,
2302 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2303 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2305 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2308 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2309 reloc
.r_vaddr
= 0x0038;
2310 reloc
.r_symndx
= filehdr
.f_nsyms
;
2311 reloc
.r_type
= R_POS
;
2313 bfd_coff_swap_reloc_out (abfd
, &reloc
,
2314 &reloc_ext
[data_scnhdr
.s_nreloc
* RELSZ
]);
2316 filehdr
.f_nsyms
+= 2;
2317 data_scnhdr
.s_nreloc
+= 1;
2322 memset (&syment
, 0, sizeof (struct internal_syment
));
2323 memset (&auxent
, 0, sizeof (union internal_auxent
));
2325 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2326 memcpy (st_tmp
, rtld_name
, strlen (rtld_name
));
2327 st_tmp
+= strlen (rtld_name
) + 1;
2329 syment
.n_sclass
= C_EXT
;
2330 syment
.n_numaux
= 1;
2331 bfd_coff_swap_sym_out (abfd
, &syment
,
2332 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2333 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2335 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2338 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2339 reloc
.r_vaddr
= 0x0000;
2340 reloc
.r_symndx
= filehdr
.f_nsyms
;
2341 reloc
.r_type
= R_POS
;
2343 bfd_coff_swap_reloc_out (abfd
, &reloc
,
2344 &reloc_ext
[data_scnhdr
.s_nreloc
* RELSZ
]);
2346 filehdr
.f_nsyms
+= 2;
2347 data_scnhdr
.s_nreloc
+= 1;
2349 bss_scnhdr
.s_size
= 0;
2352 data_scnhdr
.s_relptr
= data_scnhdr
.s_scnptr
+ data_buffer_size
;
2353 filehdr
.f_symptr
= data_scnhdr
.s_relptr
+ data_scnhdr
.s_nreloc
* RELSZ
;
2355 bfd_coff_swap_filehdr_out (abfd
, &filehdr
, filehdr_ext
);
2356 bfd_bwrite (filehdr_ext
, FILHSZ
, abfd
);
2357 bfd_coff_swap_scnhdr_out (abfd
, &text_scnhdr
, &scnhdr_ext
[SCNHSZ
* 0]);
2358 bfd_coff_swap_scnhdr_out (abfd
, &data_scnhdr
, &scnhdr_ext
[SCNHSZ
* 1]);
2359 bfd_coff_swap_scnhdr_out (abfd
, &bss_scnhdr
, &scnhdr_ext
[SCNHSZ
* 2]);
2360 bfd_bwrite (scnhdr_ext
, 3 * SCNHSZ
, abfd
);
2361 bfd_bwrite (data_buffer
, data_buffer_size
, abfd
);
2362 bfd_bwrite (reloc_ext
, data_scnhdr
.s_nreloc
* RELSZ
, abfd
);
2363 bfd_bwrite (syment_ext
, filehdr
.f_nsyms
* SYMESZ
, abfd
);
2364 bfd_bwrite (string_table
, string_table_size
, abfd
);
2372 /* The typical dynamic reloc. */
2374 static reloc_howto_type xcoff64_dynamic_reloc
=
2375 HOWTO (0, /* type */
2377 4, /* size (0 = byte, 1 = short, 2 = long) */
2379 false, /* pc_relative */
2381 complain_overflow_bitfield
, /* complain_on_overflow */
2382 0, /* special_function */
2384 true, /* partial_inplace */
2385 MINUS_ONE
, /* src_mask */
2386 MINUS_ONE
, /* dst_mask */
2387 false); /* pcrel_offset */
2389 static const unsigned long xcoff64_glink_code
[10] =
2391 0xe9820000, /* ld r12,0(r2) */
2392 0xf8410028, /* std r2,40(r1) */
2393 0xe80c0000, /* ld r0,0(r12) */
2394 0xe84c0008, /* ld r0,8(r12) */
2395 0x7c0903a6, /* mtctr r0 */
2396 0x4e800420, /* bctr */
2397 0x00000000, /* start of traceback table */
2398 0x000ca000, /* traceback table */
2399 0x00000000, /* traceback table */
2400 0x00000018, /* ??? */
2403 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
2405 { /* COFF backend, defined in libcoff.h. */
2406 _bfd_xcoff64_swap_aux_in
,
2407 _bfd_xcoff64_swap_sym_in
,
2408 _bfd_xcoff64_swap_lineno_in
,
2409 _bfd_xcoff64_swap_aux_out
,
2410 _bfd_xcoff64_swap_sym_out
,
2411 _bfd_xcoff64_swap_lineno_out
,
2412 xcoff64_swap_reloc_out
,
2413 coff_swap_filehdr_out
,
2414 coff_swap_aouthdr_out
,
2415 coff_swap_scnhdr_out
,
2424 true, /* _bfd_coff_long_filenames */
2425 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
2426 3, /* _bfd_coff_default_section_alignment_power */
2427 true, /* _bfd_coff_force_symnames_in_strings */
2428 4, /* _bfd_coff_debug_string_prefix_length */
2429 32768, /* _bfd_coff_max_nscns */
2430 coff_swap_filehdr_in
,
2431 coff_swap_aouthdr_in
,
2432 coff_swap_scnhdr_in
,
2433 xcoff64_swap_reloc_in
,
2434 xcoff64_bad_format_hook
,
2435 coff_set_arch_mach_hook
,
2438 coff_set_alignment_hook
,
2439 coff_slurp_symbol_table
,
2440 symname_in_debug_hook
,
2441 coff_pointerize_aux_hook
,
2443 dummy_reloc16_extra_cases
,
2444 dummy_reloc16_estimate
,
2445 NULL
, /* bfd_coff_symbol_classification */
2446 coff_compute_section_file_positions
,
2447 NULL
, /* _bfd_coff_start_final_link */
2448 xcoff64_ppc_relocate_section
,
2449 coff_rtype_to_howto
,
2450 NULL
, /* _bfd_coff_adjust_symndx */
2451 _bfd_generic_link_add_one_symbol
,
2452 coff_link_output_has_begun
,
2453 coff_final_link_postscript
,
2454 NULL
/* print_pdata. */
2457 0x01EF, /* magic number */
2461 /* Function pointers to xcoff specific swap routines. */
2462 xcoff64_swap_ldhdr_in
,
2463 xcoff64_swap_ldhdr_out
,
2464 xcoff64_swap_ldsym_in
,
2465 xcoff64_swap_ldsym_out
,
2466 xcoff64_swap_ldrel_in
,
2467 xcoff64_swap_ldrel_out
,
2473 24, /* _xcoff_function_descriptor_size */
2474 0, /* _xcoff_small_aout_header_size */
2477 2, /* _xcoff_ldhdr_version */
2479 _bfd_xcoff64_put_symbol_name
,
2480 _bfd_xcoff64_put_ldsymbol_name
,
2481 &xcoff64_dynamic_reloc
,
2482 xcoff64_create_csect_from_smclas
,
2484 /* Lineno and reloc count overflow. */
2485 xcoff64_is_lineno_count_overflow
,
2486 xcoff64_is_reloc_count_overflow
,
2488 xcoff64_loader_symbol_offset
,
2489 xcoff64_loader_reloc_offset
,
2492 &xcoff64_glink_code
[0],
2493 40, /* _xcoff_glink_size */
2496 88, /* _xcoff_rtinit_size */
2497 xcoff64_generate_rtinit
,
2500 /* The transfer vector that leads the outside world to all of the above. */
2501 const bfd_target rs6000_xcoff64_vec
=
2504 bfd_target_xcoff_flavour
,
2505 BFD_ENDIAN_BIG
, /* data byte order is big */
2506 BFD_ENDIAN_BIG
, /* header byte order is big */
2508 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
2509 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
2511 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
2512 0, /* leading char */
2513 '/', /* ar_pad_char */
2514 15, /* ar_max_namelen */
2515 0, /* match priority. */
2516 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
2540 { /* bfd_check_format */
2547 { /* bfd_set_format */
2548 _bfd_bool_bfd_false_error
,
2550 _bfd_generic_mkarchive
,
2551 _bfd_bool_bfd_false_error
2554 {/* bfd_write_contents */
2555 _bfd_bool_bfd_false_error
,
2556 coff_write_object_contents
,
2557 _bfd_xcoff_write_archive_contents
,
2558 _bfd_bool_bfd_false_error
2562 _bfd_archive_close_and_cleanup
,
2564 coff_new_section_hook
,
2565 _bfd_generic_get_section_contents
,
2566 _bfd_generic_get_section_contents_in_window
,
2569 _bfd_xcoff_copy_private_bfd_data
,
2570 _bfd_generic_bfd_merge_private_bfd_data
,
2571 _bfd_generic_init_private_section_data
,
2572 _bfd_generic_bfd_copy_private_section_data
,
2573 _bfd_generic_bfd_copy_private_symbol_data
,
2574 _bfd_generic_bfd_copy_private_header_data
,
2575 _bfd_generic_bfd_set_private_flags
,
2576 _bfd_generic_bfd_print_private_bfd_data
,
2579 BFD_JUMP_TABLE_CORE (coff
),
2582 xcoff64_slurp_armap
,
2583 _bfd_noarchive_slurp_extended_name_table
,
2584 _bfd_noarchive_construct_extended_name_table
,
2585 bfd_dont_truncate_arname
,
2586 _bfd_xcoff_write_armap
,
2587 _bfd_xcoff_read_ar_hdr
,
2588 _bfd_generic_write_ar_hdr
,
2589 xcoff64_openr_next_archived_file
,
2590 _bfd_generic_get_elt_at_index
,
2591 _bfd_xcoff_stat_arch_elt
,
2595 coff_get_symtab_upper_bound
,
2596 coff_canonicalize_symtab
,
2597 coff_make_empty_symbol
,
2599 coff_get_symbol_info
,
2600 coff_get_symbol_version_string
,
2601 _bfd_xcoff_is_local_label_name
,
2602 coff_bfd_is_target_special_symbol
,
2604 coff_find_nearest_line
,
2606 coff_find_inliner_info
,
2607 coff_bfd_make_debug_symbol
,
2608 _bfd_generic_read_minisymbols
,
2609 _bfd_generic_minisymbol_to_symbol
,
2612 coff_get_reloc_upper_bound
,
2613 coff_canonicalize_reloc
,
2614 _bfd_generic_set_reloc
,
2615 xcoff64_reloc_type_lookup
,
2616 xcoff64_reloc_name_lookup
,
2620 coff_set_section_contents
,
2623 xcoff64_sizeof_headers
,
2624 bfd_generic_get_relocated_section_contents
,
2625 bfd_generic_relax_section
,
2626 _bfd_xcoff_bfd_link_hash_table_create
,
2627 _bfd_xcoff_bfd_link_add_symbols
,
2628 _bfd_generic_link_just_syms
,
2629 _bfd_generic_copy_link_hash_symbol_type
,
2630 _bfd_xcoff_bfd_final_link
,
2631 _bfd_generic_link_split_section
,
2632 _bfd_generic_link_check_relocs
,
2633 bfd_generic_gc_sections
,
2634 bfd_generic_lookup_section_flags
,
2635 bfd_generic_merge_sections
,
2636 bfd_generic_is_group_section
,
2637 bfd_generic_group_name
,
2638 bfd_generic_discard_group
,
2639 _bfd_generic_section_already_linked
,
2640 _bfd_xcoff_define_common_symbol
,
2641 _bfd_generic_link_hide_symbol
,
2642 bfd_generic_define_start_stop
,
2645 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
2646 _bfd_xcoff_canonicalize_dynamic_symtab
,
2647 _bfd_nodynamic_get_synthetic_symtab
,
2648 _bfd_xcoff_get_dynamic_reloc_upper_bound
,
2649 _bfd_xcoff_canonicalize_dynamic_reloc
,
2651 /* Opposite endian version, none exists */
2654 &bfd_xcoff_backend_data
,
2657 extern bfd_cleanup xcoff64_core_p
2659 extern bool xcoff64_core_file_matches_executable_p
2661 extern char *xcoff64_core_file_failing_command
2663 extern int xcoff64_core_file_failing_signal
2665 #define xcoff64_core_file_pid _bfd_nocore_core_file_pid
2668 static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data
=
2670 { /* COFF backend, defined in libcoff.h. */
2671 _bfd_xcoff64_swap_aux_in
,
2672 _bfd_xcoff64_swap_sym_in
,
2673 _bfd_xcoff64_swap_lineno_in
,
2674 _bfd_xcoff64_swap_aux_out
,
2675 _bfd_xcoff64_swap_sym_out
,
2676 _bfd_xcoff64_swap_lineno_out
,
2677 xcoff64_swap_reloc_out
,
2678 coff_swap_filehdr_out
,
2679 coff_swap_aouthdr_out
,
2680 coff_swap_scnhdr_out
,
2689 true, /* _bfd_coff_long_filenames */
2690 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
2691 3, /* _bfd_coff_default_section_alignment_power */
2692 true, /* _bfd_coff_force_symnames_in_strings */
2693 4, /* _bfd_coff_debug_string_prefix_length */
2694 32768, /* _bfd_coff_max_nscns */
2695 coff_swap_filehdr_in
,
2696 coff_swap_aouthdr_in
,
2697 coff_swap_scnhdr_in
,
2698 xcoff64_swap_reloc_in
,
2699 xcoff64_bad_format_hook
,
2700 coff_set_arch_mach_hook
,
2703 coff_set_alignment_hook
,
2704 coff_slurp_symbol_table
,
2705 symname_in_debug_hook
,
2706 coff_pointerize_aux_hook
,
2708 dummy_reloc16_extra_cases
,
2709 dummy_reloc16_estimate
,
2710 NULL
, /* bfd_coff_sym_is_global */
2711 coff_compute_section_file_positions
,
2712 NULL
, /* _bfd_coff_start_final_link */
2713 xcoff64_ppc_relocate_section
,
2714 coff_rtype_to_howto
,
2715 NULL
, /* _bfd_coff_adjust_symndx */
2716 _bfd_generic_link_add_one_symbol
,
2717 coff_link_output_has_begun
,
2718 coff_final_link_postscript
,
2719 NULL
/* print_pdata. */
2722 U64_TOCMAGIC
, /* magic number */
2726 /* Function pointers to xcoff specific swap routines. */
2727 xcoff64_swap_ldhdr_in
,
2728 xcoff64_swap_ldhdr_out
,
2729 xcoff64_swap_ldsym_in
,
2730 xcoff64_swap_ldsym_out
,
2731 xcoff64_swap_ldrel_in
,
2732 xcoff64_swap_ldrel_out
,
2738 24, /* _xcoff_function_descriptor_size */
2739 0, /* _xcoff_small_aout_header_size */
2741 2, /* _xcoff_ldhdr_version */
2743 _bfd_xcoff64_put_symbol_name
,
2744 _bfd_xcoff64_put_ldsymbol_name
,
2745 &xcoff64_dynamic_reloc
,
2746 xcoff64_create_csect_from_smclas
,
2748 /* Lineno and reloc count overflow. */
2749 xcoff64_is_lineno_count_overflow
,
2750 xcoff64_is_reloc_count_overflow
,
2752 xcoff64_loader_symbol_offset
,
2753 xcoff64_loader_reloc_offset
,
2756 &xcoff64_glink_code
[0],
2757 40, /* _xcoff_glink_size */
2760 88, /* _xcoff_rtinit_size */
2761 xcoff64_generate_rtinit
,
2764 /* The transfer vector that leads the outside world to all of the above. */
2765 const bfd_target rs6000_xcoff64_aix_vec
=
2767 "aix5coff64-rs6000",
2768 bfd_target_xcoff_flavour
,
2769 BFD_ENDIAN_BIG
, /* data byte order is big */
2770 BFD_ENDIAN_BIG
, /* header byte order is big */
2772 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
2773 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
2775 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
2776 0, /* leading char */
2777 '/', /* ar_pad_char */
2778 15, /* ar_max_namelen */
2779 0, /* match priority. */
2780 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
2804 { /* bfd_check_format */
2811 { /* bfd_set_format */
2812 _bfd_bool_bfd_false_error
,
2814 _bfd_generic_mkarchive
,
2815 _bfd_bool_bfd_false_error
2818 {/* bfd_write_contents */
2819 _bfd_bool_bfd_false_error
,
2820 coff_write_object_contents
,
2821 _bfd_xcoff_write_archive_contents
,
2822 _bfd_bool_bfd_false_error
2826 _bfd_archive_close_and_cleanup
,
2828 coff_new_section_hook
,
2829 _bfd_generic_get_section_contents
,
2830 _bfd_generic_get_section_contents_in_window
,
2833 _bfd_xcoff_copy_private_bfd_data
,
2834 _bfd_generic_bfd_merge_private_bfd_data
,
2835 _bfd_generic_init_private_section_data
,
2836 _bfd_generic_bfd_copy_private_section_data
,
2837 _bfd_generic_bfd_copy_private_symbol_data
,
2838 _bfd_generic_bfd_copy_private_header_data
,
2839 _bfd_generic_bfd_set_private_flags
,
2840 _bfd_generic_bfd_print_private_bfd_data
,
2843 BFD_JUMP_TABLE_CORE (xcoff64
),
2846 xcoff64_slurp_armap
,
2847 _bfd_noarchive_slurp_extended_name_table
,
2848 _bfd_noarchive_construct_extended_name_table
,
2849 bfd_dont_truncate_arname
,
2850 _bfd_xcoff_write_armap
,
2851 _bfd_xcoff_read_ar_hdr
,
2852 _bfd_generic_write_ar_hdr
,
2853 xcoff64_openr_next_archived_file
,
2854 _bfd_generic_get_elt_at_index
,
2855 _bfd_xcoff_stat_arch_elt
,
2859 coff_get_symtab_upper_bound
,
2860 coff_canonicalize_symtab
,
2861 coff_make_empty_symbol
,
2863 coff_get_symbol_info
,
2864 coff_get_symbol_version_string
,
2865 _bfd_xcoff_is_local_label_name
,
2866 coff_bfd_is_target_special_symbol
,
2868 coff_find_nearest_line
,
2870 coff_find_inliner_info
,
2871 coff_bfd_make_debug_symbol
,
2872 _bfd_generic_read_minisymbols
,
2873 _bfd_generic_minisymbol_to_symbol
,
2876 coff_get_reloc_upper_bound
,
2877 coff_canonicalize_reloc
,
2878 _bfd_generic_set_reloc
,
2879 xcoff64_reloc_type_lookup
,
2880 xcoff64_reloc_name_lookup
,
2884 coff_set_section_contents
,
2887 xcoff64_sizeof_headers
,
2888 bfd_generic_get_relocated_section_contents
,
2889 bfd_generic_relax_section
,
2890 _bfd_xcoff_bfd_link_hash_table_create
,
2891 _bfd_xcoff_bfd_link_add_symbols
,
2892 _bfd_generic_link_just_syms
,
2893 _bfd_generic_copy_link_hash_symbol_type
,
2894 _bfd_xcoff_bfd_final_link
,
2895 _bfd_generic_link_split_section
,
2896 _bfd_generic_link_check_relocs
,
2897 bfd_generic_gc_sections
,
2898 bfd_generic_lookup_section_flags
,
2899 bfd_generic_merge_sections
,
2900 bfd_generic_is_group_section
,
2901 bfd_generic_group_name
,
2902 bfd_generic_discard_group
,
2903 _bfd_generic_section_already_linked
,
2904 _bfd_xcoff_define_common_symbol
,
2905 _bfd_generic_link_hide_symbol
,
2906 bfd_generic_define_start_stop
,
2909 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
2910 _bfd_xcoff_canonicalize_dynamic_symtab
,
2911 _bfd_nodynamic_get_synthetic_symtab
,
2912 _bfd_xcoff_get_dynamic_reloc_upper_bound
,
2913 _bfd_xcoff_canonicalize_dynamic_reloc
,
2915 /* Opposite endian version, none exists. */
2918 & bfd_xcoff_aix5_backend_data
,