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
, int in_class
,
366 int indx
, int numaux
, void *in1
)
368 union external_auxent
*ext
= (union external_auxent
*) ext1
;
369 union internal_auxent
*in
= (union internal_auxent
*) in1
;
374 if (ext
->x_file
.x_n
.x_n
.x_zeroes
[0] == 0)
376 in
->x_file
.x_n
.x_zeroes
= 0;
377 in
->x_file
.x_n
.x_offset
=
378 H_GET_32 (abfd
, ext
->x_file
.x_n
.x_n
.x_offset
);
382 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_n
.x_fname
, FILNMLEN
);
386 /* RS/6000 "csect" auxents */
390 if (indx
+ 1 == numaux
)
392 bfd_signed_vma h
= 0;
395 h
= H_GET_S32 (abfd
, ext
->x_csect
.x_scnlen_hi
);
396 l
= H_GET_32 (abfd
, ext
->x_csect
.x_scnlen_lo
);
398 in
->x_csect
.x_scnlen
.l
= h
<< 32 | (l
& 0xffffffff);
400 in
->x_csect
.x_parmhash
= H_GET_32 (abfd
, ext
->x_csect
.x_parmhash
);
401 in
->x_csect
.x_snhash
= H_GET_16 (abfd
, ext
->x_csect
.x_snhash
);
402 /* We don't have to hack bitfields in x_smtyp because it's
403 defined by shifts-and-ands, which are equivalent on all
405 in
->x_csect
.x_smtyp
= H_GET_8 (abfd
, ext
->x_csect
.x_smtyp
);
406 in
->x_csect
.x_smclas
= H_GET_8 (abfd
, ext
->x_csect
.x_smclas
);
416 /* PE defines some extra fields; we zero them out for
418 in
->x_scn
.x_checksum
= 0;
419 in
->x_scn
.x_associated
= 0;
420 in
->x_scn
.x_comdat
= 0;
427 if (in_class
== C_BLOCK
|| in_class
== C_FCN
|| ISFCN (type
)
430 in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
431 = H_GET_64 (abfd
, ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
432 in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
433 = H_GET_32 (abfd
, ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
437 in
->x_sym
.x_misc
.x_fsize
438 = H_GET_32 (abfd
, ext
->x_sym
.x_fcnary
.x_fcn
.x_fsize
);
442 in
->x_sym
.x_misc
.x_lnsz
.x_lnno
443 = H_GET_32 (abfd
, ext
->x_sym
.x_fcnary
.x_lnsz
.x_lnno
);
444 in
->x_sym
.x_misc
.x_lnsz
.x_size
445 = H_GET_16 (abfd
, ext
->x_sym
.x_fcnary
.x_lnsz
.x_size
);
452 _bfd_xcoff64_swap_aux_out (bfd
*abfd
, void *inp
, int type
, int in_class
,
453 int indx ATTRIBUTE_UNUSED
,
454 int numaux ATTRIBUTE_UNUSED
,
457 union internal_auxent
*in
= (union internal_auxent
*) inp
;
458 union external_auxent
*ext
= (union external_auxent
*) extp
;
460 memset (ext
, 0, bfd_coff_auxesz (abfd
));
464 if (in
->x_file
.x_n
.x_zeroes
== 0)
466 H_PUT_32 (abfd
, 0, ext
->x_file
.x_n
.x_n
.x_zeroes
);
467 H_PUT_32 (abfd
, in
->x_file
.x_n
.x_offset
,
468 ext
->x_file
.x_n
.x_n
.x_offset
);
472 memcpy (ext
->x_file
.x_n
.x_fname
, in
->x_file
.x_fname
, FILNMLEN
);
474 H_PUT_8 (abfd
, _AUX_FILE
, ext
->x_auxtype
.x_auxtype
);
477 /* RS/6000 "csect" auxents */
481 if (indx
+ 1 == numaux
)
485 temp
= in
->x_csect
.x_scnlen
.l
& 0xffffffff;
486 H_PUT_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_lo
);
487 temp
= in
->x_csect
.x_scnlen
.l
>> 32;
488 H_PUT_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_hi
);
489 H_PUT_32 (abfd
, in
->x_csect
.x_parmhash
, ext
->x_csect
.x_parmhash
);
490 H_PUT_16 (abfd
, in
->x_csect
.x_snhash
, ext
->x_csect
.x_snhash
);
491 /* We don't have to hack bitfields in x_smtyp because it's
492 defined by shifts-and-ands, which are equivalent on all
494 H_PUT_8 (abfd
, in
->x_csect
.x_smtyp
, ext
->x_csect
.x_smtyp
);
495 H_PUT_8 (abfd
, in
->x_csect
.x_smclas
, ext
->x_csect
.x_smclas
);
496 H_PUT_8 (abfd
, _AUX_CSECT
, ext
->x_auxtype
.x_auxtype
);
511 if (in_class
== C_BLOCK
|| in_class
== C_FCN
|| ISFCN (type
)
514 H_PUT_64 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
,
515 ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
516 H_PUT_8 (abfd
, _AUX_FCN
,
517 ext
->x_auxtype
.x_auxtype
);
518 H_PUT_32 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
,
519 ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
523 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_fsize
,
524 ext
->x_sym
.x_fcnary
.x_fcn
.x_fsize
);
528 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_lnno
,
529 ext
->x_sym
.x_fcnary
.x_lnsz
.x_lnno
);
530 H_PUT_16 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_size
,
531 ext
->x_sym
.x_fcnary
.x_lnsz
.x_size
);
536 return bfd_coff_auxesz (abfd
);
540 _bfd_xcoff64_put_symbol_name (struct bfd_link_info
*info
,
541 struct bfd_strtab_hash
*strtab
,
542 struct internal_syment
*sym
,
548 hash
= !info
->traditional_format
;
549 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
551 if (indx
== (bfd_size_type
) -1)
554 sym
->_n
._n_n
._n_zeroes
= 0;
555 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
561 _bfd_xcoff64_put_ldsymbol_name (bfd
*abfd ATTRIBUTE_UNUSED
,
562 struct xcoff_loader_info
*ldinfo
,
563 struct internal_ldsym
*ldsym
,
569 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
)
571 bfd_size_type newalc
;
574 newalc
= ldinfo
->string_alc
* 2;
577 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
580 newstrings
= bfd_realloc (ldinfo
->strings
, newalc
);
581 if (newstrings
== NULL
)
583 ldinfo
->failed
= true;
586 ldinfo
->string_alc
= newalc
;
587 ldinfo
->strings
= newstrings
;
590 bfd_put_16 (ldinfo
->output_bfd
, (bfd_vma
) (len
+ 1),
591 ldinfo
->strings
+ ldinfo
->string_size
);
592 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
593 ldsym
->_l
._l_l
._l_zeroes
= 0;
594 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
595 ldinfo
->string_size
+= len
+ 3;
600 /* Routines to swap information in the XCOFF .loader section. If we
601 ever need to write an XCOFF loader, this stuff will need to be
602 moved to another file shared by the linker (which XCOFF calls the
603 ``binder'') and the loader. */
605 /* Swap in the ldhdr structure. */
608 xcoff64_swap_ldhdr_in (bfd
*abfd
,
610 struct internal_ldhdr
*dst
)
612 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
614 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
615 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
616 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
617 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
618 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
619 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
620 dst
->l_impoff
= bfd_get_64 (abfd
, src
->l_impoff
);
621 dst
->l_stoff
= bfd_get_64 (abfd
, src
->l_stoff
);
622 dst
->l_symoff
= bfd_get_64 (abfd
, src
->l_symoff
);
623 dst
->l_rldoff
= bfd_get_64 (abfd
, src
->l_rldoff
);
626 /* Swap out the ldhdr structure. */
629 xcoff64_swap_ldhdr_out (bfd
*abfd
, const struct internal_ldhdr
*src
, void *d
)
631 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
633 bfd_put_32 (abfd
, (bfd_vma
) src
->l_version
, dst
->l_version
);
634 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
635 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
636 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
637 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
638 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
639 bfd_put_64 (abfd
, src
->l_impoff
, dst
->l_impoff
);
640 bfd_put_64 (abfd
, src
->l_stoff
, dst
->l_stoff
);
641 bfd_put_64 (abfd
, src
->l_symoff
, dst
->l_symoff
);
642 bfd_put_64 (abfd
, src
->l_rldoff
, dst
->l_rldoff
);
645 /* Swap in the ldsym structure. */
648 xcoff64_swap_ldsym_in (bfd
*abfd
, const void *s
, struct internal_ldsym
*dst
)
650 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
651 /* XCOFF64 does not use l_zeroes like XCOFF32
652 Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
653 as an offset into the loader symbol table. */
654 dst
->_l
._l_l
._l_zeroes
= 0;
655 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->l_offset
);
656 dst
->l_value
= bfd_get_64 (abfd
, src
->l_value
);
657 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
658 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
659 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
660 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
661 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
664 /* Swap out the ldsym structure. */
667 xcoff64_swap_ldsym_out (bfd
*abfd
, const struct internal_ldsym
*src
, void *d
)
669 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
671 bfd_put_64 (abfd
, src
->l_value
, dst
->l_value
);
672 bfd_put_32 (abfd
, (bfd_vma
) src
->_l
._l_l
._l_offset
, dst
->l_offset
);
673 bfd_put_16 (abfd
, (bfd_vma
) src
->l_scnum
, dst
->l_scnum
);
674 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
675 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
676 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
677 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
681 xcoff64_swap_reloc_in (bfd
*abfd
, void *s
, void *d
)
683 struct external_reloc
*src
= (struct external_reloc
*) s
;
684 struct internal_reloc
*dst
= (struct internal_reloc
*) d
;
686 memset (dst
, 0, sizeof (struct internal_reloc
));
688 dst
->r_vaddr
= bfd_get_64 (abfd
, src
->r_vaddr
);
689 dst
->r_symndx
= bfd_get_32 (abfd
, src
->r_symndx
);
690 dst
->r_size
= bfd_get_8 (abfd
, src
->r_size
);
691 dst
->r_type
= bfd_get_8 (abfd
, src
->r_type
);
695 xcoff64_swap_reloc_out (bfd
*abfd
, void *s
, void *d
)
697 struct internal_reloc
*src
= (struct internal_reloc
*) s
;
698 struct external_reloc
*dst
= (struct external_reloc
*) d
;
700 bfd_put_64 (abfd
, src
->r_vaddr
, dst
->r_vaddr
);
701 bfd_put_32 (abfd
, src
->r_symndx
, dst
->r_symndx
);
702 bfd_put_8 (abfd
, src
->r_type
, dst
->r_type
);
703 bfd_put_8 (abfd
, src
->r_size
, dst
->r_size
);
705 return bfd_coff_relsz (abfd
);
708 /* Swap in the ldrel structure. */
711 xcoff64_swap_ldrel_in (bfd
*abfd
, const void *s
, struct internal_ldrel
*dst
)
713 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
715 dst
->l_vaddr
= bfd_get_64 (abfd
, src
->l_vaddr
);
716 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
717 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
718 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
721 /* Swap out the ldrel structure. */
724 xcoff64_swap_ldrel_out (bfd
*abfd
, const struct internal_ldrel
*src
, void *d
)
726 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
728 bfd_put_64 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
729 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rtype
, dst
->l_rtype
);
730 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rsecnm
, dst
->l_rsecnm
);
731 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
736 xcoff64_reloc_type_br (bfd
*input_bfd
,
737 asection
*input_section
,
738 bfd
*output_bfd ATTRIBUTE_UNUSED
,
739 struct internal_reloc
*rel
,
740 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
741 struct reloc_howto_struct
*howto
,
747 struct xcoff_link_hash_entry
*h
;
748 bfd_vma section_offset
;
750 if (0 > rel
->r_symndx
)
753 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
754 section_offset
= rel
->r_vaddr
- input_section
->vma
;
756 /* If we see an R_BR or R_RBR reloc which is jumping to global
757 linkage code, and it is followed by an appropriate cror nop
758 instruction, we replace the cror with ld r2,40(r1). This
759 restores the TOC after the glink code. Contrariwise, if the
760 call is followed by a ld r2,40(r1), but the call is not
761 going to global linkage code, we can replace the load with a
764 && (bfd_link_hash_defined
== h
->root
.type
765 || bfd_link_hash_defweak
== h
->root
.type
)
766 && section_offset
+ 8 <= input_section
->size
)
771 pnext
= contents
+ section_offset
+ 4;
772 next
= bfd_get_32 (input_bfd
, pnext
);
774 /* The _ptrgl function is magic. It is used by the AIX compiler to call
775 a function through a pointer. */
776 if (h
->smclas
== XMC_GL
|| strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
778 if (next
== 0x4def7b82 /* cror 15,15,15 */
779 || next
== 0x4ffffb82 /* cror 31,31,31 */
780 || next
== 0x60000000) /* ori r0,r0,0 */
781 bfd_put_32 (input_bfd
, 0xe8410028, pnext
); /* ld r2,40(r1) */
785 if (next
== 0xe8410028) /* ld r2,40(r1) */
786 bfd_put_32 (input_bfd
, 0x60000000, pnext
); /* ori r0,r0,0 */
789 else if (NULL
!= h
&& bfd_link_hash_undefined
== h
->root
.type
)
791 /* Normally, this relocation is against a defined symbol. In the
792 case where this is a partial link and the output section offset
793 is greater than 2^25, the linker will return an invalid error
794 message that the relocation has been truncated. Yes it has been
795 truncated but no it not important. For this case, disable the
796 overflow checking. */
797 howto
->complain_on_overflow
= complain_overflow_dont
;
800 /* The original PC-relative relocation is biased by -r_vaddr, so adding
801 the value below will give the absolute target address. */
802 *relocation
= val
+ addend
+ rel
->r_vaddr
;
804 howto
->src_mask
&= ~3;
805 howto
->dst_mask
= howto
->src_mask
;
808 && (h
->root
.type
== bfd_link_hash_defined
809 || h
->root
.type
== bfd_link_hash_defweak
)
810 && bfd_is_abs_section (h
->root
.u
.def
.section
)
811 && section_offset
+ 4 <= input_section
->size
)
816 /* Turn the relative branch into an absolute one by setting the
818 ptr
= contents
+ section_offset
;
819 insn
= bfd_get_32 (input_bfd
, ptr
);
821 bfd_put_32 (input_bfd
, insn
, ptr
);
823 /* Make the howto absolute too. */
824 howto
->pc_relative
= false;
825 howto
->complain_on_overflow
= complain_overflow_bitfield
;
829 /* Use a PC-relative howto and subtract the instruction's address
830 from the target address we calculated above. */
831 howto
->pc_relative
= true;
832 *relocation
-= (input_section
->output_section
->vma
833 + input_section
->output_offset
841 /* The XCOFF reloc table.
842 Cf xcoff_howto_table comments. */
844 reloc_howto_type xcoff64_howto_table
[] =
846 /* 0x00: Standard 64 bit relocation. */
847 HOWTO (R_POS
, /* type */
849 4, /* size (0 = byte, 1 = short, 2 = long) */
851 false, /* pc_relative */
853 complain_overflow_bitfield
, /* complain_on_overflow */
854 0, /* special_function */
855 "R_POS_64", /* name */
856 true, /* partial_inplace */
857 MINUS_ONE
, /* src_mask */
858 MINUS_ONE
, /* dst_mask */
859 false), /* pcrel_offset */
861 /* 0x01: 64 bit relocation, but store negative value. */
862 HOWTO (R_NEG
, /* type */
864 -4, /* size (0 = byte, 1 = short, 2 = long) */
866 false, /* pc_relative */
868 complain_overflow_bitfield
, /* complain_on_overflow */
869 0, /* special_function */
871 true, /* partial_inplace */
872 MINUS_ONE
, /* src_mask */
873 MINUS_ONE
, /* dst_mask */
874 false), /* pcrel_offset */
876 /* 0x02: 64 bit PC relative relocation. */
877 HOWTO (R_REL
, /* type */
879 4, /* size (0 = byte, 1 = short, 2 = long) */
881 true, /* pc_relative */
883 complain_overflow_signed
, /* complain_on_overflow */
884 0, /* special_function */
886 true, /* partial_inplace */
887 MINUS_ONE
, /* src_mask */
888 MINUS_ONE
, /* dst_mask */
889 false), /* pcrel_offset */
891 /* 0x03: 16 bit TOC relative relocation. */
892 HOWTO (R_TOC
, /* type */
894 1, /* size (0 = byte, 1 = short, 2 = long) */
896 false, /* pc_relative */
898 complain_overflow_bitfield
, /* complain_on_overflow */
899 0, /* special_function */
901 true, /* partial_inplace */
903 0xffff, /* dst_mask */
904 false), /* pcrel_offset */
906 /* 0x04: Same as R_TOC. */
907 HOWTO (R_TRL
, /* type */
909 1, /* size (0 = byte, 1 = short, 2 = long) */
911 false, /* pc_relative */
913 complain_overflow_bitfield
, /* complain_on_overflow */
914 0, /* special_function */
916 true, /* partial_inplace */
918 0xffff, /* dst_mask */
919 false), /* pcrel_offset */
921 /* 0x05: External TOC relative symbol. */
922 HOWTO (R_GL
, /* type */
924 1, /* size (0 = byte, 1 = short, 2 = long) */
926 false, /* pc_relative */
928 complain_overflow_bitfield
, /* complain_on_overflow */
929 0, /* special_function */
931 true, /* partial_inplace */
933 0xffff, /* dst_mask */
934 false), /* pcrel_offset */
936 /* 0x06: Local TOC relative symbol. */
937 HOWTO (R_TCL
, /* type */
939 1, /* size (0 = byte, 1 = short, 2 = long) */
941 false, /* pc_relative */
943 complain_overflow_bitfield
, /* complain_on_overflow */
944 0, /* special_function */
946 true, /* partial_inplace */
948 0xffff, /* dst_mask */
949 false), /* pcrel_offset */
953 /* 0x08: Same as R_RBA. */
954 HOWTO (R_BA
, /* type */
956 2, /* size (0 = byte, 1 = short, 2 = long) */
958 false, /* pc_relative */
960 complain_overflow_bitfield
, /* complain_on_overflow */
961 0, /* special_function */
962 "R_BA_26", /* name */
963 true, /* partial_inplace */
964 0x03fffffc, /* src_mask */
965 0x03fffffc, /* dst_mask */
966 false), /* pcrel_offset */
970 /* 0x0a: Same as R_RBR. */
971 HOWTO (R_BR
, /* type */
973 2, /* size (0 = byte, 1 = short, 2 = long) */
975 true, /* pc_relative */
977 complain_overflow_signed
, /* complain_on_overflow */
978 0, /* special_function */
980 true, /* partial_inplace */
981 0x03fffffc, /* src_mask */
982 0x03fffffc, /* dst_mask */
983 false), /* pcrel_offset */
987 /* 0x0c: Same as R_POS. */
988 HOWTO (R_RL
, /* type */
990 4, /* size (0 = byte, 1 = short, 2 = long) */
992 false, /* pc_relative */
994 complain_overflow_bitfield
, /* complain_on_overflow */
995 0, /* special_function */
997 true, /* partial_inplace */
998 MINUS_ONE
, /* src_mask */
999 MINUS_ONE
, /* dst_mask */
1000 false), /* pcrel_offset */
1002 /* 0x0d: Same as R_POS. */
1003 HOWTO (R_RLA
, /* type */
1005 4, /* size (0 = byte, 1 = short, 2 = long) */
1007 false, /* pc_relative */
1009 complain_overflow_bitfield
, /* complain_on_overflow */
1010 0, /* special_function */
1012 true, /* partial_inplace */
1013 MINUS_ONE
, /* src_mask */
1014 MINUS_ONE
, /* dst_mask */
1015 false), /* pcrel_offset */
1019 /* 0x0f: Non-relocating reference. Bitsize is 1 so that r_rsize is 0. */
1020 HOWTO (R_REF
, /* type */
1022 0, /* size (0 = byte, 1 = short, 2 = long) */
1024 false, /* pc_relative */
1026 complain_overflow_dont
, /* complain_on_overflow */
1027 0, /* special_function */
1029 false, /* partial_inplace */
1032 false), /* pcrel_offset */
1038 /* 0x13: Same as R_TOC */
1039 HOWTO (R_TRLA
, /* type */
1041 1, /* size (0 = byte, 1 = short, 2 = long) */
1043 false, /* pc_relative */
1045 complain_overflow_bitfield
, /* complain_on_overflow */
1046 0, /* special_function */
1047 "R_TRLA", /* name */
1048 true, /* partial_inplace */
1049 0xffff, /* src_mask */
1050 0xffff, /* dst_mask */
1051 false), /* pcrel_offset */
1053 /* 0x14: Modifiable relative branch. */
1054 HOWTO (R_RRTBI
, /* type */
1056 2, /* size (0 = byte, 1 = short, 2 = long) */
1058 false, /* pc_relative */
1060 complain_overflow_bitfield
, /* complain_on_overflow */
1061 0, /* special_function */
1062 "R_RRTBI", /* name */
1063 true, /* partial_inplace */
1064 0xffffffff, /* src_mask */
1065 0xffffffff, /* dst_mask */
1066 false), /* pcrel_offset */
1068 /* 0x15: Modifiable absolute branch. */
1069 HOWTO (R_RRTBA
, /* type */
1071 2, /* size (0 = byte, 1 = short, 2 = long) */
1073 false, /* pc_relative */
1075 complain_overflow_bitfield
, /* complain_on_overflow */
1076 0, /* special_function */
1077 "R_RRTBA", /* name */
1078 true, /* partial_inplace */
1079 0xffffffff, /* src_mask */
1080 0xffffffff, /* dst_mask */
1081 false), /* pcrel_offset */
1083 /* 0x16: Modifiable call absolute indirect. */
1084 HOWTO (R_CAI
, /* type */
1086 1, /* size (0 = byte, 1 = short, 2 = long) */
1088 false, /* pc_relative */
1090 complain_overflow_bitfield
, /* complain_on_overflow */
1091 0, /* special_function */
1093 true, /* partial_inplace */
1094 0xffff, /* src_mask */
1095 0xffff, /* dst_mask */
1096 false), /* pcrel_offset */
1098 /* 0x17: Modifiable call relative. */
1099 HOWTO (R_CREL
, /* type */
1101 1, /* size (0 = byte, 1 = short, 2 = long) */
1103 false, /* pc_relative */
1105 complain_overflow_bitfield
, /* complain_on_overflow */
1106 0, /* special_function */
1107 "R_CREL", /* name */
1108 true, /* partial_inplace */
1109 0xffff, /* src_mask */
1110 0xffff, /* dst_mask */
1111 false), /* pcrel_offset */
1113 /* 0x18: Modifiable branch absolute. */
1114 HOWTO (R_RBA
, /* type */
1116 2, /* size (0 = byte, 1 = short, 2 = long) */
1118 false, /* pc_relative */
1120 complain_overflow_bitfield
, /* complain_on_overflow */
1121 0, /* special_function */
1123 true, /* partial_inplace */
1124 0x03fffffc, /* src_mask */
1125 0x03fffffc, /* dst_mask */
1126 false), /* pcrel_offset */
1128 /* 0x19: Modifiable branch absolute. */
1129 HOWTO (R_RBAC
, /* type */
1131 2, /* size (0 = byte, 1 = short, 2 = long) */
1133 false, /* pc_relative */
1135 complain_overflow_bitfield
, /* complain_on_overflow */
1136 0, /* special_function */
1137 "R_RBAC", /* name */
1138 true, /* partial_inplace */
1139 0xffffffff, /* src_mask */
1140 0xffffffff, /* dst_mask */
1141 false), /* pcrel_offset */
1143 /* 0x1a: Modifiable branch relative. */
1144 HOWTO (R_RBR
, /* type */
1146 2, /* size (0 = byte, 1 = short, 2 = long) */
1148 false, /* pc_relative */
1150 complain_overflow_signed
, /* complain_on_overflow */
1151 0, /* special_function */
1152 "R_RBR_26", /* name */
1153 true, /* partial_inplace */
1154 0x03fffffc, /* src_mask */
1155 0x03fffffc, /* dst_mask */
1156 false), /* pcrel_offset */
1158 /* 0x1b: Modifiable branch absolute. */
1159 HOWTO (R_RBRC
, /* type */
1161 1, /* size (0 = byte, 1 = short, 2 = long) */
1163 false, /* pc_relative */
1165 complain_overflow_bitfield
, /* complain_on_overflow */
1166 0, /* special_function */
1167 "R_RBRC", /* name */
1168 true, /* partial_inplace */
1169 0xffff, /* src_mask */
1170 0xffff, /* dst_mask */
1171 false), /* pcrel_offset */
1173 /* 0x1c: Standard 32 bit relocation. */
1174 HOWTO (R_POS
, /* type */
1176 2, /* size (0 = byte, 1 = short, 2 = long) */
1178 false, /* pc_relative */
1180 complain_overflow_bitfield
, /* complain_on_overflow */
1181 0, /* special_function */
1182 "R_POS_32", /* name */
1183 true, /* partial_inplace */
1184 0xffffffff, /* src_mask */
1185 0xffffffff, /* dst_mask */
1186 false), /* pcrel_offset */
1188 /* 0x1d: 16 bit Non modifiable absolute branch. */
1189 HOWTO (R_BA
, /* type */
1191 1, /* size (0 = byte, 1 = short, 2 = long) */
1193 false, /* pc_relative */
1195 complain_overflow_bitfield
, /* complain_on_overflow */
1196 0, /* special_function */
1197 "R_BA_16", /* name */
1198 true, /* partial_inplace */
1199 0xfffc, /* src_mask */
1200 0xfffc, /* dst_mask */
1201 false), /* pcrel_offset */
1203 /* 0x1e: Modifiable branch relative. */
1204 HOWTO (R_RBR
, /* type */
1206 1, /* size (0 = byte, 1 = short, 2 = long) */
1208 true, /* pc_relative */
1210 complain_overflow_signed
, /* complain_on_overflow */
1211 0, /* special_function */
1212 "R_RBR_16", /* name */
1213 true, /* partial_inplace */
1214 0xfffc, /* src_mask */
1215 0xfffc, /* dst_mask */
1216 false), /* pcrel_offset */
1218 /* 0x1f: Modifiable branch absolute. */
1219 HOWTO (R_RBA
, /* type */
1221 1, /* size (0 = byte, 1 = short, 2 = long) */
1223 false, /* pc_relative */
1225 complain_overflow_bitfield
, /* complain_on_overflow */
1226 0, /* special_function */
1227 "R_RBA_16", /* name */
1228 true, /* partial_inplace */
1229 0xffff, /* src_mask */
1230 0xffff, /* dst_mask */
1231 false), /* pcrel_offset */
1233 /* 0x20: General-dynamic TLS relocation. */
1234 HOWTO (R_TLS
, /* type */
1236 4, /* size (0 = byte, 1 = short, 2 = long) */
1238 false, /* pc_relative */
1240 complain_overflow_bitfield
, /* complain_on_overflow */
1241 0, /* special_function */
1243 true, /* partial_inplace */
1244 MINUS_ONE
, /* src_mask */
1245 MINUS_ONE
, /* dst_mask */
1246 false), /* pcrel_offset */
1248 /* 0x21: Initial-exec TLS relocation. */
1249 HOWTO (R_TLS_IE
, /* type */
1251 4, /* size (0 = byte, 1 = short, 2 = long) */
1253 false, /* pc_relative */
1255 complain_overflow_bitfield
, /* complain_on_overflow */
1256 0, /* special_function */
1257 "R_TLS_IE", /* name */
1258 true, /* partial_inplace */
1259 MINUS_ONE
, /* src_mask */
1260 MINUS_ONE
, /* dst_mask */
1261 false), /* pcrel_offset */
1263 /* 0x22: Local-dynamic TLS relocation. */
1264 HOWTO (R_TLS_LD
, /* type */
1266 4, /* size (0 = byte, 1 = short, 2 = long) */
1268 false, /* pc_relative */
1270 complain_overflow_bitfield
, /* complain_on_overflow */
1271 0, /* special_function */
1272 "R_TLS_LD", /* name */
1273 true, /* partial_inplace */
1274 MINUS_ONE
, /* src_mask */
1275 MINUS_ONE
, /* dst_mask */
1276 false), /* pcrel_offset */
1278 /* 0x23: Local-exec TLS relocation. */
1279 HOWTO (R_TLS_LE
, /* type */
1281 4, /* size (0 = byte, 1 = short, 2 = long) */
1283 false, /* pc_relative */
1285 complain_overflow_bitfield
, /* complain_on_overflow */
1286 0, /* special_function */
1287 "R_TLS_LE", /* name */
1288 true, /* partial_inplace */
1289 MINUS_ONE
, /* src_mask */
1290 MINUS_ONE
, /* dst_mask */
1291 false), /* pcrel_offset */
1293 /* 0x24: TLS relocation. */
1294 HOWTO (R_TLSM
, /* type */
1296 4, /* size (0 = byte, 1 = short, 2 = long) */
1298 false, /* pc_relative */
1300 complain_overflow_bitfield
, /* complain_on_overflow */
1301 0, /* special_function */
1302 "R_TLSM", /* name */
1303 true, /* partial_inplace */
1304 MINUS_ONE
, /* src_mask */
1305 MINUS_ONE
, /* dst_mask */
1306 false), /* pcrel_offset */
1308 /* 0x25: TLS module relocation. */
1309 HOWTO (R_TLSML
, /* type */
1311 4, /* size (0 = byte, 1 = short, 2 = long) */
1313 false, /* pc_relative */
1315 complain_overflow_bitfield
, /* complain_on_overflow */
1316 0, /* special_function */
1317 "R_TLSM", /* name */
1318 true, /* partial_inplace */
1319 MINUS_ONE
, /* src_mask */
1320 MINUS_ONE
, /* dst_mask */
1321 false), /* pcrel_offset */
1323 /* 0x26: 32 bit relocation, but store negative value. */
1324 HOWTO (R_NEG
, /* type */
1326 -2, /* size (0 = byte, 1 = short, 2 = long) */
1328 false, /* pc_relative */
1330 complain_overflow_bitfield
, /* complain_on_overflow */
1331 0, /* special_function */
1332 "R_NEG_32", /* name */
1333 true, /* partial_inplace */
1334 MINUS_ONE
, /* src_mask */
1335 MINUS_ONE
, /* dst_mask */
1336 false), /* pcrel_offset */
1348 HOWTO (R_TOCU
, /* type */
1349 16, /* rightshift */
1350 1, /* size (0 = byte, 1 = short, 2 = long) */
1352 false, /* pc_relative */
1354 complain_overflow_bitfield
, /* complain_on_overflow */
1355 0, /* special_function */
1356 "R_TOCU", /* name */
1357 true, /* partial_inplace */
1359 0xffff, /* dst_mask */
1360 false), /* pcrel_offset */
1362 /* 0x31: Low-order 16 bit TOC relative relocation. */
1363 HOWTO (R_TOCL
, /* type */
1365 1, /* size (0 = byte, 1 = short, 2 = long) */
1367 false, /* pc_relative */
1369 complain_overflow_dont
, /* complain_on_overflow */
1370 0, /* special_function */
1371 "R_TOCL", /* name */
1372 true, /* partial_inplace */
1374 0xffff, /* dst_mask */
1375 false), /* pcrel_offset */
1380 xcoff64_rtype2howto (arelent
*relent
, struct internal_reloc
*internal
)
1382 if (internal
->r_type
> R_TOCL
)
1385 /* Default howto layout works most of the time */
1386 relent
->howto
= &xcoff64_howto_table
[internal
->r_type
];
1388 /* Special case some 16 bit reloc */
1389 if (15 == (internal
->r_size
& 0x3f))
1391 if (R_BA
== internal
->r_type
)
1392 relent
->howto
= &xcoff64_howto_table
[0x1d];
1393 else if (R_RBR
== internal
->r_type
)
1394 relent
->howto
= &xcoff64_howto_table
[0x1e];
1395 else if (R_RBA
== internal
->r_type
)
1396 relent
->howto
= &xcoff64_howto_table
[0x1f];
1398 /* Special case 32 bit */
1399 else if (31 == (internal
->r_size
& 0x3f))
1401 if (R_POS
== internal
->r_type
)
1402 relent
->howto
= &xcoff64_howto_table
[0x1c];
1404 if (R_NEG
== internal
->r_type
)
1405 relent
->howto
= &xcoff64_howto_table
[0x26];
1408 /* The r_size field of an XCOFF reloc encodes the bitsize of the
1409 relocation, as well as indicating whether it is signed or not.
1410 Doublecheck that the relocation information gathered from the
1411 type matches this information. The bitsize is not significant
1412 for R_REF relocs. */
1413 if (relent
->howto
->dst_mask
!= 0
1414 && (relent
->howto
->bitsize
1415 != ((unsigned int) internal
->r_size
& 0x3f) + 1))
1420 xcoff64_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1421 bfd_reloc_code_real_type code
)
1425 case BFD_RELOC_PPC_B26
:
1426 return &xcoff64_howto_table
[0xa];
1427 case BFD_RELOC_PPC_BA16
:
1428 return &xcoff64_howto_table
[0x1d];
1429 case BFD_RELOC_PPC_BA26
:
1430 return &xcoff64_howto_table
[8];
1431 case BFD_RELOC_PPC_TOC16
:
1432 return &xcoff64_howto_table
[3];
1433 case BFD_RELOC_PPC_TOC16_HI
:
1434 return &xcoff64_howto_table
[0x30];
1435 case BFD_RELOC_PPC_TOC16_LO
:
1436 return &xcoff64_howto_table
[0x31];
1437 case BFD_RELOC_PPC_B16
:
1438 return &xcoff64_howto_table
[0x1e];
1440 case BFD_RELOC_CTOR
:
1441 return &xcoff64_howto_table
[0x1c];
1443 return &xcoff64_howto_table
[0];
1444 case BFD_RELOC_NONE
:
1445 return &xcoff64_howto_table
[0xf];
1446 case BFD_RELOC_PPC_NEG
:
1447 return &xcoff64_howto_table
[0x1];
1448 case BFD_RELOC_PPC64_TLSGD
:
1449 return &xcoff64_howto_table
[0x20];
1450 case BFD_RELOC_PPC64_TLSIE
:
1451 return &xcoff64_howto_table
[0x21];
1452 case BFD_RELOC_PPC64_TLSLD
:
1453 return &xcoff64_howto_table
[0x22];
1454 case BFD_RELOC_PPC64_TLSLE
:
1455 return &xcoff64_howto_table
[0x23];
1456 case BFD_RELOC_PPC64_TLSM
:
1457 return &xcoff64_howto_table
[0x24];
1458 case BFD_RELOC_PPC64_TLSML
:
1459 return &xcoff64_howto_table
[0x25];
1465 static reloc_howto_type
*
1466 xcoff64_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1472 i
< sizeof (xcoff64_howto_table
) / sizeof (xcoff64_howto_table
[0]);
1474 if (xcoff64_howto_table
[i
].name
!= NULL
1475 && strcasecmp (xcoff64_howto_table
[i
].name
, r_name
) == 0)
1476 return &xcoff64_howto_table
[i
];
1481 /* This is the relocation function for the PowerPC64.
1482 See xcoff_ppc_relocation_section for more information. */
1485 xcoff64_ppc_relocate_section (bfd
*output_bfd
,
1486 struct bfd_link_info
*info
,
1488 asection
*input_section
,
1490 struct internal_reloc
*relocs
,
1491 struct internal_syment
*syms
,
1492 asection
**sections
)
1494 struct internal_reloc
*rel
;
1495 struct internal_reloc
*relend
;
1498 relend
= rel
+ input_section
->reloc_count
;
1499 for (; rel
< relend
; rel
++)
1502 struct xcoff_link_hash_entry
*h
;
1503 struct internal_syment
*sym
;
1506 struct reloc_howto_struct howto
;
1508 bfd_vma value_to_relocate
;
1512 /* Relocation type R_REF is a special relocation type which is
1513 merely used to prevent garbage collection from occurring for
1514 the csect including the symbol which it references. */
1515 if (rel
->r_type
== R_REF
)
1518 /* Retrieve default value in HOWTO table and fix up according
1519 to r_size field, if it can be different.
1520 This should be made during relocation reading but the algorithms
1521 are expecting constant howtos. */
1522 memcpy (&howto
, &xcoff64_howto_table
[rel
->r_type
], sizeof (howto
));
1523 if (howto
.bitsize
!= (rel
->r_size
& 0x3f) + 1)
1525 switch (rel
->r_type
)
1529 howto
.bitsize
= (rel
->r_size
& 0x3f) + 1;
1530 howto
.size
= howto
.bitsize
> 16 ? (howto
.bitsize
> 32 ? 4 : 2) : 1;
1531 howto
.src_mask
= howto
.dst_mask
= N_ONES (howto
.bitsize
);
1536 (_("%pB: relocatation (%d) at (0x%" BFD_VMA_FMT
"x) has wrong"
1537 " r_rsize (0x%x)\n"),
1538 input_bfd
, rel
->r_type
, rel
->r_vaddr
, rel
->r_size
);
1543 howto
.complain_on_overflow
= (rel
->r_size
& 0x80
1544 ? complain_overflow_signed
1545 : complain_overflow_bitfield
);
1552 symndx
= rel
->r_symndx
;
1558 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
1559 sym
= syms
+ symndx
;
1560 addend
= - sym
->n_value
;
1564 sec
= sections
[symndx
];
1565 /* Hack to make sure we use the right TOC anchor value
1566 if this reloc is against the TOC anchor. */
1567 if (sec
->name
[3] == '0'
1568 && strcmp (sec
->name
, ".tc0") == 0)
1569 val
= xcoff_data (output_bfd
)->toc
;
1571 val
= (sec
->output_section
->vma
1572 + sec
->output_offset
1578 if (info
->unresolved_syms_in_objects
!= RM_IGNORE
1579 && (h
->flags
& XCOFF_WAS_UNDEFINED
) != 0)
1580 info
->callbacks
->undefined_symbol
1581 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
1582 rel
->r_vaddr
- input_section
->vma
,
1583 info
->unresolved_syms_in_objects
== RM_DIAGNOSE
1584 && !info
->warn_unresolved_syms
);
1586 if (h
->root
.type
== bfd_link_hash_defined
1587 || h
->root
.type
== bfd_link_hash_defweak
)
1589 sec
= h
->root
.u
.def
.section
;
1590 val
= (h
->root
.u
.def
.value
1591 + sec
->output_section
->vma
1592 + sec
->output_offset
);
1594 else if (h
->root
.type
== bfd_link_hash_common
)
1596 sec
= h
->root
.u
.c
.p
->section
;
1597 val
= (sec
->output_section
->vma
1598 + sec
->output_offset
);
1602 BFD_ASSERT (bfd_link_relocatable (info
)
1603 || (h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
1604 || (h
->flags
& XCOFF_IMPORT
) != 0);
1609 if (rel
->r_type
>= XCOFF_MAX_CALCULATE_RELOCATION
1610 || !((*xcoff64_calculate_relocation
[rel
->r_type
])
1611 (input_bfd
, input_section
, output_bfd
, rel
, sym
, &howto
, val
,
1612 addend
, &relocation
, contents
)))
1616 address
= rel
->r_vaddr
- input_section
->vma
;
1617 location
= contents
+ address
;
1619 if (address
> input_section
->size
)
1622 /* Get the value we are going to relocate. */
1623 if (1 == howto
.size
)
1624 value_to_relocate
= bfd_get_16 (input_bfd
, location
);
1625 else if (2 == howto
.size
)
1626 value_to_relocate
= bfd_get_32 (input_bfd
, location
);
1628 value_to_relocate
= bfd_get_64 (input_bfd
, location
);
1632 FIXME: We may drop bits during the addition
1633 which we don't check for. We must either check at every single
1634 operation, which would be tedious, or we must do the computations
1635 in a type larger than bfd_vma, which would be inefficient. */
1637 if (((*xcoff_complain_overflow
[howto
.complain_on_overflow
])
1638 (input_bfd
, value_to_relocate
, relocation
, &howto
)))
1641 char buf
[SYMNMLEN
+ 1];
1642 char reloc_type_name
[10];
1654 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
1658 sprintf (reloc_type_name
, "0x%02x", rel
->r_type
);
1660 (*info
->callbacks
->reloc_overflow
)
1661 (info
, (h
? &h
->root
: NULL
), name
, reloc_type_name
,
1662 (bfd_vma
) 0, input_bfd
, input_section
,
1663 rel
->r_vaddr
- input_section
->vma
);
1666 /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */
1667 value_to_relocate
= ((value_to_relocate
& ~howto
.dst_mask
)
1668 | (((value_to_relocate
& howto
.src_mask
)
1669 + relocation
) & howto
.dst_mask
));
1671 /* Put the value back in the object file. */
1672 if (1 == howto
.size
)
1673 bfd_put_16 (input_bfd
, value_to_relocate
, location
);
1674 else if (2 == howto
.size
)
1675 bfd_put_32 (input_bfd
, value_to_relocate
, location
);
1677 bfd_put_64 (input_bfd
, value_to_relocate
, location
);
1684 /* PR 21786: The PE/COFF standard does not require NUL termination for any of
1685 the ASCII fields in the archive headers. So in order to be able to extract
1686 numerical values we provide our own versions of strtol and strtoll which
1687 take a maximum length as an additional parameter. Also - just to save space,
1688 we omit the endptr return parameter, since we know that it is never used. */
1691 _bfd_strntol (const char * nptr
, int base
, unsigned int maxlen
)
1693 char buf
[24]; /* Should be enough. */
1695 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1697 memcpy (buf
, nptr
, maxlen
);
1699 return strtol (buf
, NULL
, base
);
1703 _bfd_strntoll (const char * nptr
, int base
, unsigned int maxlen
)
1705 char buf
[32]; /* Should be enough. */
1707 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1709 memcpy (buf
, nptr
, maxlen
);
1711 return strtoll (buf
, NULL
, base
);
1714 /* Macro to read an ASCII value stored in an archive header field. */
1715 #define GET_VALUE_IN_FIELD(VAR, FIELD, BASE) \
1718 (VAR) = (sizeof (VAR) > sizeof (long) \
1719 ? _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
1720 : _bfd_strntol (FIELD, BASE, sizeof FIELD)); \
1724 /* Read in the armap of an XCOFF archive. */
1727 xcoff64_slurp_armap (bfd
*abfd
)
1731 bfd_size_type sz
, amt
;
1732 bfd_byte
*contents
, *cend
;
1738 /* This is for the new format. */
1739 struct xcoff_ar_hdr_big hdr
;
1741 if (xcoff_ardata (abfd
) == NULL
)
1743 abfd
->has_armap
= false;
1747 off
= bfd_scan_vma (xcoff_ardata_big (abfd
)->symoff64
,
1748 (const char **) NULL
, 10);
1751 abfd
->has_armap
= false;
1755 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1758 /* The symbol table starts with a normal archive header. */
1759 if (bfd_bread (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR_BIG
, abfd
)
1760 != SIZEOF_AR_HDR_BIG
)
1763 /* Skip the name (normally empty). */
1764 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1765 pos
= ((namlen
+ 1) & ~(size_t) 1) + SXCOFFARFMAG
;
1766 if (bfd_seek (abfd
, pos
, SEEK_CUR
) != 0)
1769 sz
= bfd_scan_vma (hdr
.size
, (const char **) NULL
, 10);
1772 bfd_set_error (bfd_error_bad_value
);
1776 /* Read in the entire symbol table. */
1777 contents
= (bfd_byte
*) _bfd_alloc_and_read (abfd
, sz
+ 1, sz
);
1778 if (contents
== NULL
)
1781 /* Ensure strings are NULL terminated so we don't wander off the end
1785 /* The symbol table starts with an eight byte count. */
1786 c
= H_GET_64 (abfd
, contents
);
1790 bfd_set_error (bfd_error_bad_value
);
1794 amt
*= sizeof (carsym
);
1795 bfd_ardata (abfd
)->symdefs
= (carsym
*) bfd_alloc (abfd
, amt
);
1796 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1799 /* After the count comes a list of eight byte file offsets. */
1800 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1802 ++i
, ++arsym
, p
+= 8)
1803 arsym
->file_offset
= H_GET_64 (abfd
, p
);
1805 /* After the file offsets come null terminated symbol names. */
1806 cend
= contents
+ sz
;
1807 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1809 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1813 bfd_set_error (bfd_error_bad_value
);
1816 arsym
->name
= (char *) p
;
1819 bfd_ardata (abfd
)->symdef_count
= c
;
1820 abfd
->has_armap
= true;
1826 /* See if this is an NEW XCOFF archive. */
1829 xcoff64_archive_p (bfd
*abfd
)
1831 struct artdata
*tdata_hold
;
1832 char magic
[SXCOFFARMAG
];
1833 /* This is the new format. */
1834 struct xcoff_ar_file_hdr_big hdr
;
1835 size_t amt
= SXCOFFARMAG
;
1837 if (bfd_bread (magic
, amt
, abfd
) != amt
)
1839 if (bfd_get_error () != bfd_error_system_call
)
1840 bfd_set_error (bfd_error_wrong_format
);
1844 if (strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0)
1846 bfd_set_error (bfd_error_wrong_format
);
1850 /* Copy over the magic string. */
1851 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1853 /* Now read the rest of the file header. */
1854 amt
= SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
;
1855 if (bfd_bread (&hdr
.memoff
, amt
, abfd
) != amt
)
1857 if (bfd_get_error () != bfd_error_system_call
)
1858 bfd_set_error (bfd_error_wrong_format
);
1862 tdata_hold
= bfd_ardata (abfd
);
1864 amt
= sizeof (struct artdata
);
1865 bfd_ardata (abfd
) = (struct artdata
*) bfd_zalloc (abfd
, amt
);
1866 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1867 goto error_ret_restore
;
1869 /* Already cleared by bfd_zalloc above.
1870 bfd_ardata (abfd)->cache = NULL;
1871 bfd_ardata (abfd)->archive_head = NULL;
1872 bfd_ardata (abfd)->symdefs = NULL;
1873 bfd_ardata (abfd)->extended_names = NULL;
1874 bfd_ardata (abfd)->extended_names_size = 0; */
1875 bfd_ardata (abfd
)->first_file_filepos
= bfd_scan_vma (hdr
.firstmemoff
,
1876 (const char **) NULL
,
1879 amt
= SIZEOF_AR_FILE_HDR_BIG
;
1880 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, amt
);
1881 if (bfd_ardata (abfd
)->tdata
== NULL
)
1884 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1886 if (! xcoff64_slurp_armap (abfd
))
1889 bfd_release (abfd
, bfd_ardata (abfd
));
1891 bfd_ardata (abfd
) = tdata_hold
;
1895 return _bfd_no_cleanup
;
1899 /* Open the next element in an XCOFF archive. */
1902 xcoff64_openr_next_archived_file (bfd
*archive
, bfd
*last_file
)
1906 if ((xcoff_ardata (archive
) == NULL
)
1907 || ! xcoff_big_format_p (archive
))
1909 bfd_set_error (bfd_error_invalid_operation
);
1913 if (last_file
== NULL
)
1915 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1919 filestart
= bfd_scan_vma (arch_xhdr_big (last_file
)->nextoff
,
1920 (const char **) NULL
, 10);
1924 || filestart
== bfd_scan_vma (xcoff_ardata_big (archive
)->memoff
,
1925 (const char **) NULL
, 10)
1926 || filestart
== bfd_scan_vma (xcoff_ardata_big (archive
)->symoff
,
1927 (const char **) NULL
, 10))
1929 bfd_set_error (bfd_error_no_more_archived_files
);
1933 return _bfd_get_elt_at_filepos (archive
, (file_ptr
) filestart
);
1936 /* We can't use the usual coff_sizeof_headers routine, because AIX
1937 always uses an a.out header. */
1940 xcoff64_sizeof_headers (bfd
*abfd
,
1941 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
1945 size
= bfd_coff_filhsz (abfd
);
1947 /* Don't think the small aout header can be used since some of the
1948 old elements have been reordered past the end of the old coff
1951 if (xcoff_data (abfd
)->full_aouthdr
)
1952 size
+= bfd_coff_aoutsz (abfd
);
1954 size
+= abfd
->section_count
* bfd_coff_scnhsz (abfd
);
1959 xcoff64_create_csect_from_smclas (bfd
*abfd
, union internal_auxent
*aux
,
1960 const char *symbol_name
)
1962 asection
*return_value
= NULL
;
1964 /* Changes from 32 :
1965 .sv == 8, is only for 32 bit programs
1966 .ti == 12 and .tb == 13 are now reserved. */
1967 static const char * const names
[] =
1969 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
1970 NULL
, ".bs", ".ds", ".uc", NULL
, NULL
, NULL
, ".tc0",
1971 ".td", ".sv64", ".sv3264", NULL
, ".tl", ".ul", ".te"
1974 if ((aux
->x_csect
.x_smclas
< ARRAY_SIZE (names
))
1975 && (NULL
!= names
[aux
->x_csect
.x_smclas
]))
1978 return_value
= bfd_make_section_anyway
1979 (abfd
, names
[aux
->x_csect
.x_smclas
]);
1985 /* xgettext: c-format */
1986 (_("%pB: symbol `%s' has unrecognized smclas %d"),
1987 abfd
, symbol_name
, aux
->x_csect
.x_smclas
);
1988 bfd_set_error (bfd_error_bad_value
);
1991 return return_value
;
1995 xcoff64_is_lineno_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
,
1996 bfd_vma value ATTRIBUTE_UNUSED
)
2002 xcoff64_is_reloc_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
,
2003 bfd_vma value ATTRIBUTE_UNUSED
)
2009 xcoff64_loader_symbol_offset (bfd
*abfd ATTRIBUTE_UNUSED
,
2010 struct internal_ldhdr
*ldhdr
)
2012 return (ldhdr
->l_symoff
);
2016 xcoff64_loader_reloc_offset (bfd
*abfd ATTRIBUTE_UNUSED
,
2017 struct internal_ldhdr
*ldhdr
)
2019 return (ldhdr
->l_rldoff
);
2023 xcoff64_bad_format_hook (bfd
* abfd
, void *filehdr
)
2025 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
2027 /* Check flavor first. */
2028 if (bfd_get_flavour (abfd
) != bfd_target_xcoff_flavour
)
2031 if (bfd_xcoff_magic_number (abfd
) != internal_f
->f_magic
)
2038 xcoff64_generate_rtinit (bfd
*abfd
, const char *init
, const char *fini
,
2041 bfd_byte filehdr_ext
[FILHSZ
];
2042 bfd_byte scnhdr_ext
[SCNHSZ
* 3];
2043 bfd_byte syment_ext
[SYMESZ
* 10];
2044 bfd_byte reloc_ext
[RELSZ
* 3];
2045 bfd_byte
*data_buffer
;
2046 bfd_size_type data_buffer_size
;
2047 bfd_byte
*string_table
, *st_tmp
;
2048 bfd_size_type string_table_size
;
2050 size_t initsz
, finisz
;
2051 struct internal_filehdr filehdr
;
2052 struct internal_scnhdr text_scnhdr
;
2053 struct internal_scnhdr data_scnhdr
;
2054 struct internal_scnhdr bss_scnhdr
;
2055 struct internal_syment syment
;
2056 union internal_auxent auxent
;
2057 struct internal_reloc reloc
;
2059 char *text_name
= ".text";
2060 char *data_name
= ".data";
2061 char *bss_name
= ".bss";
2062 char *rtinit_name
= "__rtinit";
2063 char *rtld_name
= "__rtld";
2065 if (! bfd_xcoff_rtinit_size (abfd
))
2068 initsz
= (init
== NULL
? 0 : 1 + strlen (init
));
2069 finisz
= (fini
== NULL
? 0 : 1 + strlen (fini
));
2072 memset (filehdr_ext
, 0, FILHSZ
);
2073 memset (&filehdr
, 0, sizeof (struct internal_filehdr
));
2074 filehdr
.f_magic
= bfd_xcoff_magic_number (abfd
);
2075 filehdr
.f_nscns
= 3;
2076 filehdr
.f_timdat
= 0;
2077 filehdr
.f_nsyms
= 0; /* at least 6, no more than 8 */
2078 filehdr
.f_symptr
= 0; /* set below */
2079 filehdr
.f_opthdr
= 0;
2080 filehdr
.f_flags
= 0;
2082 /* Section headers. */
2083 memset (scnhdr_ext
, 0, 3 * SCNHSZ
);
2086 memset (&text_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2087 memcpy (text_scnhdr
.s_name
, text_name
, strlen (text_name
));
2088 text_scnhdr
.s_paddr
= 0;
2089 text_scnhdr
.s_vaddr
= 0;
2090 text_scnhdr
.s_size
= 0;
2091 text_scnhdr
.s_scnptr
= 0;
2092 text_scnhdr
.s_relptr
= 0;
2093 text_scnhdr
.s_lnnoptr
= 0;
2094 text_scnhdr
.s_nreloc
= 0;
2095 text_scnhdr
.s_nlnno
= 0;
2096 text_scnhdr
.s_flags
= STYP_TEXT
;
2099 memset (&data_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2100 memcpy (data_scnhdr
.s_name
, data_name
, strlen (data_name
));
2101 data_scnhdr
.s_paddr
= 0;
2102 data_scnhdr
.s_vaddr
= 0;
2103 data_scnhdr
.s_size
= 0; /* set below */
2104 data_scnhdr
.s_scnptr
= FILHSZ
+ 3 * SCNHSZ
;
2105 data_scnhdr
.s_relptr
= 0; /* set below */
2106 data_scnhdr
.s_lnnoptr
= 0;
2107 data_scnhdr
.s_nreloc
= 0; /* either 1 or 2 */
2108 data_scnhdr
.s_nlnno
= 0;
2109 data_scnhdr
.s_flags
= STYP_DATA
;
2112 memset (&bss_scnhdr
, 0, sizeof (struct internal_scnhdr
));
2113 memcpy (bss_scnhdr
.s_name
, bss_name
, strlen (bss_name
));
2114 bss_scnhdr
.s_paddr
= 0; /* set below */
2115 bss_scnhdr
.s_vaddr
= 0; /* set below */
2116 bss_scnhdr
.s_size
= 0; /* set below */
2117 bss_scnhdr
.s_scnptr
= 0;
2118 bss_scnhdr
.s_relptr
= 0;
2119 bss_scnhdr
.s_lnnoptr
= 0;
2120 bss_scnhdr
.s_nreloc
= 0;
2121 bss_scnhdr
.s_nlnno
= 0;
2122 bss_scnhdr
.s_flags
= STYP_BSS
;
2125 0x0000 0x00000000 : rtl
2127 0x0008 0x00000018 : offset to init, or 0
2128 0x000C 0x00000038 : offset to fini, or 0
2129 0x0010 0x00000010 : size of descriptor
2130 0x0014 0x00000000 : pad
2131 0x0018 0x00000000 : init, needs a reloc
2133 0x0020 0x00000058 : offset to init name
2134 0x0024 0x00000000 : flags, padded to a word
2135 0x0028 0x00000000 : empty init
2139 0x0038 0x00000000 : fini, needs a reloc
2141 0x0040 0x00000??? : offset to fini name
2142 0x0044 0x00000000 : flags, padded to a word
2143 0x0048 0x00000000 : empty fini
2148 0x0058 + initsz fini name */
2150 data_buffer_size
= 0x0058 + initsz
+ finisz
;
2151 data_buffer_size
= (data_buffer_size
+ 7) &~ (bfd_size_type
) 7;
2153 data_buffer
= (bfd_byte
*) bfd_zmalloc (data_buffer_size
);
2154 if (data_buffer
== NULL
)
2160 bfd_put_32 (abfd
, val
, &data_buffer
[0x08]);
2162 bfd_put_32 (abfd
, val
, &data_buffer
[0x20]);
2163 memcpy (&data_buffer
[val
], init
, initsz
);
2169 bfd_put_32 (abfd
, val
, &data_buffer
[0x0C]);
2170 val
= 0x58 + initsz
;
2171 bfd_put_32 (abfd
, val
, &data_buffer
[0x40]);
2172 memcpy (&data_buffer
[val
], fini
, finisz
);
2176 bfd_put_32 (abfd
, val
, &data_buffer
[0x10]);
2177 data_scnhdr
.s_size
= data_buffer_size
;
2178 bss_scnhdr
.s_paddr
= bss_scnhdr
.s_vaddr
= data_scnhdr
.s_size
;
2181 string_table_size
= 4;
2182 string_table_size
+= strlen (data_name
) + 1;
2183 string_table_size
+= strlen (rtinit_name
) + 1;
2184 string_table_size
+= initsz
;
2185 string_table_size
+= finisz
;
2187 string_table_size
+= strlen (rtld_name
) + 1;
2189 string_table
= (bfd_byte
*) bfd_zmalloc (string_table_size
);
2190 if (string_table
== NULL
)
2193 val
= string_table_size
;
2194 bfd_put_32 (abfd
, val
, &string_table
[0]);
2195 st_tmp
= string_table
+ 4;
2203 memset (syment_ext
, 0, 10 * SYMESZ
);
2204 memset (reloc_ext
, 0, 3 * RELSZ
);
2207 memset (&syment
, 0, sizeof (struct internal_syment
));
2208 memset (&auxent
, 0, sizeof (union internal_auxent
));
2210 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2211 memcpy (st_tmp
, data_name
, strlen (data_name
));
2212 st_tmp
+= strlen (data_name
) + 1;
2215 syment
.n_sclass
= C_HIDEXT
;
2216 syment
.n_numaux
= 1;
2217 auxent
.x_csect
.x_scnlen
.l
= data_buffer_size
;
2218 auxent
.x_csect
.x_smtyp
= 3 << 3 | XTY_SD
;
2219 auxent
.x_csect
.x_smclas
= XMC_RW
;
2220 bfd_coff_swap_sym_out (abfd
, &syment
,
2221 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2222 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2224 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2225 filehdr
.f_nsyms
+= 2;
2228 memset (&syment
, 0, sizeof (struct internal_syment
));
2229 memset (&auxent
, 0, sizeof (union internal_auxent
));
2230 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2231 memcpy (st_tmp
, rtinit_name
, strlen (rtinit_name
));
2232 st_tmp
+= strlen (rtinit_name
) + 1;
2235 syment
.n_sclass
= C_EXT
;
2236 syment
.n_numaux
= 1;
2237 auxent
.x_csect
.x_smtyp
= XTY_LD
;
2238 auxent
.x_csect
.x_smclas
= XMC_RW
;
2239 bfd_coff_swap_sym_out (abfd
, &syment
,
2240 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2241 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2243 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2244 filehdr
.f_nsyms
+= 2;
2249 memset (&syment
, 0, sizeof (struct internal_syment
));
2250 memset (&auxent
, 0, sizeof (union internal_auxent
));
2252 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2253 memcpy (st_tmp
, init
, initsz
);
2256 syment
.n_sclass
= C_EXT
;
2257 syment
.n_numaux
= 1;
2258 bfd_coff_swap_sym_out (abfd
, &syment
,
2259 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2260 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2262 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2264 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2265 reloc
.r_vaddr
= 0x0018;
2266 reloc
.r_symndx
= filehdr
.f_nsyms
;
2267 reloc
.r_type
= R_POS
;
2269 bfd_coff_swap_reloc_out (abfd
, &reloc
, &reloc_ext
[0]);
2271 filehdr
.f_nsyms
+= 2;
2272 data_scnhdr
.s_nreloc
+= 1;
2278 memset (&syment
, 0, sizeof (struct internal_syment
));
2279 memset (&auxent
, 0, sizeof (union internal_auxent
));
2281 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2282 memcpy (st_tmp
, fini
, finisz
);
2285 syment
.n_sclass
= C_EXT
;
2286 syment
.n_numaux
= 1;
2287 bfd_coff_swap_sym_out (abfd
, &syment
,
2288 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2289 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2291 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2294 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2295 reloc
.r_vaddr
= 0x0038;
2296 reloc
.r_symndx
= filehdr
.f_nsyms
;
2297 reloc
.r_type
= R_POS
;
2299 bfd_coff_swap_reloc_out (abfd
, &reloc
,
2300 &reloc_ext
[data_scnhdr
.s_nreloc
* RELSZ
]);
2302 filehdr
.f_nsyms
+= 2;
2303 data_scnhdr
.s_nreloc
+= 1;
2308 memset (&syment
, 0, sizeof (struct internal_syment
));
2309 memset (&auxent
, 0, sizeof (union internal_auxent
));
2311 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
2312 memcpy (st_tmp
, rtld_name
, strlen (rtld_name
));
2313 st_tmp
+= strlen (rtld_name
) + 1;
2315 syment
.n_sclass
= C_EXT
;
2316 syment
.n_numaux
= 1;
2317 bfd_coff_swap_sym_out (abfd
, &syment
,
2318 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
2319 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
2321 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
2324 memset (&reloc
, 0, sizeof (struct internal_reloc
));
2325 reloc
.r_vaddr
= 0x0000;
2326 reloc
.r_symndx
= filehdr
.f_nsyms
;
2327 reloc
.r_type
= R_POS
;
2329 bfd_coff_swap_reloc_out (abfd
, &reloc
,
2330 &reloc_ext
[data_scnhdr
.s_nreloc
* RELSZ
]);
2332 filehdr
.f_nsyms
+= 2;
2333 data_scnhdr
.s_nreloc
+= 1;
2335 bss_scnhdr
.s_size
= 0;
2338 data_scnhdr
.s_relptr
= data_scnhdr
.s_scnptr
+ data_buffer_size
;
2339 filehdr
.f_symptr
= data_scnhdr
.s_relptr
+ data_scnhdr
.s_nreloc
* RELSZ
;
2341 bfd_coff_swap_filehdr_out (abfd
, &filehdr
, filehdr_ext
);
2342 bfd_bwrite (filehdr_ext
, FILHSZ
, abfd
);
2343 bfd_coff_swap_scnhdr_out (abfd
, &text_scnhdr
, &scnhdr_ext
[SCNHSZ
* 0]);
2344 bfd_coff_swap_scnhdr_out (abfd
, &data_scnhdr
, &scnhdr_ext
[SCNHSZ
* 1]);
2345 bfd_coff_swap_scnhdr_out (abfd
, &bss_scnhdr
, &scnhdr_ext
[SCNHSZ
* 2]);
2346 bfd_bwrite (scnhdr_ext
, 3 * SCNHSZ
, abfd
);
2347 bfd_bwrite (data_buffer
, data_buffer_size
, abfd
);
2348 bfd_bwrite (reloc_ext
, data_scnhdr
.s_nreloc
* RELSZ
, abfd
);
2349 bfd_bwrite (syment_ext
, filehdr
.f_nsyms
* SYMESZ
, abfd
);
2350 bfd_bwrite (string_table
, string_table_size
, abfd
);
2358 /* The typical dynamic reloc. */
2360 static reloc_howto_type xcoff64_dynamic_reloc
=
2361 HOWTO (0, /* type */
2363 4, /* size (0 = byte, 1 = short, 2 = long) */
2365 false, /* pc_relative */
2367 complain_overflow_bitfield
, /* complain_on_overflow */
2368 0, /* special_function */
2370 true, /* partial_inplace */
2371 MINUS_ONE
, /* src_mask */
2372 MINUS_ONE
, /* dst_mask */
2373 false); /* pcrel_offset */
2375 static const unsigned long xcoff64_glink_code
[10] =
2377 0xe9820000, /* ld r12,0(r2) */
2378 0xf8410028, /* std r2,40(r1) */
2379 0xe80c0000, /* ld r0,0(r12) */
2380 0xe84c0008, /* ld r0,8(r12) */
2381 0x7c0903a6, /* mtctr r0 */
2382 0x4e800420, /* bctr */
2383 0x00000000, /* start of traceback table */
2384 0x000ca000, /* traceback table */
2385 0x00000000, /* traceback table */
2386 0x00000018, /* ??? */
2389 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
2391 { /* COFF backend, defined in libcoff.h. */
2392 _bfd_xcoff64_swap_aux_in
,
2393 _bfd_xcoff64_swap_sym_in
,
2394 _bfd_xcoff64_swap_lineno_in
,
2395 _bfd_xcoff64_swap_aux_out
,
2396 _bfd_xcoff64_swap_sym_out
,
2397 _bfd_xcoff64_swap_lineno_out
,
2398 xcoff64_swap_reloc_out
,
2399 coff_swap_filehdr_out
,
2400 coff_swap_aouthdr_out
,
2401 coff_swap_scnhdr_out
,
2410 true, /* _bfd_coff_long_filenames */
2411 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
2412 3, /* _bfd_coff_default_section_alignment_power */
2413 true, /* _bfd_coff_force_symnames_in_strings */
2414 4, /* _bfd_coff_debug_string_prefix_length */
2415 32768, /* _bfd_coff_max_nscns */
2416 coff_swap_filehdr_in
,
2417 coff_swap_aouthdr_in
,
2418 coff_swap_scnhdr_in
,
2419 xcoff64_swap_reloc_in
,
2420 xcoff64_bad_format_hook
,
2421 coff_set_arch_mach_hook
,
2424 coff_set_alignment_hook
,
2425 coff_slurp_symbol_table
,
2426 symname_in_debug_hook
,
2427 coff_pointerize_aux_hook
,
2429 dummy_reloc16_extra_cases
,
2430 dummy_reloc16_estimate
,
2431 NULL
, /* bfd_coff_symbol_classification */
2432 coff_compute_section_file_positions
,
2433 NULL
, /* _bfd_coff_start_final_link */
2434 xcoff64_ppc_relocate_section
,
2435 coff_rtype_to_howto
,
2436 NULL
, /* _bfd_coff_adjust_symndx */
2437 _bfd_generic_link_add_one_symbol
,
2438 coff_link_output_has_begun
,
2439 coff_final_link_postscript
,
2440 NULL
/* print_pdata. */
2443 0x01EF, /* magic number */
2447 /* Function pointers to xcoff specific swap routines. */
2448 xcoff64_swap_ldhdr_in
,
2449 xcoff64_swap_ldhdr_out
,
2450 xcoff64_swap_ldsym_in
,
2451 xcoff64_swap_ldsym_out
,
2452 xcoff64_swap_ldrel_in
,
2453 xcoff64_swap_ldrel_out
,
2459 24, /* _xcoff_function_descriptor_size */
2460 0, /* _xcoff_small_aout_header_size */
2463 2, /* _xcoff_ldhdr_version */
2465 _bfd_xcoff64_put_symbol_name
,
2466 _bfd_xcoff64_put_ldsymbol_name
,
2467 &xcoff64_dynamic_reloc
,
2468 xcoff64_create_csect_from_smclas
,
2470 /* Lineno and reloc count overflow. */
2471 xcoff64_is_lineno_count_overflow
,
2472 xcoff64_is_reloc_count_overflow
,
2474 xcoff64_loader_symbol_offset
,
2475 xcoff64_loader_reloc_offset
,
2478 &xcoff64_glink_code
[0],
2479 40, /* _xcoff_glink_size */
2482 88, /* _xcoff_rtinit_size */
2483 xcoff64_generate_rtinit
,
2486 /* The transfer vector that leads the outside world to all of the above. */
2487 const bfd_target rs6000_xcoff64_vec
=
2490 bfd_target_xcoff_flavour
,
2491 BFD_ENDIAN_BIG
, /* data byte order is big */
2492 BFD_ENDIAN_BIG
, /* header byte order is big */
2494 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
2495 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
2497 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
2498 0, /* leading char */
2499 '/', /* ar_pad_char */
2500 15, /* ar_max_namelen */
2501 0, /* match priority. */
2502 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
2526 { /* bfd_check_format */
2533 { /* bfd_set_format */
2534 _bfd_bool_bfd_false_error
,
2536 _bfd_generic_mkarchive
,
2537 _bfd_bool_bfd_false_error
2540 {/* bfd_write_contents */
2541 _bfd_bool_bfd_false_error
,
2542 coff_write_object_contents
,
2543 _bfd_xcoff_write_archive_contents
,
2544 _bfd_bool_bfd_false_error
2548 _bfd_archive_close_and_cleanup
,
2550 coff_new_section_hook
,
2551 _bfd_generic_get_section_contents
,
2552 _bfd_generic_get_section_contents_in_window
,
2555 _bfd_xcoff_copy_private_bfd_data
,
2556 _bfd_generic_bfd_merge_private_bfd_data
,
2557 _bfd_generic_init_private_section_data
,
2558 _bfd_generic_bfd_copy_private_section_data
,
2559 _bfd_generic_bfd_copy_private_symbol_data
,
2560 _bfd_generic_bfd_copy_private_header_data
,
2561 _bfd_generic_bfd_set_private_flags
,
2562 _bfd_generic_bfd_print_private_bfd_data
,
2565 BFD_JUMP_TABLE_CORE (coff
),
2568 xcoff64_slurp_armap
,
2569 _bfd_noarchive_slurp_extended_name_table
,
2570 _bfd_noarchive_construct_extended_name_table
,
2571 bfd_dont_truncate_arname
,
2572 _bfd_xcoff_write_armap
,
2573 _bfd_xcoff_read_ar_hdr
,
2574 _bfd_generic_write_ar_hdr
,
2575 xcoff64_openr_next_archived_file
,
2576 _bfd_generic_get_elt_at_index
,
2577 _bfd_xcoff_stat_arch_elt
,
2581 coff_get_symtab_upper_bound
,
2582 coff_canonicalize_symtab
,
2583 coff_make_empty_symbol
,
2585 coff_get_symbol_info
,
2586 coff_get_symbol_version_string
,
2587 _bfd_xcoff_is_local_label_name
,
2588 coff_bfd_is_target_special_symbol
,
2590 coff_find_nearest_line
,
2592 coff_find_inliner_info
,
2593 coff_bfd_make_debug_symbol
,
2594 _bfd_generic_read_minisymbols
,
2595 _bfd_generic_minisymbol_to_symbol
,
2598 coff_get_reloc_upper_bound
,
2599 coff_canonicalize_reloc
,
2600 _bfd_generic_set_reloc
,
2601 xcoff64_reloc_type_lookup
,
2602 xcoff64_reloc_name_lookup
,
2606 coff_set_section_contents
,
2609 xcoff64_sizeof_headers
,
2610 bfd_generic_get_relocated_section_contents
,
2611 bfd_generic_relax_section
,
2612 _bfd_xcoff_bfd_link_hash_table_create
,
2613 _bfd_xcoff_bfd_link_add_symbols
,
2614 _bfd_generic_link_just_syms
,
2615 _bfd_generic_copy_link_hash_symbol_type
,
2616 _bfd_xcoff_bfd_final_link
,
2617 _bfd_generic_link_split_section
,
2618 _bfd_generic_link_check_relocs
,
2619 bfd_generic_gc_sections
,
2620 bfd_generic_lookup_section_flags
,
2621 bfd_generic_merge_sections
,
2622 bfd_generic_is_group_section
,
2623 bfd_generic_group_name
,
2624 bfd_generic_discard_group
,
2625 _bfd_generic_section_already_linked
,
2626 _bfd_xcoff_define_common_symbol
,
2627 _bfd_generic_link_hide_symbol
,
2628 bfd_generic_define_start_stop
,
2631 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
2632 _bfd_xcoff_canonicalize_dynamic_symtab
,
2633 _bfd_nodynamic_get_synthetic_symtab
,
2634 _bfd_xcoff_get_dynamic_reloc_upper_bound
,
2635 _bfd_xcoff_canonicalize_dynamic_reloc
,
2637 /* Opposite endian version, none exists */
2640 &bfd_xcoff_backend_data
,
2643 extern bfd_cleanup xcoff64_core_p
2645 extern bool xcoff64_core_file_matches_executable_p
2647 extern char *xcoff64_core_file_failing_command
2649 extern int xcoff64_core_file_failing_signal
2651 #define xcoff64_core_file_pid _bfd_nocore_core_file_pid
2654 static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data
=
2656 { /* COFF backend, defined in libcoff.h. */
2657 _bfd_xcoff64_swap_aux_in
,
2658 _bfd_xcoff64_swap_sym_in
,
2659 _bfd_xcoff64_swap_lineno_in
,
2660 _bfd_xcoff64_swap_aux_out
,
2661 _bfd_xcoff64_swap_sym_out
,
2662 _bfd_xcoff64_swap_lineno_out
,
2663 xcoff64_swap_reloc_out
,
2664 coff_swap_filehdr_out
,
2665 coff_swap_aouthdr_out
,
2666 coff_swap_scnhdr_out
,
2675 true, /* _bfd_coff_long_filenames */
2676 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
2677 3, /* _bfd_coff_default_section_alignment_power */
2678 true, /* _bfd_coff_force_symnames_in_strings */
2679 4, /* _bfd_coff_debug_string_prefix_length */
2680 32768, /* _bfd_coff_max_nscns */
2681 coff_swap_filehdr_in
,
2682 coff_swap_aouthdr_in
,
2683 coff_swap_scnhdr_in
,
2684 xcoff64_swap_reloc_in
,
2685 xcoff64_bad_format_hook
,
2686 coff_set_arch_mach_hook
,
2689 coff_set_alignment_hook
,
2690 coff_slurp_symbol_table
,
2691 symname_in_debug_hook
,
2692 coff_pointerize_aux_hook
,
2694 dummy_reloc16_extra_cases
,
2695 dummy_reloc16_estimate
,
2696 NULL
, /* bfd_coff_sym_is_global */
2697 coff_compute_section_file_positions
,
2698 NULL
, /* _bfd_coff_start_final_link */
2699 xcoff64_ppc_relocate_section
,
2700 coff_rtype_to_howto
,
2701 NULL
, /* _bfd_coff_adjust_symndx */
2702 _bfd_generic_link_add_one_symbol
,
2703 coff_link_output_has_begun
,
2704 coff_final_link_postscript
,
2705 NULL
/* print_pdata. */
2708 U64_TOCMAGIC
, /* magic number */
2712 /* Function pointers to xcoff specific swap routines. */
2713 xcoff64_swap_ldhdr_in
,
2714 xcoff64_swap_ldhdr_out
,
2715 xcoff64_swap_ldsym_in
,
2716 xcoff64_swap_ldsym_out
,
2717 xcoff64_swap_ldrel_in
,
2718 xcoff64_swap_ldrel_out
,
2724 24, /* _xcoff_function_descriptor_size */
2725 0, /* _xcoff_small_aout_header_size */
2727 2, /* _xcoff_ldhdr_version */
2729 _bfd_xcoff64_put_symbol_name
,
2730 _bfd_xcoff64_put_ldsymbol_name
,
2731 &xcoff64_dynamic_reloc
,
2732 xcoff64_create_csect_from_smclas
,
2734 /* Lineno and reloc count overflow. */
2735 xcoff64_is_lineno_count_overflow
,
2736 xcoff64_is_reloc_count_overflow
,
2738 xcoff64_loader_symbol_offset
,
2739 xcoff64_loader_reloc_offset
,
2742 &xcoff64_glink_code
[0],
2743 40, /* _xcoff_glink_size */
2746 88, /* _xcoff_rtinit_size */
2747 xcoff64_generate_rtinit
,
2750 /* The transfer vector that leads the outside world to all of the above. */
2751 const bfd_target rs6000_xcoff64_aix_vec
=
2753 "aix5coff64-rs6000",
2754 bfd_target_xcoff_flavour
,
2755 BFD_ENDIAN_BIG
, /* data byte order is big */
2756 BFD_ENDIAN_BIG
, /* header byte order is big */
2758 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
2759 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
2761 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
2762 0, /* leading char */
2763 '/', /* ar_pad_char */
2764 15, /* ar_max_namelen */
2765 0, /* match priority. */
2766 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
2790 { /* bfd_check_format */
2797 { /* bfd_set_format */
2798 _bfd_bool_bfd_false_error
,
2800 _bfd_generic_mkarchive
,
2801 _bfd_bool_bfd_false_error
2804 {/* bfd_write_contents */
2805 _bfd_bool_bfd_false_error
,
2806 coff_write_object_contents
,
2807 _bfd_xcoff_write_archive_contents
,
2808 _bfd_bool_bfd_false_error
2812 _bfd_archive_close_and_cleanup
,
2814 coff_new_section_hook
,
2815 _bfd_generic_get_section_contents
,
2816 _bfd_generic_get_section_contents_in_window
,
2819 _bfd_xcoff_copy_private_bfd_data
,
2820 _bfd_generic_bfd_merge_private_bfd_data
,
2821 _bfd_generic_init_private_section_data
,
2822 _bfd_generic_bfd_copy_private_section_data
,
2823 _bfd_generic_bfd_copy_private_symbol_data
,
2824 _bfd_generic_bfd_copy_private_header_data
,
2825 _bfd_generic_bfd_set_private_flags
,
2826 _bfd_generic_bfd_print_private_bfd_data
,
2829 BFD_JUMP_TABLE_CORE (xcoff64
),
2832 xcoff64_slurp_armap
,
2833 _bfd_noarchive_slurp_extended_name_table
,
2834 _bfd_noarchive_construct_extended_name_table
,
2835 bfd_dont_truncate_arname
,
2836 _bfd_xcoff_write_armap
,
2837 _bfd_xcoff_read_ar_hdr
,
2838 _bfd_generic_write_ar_hdr
,
2839 xcoff64_openr_next_archived_file
,
2840 _bfd_generic_get_elt_at_index
,
2841 _bfd_xcoff_stat_arch_elt
,
2845 coff_get_symtab_upper_bound
,
2846 coff_canonicalize_symtab
,
2847 coff_make_empty_symbol
,
2849 coff_get_symbol_info
,
2850 coff_get_symbol_version_string
,
2851 _bfd_xcoff_is_local_label_name
,
2852 coff_bfd_is_target_special_symbol
,
2854 coff_find_nearest_line
,
2856 coff_find_inliner_info
,
2857 coff_bfd_make_debug_symbol
,
2858 _bfd_generic_read_minisymbols
,
2859 _bfd_generic_minisymbol_to_symbol
,
2862 coff_get_reloc_upper_bound
,
2863 coff_canonicalize_reloc
,
2864 _bfd_generic_set_reloc
,
2865 xcoff64_reloc_type_lookup
,
2866 xcoff64_reloc_name_lookup
,
2870 coff_set_section_contents
,
2873 xcoff64_sizeof_headers
,
2874 bfd_generic_get_relocated_section_contents
,
2875 bfd_generic_relax_section
,
2876 _bfd_xcoff_bfd_link_hash_table_create
,
2877 _bfd_xcoff_bfd_link_add_symbols
,
2878 _bfd_generic_link_just_syms
,
2879 _bfd_generic_copy_link_hash_symbol_type
,
2880 _bfd_xcoff_bfd_final_link
,
2881 _bfd_generic_link_split_section
,
2882 _bfd_generic_link_check_relocs
,
2883 bfd_generic_gc_sections
,
2884 bfd_generic_lookup_section_flags
,
2885 bfd_generic_merge_sections
,
2886 bfd_generic_is_group_section
,
2887 bfd_generic_group_name
,
2888 bfd_generic_discard_group
,
2889 _bfd_generic_section_already_linked
,
2890 _bfd_xcoff_define_common_symbol
,
2891 _bfd_generic_link_hide_symbol
,
2892 bfd_generic_define_start_stop
,
2895 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
2896 _bfd_xcoff_canonicalize_dynamic_symtab
,
2897 _bfd_nodynamic_get_synthetic_symtab
,
2898 _bfd_xcoff_get_dynamic_reloc_upper_bound
,
2899 _bfd_xcoff_canonicalize_dynamic_reloc
,
2901 /* Opposite endian version, none exists. */
2904 & bfd_xcoff_aix5_backend_data
,