1 /* BFD back-end for IBM RS/6000 "XCOFF64" files.
2 Copyright (C) 2000-2021 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_zeroes
= 0;
390 in
->x_file
.x_n
.x_offset
=
391 H_GET_32 (abfd
, ext
->x_file
.x_n
.x_n
.x_offset
);
394 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_n
.x_fname
, FILNMLEN
);
397 /* RS/6000 "csect" auxents.
398 There is always a CSECT auxiliary entry. But functions can
399 have FCN and EXCEPT ones too. In this case, CSECT is always the last
401 For now, we only support FCN types. */
405 if (indx
+ 1 == numaux
)
407 /* C_EXT can have several aux enties. But the _AUX_CSECT is always
409 auxtype
= H_GET_8 (abfd
, ext
->x_csect
.x_auxtype
);
410 if (auxtype
!= _AUX_CSECT
)
413 bfd_signed_vma h
= 0;
416 h
= H_GET_S32 (abfd
, ext
->x_csect
.x_scnlen_hi
);
417 l
= H_GET_32 (abfd
, ext
->x_csect
.x_scnlen_lo
);
419 in
->x_csect
.x_scnlen
.l
= h
<< 32 | (l
& 0xffffffff);
421 in
->x_csect
.x_parmhash
= H_GET_32 (abfd
, ext
->x_csect
.x_parmhash
);
422 in
->x_csect
.x_snhash
= H_GET_16 (abfd
, ext
->x_csect
.x_snhash
);
423 /* We don't have to hack bitfields in x_smtyp because it's
424 defined by shifts-and-ands, which are equivalent on all
426 in
->x_csect
.x_smtyp
= H_GET_8 (abfd
, ext
->x_csect
.x_smtyp
);
427 in
->x_csect
.x_smclas
= H_GET_8 (abfd
, ext
->x_csect
.x_smclas
);
431 /* It can also be a _AUX_EXCEPT entry. But it's not supported
433 auxtype
= H_GET_8 (abfd
, ext
->x_fcn
.x_auxtype
);
434 if (auxtype
!= _AUX_FCN
)
437 in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
438 = H_GET_64 (abfd
, ext
->x_fcn
.x_lnnoptr
);
439 in
->x_sym
.x_misc
.x_fsize
440 = H_GET_32 (abfd
, ext
->x_fcn
.x_fsize
);
441 in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
442 = H_GET_32 (abfd
, ext
->x_fcn
.x_endndx
);
448 /* xgettext: c-format */
449 (_("%pB: C_STAT isn't supported by XCOFF64"),
451 bfd_set_error (bfd_error_bad_value
);
456 auxtype
= H_GET_8 (abfd
, ext
->x_sym
.x_auxtype
);
457 if (auxtype
!= _AUX_SYM
)
460 in
->x_sym
.x_misc
.x_lnsz
.x_lnno
461 = H_GET_32 (abfd
, ext
->x_sym
.x_lnno
);
465 auxtype
= H_GET_8 (abfd
, ext
->x_sect
.x_auxtype
);
466 if (auxtype
!= _AUX_SECT
)
469 in
->x_sect
.x_scnlen
= H_GET_64 (abfd
, ext
->x_sect
.x_scnlen
);
470 in
->x_sect
.x_nreloc
= H_GET_64 (abfd
, ext
->x_sect
.x_nreloc
);
478 /* xgettext: c-format */
479 (_("%pB: wrong auxtype %#x for storage class %#x"),
480 abfd
, auxtype
, (unsigned int) in_class
);
481 bfd_set_error (bfd_error_bad_value
);
487 _bfd_xcoff64_swap_aux_out (bfd
*abfd
, void *inp
, int type ATTRIBUTE_UNUSED
,
488 int in_class
, int indx
, int numaux
, void *extp
)
490 union internal_auxent
*in
= (union internal_auxent
*) inp
;
491 union external_auxent
*ext
= (union external_auxent
*) extp
;
493 memset (ext
, 0, bfd_coff_auxesz (abfd
));
498 /* xgettext: c-format */
499 (_("%pB: unsupported swap_aux_out for storage class %#x"),
500 abfd
, (unsigned int) in_class
);
501 bfd_set_error (bfd_error_bad_value
);
505 if (in
->x_file
.x_n
.x_zeroes
== 0)
507 H_PUT_32 (abfd
, 0, ext
->x_file
.x_n
.x_n
.x_zeroes
);
508 H_PUT_32 (abfd
, in
->x_file
.x_n
.x_offset
,
509 ext
->x_file
.x_n
.x_n
.x_offset
);
512 memcpy (ext
->x_file
.x_n
.x_fname
, in
->x_file
.x_fname
, FILNMLEN
);
513 H_PUT_8 (abfd
, _AUX_FILE
, ext
->x_file
.x_auxtype
);
516 /* RS/6000 "csect" auxents.
517 There is always a CSECT auxiliary entry. But functions can
518 have FCN and EXCEPT ones too. In this case, CSECT is always the last
520 For now, we only support FCN types. */
524 if (indx
+ 1 == numaux
)
528 temp
= in
->x_csect
.x_scnlen
.l
& 0xffffffff;
529 H_PUT_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_lo
);
530 temp
= in
->x_csect
.x_scnlen
.l
>> 32;
531 H_PUT_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_hi
);
532 H_PUT_32 (abfd
, in
->x_csect
.x_parmhash
, ext
->x_csect
.x_parmhash
);
533 H_PUT_16 (abfd
, in
->x_csect
.x_snhash
, ext
->x_csect
.x_snhash
);
534 /* We don't have to hack bitfields in x_smtyp because it's
535 defined by shifts-and-ands, which are equivalent on all
537 H_PUT_8 (abfd
, in
->x_csect
.x_smtyp
, ext
->x_csect
.x_smtyp
);
538 H_PUT_8 (abfd
, in
->x_csect
.x_smclas
, ext
->x_csect
.x_smclas
);
539 H_PUT_8 (abfd
, _AUX_CSECT
, ext
->x_csect
.x_auxtype
);
543 H_PUT_64 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
,
544 ext
->x_fcn
.x_lnnoptr
);
545 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_fsize
, ext
->x_fcn
.x_fsize
);
546 H_PUT_32 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
,
547 ext
->x_fcn
.x_endndx
);
548 H_PUT_8 (abfd
, _AUX_FCN
, ext
->x_csect
.x_auxtype
);
554 /* xgettext: c-format */
555 (_("%pB: C_STAT isn't supported by XCOFF64"),
557 bfd_set_error (bfd_error_bad_value
);
562 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_lnno
, ext
->x_sym
.x_lnno
);
563 H_PUT_8 (abfd
, _AUX_SYM
, ext
->x_sym
.x_auxtype
);
567 H_PUT_64 (abfd
, in
->x_sect
.x_scnlen
, ext
->x_sect
.x_scnlen
);
568 H_PUT_64 (abfd
, in
->x_sect
.x_nreloc
, ext
->x_sect
.x_nreloc
);
569 H_PUT_8 (abfd
, _AUX_SECT
, ext
->x_sect
.x_auxtype
);
573 return bfd_coff_auxesz (abfd
);
577 _bfd_xcoff64_put_symbol_name (struct bfd_link_info
*info
,
578 struct bfd_strtab_hash
*strtab
,
579 struct internal_syment
*sym
,
585 hash
= !info
->traditional_format
;
586 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
588 if (indx
== (bfd_size_type
) -1)
591 sym
->_n
._n_n
._n_zeroes
= 0;
592 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
598 _bfd_xcoff64_put_ldsymbol_name (bfd
*abfd ATTRIBUTE_UNUSED
,
599 struct xcoff_loader_info
*ldinfo
,
600 struct internal_ldsym
*ldsym
,
606 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
)
608 bfd_size_type newalc
;
611 newalc
= ldinfo
->string_alc
* 2;
614 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
617 newstrings
= bfd_realloc (ldinfo
->strings
, newalc
);
618 if (newstrings
== NULL
)
620 ldinfo
->failed
= true;
623 ldinfo
->string_alc
= newalc
;
624 ldinfo
->strings
= newstrings
;
627 bfd_put_16 (ldinfo
->output_bfd
, (bfd_vma
) (len
+ 1),
628 ldinfo
->strings
+ ldinfo
->string_size
);
629 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
630 ldsym
->_l
._l_l
._l_zeroes
= 0;
631 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
632 ldinfo
->string_size
+= len
+ 3;
637 /* Routines to swap information in the XCOFF .loader section. If we
638 ever need to write an XCOFF loader, this stuff will need to be
639 moved to another file shared by the linker (which XCOFF calls the
640 ``binder'') and the loader. */
642 /* Swap in the ldhdr structure. */
645 xcoff64_swap_ldhdr_in (bfd
*abfd
,
647 struct internal_ldhdr
*dst
)
649 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
651 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
652 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
653 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
654 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
655 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
656 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
657 dst
->l_impoff
= bfd_get_64 (abfd
, src
->l_impoff
);
658 dst
->l_stoff
= bfd_get_64 (abfd
, src
->l_stoff
);
659 dst
->l_symoff
= bfd_get_64 (abfd
, src
->l_symoff
);
660 dst
->l_rldoff
= bfd_get_64 (abfd
, src
->l_rldoff
);
663 /* Swap out the ldhdr structure. */
666 xcoff64_swap_ldhdr_out (bfd
*abfd
, const struct internal_ldhdr
*src
, void *d
)
668 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
670 bfd_put_32 (abfd
, (bfd_vma
) src
->l_version
, dst
->l_version
);
671 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
672 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
673 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
674 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
675 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
676 bfd_put_64 (abfd
, src
->l_impoff
, dst
->l_impoff
);
677 bfd_put_64 (abfd
, src
->l_stoff
, dst
->l_stoff
);
678 bfd_put_64 (abfd
, src
->l_symoff
, dst
->l_symoff
);
679 bfd_put_64 (abfd
, src
->l_rldoff
, dst
->l_rldoff
);
682 /* Swap in the ldsym structure. */
685 xcoff64_swap_ldsym_in (bfd
*abfd
, const void *s
, struct internal_ldsym
*dst
)
687 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
688 /* XCOFF64 does not use l_zeroes like XCOFF32
689 Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
690 as an offset into the loader symbol table. */
691 dst
->_l
._l_l
._l_zeroes
= 0;
692 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->l_offset
);
693 dst
->l_value
= bfd_get_64 (abfd
, src
->l_value
);
694 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
695 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
696 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
697 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
698 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
701 /* Swap out the ldsym structure. */
704 xcoff64_swap_ldsym_out (bfd
*abfd
, const struct internal_ldsym
*src
, void *d
)
706 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
708 bfd_put_64 (abfd
, src
->l_value
, dst
->l_value
);
709 bfd_put_32 (abfd
, (bfd_vma
) src
->_l
._l_l
._l_offset
, dst
->l_offset
);
710 bfd_put_16 (abfd
, (bfd_vma
) src
->l_scnum
, dst
->l_scnum
);
711 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
712 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
713 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
714 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
718 xcoff64_swap_reloc_in (bfd
*abfd
, void *s
, void *d
)
720 struct external_reloc
*src
= (struct external_reloc
*) s
;
721 struct internal_reloc
*dst
= (struct internal_reloc
*) d
;
723 memset (dst
, 0, sizeof (struct internal_reloc
));
725 dst
->r_vaddr
= bfd_get_64 (abfd
, src
->r_vaddr
);
726 dst
->r_symndx
= bfd_get_32 (abfd
, src
->r_symndx
);
727 dst
->r_size
= bfd_get_8 (abfd
, src
->r_size
);
728 dst
->r_type
= bfd_get_8 (abfd
, src
->r_type
);
732 xcoff64_swap_reloc_out (bfd
*abfd
, void *s
, void *d
)
734 struct internal_reloc
*src
= (struct internal_reloc
*) s
;
735 struct external_reloc
*dst
= (struct external_reloc
*) d
;
737 bfd_put_64 (abfd
, src
->r_vaddr
, dst
->r_vaddr
);
738 bfd_put_32 (abfd
, src
->r_symndx
, dst
->r_symndx
);
739 bfd_put_8 (abfd
, src
->r_type
, dst
->r_type
);
740 bfd_put_8 (abfd
, src
->r_size
, dst
->r_size
);
742 return bfd_coff_relsz (abfd
);
745 /* Swap in the ldrel structure. */
748 xcoff64_swap_ldrel_in (bfd
*abfd
, const void *s
, struct internal_ldrel
*dst
)
750 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
752 dst
->l_vaddr
= bfd_get_64 (abfd
, src
->l_vaddr
);
753 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
754 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
755 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
758 /* Swap out the ldrel structure. */
761 xcoff64_swap_ldrel_out (bfd
*abfd
, const struct internal_ldrel
*src
, void *d
)
763 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
765 bfd_put_64 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
766 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rtype
, dst
->l_rtype
);
767 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rsecnm
, dst
->l_rsecnm
);
768 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
773 xcoff64_reloc_type_br (bfd
*input_bfd
,
774 asection
*input_section
,
775 bfd
*output_bfd ATTRIBUTE_UNUSED
,
776 struct internal_reloc
*rel
,
777 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
778 struct reloc_howto_struct
*howto
,
784 struct xcoff_link_hash_entry
*h
;
785 bfd_vma section_offset
;
787 if (0 > rel
->r_symndx
)
790 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
791 section_offset
= rel
->r_vaddr
- input_section
->vma
;
793 /* If we see an R_BR or R_RBR reloc which is jumping to global
794 linkage code, and it is followed by an appropriate cror nop
795 instruction, we replace the cror with ld r2,40(r1). This
796 restores the TOC after the glink code. Contrariwise, if the
797 call is followed by a ld r2,40(r1), but the call is not
798 going to global linkage code, we can replace the load with a
801 && (bfd_link_hash_defined
== h
->root
.type
802 || bfd_link_hash_defweak
== h
->root
.type
)
803 && section_offset
+ 8 <= input_section
->size
)
808 pnext
= contents
+ section_offset
+ 4;
809 next
= bfd_get_32 (input_bfd
, pnext
);
811 /* The _ptrgl function is magic. It is used by the AIX compiler to call
812 a function through a pointer. */
813 if (h
->smclas
== XMC_GL
|| strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
815 if (next
== 0x4def7b82 /* cror 15,15,15 */
816 || next
== 0x4ffffb82 /* cror 31,31,31 */
817 || next
== 0x60000000) /* ori r0,r0,0 */
818 bfd_put_32 (input_bfd
, 0xe8410028, pnext
); /* ld r2,40(r1) */
822 if (next
== 0xe8410028) /* ld r2,40(r1) */
823 bfd_put_32 (input_bfd
, 0x60000000, pnext
); /* ori r0,r0,0 */
826 else if (NULL
!= h
&& bfd_link_hash_undefined
== h
->root
.type
)
828 /* Normally, this relocation is against a defined symbol. In the
829 case where this is a partial link and the output section offset
830 is greater than 2^25, the linker will return an invalid error
831 message that the relocation has been truncated. Yes it has been
832 truncated but no it not important. For this case, disable the
833 overflow checking. */
834 howto
->complain_on_overflow
= complain_overflow_dont
;
837 /* The original PC-relative relocation is biased by -r_vaddr, so adding
838 the value below will give the absolute target address. */
839 *relocation
= val
+ addend
+ rel
->r_vaddr
;
841 howto
->src_mask
&= ~3;
842 howto
->dst_mask
= howto
->src_mask
;
845 && (h
->root
.type
== bfd_link_hash_defined
846 || h
->root
.type
== bfd_link_hash_defweak
)
847 && bfd_is_abs_section (h
->root
.u
.def
.section
)
848 && section_offset
+ 4 <= input_section
->size
)
853 /* Turn the relative branch into an absolute one by setting the
855 ptr
= contents
+ section_offset
;
856 insn
= bfd_get_32 (input_bfd
, ptr
);
858 bfd_put_32 (input_bfd
, insn
, ptr
);
860 /* Make the howto absolute too. */
861 howto
->pc_relative
= false;
862 howto
->complain_on_overflow
= complain_overflow_bitfield
;
866 /* Use a PC-relative howto and subtract the instruction's address
867 from the target address we calculated above. */
868 howto
->pc_relative
= true;
869 *relocation
-= (input_section
->output_section
->vma
870 + input_section
->output_offset
878 /* The XCOFF reloc table.
879 Cf xcoff_howto_table comments. */
881 reloc_howto_type xcoff64_howto_table
[] =
883 /* 0x00: Standard 64 bit relocation. */
884 HOWTO (R_POS
, /* type */
886 4, /* size (0 = byte, 1 = short, 2 = long) */
888 false, /* pc_relative */
890 complain_overflow_bitfield
, /* complain_on_overflow */
891 0, /* special_function */
892 "R_POS_64", /* name */
893 true, /* partial_inplace */
894 MINUS_ONE
, /* src_mask */
895 MINUS_ONE
, /* dst_mask */
896 false), /* pcrel_offset */
898 /* 0x01: 64 bit relocation, but store negative value. */
899 HOWTO (R_NEG
, /* type */
901 -4, /* size (0 = byte, 1 = short, 2 = long) */
903 false, /* pc_relative */
905 complain_overflow_bitfield
, /* complain_on_overflow */
906 0, /* special_function */
908 true, /* partial_inplace */
909 MINUS_ONE
, /* src_mask */
910 MINUS_ONE
, /* dst_mask */
911 false), /* pcrel_offset */
913 /* 0x02: 64 bit PC relative relocation. */
914 HOWTO (R_REL
, /* type */
916 4, /* size (0 = byte, 1 = short, 2 = long) */
918 true, /* pc_relative */
920 complain_overflow_signed
, /* complain_on_overflow */
921 0, /* special_function */
923 true, /* partial_inplace */
924 MINUS_ONE
, /* src_mask */
925 MINUS_ONE
, /* dst_mask */
926 false), /* pcrel_offset */
928 /* 0x03: 16 bit TOC relative relocation. */
929 HOWTO (R_TOC
, /* type */
931 1, /* size (0 = byte, 1 = short, 2 = long) */
933 false, /* pc_relative */
935 complain_overflow_bitfield
, /* complain_on_overflow */
936 0, /* special_function */
938 true, /* partial_inplace */
940 0xffff, /* dst_mask */
941 false), /* pcrel_offset */
943 /* 0x04: Same as R_TOC. */
944 HOWTO (R_TRL
, /* type */
946 1, /* size (0 = byte, 1 = short, 2 = long) */
948 false, /* pc_relative */
950 complain_overflow_bitfield
, /* complain_on_overflow */
951 0, /* special_function */
953 true, /* partial_inplace */
955 0xffff, /* dst_mask */
956 false), /* pcrel_offset */
958 /* 0x05: External TOC relative symbol. */
959 HOWTO (R_GL
, /* type */
961 1, /* size (0 = byte, 1 = short, 2 = long) */
963 false, /* pc_relative */
965 complain_overflow_bitfield
, /* complain_on_overflow */
966 0, /* special_function */
968 true, /* partial_inplace */
970 0xffff, /* dst_mask */
971 false), /* pcrel_offset */
973 /* 0x06: Local TOC relative symbol. */
974 HOWTO (R_TCL
, /* type */
976 1, /* size (0 = byte, 1 = short, 2 = long) */
978 false, /* pc_relative */
980 complain_overflow_bitfield
, /* complain_on_overflow */
981 0, /* special_function */
983 true, /* partial_inplace */
985 0xffff, /* dst_mask */
986 false), /* pcrel_offset */
990 /* 0x08: Same as R_RBA. */
991 HOWTO (R_BA
, /* type */
993 2, /* size (0 = byte, 1 = short, 2 = long) */
995 false, /* pc_relative */
997 complain_overflow_bitfield
, /* complain_on_overflow */
998 0, /* special_function */
999 "R_BA_26", /* name */
1000 true, /* partial_inplace */
1001 0x03fffffc, /* src_mask */
1002 0x03fffffc, /* dst_mask */
1003 false), /* pcrel_offset */
1007 /* 0x0a: Same as R_RBR. */
1008 HOWTO (R_BR
, /* type */
1010 2, /* size (0 = byte, 1 = short, 2 = long) */
1012 true, /* pc_relative */
1014 complain_overflow_signed
, /* complain_on_overflow */
1015 0, /* special_function */
1017 true, /* partial_inplace */
1018 0x03fffffc, /* src_mask */
1019 0x03fffffc, /* dst_mask */
1020 false), /* pcrel_offset */
1024 /* 0x0c: Same as R_POS. */
1025 HOWTO (R_RL
, /* type */
1027 4, /* size (0 = byte, 1 = short, 2 = long) */
1029 false, /* pc_relative */
1031 complain_overflow_bitfield
, /* complain_on_overflow */
1032 0, /* special_function */
1034 true, /* partial_inplace */
1035 MINUS_ONE
, /* src_mask */
1036 MINUS_ONE
, /* dst_mask */
1037 false), /* pcrel_offset */
1039 /* 0x0d: Same as R_POS. */
1040 HOWTO (R_RLA
, /* type */
1042 4, /* size (0 = byte, 1 = short, 2 = long) */
1044 false, /* pc_relative */
1046 complain_overflow_bitfield
, /* complain_on_overflow */
1047 0, /* special_function */
1049 true, /* partial_inplace */
1050 MINUS_ONE
, /* src_mask */
1051 MINUS_ONE
, /* dst_mask */
1052 false), /* pcrel_offset */
1056 /* 0x0f: Non-relocating reference. Bitsize is 1 so that r_rsize is 0. */
1057 HOWTO (R_REF
, /* type */
1059 0, /* size (0 = byte, 1 = short, 2 = long) */
1061 false, /* pc_relative */
1063 complain_overflow_dont
, /* complain_on_overflow */
1064 0, /* special_function */
1066 false, /* partial_inplace */
1069 false), /* pcrel_offset */
1075 /* 0x13: Same as R_TOC */
1076 HOWTO (R_TRLA
, /* type */
1078 1, /* size (0 = byte, 1 = short, 2 = long) */
1080 false, /* pc_relative */
1082 complain_overflow_bitfield
, /* complain_on_overflow */
1083 0, /* special_function */
1084 "R_TRLA", /* name */
1085 true, /* partial_inplace */
1086 0xffff, /* src_mask */
1087 0xffff, /* dst_mask */
1088 false), /* pcrel_offset */
1090 /* 0x14: Modifiable relative branch. */
1091 HOWTO (R_RRTBI
, /* type */
1093 2, /* size (0 = byte, 1 = short, 2 = long) */
1095 false, /* pc_relative */
1097 complain_overflow_bitfield
, /* complain_on_overflow */
1098 0, /* special_function */
1099 "R_RRTBI", /* name */
1100 true, /* partial_inplace */
1101 0xffffffff, /* src_mask */
1102 0xffffffff, /* dst_mask */
1103 false), /* pcrel_offset */
1105 /* 0x15: Modifiable absolute branch. */
1106 HOWTO (R_RRTBA
, /* type */
1108 2, /* size (0 = byte, 1 = short, 2 = long) */
1110 false, /* pc_relative */
1112 complain_overflow_bitfield
, /* complain_on_overflow */
1113 0, /* special_function */
1114 "R_RRTBA", /* name */
1115 true, /* partial_inplace */
1116 0xffffffff, /* src_mask */
1117 0xffffffff, /* dst_mask */
1118 false), /* pcrel_offset */
1120 /* 0x16: Modifiable call absolute indirect. */
1121 HOWTO (R_CAI
, /* type */
1123 1, /* size (0 = byte, 1 = short, 2 = long) */
1125 false, /* pc_relative */
1127 complain_overflow_bitfield
, /* complain_on_overflow */
1128 0, /* special_function */
1130 true, /* partial_inplace */
1131 0xffff, /* src_mask */
1132 0xffff, /* dst_mask */
1133 false), /* pcrel_offset */
1135 /* 0x17: Modifiable call relative. */
1136 HOWTO (R_CREL
, /* type */
1138 1, /* size (0 = byte, 1 = short, 2 = long) */
1140 false, /* pc_relative */
1142 complain_overflow_bitfield
, /* complain_on_overflow */
1143 0, /* special_function */
1144 "R_CREL", /* name */
1145 true, /* partial_inplace */
1146 0xffff, /* src_mask */
1147 0xffff, /* dst_mask */
1148 false), /* pcrel_offset */
1150 /* 0x18: Modifiable branch absolute. */
1151 HOWTO (R_RBA
, /* type */
1153 2, /* size (0 = byte, 1 = short, 2 = long) */
1155 false, /* pc_relative */
1157 complain_overflow_bitfield
, /* complain_on_overflow */
1158 0, /* special_function */
1160 true, /* partial_inplace */
1161 0x03fffffc, /* src_mask */
1162 0x03fffffc, /* dst_mask */
1163 false), /* pcrel_offset */
1165 /* 0x19: Modifiable branch absolute. */
1166 HOWTO (R_RBAC
, /* type */
1168 2, /* size (0 = byte, 1 = short, 2 = long) */
1170 false, /* pc_relative */
1172 complain_overflow_bitfield
, /* complain_on_overflow */
1173 0, /* special_function */
1174 "R_RBAC", /* name */
1175 true, /* partial_inplace */
1176 0xffffffff, /* src_mask */
1177 0xffffffff, /* dst_mask */
1178 false), /* pcrel_offset */
1180 /* 0x1a: Modifiable branch relative. */
1181 HOWTO (R_RBR
, /* type */
1183 2, /* size (0 = byte, 1 = short, 2 = long) */
1185 false, /* pc_relative */
1187 complain_overflow_signed
, /* complain_on_overflow */
1188 0, /* special_function */
1189 "R_RBR_26", /* name */
1190 true, /* partial_inplace */
1191 0x03fffffc, /* src_mask */
1192 0x03fffffc, /* dst_mask */
1193 false), /* pcrel_offset */
1195 /* 0x1b: Modifiable branch absolute. */
1196 HOWTO (R_RBRC
, /* type */
1198 1, /* size (0 = byte, 1 = short, 2 = long) */
1200 false, /* pc_relative */
1202 complain_overflow_bitfield
, /* complain_on_overflow */
1203 0, /* special_function */
1204 "R_RBRC", /* name */
1205 true, /* partial_inplace */
1206 0xffff, /* src_mask */
1207 0xffff, /* dst_mask */
1208 false), /* pcrel_offset */
1210 /* 0x1c: Standard 32 bit relocation. */
1211 HOWTO (R_POS
, /* type */
1213 2, /* size (0 = byte, 1 = short, 2 = long) */
1215 false, /* pc_relative */
1217 complain_overflow_bitfield
, /* complain_on_overflow */
1218 0, /* special_function */
1219 "R_POS_32", /* name */
1220 true, /* partial_inplace */
1221 0xffffffff, /* src_mask */
1222 0xffffffff, /* dst_mask */
1223 false), /* pcrel_offset */
1225 /* 0x1d: 16 bit Non modifiable absolute branch. */
1226 HOWTO (R_BA
, /* type */
1228 1, /* size (0 = byte, 1 = short, 2 = long) */
1230 false, /* pc_relative */
1232 complain_overflow_bitfield
, /* complain_on_overflow */
1233 0, /* special_function */
1234 "R_BA_16", /* name */
1235 true, /* partial_inplace */
1236 0xfffc, /* src_mask */
1237 0xfffc, /* dst_mask */
1238 false), /* pcrel_offset */
1240 /* 0x1e: Modifiable branch relative. */
1241 HOWTO (R_RBR
, /* type */
1243 1, /* size (0 = byte, 1 = short, 2 = long) */
1245 true, /* pc_relative */
1247 complain_overflow_signed
, /* complain_on_overflow */
1248 0, /* special_function */
1249 "R_RBR_16", /* name */
1250 true, /* partial_inplace */
1251 0xfffc, /* src_mask */
1252 0xfffc, /* dst_mask */
1253 false), /* pcrel_offset */
1255 /* 0x1f: Modifiable branch absolute. */
1256 HOWTO (R_RBA
, /* type */
1258 1, /* size (0 = byte, 1 = short, 2 = long) */
1260 false, /* pc_relative */
1262 complain_overflow_bitfield
, /* complain_on_overflow */
1263 0, /* special_function */
1264 "R_RBA_16", /* name */
1265 true, /* partial_inplace */
1266 0xffff, /* src_mask */
1267 0xffff, /* dst_mask */
1268 false), /* pcrel_offset */
1270 /* 0x20: General-dynamic TLS relocation. */
1271 HOWTO (R_TLS
, /* type */
1273 4, /* size (0 = byte, 1 = short, 2 = long) */
1275 false, /* pc_relative */
1277 complain_overflow_bitfield
, /* complain_on_overflow */
1278 0, /* special_function */
1280 true, /* partial_inplace */
1281 MINUS_ONE
, /* src_mask */
1282 MINUS_ONE
, /* dst_mask */
1283 false), /* pcrel_offset */
1285 /* 0x21: Initial-exec TLS relocation. */
1286 HOWTO (R_TLS_IE
, /* type */
1288 4, /* size (0 = byte, 1 = short, 2 = long) */
1290 false, /* pc_relative */
1292 complain_overflow_bitfield
, /* complain_on_overflow */
1293 0, /* special_function */
1294 "R_TLS_IE", /* name */
1295 true, /* partial_inplace */
1296 MINUS_ONE
, /* src_mask */
1297 MINUS_ONE
, /* dst_mask */
1298 false), /* pcrel_offset */
1300 /* 0x22: Local-dynamic TLS relocation. */
1301 HOWTO (R_TLS_LD
, /* type */
1303 4, /* size (0 = byte, 1 = short, 2 = long) */
1305 false, /* pc_relative */
1307 complain_overflow_bitfield
, /* complain_on_overflow */
1308 0, /* special_function */
1309 "R_TLS_LD", /* name */
1310 true, /* partial_inplace */
1311 MINUS_ONE
, /* src_mask */
1312 MINUS_ONE
, /* dst_mask */
1313 false), /* pcrel_offset */
1315 /* 0x23: Local-exec TLS relocation. */
1316 HOWTO (R_TLS_LE
, /* type */
1318 4, /* size (0 = byte, 1 = short, 2 = long) */
1320 false, /* pc_relative */
1322 complain_overflow_bitfield
, /* complain_on_overflow */
1323 0, /* special_function */
1324 "R_TLS_LE", /* name */
1325 true, /* partial_inplace */
1326 MINUS_ONE
, /* src_mask */
1327 MINUS_ONE
, /* dst_mask */
1328 false), /* pcrel_offset */
1330 /* 0x24: TLS relocation. */
1331 HOWTO (R_TLSM
, /* type */
1333 4, /* size (0 = byte, 1 = short, 2 = long) */
1335 false, /* pc_relative */
1337 complain_overflow_bitfield
, /* complain_on_overflow */
1338 0, /* special_function */
1339 "R_TLSM", /* name */
1340 true, /* partial_inplace */
1341 MINUS_ONE
, /* src_mask */
1342 MINUS_ONE
, /* dst_mask */
1343 false), /* pcrel_offset */
1345 /* 0x25: TLS module relocation. */
1346 HOWTO (R_TLSML
, /* type */
1348 4, /* size (0 = byte, 1 = short, 2 = long) */
1350 false, /* pc_relative */
1352 complain_overflow_bitfield
, /* complain_on_overflow */
1353 0, /* special_function */
1354 "R_TLSM", /* name */
1355 true, /* partial_inplace */
1356 MINUS_ONE
, /* src_mask */
1357 MINUS_ONE
, /* dst_mask */
1358 false), /* pcrel_offset */
1360 /* 0x26: 32 bit relocation, but store negative value. */
1361 HOWTO (R_NEG
, /* type */
1363 -2, /* size (0 = byte, 1 = short, 2 = long) */
1365 false, /* pc_relative */
1367 complain_overflow_bitfield
, /* complain_on_overflow */
1368 0, /* special_function */
1369 "R_NEG_32", /* name */
1370 true, /* partial_inplace */
1371 MINUS_ONE
, /* src_mask */
1372 MINUS_ONE
, /* dst_mask */
1373 false), /* pcrel_offset */
1385 HOWTO (R_TOCU
, /* type */
1386 16, /* rightshift */
1387 1, /* size (0 = byte, 1 = short, 2 = long) */
1389 false, /* pc_relative */
1391 complain_overflow_bitfield
, /* complain_on_overflow */
1392 0, /* special_function */
1393 "R_TOCU", /* name */
1394 true, /* partial_inplace */
1396 0xffff, /* dst_mask */
1397 false), /* pcrel_offset */
1399 /* 0x31: Low-order 16 bit TOC relative relocation. */
1400 HOWTO (R_TOCL
, /* type */
1402 1, /* size (0 = byte, 1 = short, 2 = long) */
1404 false, /* pc_relative */
1406 complain_overflow_dont
, /* complain_on_overflow */
1407 0, /* special_function */
1408 "R_TOCL", /* name */
1409 true, /* partial_inplace */
1411 0xffff, /* dst_mask */
1412 false), /* pcrel_offset */
1417 xcoff64_rtype2howto (arelent
*relent
, struct internal_reloc
*internal
)
1419 if (internal
->r_type
> R_TOCL
)
1422 /* Default howto layout works most of the time */
1423 relent
->howto
= &xcoff64_howto_table
[internal
->r_type
];
1425 /* Special case some 16 bit reloc */
1426 if (15 == (internal
->r_size
& 0x3f))
1428 if (R_BA
== internal
->r_type
)
1429 relent
->howto
= &xcoff64_howto_table
[0x1d];
1430 else if (R_RBR
== internal
->r_type
)
1431 relent
->howto
= &xcoff64_howto_table
[0x1e];
1432 else if (R_RBA
== internal
->r_type
)
1433 relent
->howto
= &xcoff64_howto_table
[0x1f];
1435 /* Special case 32 bit */
1436 else if (31 == (internal
->r_size
& 0x3f))
1438 if (R_POS
== internal
->r_type
)
1439 relent
->howto
= &xcoff64_howto_table
[0x1c];
1441 if (R_NEG
== internal
->r_type
)
1442 relent
->howto
= &xcoff64_howto_table
[0x26];
1445 /* The r_size field of an XCOFF reloc encodes the bitsize of the
1446 relocation, as well as indicating whether it is signed or not.
1447 Doublecheck that the relocation information gathered from the
1448 type matches this information. The bitsize is not significant
1449 for R_REF relocs. */
1450 if (relent
->howto
->dst_mask
!= 0
1451 && (relent
->howto
->bitsize
1452 != ((unsigned int) internal
->r_size
& 0x3f) + 1))
1457 xcoff64_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1458 bfd_reloc_code_real_type code
)
1462 case BFD_RELOC_PPC_B26
:
1463 return &xcoff64_howto_table
[0xa];
1464 case BFD_RELOC_PPC_BA16
:
1465 return &xcoff64_howto_table
[0x1d];
1466 case BFD_RELOC_PPC_BA26
:
1467 return &xcoff64_howto_table
[8];
1468 case BFD_RELOC_PPC_TOC16
:
1469 return &xcoff64_howto_table
[3];
1470 case BFD_RELOC_PPC_TOC16_HI
:
1471 return &xcoff64_howto_table
[0x30];
1472 case BFD_RELOC_PPC_TOC16_LO
:
1473 return &xcoff64_howto_table
[0x31];
1474 case BFD_RELOC_PPC_B16
:
1475 return &xcoff64_howto_table
[0x1e];
1477 case BFD_RELOC_CTOR
:
1478 return &xcoff64_howto_table
[0x1c];
1480 return &xcoff64_howto_table
[0];
1481 case BFD_RELOC_NONE
:
1482 return &xcoff64_howto_table
[0xf];
1483 case BFD_RELOC_PPC_NEG
:
1484 return &xcoff64_howto_table
[0x1];
1485 case BFD_RELOC_PPC64_TLSGD
:
1486 return &xcoff64_howto_table
[0x20];
1487 case BFD_RELOC_PPC64_TLSIE
:
1488 return &xcoff64_howto_table
[0x21];
1489 case BFD_RELOC_PPC64_TLSLD
:
1490 return &xcoff64_howto_table
[0x22];
1491 case BFD_RELOC_PPC64_TLSLE
:
1492 return &xcoff64_howto_table
[0x23];
1493 case BFD_RELOC_PPC64_TLSM
:
1494 return &xcoff64_howto_table
[0x24];
1495 case BFD_RELOC_PPC64_TLSML
:
1496 return &xcoff64_howto_table
[0x25];
1502 static reloc_howto_type
*
1503 xcoff64_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1509 i
< sizeof (xcoff64_howto_table
) / sizeof (xcoff64_howto_table
[0]);
1511 if (xcoff64_howto_table
[i
].name
!= NULL
1512 && strcasecmp (xcoff64_howto_table
[i
].name
, r_name
) == 0)
1513 return &xcoff64_howto_table
[i
];
1518 /* This is the relocation function for the PowerPC64.
1519 See xcoff_ppc_relocation_section for more information. */
1522 xcoff64_ppc_relocate_section (bfd
*output_bfd
,
1523 struct bfd_link_info
*info
,
1525 asection
*input_section
,
1527 struct internal_reloc
*relocs
,
1528 struct internal_syment
*syms
,
1529 asection
**sections
)
1531 struct internal_reloc
*rel
;
1532 struct internal_reloc
*relend
;
1535 relend
= rel
+ input_section
->reloc_count
;
1536 for (; rel
< relend
; rel
++)
1539 struct xcoff_link_hash_entry
*h
;
1540 struct internal_syment
*sym
;
1543 struct reloc_howto_struct howto
;
1545 bfd_vma value_to_relocate
;
1549 /* Relocation type R_REF is a special relocation type which is
1550 merely used to prevent garbage collection from occurring for
1551 the csect including the symbol which it references. */
1552 if (rel
->r_type
== R_REF
)
1555 /* Retrieve default value in HOWTO table and fix up according
1556 to r_size field, if it can be different.
1557 This should be made during relocation reading but the algorithms
1558 are expecting constant howtos. */
1559 memcpy (&howto
, &xcoff64_howto_table
[rel
->r_type
], sizeof (howto
));
1560 if (howto
.bitsize
!= (rel
->r_size
& 0x3f) + 1)
1562 switch (rel
->r_type
)
1566 howto
.bitsize
= (rel
->r_size
& 0x3f) + 1;
1567 howto
.size
= howto
.bitsize
> 16 ? (howto
.bitsize
> 32 ? 4 : 2) : 1;
1568 howto
.src_mask
= howto
.dst_mask
= N_ONES (howto
.bitsize
);
1573 (_("%pB: relocation (%d) at (0x%" BFD_VMA_FMT
"x) has wrong"
1574 " r_rsize (0x%x)\n"),
1575 input_bfd
, rel
->r_type
, rel
->r_vaddr
, rel
->r_size
);
1580 howto
.complain_on_overflow
= (rel
->r_size
& 0x80
1581 ? complain_overflow_signed
1582 : complain_overflow_bitfield
);
1589 symndx
= rel
->r_symndx
;
1595 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
1596 sym
= syms
+ symndx
;
1597 addend
= - sym
->n_value
;
1601 sec
= sections
[symndx
];
1602 /* Hack to make sure we use the right TOC anchor value
1603 if this reloc is against the TOC anchor. */
1604 if (sec
->name
[3] == '0'
1605 && strcmp (sec
->name
, ".tc0") == 0)
1606 val
= xcoff_data (output_bfd
)->toc
;
1608 val
= (sec
->output_section
->vma
1609 + sec
->output_offset
1615 if (info
->unresolved_syms_in_objects
!= RM_IGNORE
1616 && (h
->flags
& XCOFF_WAS_UNDEFINED
) != 0)
1617 info
->callbacks
->undefined_symbol
1618 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
1619 rel
->r_vaddr
- input_section
->vma
,
1620 info
->unresolved_syms_in_objects
== RM_DIAGNOSE
1621 && !info
->warn_unresolved_syms
);
1623 if (h
->root
.type
== bfd_link_hash_defined
1624 || h
->root
.type
== bfd_link_hash_defweak
)
1626 sec
= h
->root
.u
.def
.section
;
1627 val
= (h
->root
.u
.def
.value
1628 + sec
->output_section
->vma
1629 + sec
->output_offset
);
1631 else if (h
->root
.type
== bfd_link_hash_common
)
1633 sec
= h
->root
.u
.c
.p
->section
;
1634 val
= (sec
->output_section
->vma
1635 + sec
->output_offset
);
1639 BFD_ASSERT (bfd_link_relocatable (info
)
1640 || (h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
1641 || (h
->flags
& XCOFF_IMPORT
) != 0);
1646 if (rel
->r_type
>= XCOFF_MAX_CALCULATE_RELOCATION
1647 || !((*xcoff64_calculate_relocation
[rel
->r_type
])
1648 (input_bfd
, input_section
, output_bfd
, rel
, sym
, &howto
, val
,
1649 addend
, &relocation
, contents
)))
1653 address
= rel
->r_vaddr
- input_section
->vma
;
1654 location
= contents
+ address
;
1656 if (address
> input_section
->size
)
1659 /* Get the value we are going to relocate. */
1660 if (1 == howto
.size
)
1661 value_to_relocate
= bfd_get_16 (input_bfd
, location
);
1662 else if (2 == howto
.size
)
1663 value_to_relocate
= bfd_get_32 (input_bfd
, location
);
1665 value_to_relocate
= bfd_get_64 (input_bfd
, location
);
1669 FIXME: We may drop bits during the addition
1670 which we don't check for. We must either check at every single
1671 operation, which would be tedious, or we must do the computations
1672 in a type larger than bfd_vma, which would be inefficient. */
1674 if (((*xcoff_complain_overflow
[howto
.complain_on_overflow
])
1675 (input_bfd
, value_to_relocate
, relocation
, &howto
)))
1678 char buf
[SYMNMLEN
+ 1];
1679 char reloc_type_name
[10];
1691 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
1695 sprintf (reloc_type_name
, "0x%02x", rel
->r_type
);
1697 (*info
->callbacks
->reloc_overflow
)
1698 (info
, (h
? &h
->root
: NULL
), name
, reloc_type_name
,
1699 (bfd_vma
) 0, input_bfd
, input_section
,
1700 rel
->r_vaddr
- input_section
->vma
);
1703 /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */
1704 value_to_relocate
= ((value_to_relocate
& ~howto
.dst_mask
)
1705 | (((value_to_relocate
& howto
.src_mask
)
1706 + relocation
) & howto
.dst_mask
));
1708 /* Put the value back in the object file. */
1709 if (1 == howto
.size
)
1710 bfd_put_16 (input_bfd
, value_to_relocate
, location
);
1711 else if (2 == howto
.size
)
1712 bfd_put_32 (input_bfd
, value_to_relocate
, location
);
1714 bfd_put_64 (input_bfd
, value_to_relocate
, location
);
1721 /* PR 21786: The PE/COFF standard does not require NUL termination for any of
1722 the ASCII fields in the archive headers. So in order to be able to extract
1723 numerical values we provide our own versions of strtol and strtoll which
1724 take a maximum length as an additional parameter. Also - just to save space,
1725 we omit the endptr return parameter, since we know that it is never used. */
1728 _bfd_strntol (const char * nptr
, int base
, unsigned int maxlen
)
1730 char buf
[24]; /* Should be enough. */
1732 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1734 memcpy (buf
, nptr
, maxlen
);
1736 return strtol (buf
, NULL
, base
);
1740 _bfd_strntoll (const char * nptr
, int base
, unsigned int maxlen
)
1742 char buf
[32]; /* Should be enough. */
1744 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1746 memcpy (buf
, nptr
, maxlen
);
1748 return strtoll (buf
, NULL
, base
);
1751 /* Macro to read an ASCII value stored in an archive header field. */
1752 #define GET_VALUE_IN_FIELD(VAR, FIELD, BASE) \
1755 (VAR) = (sizeof (VAR) > sizeof (long) \
1756 ? _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
1757 : _bfd_strntol (FIELD, BASE, sizeof FIELD)); \
1761 /* Read in the armap of an XCOFF archive. */
1764 xcoff64_slurp_armap (bfd
*abfd
)
1768 bfd_size_type sz
, amt
;
1769 bfd_byte
*contents
, *cend
;
1775 /* This is for the new format. */
1776 struct xcoff_ar_hdr_big hdr
;
1778 if (xcoff_ardata (abfd
) == NULL
)
1780 abfd
->has_armap
= false;
1784 off
= bfd_scan_vma (xcoff_ardata_big (abfd
)->symoff64
,
1785 (const char **) NULL
, 10);
1788 abfd
->has_armap
= false;
1792 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1795 /* The symbol table starts with a normal archive header. */
1796 if (bfd_bread (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR_BIG
, abfd
)
1797 != SIZEOF_AR_HDR_BIG
)
1800 /* Skip the name (normally empty). */
1801 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1802 pos
= ((namlen
+ 1) & ~(size_t) 1) + SXCOFFARFMAG
;
1803 if (bfd_seek (abfd
, pos
, SEEK_CUR
) != 0)
1806 sz
= bfd_scan_vma (hdr
.size
, (const char **) NULL
, 10);
1809 bfd_set_error (bfd_error_bad_value
);
1813 /* Read in the entire symbol table. */
1814 contents
= (bfd_byte
*) _bfd_alloc_and_read (abfd
, sz
+ 1, sz
);
1815 if (contents
== NULL
)
1818 /* Ensure strings are NULL terminated so we don't wander off the end
1822 /* The symbol table starts with an eight byte count. */
1823 c
= H_GET_64 (abfd
, contents
);
1827 bfd_set_error (bfd_error_bad_value
);
1831 amt
*= sizeof (carsym
);
1832 bfd_ardata (abfd
)->symdefs
= (carsym
*) bfd_alloc (abfd
, amt
);
1833 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1836 /* After the count comes a list of eight byte file offsets. */
1837 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1839 ++i
, ++arsym
, p
+= 8)
1840 arsym
->file_offset
= H_GET_64 (abfd
, p
);
1842 /* After the file offsets come null terminated symbol names. */
1843 cend
= contents
+ sz
;
1844 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1846 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1850 bfd_set_error (bfd_error_bad_value
);
1853 arsym
->name
= (char *) p
;
1856 bfd_ardata (abfd
)->symdef_count
= c
;
1857 abfd
->has_armap
= true;
1863 /* See if this is an NEW XCOFF archive. */
1866 xcoff64_archive_p (bfd
*abfd
)
1868 struct artdata
*tdata_hold
;
1869 char magic
[SXCOFFARMAG
];
1870 /* This is the new format. */
1871 struct xcoff_ar_file_hdr_big hdr
;
1872 size_t amt
= SXCOFFARMAG
;
1874 if (bfd_bread (magic
, amt
, abfd
) != amt
)
1876 if (bfd_get_error () != bfd_error_system_call
)
1877 bfd_set_error (bfd_error_wrong_format
);
1881 if (strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0)
1883 bfd_set_error (bfd_error_wrong_format
);
1887 /* Copy over the magic string. */
1888 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1890 /* Now read the rest of the file header. */
1891 amt
= SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
;
1892 if (bfd_bread (&hdr
.memoff
, amt
, abfd
) != amt
)
1894 if (bfd_get_error () != bfd_error_system_call
)
1895 bfd_set_error (bfd_error_wrong_format
);
1899 tdata_hold
= bfd_ardata (abfd
);
1901 amt
= sizeof (struct artdata
);
1902 bfd_ardata (abfd
) = (struct artdata
*) bfd_zalloc (abfd
, amt
);
1903 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1904 goto error_ret_restore
;
1906 /* Already cleared by bfd_zalloc above.
1907 bfd_ardata (abfd)->cache = NULL;
1908 bfd_ardata (abfd)->archive_head = NULL;
1909 bfd_ardata (abfd)->symdefs = NULL;
1910 bfd_ardata (abfd)->extended_names = NULL;
1911 bfd_ardata (abfd)->extended_names_size = 0; */
1912 bfd_ardata (abfd
)->first_file_filepos
= bfd_scan_vma (hdr
.firstmemoff
,
1913 (const char **) NULL
,
1916 amt
= SIZEOF_AR_FILE_HDR_BIG
;
1917 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, amt
);
1918 if (bfd_ardata (abfd
)->tdata
== NULL
)
1921 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1923 if (! xcoff64_slurp_armap (abfd
))
1926 bfd_release (abfd
, bfd_ardata (abfd
));
1928 bfd_ardata (abfd
) = tdata_hold
;
1932 return _bfd_no_cleanup
;
1936 /* Open the next element in an XCOFF archive. */
1939 xcoff64_openr_next_archived_file (bfd
*archive
, bfd
*last_file
)
1941 if ((xcoff_ardata (archive
) == NULL
)
1942 || ! xcoff_big_format_p (archive
))
1944 bfd_set_error (bfd_error_invalid_operation
);
1948 return _bfd_xcoff_openr_next_archived_file (archive
, last_file
);
1951 /* We can't use the usual coff_sizeof_headers routine, because AIX
1952 always uses an a.out header. */
1955 xcoff64_sizeof_headers (bfd
*abfd
,
1956 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
1960 size
= bfd_coff_filhsz (abfd
);
1962 /* Don't think the small aout header can be used since some of the
1963 old elements have been reordered past the end of the old coff
1966 if (xcoff_data (abfd
)->full_aouthdr
)
1967 size
+= bfd_coff_aoutsz (abfd
);
1969 size
+= abfd
->section_count
* bfd_coff_scnhsz (abfd
);
1974 xcoff64_create_csect_from_smclas (bfd
*abfd
, union internal_auxent
*aux
,
1975 const char *symbol_name
)
1977 asection
*return_value
= NULL
;
1979 /* Changes from 32 :
1980 .sv == 8, is only for 32 bit programs
1981 .ti == 12 and .tb == 13 are now reserved. */
1982 static const char * const names
[] =
1984 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
1985 NULL
, ".bs", ".ds", ".uc", NULL
, NULL
, NULL
, ".tc0",
1986 ".td", ".sv64", ".sv3264", NULL
, ".tl", ".ul", ".te"
1989 if ((aux
->x_csect
.x_smclas
< ARRAY_SIZE (names
))
1990 && (NULL
!= names
[aux
->x_csect
.x_smclas
]))
1993 return_value
= bfd_make_section_anyway
1994 (abfd
, names
[aux
->x_csect
.x_smclas
]);
2000 /* xgettext: c-format */
2001 (_("%pB: symbol `%s' has unrecognized smclas %d"),
2002 abfd
, symbol_name
, aux
->x_csect
.x_smclas
);
2003 bfd_set_error (bfd_error_bad_value
);
2006 return return_value
;
2010 xcoff64_is_lineno_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
,
2011 bfd_vma value ATTRIBUTE_UNUSED
)
2017 xcoff64_is_reloc_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
,
2018 bfd_vma value ATTRIBUTE_UNUSED
)
2024 xcoff64_loader_symbol_offset (bfd
*abfd ATTRIBUTE_UNUSED
,
2025 struct internal_ldhdr
*ldhdr
)
2027 return (ldhdr
->l_symoff
);
2031 xcoff64_loader_reloc_offset (bfd
*abfd ATTRIBUTE_UNUSED
,
2032 struct internal_ldhdr
*ldhdr
)
2034 return (ldhdr
->l_rldoff
);
2038 xcoff64_bad_format_hook (bfd
* abfd
, void *filehdr
)
2040 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
2042 /* Check flavor first. */
2043 if (bfd_get_flavour (abfd
) != bfd_target_xcoff_flavour
)
2046 if (bfd_xcoff_magic_number (abfd
) != internal_f
->f_magic
)
2053 xcoff64_generate_rtinit (bfd
*abfd
, const char *init
, const char *fini
,
2056 bfd_byte filehdr_ext
[FILHSZ
];
2057 bfd_byte scnhdr_ext
[SCNHSZ
* 3];
2058 bfd_byte syment_ext
[SYMESZ
* 10];
2059 bfd_byte reloc_ext
[RELSZ
* 3];
2060 bfd_byte
*data_buffer
;
2061 bfd_size_type data_buffer_size
;
2062 bfd_byte
*string_table
, *st_tmp
;
2063 bfd_size_type string_table_size
;
2065 size_t initsz
, finisz
;
2066 struct internal_filehdr filehdr
;
2067 struct internal_scnhdr text_scnhdr
;
2068 struct internal_scnhdr data_scnhdr
;
2069 struct internal_scnhdr bss_scnhdr
;
2070 struct internal_syment syment
;
2071 union internal_auxent auxent
;
2072 struct internal_reloc reloc
;
2074 char *text_name
= ".text";
2075 char *data_name
= ".data";
2076 char *bss_name
= ".bss";
2077 char *rtinit_name
= "__rtinit";
2078 char *rtld_name
= "__rtld";
2080 if (! bfd_xcoff_rtinit_size (abfd
))
2083 initsz
= (init
== NULL
? 0 : 1 + strlen (init
));
2084 finisz
= (fini
== NULL
? 0 : 1 + strlen (fini
));
2087 memset (filehdr_ext
, 0, FILHSZ
);
2088 memset (&filehdr
, 0, sizeof (struct internal_filehdr
));
2089 filehdr
.f_magic
= bfd_xcoff_magic_number (abfd
);
2090 filehdr
.f_nscns
= 3;
2091 filehdr
.f_timdat
= 0;
2092 filehdr
.f_nsyms
= 0; /* at least 6, no more than 8 */
2093 filehdr
.f_symptr
= 0; /* set below */
2094 filehdr
.f_opthdr
= 0;
2095 filehdr
.f_flags
= 0;
2097 /* Section headers. */
2098 memset (scnhdr_ext
, 0, 3 * SCNHSZ
);
2101 memset (&text_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2102 memcpy (text_scnhdr
.s_name
, text_name
, strlen (text_name
));
2103 text_scnhdr
.s_paddr
= 0;
2104 text_scnhdr
.s_vaddr
= 0;
2105 text_scnhdr
.s_size
= 0;
2106 text_scnhdr
.s_scnptr
= 0;
2107 text_scnhdr
.s_relptr
= 0;
2108 text_scnhdr
.s_lnnoptr
= 0;
2109 text_scnhdr
.s_nreloc
= 0;
2110 text_scnhdr
.s_nlnno
= 0;
2111 text_scnhdr
.s_flags
= STYP_TEXT
;
2114 memset (&data_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2115 memcpy (data_scnhdr
.s_name
, data_name
, strlen (data_name
));
2116 data_scnhdr
.s_paddr
= 0;
2117 data_scnhdr
.s_vaddr
= 0;
2118 data_scnhdr
.s_size
= 0; /* set below */
2119 data_scnhdr
.s_scnptr
= FILHSZ
+ 3 * SCNHSZ
;
2120 data_scnhdr
.s_relptr
= 0; /* set below */
2121 data_scnhdr
.s_lnnoptr
= 0;
2122 data_scnhdr
.s_nreloc
= 0; /* either 1 or 2 */
2123 data_scnhdr
.s_nlnno
= 0;
2124 data_scnhdr
.s_flags
= STYP_DATA
;
2127 memset (&bss_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2128 memcpy (bss_scnhdr
.s_name
, bss_name
, strlen (bss_name
));
2129 bss_scnhdr
.s_paddr
= 0; /* set below */
2130 bss_scnhdr
.s_vaddr
= 0; /* set below */
2131 bss_scnhdr
.s_size
= 0; /* set below */
2132 bss_scnhdr
.s_scnptr
= 0;
2133 bss_scnhdr
.s_relptr
= 0;
2134 bss_scnhdr
.s_lnnoptr
= 0;
2135 bss_scnhdr
.s_nreloc
= 0;
2136 bss_scnhdr
.s_nlnno
= 0;
2137 bss_scnhdr
.s_flags
= STYP_BSS
;
2140 0x0000 0x00000000 : rtl
2142 0x0008 0x00000018 : offset to init, or 0
2143 0x000C 0x00000038 : offset to fini, or 0
2144 0x0010 0x00000010 : size of descriptor
2145 0x0014 0x00000000 : pad
2146 0x0018 0x00000000 : init, needs a reloc
2148 0x0020 0x00000058 : offset to init name
2149 0x0024 0x00000000 : flags, padded to a word
2150 0x0028 0x00000000 : empty init
2154 0x0038 0x00000000 : fini, needs a reloc
2156 0x0040 0x00000??? : offset to fini name
2157 0x0044 0x00000000 : flags, padded to a word
2158 0x0048 0x00000000 : empty fini
2163 0x0058 + initsz fini name */
2165 data_buffer_size
= 0x0058 + initsz
+ finisz
;
2166 data_buffer_size
= (data_buffer_size
+ 7) &~ (bfd_size_type
) 7;
2168 data_buffer
= (bfd_byte
*) bfd_zmalloc (data_buffer_size
);
2169 if (data_buffer
== NULL
)
2175 bfd_put_32 (abfd
, val
, &data_buffer
[0x08]);
2177 bfd_put_32 (abfd
, val
, &data_buffer
[0x20]);
2178 memcpy (&data_buffer
[val
], init
, initsz
);
2184 bfd_put_32 (abfd
, val
, &data_buffer
[0x0C]);
2185 val
= 0x58 + initsz
;
2186 bfd_put_32 (abfd
, val
, &data_buffer
[0x40]);
2187 memcpy (&data_buffer
[val
], fini
, finisz
);
2191 bfd_put_32 (abfd
, val
, &data_buffer
[0x10]);
2192 data_scnhdr
.s_size
= data_buffer_size
;
2193 bss_scnhdr
.s_paddr
= bss_scnhdr
.s_vaddr
= data_scnhdr
.s_size
;
2196 string_table_size
= 4;
2197 string_table_size
+= strlen (data_name
) + 1;
2198 string_table_size
+= strlen (rtinit_name
) + 1;
2199 string_table_size
+= initsz
;
2200 string_table_size
+= finisz
;
2202 string_table_size
+= strlen (rtld_name
) + 1;
2204 string_table
= (bfd_byte
*) bfd_zmalloc (string_table_size
);
2205 if (string_table
== NULL
)
2208 val
= string_table_size
;
2209 bfd_put_32 (abfd
, val
, &string_table
[0]);
2210 st_tmp
= string_table
+ 4;
2218 memset (syment_ext
, 0, 10 * SYMESZ
);
2219 memset (reloc_ext
, 0, 3 * RELSZ
);
2222 memset (&syment
, 0, sizeof (struct internal_syment
));
2223 memset (&auxent
, 0, sizeof (union internal_auxent
));
2225 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2226 memcpy (st_tmp
, data_name
, strlen (data_name
));
2227 st_tmp
+= strlen (data_name
) + 1;
2230 syment
.n_sclass
= C_HIDEXT
;
2231 syment
.n_numaux
= 1;
2232 auxent
.x_csect
.x_scnlen
.l
= data_buffer_size
;
2233 auxent
.x_csect
.x_smtyp
= 3 << 3 | XTY_SD
;
2234 auxent
.x_csect
.x_smclas
= XMC_RW
;
2235 bfd_coff_swap_sym_out (abfd
, &syment
,
2236 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2237 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2239 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2240 filehdr
.f_nsyms
+= 2;
2243 memset (&syment
, 0, sizeof (struct internal_syment
));
2244 memset (&auxent
, 0, sizeof (union internal_auxent
));
2245 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2246 memcpy (st_tmp
, rtinit_name
, strlen (rtinit_name
));
2247 st_tmp
+= strlen (rtinit_name
) + 1;
2250 syment
.n_sclass
= C_EXT
;
2251 syment
.n_numaux
= 1;
2252 auxent
.x_csect
.x_smtyp
= XTY_LD
;
2253 auxent
.x_csect
.x_smclas
= XMC_RW
;
2254 bfd_coff_swap_sym_out (abfd
, &syment
,
2255 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2256 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2258 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2259 filehdr
.f_nsyms
+= 2;
2264 memset (&syment
, 0, sizeof (struct internal_syment
));
2265 memset (&auxent
, 0, sizeof (union internal_auxent
));
2267 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2268 memcpy (st_tmp
, init
, initsz
);
2271 syment
.n_sclass
= C_EXT
;
2272 syment
.n_numaux
= 1;
2273 bfd_coff_swap_sym_out (abfd
, &syment
,
2274 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2275 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2277 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2279 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2280 reloc
.r_vaddr
= 0x0018;
2281 reloc
.r_symndx
= filehdr
.f_nsyms
;
2282 reloc
.r_type
= R_POS
;
2284 bfd_coff_swap_reloc_out (abfd
, &reloc
, &reloc_ext
[0]);
2286 filehdr
.f_nsyms
+= 2;
2287 data_scnhdr
.s_nreloc
+= 1;
2293 memset (&syment
, 0, sizeof (struct internal_syment
));
2294 memset (&auxent
, 0, sizeof (union internal_auxent
));
2296 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2297 memcpy (st_tmp
, fini
, finisz
);
2300 syment
.n_sclass
= C_EXT
;
2301 syment
.n_numaux
= 1;
2302 bfd_coff_swap_sym_out (abfd
, &syment
,
2303 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2304 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2306 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2309 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2310 reloc
.r_vaddr
= 0x0038;
2311 reloc
.r_symndx
= filehdr
.f_nsyms
;
2312 reloc
.r_type
= R_POS
;
2314 bfd_coff_swap_reloc_out (abfd
, &reloc
,
2315 &reloc_ext
[data_scnhdr
.s_nreloc
* RELSZ
]);
2317 filehdr
.f_nsyms
+= 2;
2318 data_scnhdr
.s_nreloc
+= 1;
2323 memset (&syment
, 0, sizeof (struct internal_syment
));
2324 memset (&auxent
, 0, sizeof (union internal_auxent
));
2326 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2327 memcpy (st_tmp
, rtld_name
, strlen (rtld_name
));
2328 st_tmp
+= strlen (rtld_name
) + 1;
2330 syment
.n_sclass
= C_EXT
;
2331 syment
.n_numaux
= 1;
2332 bfd_coff_swap_sym_out (abfd
, &syment
,
2333 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2334 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2336 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2339 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2340 reloc
.r_vaddr
= 0x0000;
2341 reloc
.r_symndx
= filehdr
.f_nsyms
;
2342 reloc
.r_type
= R_POS
;
2344 bfd_coff_swap_reloc_out (abfd
, &reloc
,
2345 &reloc_ext
[data_scnhdr
.s_nreloc
* RELSZ
]);
2347 filehdr
.f_nsyms
+= 2;
2348 data_scnhdr
.s_nreloc
+= 1;
2350 bss_scnhdr
.s_size
= 0;
2353 data_scnhdr
.s_relptr
= data_scnhdr
.s_scnptr
+ data_buffer_size
;
2354 filehdr
.f_symptr
= data_scnhdr
.s_relptr
+ data_scnhdr
.s_nreloc
* RELSZ
;
2356 bfd_coff_swap_filehdr_out (abfd
, &filehdr
, filehdr_ext
);
2357 bfd_bwrite (filehdr_ext
, FILHSZ
, abfd
);
2358 bfd_coff_swap_scnhdr_out (abfd
, &text_scnhdr
, &scnhdr_ext
[SCNHSZ
* 0]);
2359 bfd_coff_swap_scnhdr_out (abfd
, &data_scnhdr
, &scnhdr_ext
[SCNHSZ
* 1]);
2360 bfd_coff_swap_scnhdr_out (abfd
, &bss_scnhdr
, &scnhdr_ext
[SCNHSZ
* 2]);
2361 bfd_bwrite (scnhdr_ext
, 3 * SCNHSZ
, abfd
);
2362 bfd_bwrite (data_buffer
, data_buffer_size
, abfd
);
2363 bfd_bwrite (reloc_ext
, data_scnhdr
.s_nreloc
* RELSZ
, abfd
);
2364 bfd_bwrite (syment_ext
, filehdr
.f_nsyms
* SYMESZ
, abfd
);
2365 bfd_bwrite (string_table
, string_table_size
, abfd
);
2373 /* The typical dynamic reloc. */
2375 static reloc_howto_type xcoff64_dynamic_reloc
=
2376 HOWTO (0, /* type */
2378 4, /* size (0 = byte, 1 = short, 2 = long) */
2380 false, /* pc_relative */
2382 complain_overflow_bitfield
, /* complain_on_overflow */
2383 0, /* special_function */
2385 true, /* partial_inplace */
2386 MINUS_ONE
, /* src_mask */
2387 MINUS_ONE
, /* dst_mask */
2388 false); /* pcrel_offset */
2390 static const unsigned long xcoff64_glink_code
[10] =
2392 0xe9820000, /* ld r12,0(r2) */
2393 0xf8410028, /* std r2,40(r1) */
2394 0xe80c0000, /* ld r0,0(r12) */
2395 0xe84c0008, /* ld r0,8(r12) */
2396 0x7c0903a6, /* mtctr r0 */
2397 0x4e800420, /* bctr */
2398 0x00000000, /* start of traceback table */
2399 0x000ca000, /* traceback table */
2400 0x00000000, /* traceback table */
2401 0x00000018, /* ??? */
2404 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
2406 { /* COFF backend, defined in libcoff.h. */
2407 _bfd_xcoff64_swap_aux_in
,
2408 _bfd_xcoff64_swap_sym_in
,
2409 _bfd_xcoff64_swap_lineno_in
,
2410 _bfd_xcoff64_swap_aux_out
,
2411 _bfd_xcoff64_swap_sym_out
,
2412 _bfd_xcoff64_swap_lineno_out
,
2413 xcoff64_swap_reloc_out
,
2414 coff_swap_filehdr_out
,
2415 coff_swap_aouthdr_out
,
2416 coff_swap_scnhdr_out
,
2425 true, /* _bfd_coff_long_filenames */
2426 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
2427 3, /* _bfd_coff_default_section_alignment_power */
2428 true, /* _bfd_coff_force_symnames_in_strings */
2429 4, /* _bfd_coff_debug_string_prefix_length */
2430 32768, /* _bfd_coff_max_nscns */
2431 coff_swap_filehdr_in
,
2432 coff_swap_aouthdr_in
,
2433 coff_swap_scnhdr_in
,
2434 xcoff64_swap_reloc_in
,
2435 xcoff64_bad_format_hook
,
2436 coff_set_arch_mach_hook
,
2439 coff_set_alignment_hook
,
2440 coff_slurp_symbol_table
,
2441 symname_in_debug_hook
,
2442 coff_pointerize_aux_hook
,
2444 dummy_reloc16_extra_cases
,
2445 dummy_reloc16_estimate
,
2446 NULL
, /* bfd_coff_symbol_classification */
2447 coff_compute_section_file_positions
,
2448 NULL
, /* _bfd_coff_start_final_link */
2449 xcoff64_ppc_relocate_section
,
2450 coff_rtype_to_howto
,
2451 NULL
, /* _bfd_coff_adjust_symndx */
2452 _bfd_generic_link_add_one_symbol
,
2453 coff_link_output_has_begun
,
2454 coff_final_link_postscript
,
2455 NULL
/* print_pdata. */
2458 0x01EF, /* magic number */
2462 /* Function pointers to xcoff specific swap routines. */
2463 xcoff64_swap_ldhdr_in
,
2464 xcoff64_swap_ldhdr_out
,
2465 xcoff64_swap_ldsym_in
,
2466 xcoff64_swap_ldsym_out
,
2467 xcoff64_swap_ldrel_in
,
2468 xcoff64_swap_ldrel_out
,
2474 24, /* _xcoff_function_descriptor_size */
2475 0, /* _xcoff_small_aout_header_size */
2478 2, /* _xcoff_ldhdr_version */
2480 _bfd_xcoff64_put_symbol_name
,
2481 _bfd_xcoff64_put_ldsymbol_name
,
2482 &xcoff64_dynamic_reloc
,
2483 xcoff64_create_csect_from_smclas
,
2485 /* Lineno and reloc count overflow. */
2486 xcoff64_is_lineno_count_overflow
,
2487 xcoff64_is_reloc_count_overflow
,
2489 xcoff64_loader_symbol_offset
,
2490 xcoff64_loader_reloc_offset
,
2493 &xcoff64_glink_code
[0],
2494 40, /* _xcoff_glink_size */
2497 88, /* _xcoff_rtinit_size */
2498 xcoff64_generate_rtinit
,
2501 /* The transfer vector that leads the outside world to all of the above. */
2502 const bfd_target rs6000_xcoff64_vec
=
2505 bfd_target_xcoff_flavour
,
2506 BFD_ENDIAN_BIG
, /* data byte order is big */
2507 BFD_ENDIAN_BIG
, /* header byte order is big */
2509 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
2510 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
2512 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
2513 0, /* leading char */
2514 '/', /* ar_pad_char */
2515 15, /* ar_max_namelen */
2516 0, /* match priority. */
2517 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
2541 { /* bfd_check_format */
2548 { /* bfd_set_format */
2549 _bfd_bool_bfd_false_error
,
2551 _bfd_generic_mkarchive
,
2552 _bfd_bool_bfd_false_error
2555 {/* bfd_write_contents */
2556 _bfd_bool_bfd_false_error
,
2557 coff_write_object_contents
,
2558 _bfd_xcoff_write_archive_contents
,
2559 _bfd_bool_bfd_false_error
2563 _bfd_archive_close_and_cleanup
,
2565 coff_new_section_hook
,
2566 _bfd_generic_get_section_contents
,
2567 _bfd_generic_get_section_contents_in_window
,
2570 _bfd_xcoff_copy_private_bfd_data
,
2571 _bfd_generic_bfd_merge_private_bfd_data
,
2572 _bfd_generic_init_private_section_data
,
2573 _bfd_generic_bfd_copy_private_section_data
,
2574 _bfd_generic_bfd_copy_private_symbol_data
,
2575 _bfd_generic_bfd_copy_private_header_data
,
2576 _bfd_generic_bfd_set_private_flags
,
2577 _bfd_generic_bfd_print_private_bfd_data
,
2580 BFD_JUMP_TABLE_CORE (coff
),
2583 xcoff64_slurp_armap
,
2584 _bfd_noarchive_slurp_extended_name_table
,
2585 _bfd_noarchive_construct_extended_name_table
,
2586 bfd_dont_truncate_arname
,
2587 _bfd_xcoff_write_armap
,
2588 _bfd_xcoff_read_ar_hdr
,
2589 _bfd_generic_write_ar_hdr
,
2590 xcoff64_openr_next_archived_file
,
2591 _bfd_generic_get_elt_at_index
,
2592 _bfd_xcoff_stat_arch_elt
,
2596 coff_get_symtab_upper_bound
,
2597 coff_canonicalize_symtab
,
2598 coff_make_empty_symbol
,
2600 coff_get_symbol_info
,
2601 coff_get_symbol_version_string
,
2602 _bfd_xcoff_is_local_label_name
,
2603 coff_bfd_is_target_special_symbol
,
2605 coff_find_nearest_line
,
2607 coff_find_inliner_info
,
2608 coff_bfd_make_debug_symbol
,
2609 _bfd_generic_read_minisymbols
,
2610 _bfd_generic_minisymbol_to_symbol
,
2613 coff_get_reloc_upper_bound
,
2614 coff_canonicalize_reloc
,
2615 _bfd_generic_set_reloc
,
2616 xcoff64_reloc_type_lookup
,
2617 xcoff64_reloc_name_lookup
,
2621 coff_set_section_contents
,
2624 xcoff64_sizeof_headers
,
2625 bfd_generic_get_relocated_section_contents
,
2626 bfd_generic_relax_section
,
2627 _bfd_xcoff_bfd_link_hash_table_create
,
2628 _bfd_xcoff_bfd_link_add_symbols
,
2629 _bfd_generic_link_just_syms
,
2630 _bfd_generic_copy_link_hash_symbol_type
,
2631 _bfd_xcoff_bfd_final_link
,
2632 _bfd_generic_link_split_section
,
2633 _bfd_generic_link_check_relocs
,
2634 bfd_generic_gc_sections
,
2635 bfd_generic_lookup_section_flags
,
2636 bfd_generic_merge_sections
,
2637 bfd_generic_is_group_section
,
2638 bfd_generic_group_name
,
2639 bfd_generic_discard_group
,
2640 _bfd_generic_section_already_linked
,
2641 _bfd_xcoff_define_common_symbol
,
2642 _bfd_generic_link_hide_symbol
,
2643 bfd_generic_define_start_stop
,
2646 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
2647 _bfd_xcoff_canonicalize_dynamic_symtab
,
2648 _bfd_nodynamic_get_synthetic_symtab
,
2649 _bfd_xcoff_get_dynamic_reloc_upper_bound
,
2650 _bfd_xcoff_canonicalize_dynamic_reloc
,
2652 /* Opposite endian version, none exists */
2655 &bfd_xcoff_backend_data
,
2658 extern bfd_cleanup xcoff64_core_p
2660 extern bool xcoff64_core_file_matches_executable_p
2662 extern char *xcoff64_core_file_failing_command
2664 extern int xcoff64_core_file_failing_signal
2666 #define xcoff64_core_file_pid _bfd_nocore_core_file_pid
2669 static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data
=
2671 { /* COFF backend, defined in libcoff.h. */
2672 _bfd_xcoff64_swap_aux_in
,
2673 _bfd_xcoff64_swap_sym_in
,
2674 _bfd_xcoff64_swap_lineno_in
,
2675 _bfd_xcoff64_swap_aux_out
,
2676 _bfd_xcoff64_swap_sym_out
,
2677 _bfd_xcoff64_swap_lineno_out
,
2678 xcoff64_swap_reloc_out
,
2679 coff_swap_filehdr_out
,
2680 coff_swap_aouthdr_out
,
2681 coff_swap_scnhdr_out
,
2690 true, /* _bfd_coff_long_filenames */
2691 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
2692 3, /* _bfd_coff_default_section_alignment_power */
2693 true, /* _bfd_coff_force_symnames_in_strings */
2694 4, /* _bfd_coff_debug_string_prefix_length */
2695 32768, /* _bfd_coff_max_nscns */
2696 coff_swap_filehdr_in
,
2697 coff_swap_aouthdr_in
,
2698 coff_swap_scnhdr_in
,
2699 xcoff64_swap_reloc_in
,
2700 xcoff64_bad_format_hook
,
2701 coff_set_arch_mach_hook
,
2704 coff_set_alignment_hook
,
2705 coff_slurp_symbol_table
,
2706 symname_in_debug_hook
,
2707 coff_pointerize_aux_hook
,
2709 dummy_reloc16_extra_cases
,
2710 dummy_reloc16_estimate
,
2711 NULL
, /* bfd_coff_sym_is_global */
2712 coff_compute_section_file_positions
,
2713 NULL
, /* _bfd_coff_start_final_link */
2714 xcoff64_ppc_relocate_section
,
2715 coff_rtype_to_howto
,
2716 NULL
, /* _bfd_coff_adjust_symndx */
2717 _bfd_generic_link_add_one_symbol
,
2718 coff_link_output_has_begun
,
2719 coff_final_link_postscript
,
2720 NULL
/* print_pdata. */
2723 U64_TOCMAGIC
, /* magic number */
2727 /* Function pointers to xcoff specific swap routines. */
2728 xcoff64_swap_ldhdr_in
,
2729 xcoff64_swap_ldhdr_out
,
2730 xcoff64_swap_ldsym_in
,
2731 xcoff64_swap_ldsym_out
,
2732 xcoff64_swap_ldrel_in
,
2733 xcoff64_swap_ldrel_out
,
2739 24, /* _xcoff_function_descriptor_size */
2740 0, /* _xcoff_small_aout_header_size */
2742 2, /* _xcoff_ldhdr_version */
2744 _bfd_xcoff64_put_symbol_name
,
2745 _bfd_xcoff64_put_ldsymbol_name
,
2746 &xcoff64_dynamic_reloc
,
2747 xcoff64_create_csect_from_smclas
,
2749 /* Lineno and reloc count overflow. */
2750 xcoff64_is_lineno_count_overflow
,
2751 xcoff64_is_reloc_count_overflow
,
2753 xcoff64_loader_symbol_offset
,
2754 xcoff64_loader_reloc_offset
,
2757 &xcoff64_glink_code
[0],
2758 40, /* _xcoff_glink_size */
2761 88, /* _xcoff_rtinit_size */
2762 xcoff64_generate_rtinit
,
2765 /* The transfer vector that leads the outside world to all of the above. */
2766 const bfd_target rs6000_xcoff64_aix_vec
=
2768 "aix5coff64-rs6000",
2769 bfd_target_xcoff_flavour
,
2770 BFD_ENDIAN_BIG
, /* data byte order is big */
2771 BFD_ENDIAN_BIG
, /* header byte order is big */
2773 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
2774 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
2776 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
2777 0, /* leading char */
2778 '/', /* ar_pad_char */
2779 15, /* ar_max_namelen */
2780 0, /* match priority. */
2781 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
2805 { /* bfd_check_format */
2812 { /* bfd_set_format */
2813 _bfd_bool_bfd_false_error
,
2815 _bfd_generic_mkarchive
,
2816 _bfd_bool_bfd_false_error
2819 {/* bfd_write_contents */
2820 _bfd_bool_bfd_false_error
,
2821 coff_write_object_contents
,
2822 _bfd_xcoff_write_archive_contents
,
2823 _bfd_bool_bfd_false_error
2827 _bfd_archive_close_and_cleanup
,
2829 coff_new_section_hook
,
2830 _bfd_generic_get_section_contents
,
2831 _bfd_generic_get_section_contents_in_window
,
2834 _bfd_xcoff_copy_private_bfd_data
,
2835 _bfd_generic_bfd_merge_private_bfd_data
,
2836 _bfd_generic_init_private_section_data
,
2837 _bfd_generic_bfd_copy_private_section_data
,
2838 _bfd_generic_bfd_copy_private_symbol_data
,
2839 _bfd_generic_bfd_copy_private_header_data
,
2840 _bfd_generic_bfd_set_private_flags
,
2841 _bfd_generic_bfd_print_private_bfd_data
,
2844 BFD_JUMP_TABLE_CORE (xcoff64
),
2847 xcoff64_slurp_armap
,
2848 _bfd_noarchive_slurp_extended_name_table
,
2849 _bfd_noarchive_construct_extended_name_table
,
2850 bfd_dont_truncate_arname
,
2851 _bfd_xcoff_write_armap
,
2852 _bfd_xcoff_read_ar_hdr
,
2853 _bfd_generic_write_ar_hdr
,
2854 xcoff64_openr_next_archived_file
,
2855 _bfd_generic_get_elt_at_index
,
2856 _bfd_xcoff_stat_arch_elt
,
2860 coff_get_symtab_upper_bound
,
2861 coff_canonicalize_symtab
,
2862 coff_make_empty_symbol
,
2864 coff_get_symbol_info
,
2865 coff_get_symbol_version_string
,
2866 _bfd_xcoff_is_local_label_name
,
2867 coff_bfd_is_target_special_symbol
,
2869 coff_find_nearest_line
,
2871 coff_find_inliner_info
,
2872 coff_bfd_make_debug_symbol
,
2873 _bfd_generic_read_minisymbols
,
2874 _bfd_generic_minisymbol_to_symbol
,
2877 coff_get_reloc_upper_bound
,
2878 coff_canonicalize_reloc
,
2879 _bfd_generic_set_reloc
,
2880 xcoff64_reloc_type_lookup
,
2881 xcoff64_reloc_name_lookup
,
2885 coff_set_section_contents
,
2888 xcoff64_sizeof_headers
,
2889 bfd_generic_get_relocated_section_contents
,
2890 bfd_generic_relax_section
,
2891 _bfd_xcoff_bfd_link_hash_table_create
,
2892 _bfd_xcoff_bfd_link_add_symbols
,
2893 _bfd_generic_link_just_syms
,
2894 _bfd_generic_copy_link_hash_symbol_type
,
2895 _bfd_xcoff_bfd_final_link
,
2896 _bfd_generic_link_split_section
,
2897 _bfd_generic_link_check_relocs
,
2898 bfd_generic_gc_sections
,
2899 bfd_generic_lookup_section_flags
,
2900 bfd_generic_merge_sections
,
2901 bfd_generic_is_group_section
,
2902 bfd_generic_group_name
,
2903 bfd_generic_discard_group
,
2904 _bfd_generic_section_already_linked
,
2905 _bfd_xcoff_define_common_symbol
,
2906 _bfd_generic_link_hide_symbol
,
2907 bfd_generic_define_start_stop
,
2910 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
2911 _bfd_xcoff_canonicalize_dynamic_symtab
,
2912 _bfd_nodynamic_get_synthetic_symtab
,
2913 _bfd_xcoff_get_dynamic_reloc_upper_bound
,
2914 _bfd_xcoff_canonicalize_dynamic_reloc
,
2916 /* Opposite endian version, none exists. */
2919 & bfd_xcoff_aix5_backend_data
,