1 /* BFD back-end for IBM RS/6000 "XCOFF" files.
2 Copyright (C) 1990-2021 Free Software Foundation, Inc.
3 Written by Metin G. Ozisik, Mimi Phuong-Thao Vo, and John Gilmore.
4 Archive support from Damon A. Permezel.
5 Contributed by IBM Corporation and Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
25 #include "libiberty.h"
29 #include "coff/internal.h"
30 #include "coff/xcoff.h"
31 #include "coff/rs6000.h"
35 extern bool _bfd_xcoff_mkobject (bfd
*);
36 extern bool _bfd_xcoff_copy_private_bfd_data (bfd
*, bfd
*);
37 extern bool _bfd_xcoff_is_local_label_name (bfd
*, const char *);
38 extern reloc_howto_type
*_bfd_xcoff_reloc_type_lookup
39 (bfd
*, bfd_reloc_code_real_type
);
40 extern bool _bfd_xcoff_slurp_armap (bfd
*);
41 extern bfd_cleanup
_bfd_xcoff_archive_p (bfd
*);
42 extern void * _bfd_xcoff_read_ar_hdr (bfd
*);
43 extern bfd
*_bfd_xcoff_openr_next_archived_file (bfd
*, bfd
*);
44 extern int _bfd_xcoff_stat_arch_elt (bfd
*, struct stat
*);
45 extern bool _bfd_xcoff_write_armap
46 (bfd
*, unsigned int, struct orl
*, unsigned int, int);
47 extern bool _bfd_xcoff_write_archive_contents (bfd
*);
48 extern int _bfd_xcoff_sizeof_headers (bfd
*, struct bfd_link_info
*);
49 extern void _bfd_xcoff_swap_sym_in (bfd
*, void *, void *);
50 extern unsigned int _bfd_xcoff_swap_sym_out (bfd
*, void *, void *);
51 extern void _bfd_xcoff_swap_aux_in (bfd
*, void *, int, int, int, int, void *);
52 extern unsigned int _bfd_xcoff_swap_aux_out
53 (bfd
*, void *, int, int, int, int, void *);
54 static void xcoff_swap_reloc_in (bfd
*, void *, void *);
55 static unsigned int xcoff_swap_reloc_out (bfd
*, void *, void *);
57 /* Forward declare xcoff_rtype2howto for coffcode.h macro. */
58 void xcoff_rtype2howto (arelent
*, struct internal_reloc
*);
60 /* coffcode.h needs these to be defined. */
61 #define RS6000COFF_C 1
63 #define SELECT_RELOC(internal, howto) \
65 internal.r_type = howto->type; \
67 ((howto->complain_on_overflow == complain_overflow_signed \
70 | (howto->bitsize - 1)); \
73 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
74 #define COFF_LONG_FILENAMES
75 #define NO_COFF_SYMBOLS
76 #define RTYPE2HOWTO(cache_ptr, dst) xcoff_rtype2howto (cache_ptr, dst)
77 #define coff_mkobject _bfd_xcoff_mkobject
78 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
80 extern bfd_cleanup
rs6000coff_core_p (bfd
*abfd
);
81 extern bool rs6000coff_core_file_matches_executable_p
82 (bfd
*cbfd
, bfd
*ebfd
);
83 extern char *rs6000coff_core_file_failing_command (bfd
*abfd
);
84 extern int rs6000coff_core_file_failing_signal (bfd
*abfd
);
85 #define CORE_FILE_P rs6000coff_core_p
86 #define coff_core_file_failing_command \
87 rs6000coff_core_file_failing_command
88 #define coff_core_file_failing_signal \
89 rs6000coff_core_file_failing_signal
90 #define coff_core_file_matches_executable_p \
91 rs6000coff_core_file_matches_executable_p
92 #define coff_core_file_pid \
93 _bfd_nocore_core_file_pid
95 #define CORE_FILE_P _bfd_dummy_target
96 #define coff_core_file_failing_command \
97 _bfd_nocore_core_file_failing_command
98 #define coff_core_file_failing_signal \
99 _bfd_nocore_core_file_failing_signal
100 #define coff_core_file_matches_executable_p \
101 _bfd_nocore_core_file_matches_executable_p
102 #define coff_core_file_pid \
103 _bfd_nocore_core_file_pid
105 #define coff_SWAP_sym_in _bfd_xcoff_swap_sym_in
106 #define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out
107 #define coff_SWAP_aux_in _bfd_xcoff_swap_aux_in
108 #define coff_SWAP_aux_out _bfd_xcoff_swap_aux_out
109 #define coff_swap_reloc_in xcoff_swap_reloc_in
110 #define coff_swap_reloc_out xcoff_swap_reloc_out
111 #define NO_COFF_RELOCS
113 #ifndef bfd_pe_print_pdata
114 #define bfd_pe_print_pdata NULL
117 #include "coffcode.h"
119 /* The main body of code is in coffcode.h. */
121 static const char *normalize_filename (bfd
*);
122 static bool xcoff_write_armap_old
123 (bfd
*, unsigned int, struct orl
*, unsigned int, int);
124 static bool xcoff_write_armap_big
125 (bfd
*, unsigned int, struct orl
*, unsigned int, int);
126 static bool xcoff_write_archive_contents_old (bfd
*);
127 static bool xcoff_write_archive_contents_big (bfd
*);
128 static void xcoff_swap_ldhdr_in (bfd
*, const void *, struct internal_ldhdr
*);
129 static void xcoff_swap_ldhdr_out (bfd
*, const struct internal_ldhdr
*, void *);
130 static void xcoff_swap_ldsym_in (bfd
*, const void *, struct internal_ldsym
*);
131 static void xcoff_swap_ldsym_out (bfd
*, const struct internal_ldsym
*, void *);
132 static void xcoff_swap_ldrel_in (bfd
*, const void *, struct internal_ldrel
*);
133 static void xcoff_swap_ldrel_out (bfd
*, const struct internal_ldrel
*, void *);
134 static bool xcoff_ppc_relocate_section
135 (bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
136 struct internal_reloc
*, struct internal_syment
*, asection
**);
137 static bool _bfd_xcoff_put_ldsymbol_name
138 (bfd
*, struct xcoff_loader_info
*, struct internal_ldsym
*, const char *);
139 static asection
*xcoff_create_csect_from_smclas
140 (bfd
*, union internal_auxent
*, const char *);
141 static bool xcoff_is_lineno_count_overflow (bfd
*, bfd_vma
);
142 static bool xcoff_is_reloc_count_overflow (bfd
*, bfd_vma
);
143 static bfd_vma
xcoff_loader_symbol_offset (bfd
*, struct internal_ldhdr
*);
144 static bfd_vma
xcoff_loader_reloc_offset (bfd
*, struct internal_ldhdr
*);
145 static bool xcoff_generate_rtinit
146 (bfd
*, const char *, const char *, bool);
147 static bool do_pad (bfd
*, unsigned int);
148 static bool do_copy (bfd
*, bfd
*);
150 /* Relocation functions */
151 static xcoff_reloc_function xcoff_reloc_type_br
;
153 static xcoff_complain_function xcoff_complain_overflow_dont_func
;
154 static xcoff_complain_function xcoff_complain_overflow_bitfield_func
;
155 static xcoff_complain_function xcoff_complain_overflow_signed_func
;
156 static xcoff_complain_function xcoff_complain_overflow_unsigned_func
;
158 xcoff_reloc_function
*const
159 xcoff_calculate_relocation
[XCOFF_MAX_CALCULATE_RELOCATION
] =
161 xcoff_reloc_type_pos
, /* R_POS (0x00) */
162 xcoff_reloc_type_neg
, /* R_NEG (0x01) */
163 xcoff_reloc_type_rel
, /* R_REL (0x02) */
164 xcoff_reloc_type_toc
, /* R_TOC (0x03) */
165 xcoff_reloc_type_toc
, /* R_TRL (0x04) */
166 xcoff_reloc_type_toc
, /* R_GL (0x05) */
167 xcoff_reloc_type_toc
, /* R_TCL (0x06) */
168 xcoff_reloc_type_fail
, /* (0x07) */
169 xcoff_reloc_type_ba
, /* R_BA (0x08) */
170 xcoff_reloc_type_fail
, /* (0x09) */
171 xcoff_reloc_type_br
, /* R_BR (0x0a) */
172 xcoff_reloc_type_fail
, /* (0x0b) */
173 xcoff_reloc_type_pos
, /* R_RL (0x0c) */
174 xcoff_reloc_type_pos
, /* R_RLA (0x0d) */
175 xcoff_reloc_type_fail
, /* (0x0e) */
176 xcoff_reloc_type_noop
, /* R_REF (0x0f) */
177 xcoff_reloc_type_fail
, /* (0x10) */
178 xcoff_reloc_type_fail
, /* (0x11) */
179 xcoff_reloc_type_fail
, /* (0x12) */
180 xcoff_reloc_type_toc
, /* R_TRLA (0x13) */
181 xcoff_reloc_type_fail
, /* R_RRTBI (0x14) */
182 xcoff_reloc_type_fail
, /* R_RRTBA (0x15) */
183 xcoff_reloc_type_ba
, /* R_CAI (0x16) */
184 xcoff_reloc_type_crel
, /* R_CREL (0x17) */
185 xcoff_reloc_type_ba
, /* R_RBA (0x18) */
186 xcoff_reloc_type_ba
, /* R_RBAC (0x19) */
187 xcoff_reloc_type_br
, /* R_RBR (0x1a) */
188 xcoff_reloc_type_ba
, /* R_RBRC (0x1b) */
189 xcoff_reloc_type_fail
, /* (0x1c) */
190 xcoff_reloc_type_fail
, /* (0x1d) */
191 xcoff_reloc_type_fail
, /* (0x1e) */
192 xcoff_reloc_type_fail
, /* (0x1f) */
193 xcoff_reloc_type_tls
, /* R_TLS (0x20) */
194 xcoff_reloc_type_tls
, /* R_TLS_IE (0x21) */
195 xcoff_reloc_type_tls
, /* R_TLS_LD (0x22) */
196 xcoff_reloc_type_tls
, /* R_TLS_LE (0x23) */
197 xcoff_reloc_type_tls
, /* R_TLSM (0x24) */
198 xcoff_reloc_type_tls
, /* R_TLSML (0x25) */
199 xcoff_reloc_type_fail
, /* (0x26) */
200 xcoff_reloc_type_fail
, /* (0x27) */
201 xcoff_reloc_type_fail
, /* (0x28) */
202 xcoff_reloc_type_fail
, /* (0x29) */
203 xcoff_reloc_type_fail
, /* (0x2a) */
204 xcoff_reloc_type_fail
, /* (0x2b) */
205 xcoff_reloc_type_fail
, /* (0x2c) */
206 xcoff_reloc_type_fail
, /* (0x2d) */
207 xcoff_reloc_type_fail
, /* (0x2e) */
208 xcoff_reloc_type_fail
, /* (0x2f) */
209 xcoff_reloc_type_toc
, /* R_TOCU (0x30) */
210 xcoff_reloc_type_toc
, /* R_TOCL (0x31) */
213 xcoff_complain_function
*const
214 xcoff_complain_overflow
[XCOFF_MAX_COMPLAIN_OVERFLOW
] =
216 xcoff_complain_overflow_dont_func
,
217 xcoff_complain_overflow_bitfield_func
,
218 xcoff_complain_overflow_signed_func
,
219 xcoff_complain_overflow_unsigned_func
,
222 /* Information about one member of an archive. */
225 /* The archive member that this structure describes. */
228 /* The number of bytes of padding that must be inserted before the
229 start of the member in order to ensure that the section contents
230 are correctly aligned. */
231 unsigned int leading_padding
;
233 /* The offset of MEMBER from the start of the archive (i.e. the end
234 of the leading padding). */
237 /* The normalized name of MEMBER. */
240 /* The length of NAME, without padding. */
241 bfd_size_type namlen
;
243 /* The length of NAME, with padding. */
244 bfd_size_type padded_namlen
;
246 /* The size of MEMBER's header, including the name and magic sequence. */
247 bfd_size_type header_size
;
249 /* The size of the MEMBER's contents. */
250 bfd_size_type contents_size
;
252 /* The number of bytes of padding that must be inserted after MEMBER
253 in order to preserve even alignment. */
254 bfd_size_type trailing_padding
;
257 /* A structure used for iterating over the members of an archive. */
258 struct archive_iterator
260 /* The archive itself. */
263 /* Information about the current archive member. */
264 struct member_layout current
;
266 /* Information about the next archive member. MEMBER is null if there
267 are no more archive members, in which case OFFSET is the offset of
268 the first unused byte. */
269 struct member_layout next
;
272 /* Initialize INFO so that it describes member MEMBER of archive ARCHIVE.
273 OFFSET is the even-padded offset of MEMBER, not including any leading
274 padding needed for section alignment. */
277 member_layout_init (struct member_layout
*info
, bfd
*archive
,
278 bfd
*member
, file_ptr offset
)
280 info
->member
= member
;
281 info
->leading_padding
= 0;
284 info
->name
= normalize_filename (member
);
285 info
->namlen
= strlen (info
->name
);
286 info
->padded_namlen
= info
->namlen
+ (info
->namlen
& 1);
287 if (xcoff_big_format_p (archive
))
288 info
->header_size
= SIZEOF_AR_HDR_BIG
;
290 info
->header_size
= SIZEOF_AR_HDR
;
291 info
->header_size
+= info
->padded_namlen
+ SXCOFFARFMAG
;
292 info
->contents_size
= arelt_size (member
);
293 info
->trailing_padding
= info
->contents_size
& 1;
295 if (bfd_check_format (member
, bfd_object
)
296 && bfd_get_flavour (member
) == bfd_target_xcoff_flavour
297 && (member
->flags
& DYNAMIC
) != 0)
298 info
->leading_padding
299 = (-(offset
+ info
->header_size
)
300 & ((1 << bfd_xcoff_text_align_power (member
)) - 1));
302 info
->offset
= offset
+ info
->leading_padding
;
305 /* Set up ITERATOR to iterate through archive ARCHIVE. */
308 archive_iterator_begin (struct archive_iterator
*iterator
,
311 iterator
->archive
= archive
;
312 member_layout_init (&iterator
->next
, archive
, archive
->archive_head
,
313 xcoff_big_format_p (archive
)
314 ? SIZEOF_AR_FILE_HDR_BIG
315 : SIZEOF_AR_FILE_HDR
);
318 /* Make ITERATOR visit the first unvisited archive member. Return true
319 on success; return false if all members have been visited. */
322 archive_iterator_next (struct archive_iterator
*iterator
)
324 if (!iterator
->next
.member
)
327 iterator
->current
= iterator
->next
;
328 member_layout_init (&iterator
->next
, iterator
->archive
,
329 iterator
->current
.member
->archive_next
,
330 iterator
->current
.offset
331 + iterator
->current
.header_size
332 + iterator
->current
.contents_size
333 + iterator
->current
.trailing_padding
);
337 /* We use our own tdata type. Its first field is the COFF tdata type,
338 so the COFF routines are compatible. */
341 _bfd_xcoff_mkobject (bfd
*abfd
)
343 coff_data_type
*coff
;
344 size_t amt
= sizeof (struct xcoff_tdata
);
346 abfd
->tdata
.xcoff_obj_data
= (struct xcoff_tdata
*) bfd_zalloc (abfd
, amt
);
347 if (abfd
->tdata
.xcoff_obj_data
== NULL
)
349 coff
= coff_data (abfd
);
350 coff
->symbols
= (coff_symbol_type
*) NULL
;
351 coff
->conversion_table
= (unsigned int *) NULL
;
352 coff
->raw_syments
= (struct coff_ptr_struct
*) NULL
;
355 xcoff_data (abfd
)->modtype
= ('1' << 8) | 'L';
357 /* We set cputype to -1 to indicate that it has not been
359 xcoff_data (abfd
)->cputype
= -1;
361 xcoff_data (abfd
)->csects
= NULL
;
362 xcoff_data (abfd
)->debug_indices
= NULL
;
364 /* text section alignment is different than the default */
365 bfd_xcoff_text_align_power (abfd
) = 2;
370 /* Copy XCOFF data from one BFD to another. */
373 _bfd_xcoff_copy_private_bfd_data (bfd
*ibfd
, bfd
*obfd
)
375 struct xcoff_tdata
*ix
, *ox
;
378 if (ibfd
->xvec
!= obfd
->xvec
)
380 ix
= xcoff_data (ibfd
);
381 ox
= xcoff_data (obfd
);
382 ox
->full_aouthdr
= ix
->full_aouthdr
;
388 sec
= coff_section_from_bfd_index (ibfd
, ix
->sntoc
);
392 ox
->sntoc
= sec
->output_section
->target_index
;
394 if (ix
->snentry
== 0)
398 sec
= coff_section_from_bfd_index (ibfd
, ix
->snentry
);
402 ox
->snentry
= sec
->output_section
->target_index
;
404 bfd_xcoff_text_align_power (obfd
) = bfd_xcoff_text_align_power (ibfd
);
405 bfd_xcoff_data_align_power (obfd
) = bfd_xcoff_data_align_power (ibfd
);
406 ox
->modtype
= ix
->modtype
;
407 ox
->cputype
= ix
->cputype
;
408 ox
->maxdata
= ix
->maxdata
;
409 ox
->maxstack
= ix
->maxstack
;
413 /* I don't think XCOFF really has a notion of local labels based on
414 name. This will mean that ld -X doesn't actually strip anything.
415 The AIX native linker does not have a -X option, and it ignores the
419 _bfd_xcoff_is_local_label_name (bfd
*abfd ATTRIBUTE_UNUSED
,
420 const char *name ATTRIBUTE_UNUSED
)
426 _bfd_xcoff_swap_sym_in (bfd
*abfd
, void * ext1
, void * in1
)
428 SYMENT
*ext
= (SYMENT
*)ext1
;
429 struct internal_syment
* in
= (struct internal_syment
*)in1
;
431 if (ext
->e
.e_name
[0] != 0)
433 memcpy (in
->_n
._n_name
, ext
->e
.e_name
, SYMNMLEN
);
437 in
->_n
._n_n
._n_zeroes
= 0;
438 in
->_n
._n_n
._n_offset
= H_GET_32 (abfd
, ext
->e
.e
.e_offset
);
441 in
->n_value
= H_GET_32 (abfd
, ext
->e_value
);
442 in
->n_scnum
= (short) H_GET_16 (abfd
, ext
->e_scnum
);
443 in
->n_type
= H_GET_16 (abfd
, ext
->e_type
);
444 in
->n_sclass
= H_GET_8 (abfd
, ext
->e_sclass
);
445 in
->n_numaux
= H_GET_8 (abfd
, ext
->e_numaux
);
449 _bfd_xcoff_swap_sym_out (bfd
*abfd
, void * inp
, void * extp
)
451 struct internal_syment
*in
= (struct internal_syment
*)inp
;
452 SYMENT
*ext
=(SYMENT
*)extp
;
454 if (in
->_n
._n_name
[0] != 0)
456 memcpy (ext
->e
.e_name
, in
->_n
._n_name
, SYMNMLEN
);
460 H_PUT_32 (abfd
, 0, ext
->e
.e
.e_zeroes
);
461 H_PUT_32 (abfd
, in
->_n
._n_n
._n_offset
, ext
->e
.e
.e_offset
);
464 H_PUT_32 (abfd
, in
->n_value
, ext
->e_value
);
465 H_PUT_16 (abfd
, in
->n_scnum
, ext
->e_scnum
);
466 H_PUT_16 (abfd
, in
->n_type
, ext
->e_type
);
467 H_PUT_8 (abfd
, in
->n_sclass
, ext
->e_sclass
);
468 H_PUT_8 (abfd
, in
->n_numaux
, ext
->e_numaux
);
469 return bfd_coff_symesz (abfd
);
473 _bfd_xcoff_swap_aux_in (bfd
*abfd
, void * ext1
, int type
, int in_class
,
474 int indx
, int numaux
, void * in1
)
476 AUXENT
* ext
= (AUXENT
*)ext1
;
477 union internal_auxent
*in
= (union internal_auxent
*)in1
;
482 if (ext
->x_file
.x_n
.x_fname
[0] == 0)
484 in
->x_file
.x_n
.x_zeroes
= 0;
485 in
->x_file
.x_n
.x_offset
=
486 H_GET_32 (abfd
, ext
->x_file
.x_n
.x_n
.x_offset
);
493 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_n
.x_fname
,
494 numaux
* sizeof (AUXENT
));
498 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_n
.x_fname
, FILNMLEN
);
503 /* RS/6000 "csect" auxents */
507 if (indx
+ 1 == numaux
)
509 in
->x_csect
.x_scnlen
.l
= H_GET_32 (abfd
, ext
->x_csect
.x_scnlen
);
510 in
->x_csect
.x_parmhash
= H_GET_32 (abfd
, ext
->x_csect
.x_parmhash
);
511 in
->x_csect
.x_snhash
= H_GET_16 (abfd
, ext
->x_csect
.x_snhash
);
512 /* We don't have to hack bitfields in x_smtyp because it's
513 defined by shifts-and-ands, which are equivalent on all
515 in
->x_csect
.x_smtyp
= H_GET_8 (abfd
, ext
->x_csect
.x_smtyp
);
516 in
->x_csect
.x_smclas
= H_GET_8 (abfd
, ext
->x_csect
.x_smclas
);
517 in
->x_csect
.x_stab
= H_GET_32 (abfd
, ext
->x_csect
.x_stab
);
518 in
->x_csect
.x_snstab
= H_GET_16 (abfd
, ext
->x_csect
.x_snstab
);
528 in
->x_scn
.x_scnlen
= H_GET_32 (abfd
, ext
->x_scn
.x_scnlen
);
529 in
->x_scn
.x_nreloc
= H_GET_16 (abfd
, ext
->x_scn
.x_nreloc
);
530 in
->x_scn
.x_nlinno
= H_GET_16 (abfd
, ext
->x_scn
.x_nlinno
);
531 /* PE defines some extra fields; we zero them out for
533 in
->x_scn
.x_checksum
= 0;
534 in
->x_scn
.x_associated
= 0;
535 in
->x_scn
.x_comdat
= 0;
542 in
->x_sym
.x_tagndx
.l
= H_GET_32 (abfd
, ext
->x_sym
.x_tagndx
);
543 in
->x_sym
.x_tvndx
= H_GET_16 (abfd
, ext
->x_sym
.x_tvndx
);
545 if (in_class
== C_BLOCK
|| in_class
== C_FCN
|| ISFCN (type
)
548 in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
=
549 H_GET_32 (abfd
, ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
550 in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
=
551 H_GET_32 (abfd
, ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
555 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0] =
556 H_GET_16 (abfd
, ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0]);
557 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1] =
558 H_GET_16 (abfd
, ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1]);
559 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2] =
560 H_GET_16 (abfd
, ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2]);
561 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3] =
562 H_GET_16 (abfd
, ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3]);
567 in
->x_sym
.x_misc
.x_fsize
= H_GET_32 (abfd
, ext
->x_sym
.x_misc
.x_fsize
);
571 in
->x_sym
.x_misc
.x_lnsz
.x_lnno
=
572 H_GET_16 (abfd
, ext
->x_sym
.x_misc
.x_lnsz
.x_lnno
);
573 in
->x_sym
.x_misc
.x_lnsz
.x_size
=
574 H_GET_16 (abfd
, ext
->x_sym
.x_misc
.x_lnsz
.x_size
);
578 /* The semicolon is because MSVC doesn't like labels at
583 _bfd_xcoff_swap_aux_out (bfd
*abfd
, void * inp
, int type
, int in_class
,
584 int indx ATTRIBUTE_UNUSED
,
585 int numaux ATTRIBUTE_UNUSED
,
588 union internal_auxent
*in
= (union internal_auxent
*)inp
;
589 AUXENT
*ext
= (AUXENT
*)extp
;
591 memset (ext
, 0, bfd_coff_auxesz (abfd
));
595 if (in
->x_file
.x_fname
[0] == 0)
597 H_PUT_32 (abfd
, 0, ext
->x_file
.x_n
.x_n
.x_zeroes
);
598 H_PUT_32 (abfd
, in
->x_file
.x_n
.x_offset
,
599 ext
->x_file
.x_n
.x_n
.x_offset
);
603 memcpy (ext
->x_file
.x_n
.x_fname
, in
->x_file
.x_fname
, FILNMLEN
);
607 /* RS/6000 "csect" auxents */
611 if (indx
+ 1 == numaux
)
613 H_PUT_32 (abfd
, in
->x_csect
.x_scnlen
.l
, ext
->x_csect
.x_scnlen
);
614 H_PUT_32 (abfd
, in
->x_csect
.x_parmhash
, ext
->x_csect
.x_parmhash
);
615 H_PUT_16 (abfd
, in
->x_csect
.x_snhash
, ext
->x_csect
.x_snhash
);
616 /* We don't have to hack bitfields in x_smtyp because it's
617 defined by shifts-and-ands, which are equivalent on all
619 H_PUT_8 (abfd
, in
->x_csect
.x_smtyp
, ext
->x_csect
.x_smtyp
);
620 H_PUT_8 (abfd
, in
->x_csect
.x_smclas
, ext
->x_csect
.x_smclas
);
621 H_PUT_32 (abfd
, in
->x_csect
.x_stab
, ext
->x_csect
.x_stab
);
622 H_PUT_16 (abfd
, in
->x_csect
.x_snstab
, ext
->x_csect
.x_snstab
);
632 H_PUT_32 (abfd
, in
->x_scn
.x_scnlen
, ext
->x_scn
.x_scnlen
);
633 H_PUT_16 (abfd
, in
->x_scn
.x_nreloc
, ext
->x_scn
.x_nreloc
);
634 H_PUT_16 (abfd
, in
->x_scn
.x_nlinno
, ext
->x_scn
.x_nlinno
);
640 H_PUT_32 (abfd
, in
->x_sym
.x_tagndx
.l
, ext
->x_sym
.x_tagndx
);
641 H_PUT_16 (abfd
, in
->x_sym
.x_tvndx
, ext
->x_sym
.x_tvndx
);
643 if (in_class
== C_BLOCK
|| in_class
== C_FCN
|| ISFCN (type
)
646 H_PUT_32 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
,
647 ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
648 H_PUT_32 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
,
649 ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
653 H_PUT_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0],
654 ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0]);
655 H_PUT_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1],
656 ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1]);
657 H_PUT_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2],
658 ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2]);
659 H_PUT_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3],
660 ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3]);
664 H_PUT_32 (abfd
, in
->x_sym
.x_misc
.x_fsize
, ext
->x_sym
.x_misc
.x_fsize
);
667 H_PUT_16 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_lnno
,
668 ext
->x_sym
.x_misc
.x_lnsz
.x_lnno
);
669 H_PUT_16 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_size
,
670 ext
->x_sym
.x_misc
.x_lnsz
.x_size
);
674 return bfd_coff_auxesz (abfd
);
677 /* The XCOFF reloc table.
678 XCOFF relocations aren't defined only by the type field r_type.
679 The bitsize and whether they are signed or not, are defined by
680 r_size field. Thus, it's complicated to create a constant
681 table reference every possible relocation.
682 This table contains the "default" relocation and few modified
683 relocations what were already there. It's enough when
684 xcoff_rtype2howto is called.
685 For relocations from an input bfd to an output bfd, the default
686 relocation is retrieved and when manually adapted.
688 For now, it seems to be enought. */
690 reloc_howto_type xcoff_howto_table
[] =
692 /* 0x00: Standard 32 bit relocation. */
693 HOWTO (R_POS
, /* type */
695 2, /* size (0 = byte, 1 = short, 2 = long) */
697 false, /* pc_relative */
699 complain_overflow_bitfield
, /* complain_on_overflow */
700 0, /* special_function */
702 true, /* partial_inplace */
703 0xffffffff, /* src_mask */
704 0xffffffff, /* dst_mask */
705 false), /* pcrel_offset */
707 /* 0x01: 32 bit relocation, but store negative value. */
708 HOWTO (R_NEG
, /* type */
710 -2, /* size (0 = byte, 1 = short, 2 = long) */
712 false, /* pc_relative */
714 complain_overflow_bitfield
, /* complain_on_overflow */
715 0, /* special_function */
717 true, /* partial_inplace */
718 0xffffffff, /* src_mask */
719 0xffffffff, /* dst_mask */
720 false), /* pcrel_offset */
722 /* 0x02: 32 bit PC relative relocation. */
723 HOWTO (R_REL
, /* type */
725 2, /* size (0 = byte, 1 = short, 2 = long) */
727 true, /* pc_relative */
729 complain_overflow_signed
, /* complain_on_overflow */
730 0, /* special_function */
732 true, /* partial_inplace */
733 0xffffffff, /* src_mask */
734 0xffffffff, /* dst_mask */
735 false), /* pcrel_offset */
737 /* 0x03: 16 bit TOC relative relocation. */
738 HOWTO (R_TOC
, /* type */
740 1, /* size (0 = byte, 1 = short, 2 = long) */
742 false, /* pc_relative */
744 complain_overflow_bitfield
, /* complain_on_overflow */
745 0, /* special_function */
747 true, /* partial_inplace */
749 0xffff, /* dst_mask */
750 false), /* pcrel_offset */
752 /* 0x04: Same as R_TOC */
753 HOWTO (R_TRL
, /* type */
755 1, /* size (0 = byte, 1 = short, 2 = long) */
757 false, /* pc_relative */
759 complain_overflow_bitfield
, /* complain_on_overflow */
760 0, /* special_function */
762 true, /* partial_inplace */
764 0xffff, /* dst_mask */
765 false), /* pcrel_offset */
767 /* 0x05: External TOC relative symbol. */
768 HOWTO (R_GL
, /* type */
770 1, /* size (0 = byte, 1 = short, 2 = long) */
772 false, /* pc_relative */
774 complain_overflow_bitfield
, /* complain_on_overflow */
775 0, /* special_function */
777 true, /* partial_inplace */
779 0xffff, /* dst_mask */
780 false), /* pcrel_offset */
782 /* 0x06: Local TOC relative symbol. */
783 HOWTO (R_TCL
, /* type */
785 1, /* size (0 = byte, 1 = short, 2 = long) */
787 false, /* pc_relative */
789 complain_overflow_bitfield
, /* complain_on_overflow */
790 0, /* special_function */
792 true, /* partial_inplace */
794 0xffff, /* dst_mask */
795 false), /* pcrel_offset */
799 /* 0x08: Same as R_RBA. */
800 HOWTO (R_BA
, /* type */
802 2, /* size (0 = byte, 1 = short, 2 = long) */
804 false, /* pc_relative */
806 complain_overflow_bitfield
, /* complain_on_overflow */
807 0, /* special_function */
808 "R_BA_26", /* name */
809 true, /* partial_inplace */
810 0x03fffffc, /* src_mask */
811 0x03fffffc, /* dst_mask */
812 false), /* pcrel_offset */
816 /* 0x0a: Same as R_RBR. */
817 HOWTO (R_BR
, /* type */
819 2, /* size (0 = byte, 1 = short, 2 = long) */
821 true, /* pc_relative */
823 complain_overflow_signed
, /* complain_on_overflow */
824 0, /* special_function */
826 true, /* partial_inplace */
827 0x03fffffc, /* src_mask */
828 0x03fffffc, /* dst_mask */
829 false), /* pcrel_offset */
833 /* 0x0c: Same as R_POS. */
834 HOWTO (R_RL
, /* type */
836 2, /* size (0 = byte, 1 = short, 2 = long) */
838 false, /* pc_relative */
840 complain_overflow_bitfield
, /* complain_on_overflow */
841 0, /* special_function */
843 true, /* partial_inplace */
844 0xffffffff, /* src_mask */
845 0xffffffff, /* dst_mask */
846 false), /* pcrel_offset */
848 /* 0x0d: Same as R_POS. */
849 HOWTO (R_RLA
, /* type */
851 2, /* size (0 = byte, 1 = short, 2 = long) */
853 false, /* pc_relative */
855 complain_overflow_bitfield
, /* complain_on_overflow */
856 0, /* special_function */
858 true, /* partial_inplace */
859 0xffffffff, /* src_mask */
860 0xffffffff, /* dst_mask */
861 false), /* pcrel_offset */
865 /* 0x0f: Non-relocating reference. Bitsize is 1 so that r_rsize is 0. */
866 HOWTO (R_REF
, /* type */
868 0, /* size (0 = byte, 1 = short, 2 = long) */
870 false, /* pc_relative */
872 complain_overflow_dont
, /* complain_on_overflow */
873 0, /* special_function */
875 false, /* partial_inplace */
878 false), /* pcrel_offset */
884 /* 0x13: Same as R_TOC. */
885 HOWTO (R_TRLA
, /* type */
887 1, /* size (0 = byte, 1 = short, 2 = long) */
889 false, /* pc_relative */
891 complain_overflow_bitfield
, /* complain_on_overflow */
892 0, /* special_function */
894 true, /* partial_inplace */
896 0xffff, /* dst_mask */
897 false), /* pcrel_offset */
899 /* 0x14: Modifiable relative branch. */
900 HOWTO (R_RRTBI
, /* type */
902 2, /* size (0 = byte, 1 = short, 2 = long) */
904 false, /* pc_relative */
906 complain_overflow_bitfield
, /* complain_on_overflow */
907 0, /* special_function */
908 "R_RRTBI", /* name */
909 true, /* partial_inplace */
910 0xffffffff, /* src_mask */
911 0xffffffff, /* dst_mask */
912 false), /* pcrel_offset */
914 /* 0x15: Modifiable absolute branch. */
915 HOWTO (R_RRTBA
, /* type */
917 2, /* size (0 = byte, 1 = short, 2 = long) */
919 false, /* pc_relative */
921 complain_overflow_bitfield
, /* complain_on_overflow */
922 0, /* special_function */
923 "R_RRTBA", /* name */
924 true, /* partial_inplace */
925 0xffffffff, /* src_mask */
926 0xffffffff, /* dst_mask */
927 false), /* pcrel_offset */
929 /* 0x16: Modifiable call absolute indirect. */
930 HOWTO (R_CAI
, /* type */
932 1, /* size (0 = byte, 1 = short, 2 = long) */
934 false, /* pc_relative */
936 complain_overflow_bitfield
, /* complain_on_overflow */
937 0, /* special_function */
939 true, /* partial_inplace */
940 0xffff, /* src_mask */
941 0xffff, /* dst_mask */
942 false), /* pcrel_offset */
944 /* 0x17: Modifiable call relative. */
945 HOWTO (R_CREL
, /* type */
947 1, /* size (0 = byte, 1 = short, 2 = long) */
949 false, /* pc_relative */
951 complain_overflow_bitfield
, /* complain_on_overflow */
952 0, /* special_function */
954 true, /* partial_inplace */
955 0xffff, /* src_mask */
956 0xffff, /* dst_mask */
957 false), /* pcrel_offset */
959 /* 0x18: Modifiable branch absolute. */
960 HOWTO (R_RBA
, /* type */
962 2, /* size (0 = byte, 1 = short, 2 = long) */
964 false, /* pc_relative */
966 complain_overflow_bitfield
, /* complain_on_overflow */
967 0, /* special_function */
969 true, /* partial_inplace */
970 0x03fffffc, /* src_mask */
971 0x03fffffc, /* dst_mask */
972 false), /* pcrel_offset */
974 /* 0x19: Modifiable branch absolute. */
975 HOWTO (R_RBAC
, /* type */
977 2, /* size (0 = byte, 1 = short, 2 = long) */
979 false, /* pc_relative */
981 complain_overflow_bitfield
, /* complain_on_overflow */
982 0, /* special_function */
984 true, /* partial_inplace */
985 0xffffffff, /* src_mask */
986 0xffffffff, /* dst_mask */
987 false), /* pcrel_offset */
989 /* 0x1a: Modifiable branch relative. */
990 HOWTO (R_RBR
, /* type */
992 2, /* size (0 = byte, 1 = short, 2 = long) */
994 false, /* pc_relative */
996 complain_overflow_signed
, /* complain_on_overflow */
997 0, /* special_function */
998 "R_RBR_26", /* name */
999 true, /* partial_inplace */
1000 0x03fffffc, /* src_mask */
1001 0x03fffffc, /* dst_mask */
1002 false), /* pcrel_offset */
1004 /* 0x1b: Modifiable branch absolute. */
1005 HOWTO (R_RBRC
, /* type */
1007 1, /* size (0 = byte, 1 = short, 2 = long) */
1009 false, /* pc_relative */
1011 complain_overflow_bitfield
, /* complain_on_overflow */
1012 0, /* special_function */
1013 "R_RBRC", /* name */
1014 true, /* partial_inplace */
1015 0xffff, /* src_mask */
1016 0xffff, /* dst_mask */
1017 false), /* pcrel_offset */
1019 /* 0x1c: 16 bit Non modifiable absolute branch. */
1020 HOWTO (R_BA
, /* type */
1022 1, /* size (0 = byte, 1 = short, 2 = long) */
1024 false, /* pc_relative */
1026 complain_overflow_bitfield
, /* complain_on_overflow */
1027 0, /* special_function */
1028 "R_BA_16", /* name */
1029 true, /* partial_inplace */
1030 0xfffc, /* src_mask */
1031 0xfffc, /* dst_mask */
1032 false), /* pcrel_offset */
1034 /* 0x1d: Modifiable branch relative. */
1035 HOWTO (R_RBR
, /* type */
1037 1, /* size (0 = byte, 1 = short, 2 = long) */
1039 true, /* pc_relative */
1041 complain_overflow_signed
, /* complain_on_overflow */
1042 0, /* special_function */
1043 "R_RBR_16", /* name */
1044 true, /* partial_inplace */
1045 0xfffc, /* src_mask */
1046 0xfffc, /* dst_mask */
1047 false), /* pcrel_offset */
1049 /* 0x1e: Modifiable branch relative. */
1050 HOWTO (R_RBA
, /* type */
1052 1, /* size (0 = byte, 1 = short, 2 = long) */
1054 false, /* pc_relative */
1056 complain_overflow_signed
, /* complain_on_overflow */
1057 0, /* special_function */
1058 "R_RBA_16", /* name */
1059 true, /* partial_inplace */
1060 0xffff, /* src_mask */
1061 0xffff, /* dst_mask */
1062 false), /* pcrel_offset */
1066 /* 0x20: General-dynamic TLS relocation. */
1067 HOWTO (R_TLS
, /* type */
1069 2, /* size (0 = byte, 1 = short, 2 = long) */
1071 false, /* pc_relative */
1073 complain_overflow_bitfield
, /* complain_on_overflow */
1074 0, /* special_function */
1076 true, /* partial_inplace */
1077 0xffffffff, /* src_mask */
1078 0xffffffff, /* dst_mask */
1079 false), /* pcrel_offset */
1081 /* 0x21: Initial-exec TLS relocation. */
1082 HOWTO (R_TLS_IE
, /* type */
1084 2, /* size (0 = byte, 1 = short, 2 = long) */
1086 false, /* pc_relative */
1088 complain_overflow_bitfield
, /* complain_on_overflow */
1089 0, /* special_function */
1090 "R_TLS_IE", /* name */
1091 true, /* partial_inplace */
1092 0xffffffff, /* src_mask */
1093 0xffffffff, /* dst_mask */
1094 false), /* pcrel_offset */
1096 /* 0x22: Local-dynamic TLS relocation. */
1097 HOWTO (R_TLS_LD
, /* type */
1099 2, /* size (0 = byte, 1 = short, 2 = long) */
1101 false, /* pc_relative */
1103 complain_overflow_bitfield
, /* complain_on_overflow */
1104 0, /* special_function */
1105 "R_TLS_LD", /* name */
1106 true, /* partial_inplace */
1107 0xffffffff, /* src_mask */
1108 0xffffffff, /* dst_mask */
1109 false), /* pcrel_offset */
1111 /* 0x23: Local-exec TLS relocation. */
1112 HOWTO (R_TLS_LE
, /* type */
1114 2, /* size (0 = byte, 1 = short, 2 = long) */
1116 false, /* pc_relative */
1118 complain_overflow_bitfield
, /* complain_on_overflow */
1119 0, /* special_function */
1120 "R_TLS_LE", /* name */
1121 true, /* partial_inplace */
1122 0xffffffff, /* src_mask */
1123 0xffffffff, /* dst_mask */
1124 false), /* pcrel_offset */
1126 /* 0x24: TLS relocation. */
1127 HOWTO (R_TLSM
, /* type */
1129 2, /* size (0 = byte, 1 = short, 2 = long) */
1131 false, /* pc_relative */
1133 complain_overflow_bitfield
, /* complain_on_overflow */
1134 0, /* special_function */
1135 "R_TLSM", /* name */
1136 true, /* partial_inplace */
1137 0xffffffff, /* src_mask */
1138 0xffffffff, /* dst_mask */
1139 false), /* pcrel_offset */
1142 /* 0x25: TLS module relocation. */
1143 HOWTO (R_TLSML
, /* type */
1145 2, /* size (0 = byte, 1 = short, 2 = long) */
1147 false, /* pc_relative */
1149 complain_overflow_bitfield
, /* complain_on_overflow */
1150 0, /* special_function */
1151 "R_TLSM", /* name */
1152 true, /* partial_inplace */
1153 0xffffffff, /* src_mask */
1154 0xffffffff, /* dst_mask */
1155 false), /* pcrel_offset */
1168 /* 0x30: High-order 16 bit TOC relative relocation. */
1169 HOWTO (R_TOCU
, /* type */
1170 16, /* rightshift */
1171 1, /* size (0 = byte, 1 = short, 2 = long) */
1173 false, /* pc_relative */
1175 complain_overflow_bitfield
, /* complain_on_overflow */
1176 0, /* special_function */
1177 "R_TOCU", /* name */
1178 true, /* partial_inplace */
1180 0xffff, /* dst_mask */
1181 false), /* pcrel_offset */
1183 /* 0x31: Low-order 16 bit TOC relative relocation. */
1184 HOWTO (R_TOCL
, /* type */
1186 1, /* size (0 = byte, 1 = short, 2 = long) */
1188 false, /* pc_relative */
1190 complain_overflow_dont
, /* complain_on_overflow */
1191 0, /* special_function */
1192 "R_TOCL", /* name */
1193 true, /* partial_inplace */
1195 0xffff, /* dst_mask */
1196 false), /* pcrel_offset */
1201 xcoff_rtype2howto (arelent
*relent
, struct internal_reloc
*internal
)
1203 if (internal
->r_type
> R_TOCL
)
1206 /* Default howto layout works most of the time */
1207 relent
->howto
= &xcoff_howto_table
[internal
->r_type
];
1209 /* Special case some 16 bit reloc */
1210 if (15 == (internal
->r_size
& 0x1f))
1212 if (R_BA
== internal
->r_type
)
1213 relent
->howto
= &xcoff_howto_table
[0x1c];
1214 else if (R_RBR
== internal
->r_type
)
1215 relent
->howto
= &xcoff_howto_table
[0x1d];
1216 else if (R_RBA
== internal
->r_type
)
1217 relent
->howto
= &xcoff_howto_table
[0x1e];
1220 /* The r_size field of an XCOFF reloc encodes the bitsize of the
1221 relocation, as well as indicating whether it is signed or not.
1222 Doublecheck that the relocation information gathered from the
1223 type matches this information. The bitsize is not significant
1224 for R_REF relocs. */
1225 if (relent
->howto
->dst_mask
!= 0
1226 && (relent
->howto
->bitsize
1227 != ((unsigned int) internal
->r_size
& 0x1f) + 1))
1232 _bfd_xcoff_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1233 bfd_reloc_code_real_type code
)
1237 case BFD_RELOC_PPC_B26
:
1238 return &xcoff_howto_table
[0xa];
1239 case BFD_RELOC_PPC_BA16
:
1240 return &xcoff_howto_table
[0x1c];
1241 case BFD_RELOC_PPC_BA26
:
1242 return &xcoff_howto_table
[8];
1243 case BFD_RELOC_PPC_TOC16
:
1244 return &xcoff_howto_table
[3];
1245 case BFD_RELOC_PPC_TOC16_HI
:
1246 return &xcoff_howto_table
[0x30];
1247 case BFD_RELOC_PPC_TOC16_LO
:
1248 return &xcoff_howto_table
[0x31];
1249 case BFD_RELOC_PPC_B16
:
1250 return &xcoff_howto_table
[0x1d];
1252 case BFD_RELOC_CTOR
:
1253 return &xcoff_howto_table
[0];
1254 case BFD_RELOC_NONE
:
1255 return &xcoff_howto_table
[0xf];
1256 case BFD_RELOC_PPC_NEG
:
1257 return &xcoff_howto_table
[0x1];
1258 case BFD_RELOC_PPC_TLSGD
:
1259 return &xcoff_howto_table
[0x20];
1260 case BFD_RELOC_PPC_TLSIE
:
1261 return &xcoff_howto_table
[0x21];
1262 case BFD_RELOC_PPC_TLSLD
:
1263 return &xcoff_howto_table
[0x22];
1264 case BFD_RELOC_PPC_TLSLE
:
1265 return &xcoff_howto_table
[0x23];
1266 case BFD_RELOC_PPC_TLSM
:
1267 return &xcoff_howto_table
[0x24];
1268 case BFD_RELOC_PPC_TLSML
:
1269 return &xcoff_howto_table
[0x25];
1275 static reloc_howto_type
*
1276 _bfd_xcoff_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1282 i
< sizeof (xcoff_howto_table
) / sizeof (xcoff_howto_table
[0]);
1284 if (xcoff_howto_table
[i
].name
!= NULL
1285 && strcasecmp (xcoff_howto_table
[i
].name
, r_name
) == 0)
1286 return &xcoff_howto_table
[i
];
1291 /* XCOFF archive support. The original version of this code was by
1292 Damon A. Permezel. It was enhanced to permit cross support, and
1293 writing archive files, by Ian Lance Taylor, Cygnus Support.
1295 XCOFF uses its own archive format. Everything is hooked together
1296 with file offset links, so it is possible to rapidly update an
1297 archive in place. Of course, we don't do that. An XCOFF archive
1298 has a real file header, not just an ARMAG string. The structure of
1299 the file header and of each archive header appear below.
1301 An XCOFF archive also has a member table, which is a list of
1302 elements in the archive (you can get that by looking through the
1303 linked list, but you have to read a lot more of the file). The
1304 member table has a normal archive header with an empty name. It is
1305 normally (and perhaps must be) the second to last entry in the
1306 archive. The member table data is almost printable ASCII. It
1307 starts with a 12 character decimal string which is the number of
1308 entries in the table. For each entry it has a 12 character decimal
1309 string which is the offset in the archive of that member. These
1310 entries are followed by a series of null terminated strings which
1311 are the member names for each entry.
1313 Finally, an XCOFF archive has a global symbol table, which is what
1314 we call the armap. The global symbol table has a normal archive
1315 header with an empty name. It is normally (and perhaps must be)
1316 the last entry in the archive. The contents start with a four byte
1317 binary number which is the number of entries. This is followed by
1318 a that many four byte binary numbers; each is the file offset of an
1319 entry in the archive. These numbers are followed by a series of
1320 null terminated strings, which are symbol names.
1322 AIX 4.3 introduced a new archive format which can handle larger
1323 files and also 32- and 64-bit objects in the same archive. The
1324 things said above remain true except that there is now more than
1325 one global symbol table. The one is used to index 32-bit objects,
1326 the other for 64-bit objects.
1328 The new archives (recognizable by the new ARMAG string) has larger
1329 field lengths so that we cannot really share any code. Also we have
1330 to take care that we are not generating the new form of archives
1331 on AIX 4.2 or earlier systems. */
1333 /* PR 21786: The PE/COFF standard does not require NUL termination for any of
1334 the ASCII fields in the archive headers. So in order to be able to extract
1335 numerical values we provide our own versions of strtol and strtoll which
1336 take a maximum length as an additional parameter. Also - just to save space,
1337 we omit the endptr return parameter, since we know that it is never used. */
1340 _bfd_strntol (const char * nptr
, int base
, unsigned int maxlen
)
1342 char buf
[24]; /* Should be enough. */
1344 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1346 memcpy (buf
, nptr
, maxlen
);
1348 return strtol (buf
, NULL
, base
);
1352 _bfd_strntoll (const char * nptr
, int base
, unsigned int maxlen
)
1354 char buf
[32]; /* Should be enough. */
1356 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1358 memcpy (buf
, nptr
, maxlen
);
1360 return strtoll (buf
, NULL
, base
);
1363 /* Macro to read an ASCII value stored in an archive header field. */
1364 #define GET_VALUE_IN_FIELD(VAR, FIELD, BASE) \
1367 (VAR) = (sizeof (VAR) > sizeof (long) \
1368 ? _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
1369 : _bfd_strntol (FIELD, BASE, sizeof FIELD)); \
1373 #define EQ_VALUE_IN_FIELD(VAR, FIELD, BASE) \
1374 (sizeof (VAR) > sizeof (long) \
1375 ? (VAR) == _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
1376 : (VAR) == _bfd_strntol (FIELD, BASE, sizeof FIELD))
1378 /* Read in the armap of an XCOFF archive. */
1381 _bfd_xcoff_slurp_armap (bfd
*abfd
)
1386 bfd_byte
*contents
, *cend
;
1391 if (xcoff_ardata (abfd
) == NULL
)
1393 abfd
->has_armap
= false;
1397 if (! xcoff_big_format_p (abfd
))
1399 /* This is for the old format. */
1400 struct xcoff_ar_hdr hdr
;
1402 GET_VALUE_IN_FIELD (off
, xcoff_ardata (abfd
)->symoff
, 10);
1405 abfd
->has_armap
= false;
1409 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1412 /* The symbol table starts with a normal archive header. */
1413 if (bfd_bread (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR
, abfd
)
1417 /* Skip the name (normally empty). */
1418 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1419 off
= ((namlen
+ 1) & ~ (size_t) 1) + SXCOFFARFMAG
;
1420 if (bfd_seek (abfd
, off
, SEEK_CUR
) != 0)
1423 GET_VALUE_IN_FIELD (sz
, hdr
.size
, 10);
1426 bfd_set_error (bfd_error_bad_value
);
1430 /* Read in the entire symbol table. */
1431 contents
= (bfd_byte
*) _bfd_alloc_and_read (abfd
, sz
+ 1, sz
);
1432 if (contents
== NULL
)
1435 /* Ensure strings are NULL terminated so we don't wander off the
1436 end of the buffer. */
1439 /* The symbol table starts with a four byte count. */
1440 c
= H_GET_32 (abfd
, contents
);
1444 bfd_set_error (bfd_error_bad_value
);
1448 bfd_ardata (abfd
)->symdefs
=
1449 ((carsym
*) bfd_alloc (abfd
, c
* sizeof (carsym
)));
1450 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1453 /* After the count comes a list of four byte file offsets. */
1454 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 4;
1456 ++i
, ++arsym
, p
+= 4)
1457 arsym
->file_offset
= H_GET_32 (abfd
, p
);
1461 /* This is for the new format. */
1462 struct xcoff_ar_hdr_big hdr
;
1464 GET_VALUE_IN_FIELD (off
, xcoff_ardata_big (abfd
)->symoff
, 10);
1467 abfd
->has_armap
= false;
1471 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1474 /* The symbol table starts with a normal archive header. */
1475 if (bfd_bread (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR_BIG
, abfd
)
1476 != SIZEOF_AR_HDR_BIG
)
1479 /* Skip the name (normally empty). */
1480 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1481 off
= ((namlen
+ 1) & ~ (size_t) 1) + SXCOFFARFMAG
;
1482 if (bfd_seek (abfd
, off
, SEEK_CUR
) != 0)
1485 GET_VALUE_IN_FIELD (sz
, hdr
.size
, 10);
1488 bfd_set_error (bfd_error_bad_value
);
1492 /* Read in the entire symbol table. */
1493 contents
= (bfd_byte
*) _bfd_alloc_and_read (abfd
, sz
+ 1, sz
);
1494 if (contents
== NULL
)
1497 /* Ensure strings are NULL terminated so we don't wander off the
1498 end of the buffer. */
1501 /* The symbol table starts with an eight byte count. */
1502 c
= H_GET_64 (abfd
, contents
);
1506 bfd_set_error (bfd_error_bad_value
);
1510 bfd_ardata (abfd
)->symdefs
=
1511 ((carsym
*) bfd_alloc (abfd
, c
* sizeof (carsym
)));
1512 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1515 /* After the count comes a list of eight byte file offsets. */
1516 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1518 ++i
, ++arsym
, p
+= 8)
1519 arsym
->file_offset
= H_GET_64 (abfd
, p
);
1522 /* After the file offsets come null terminated symbol names. */
1523 cend
= contents
+ sz
;
1524 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1526 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1530 bfd_set_error (bfd_error_bad_value
);
1533 arsym
->name
= (char *) p
;
1536 bfd_ardata (abfd
)->symdef_count
= c
;
1537 abfd
->has_armap
= true;
1542 /* See if this is an XCOFF archive. */
1545 _bfd_xcoff_archive_p (bfd
*abfd
)
1547 struct artdata
*tdata_hold
;
1548 char magic
[SXCOFFARMAG
];
1549 size_t amt
= SXCOFFARMAG
;
1551 if (bfd_bread (magic
, amt
, abfd
) != amt
)
1553 if (bfd_get_error () != bfd_error_system_call
)
1554 bfd_set_error (bfd_error_wrong_format
);
1558 if (strncmp (magic
, XCOFFARMAG
, SXCOFFARMAG
) != 0
1559 && strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0)
1561 bfd_set_error (bfd_error_wrong_format
);
1565 tdata_hold
= bfd_ardata (abfd
);
1567 amt
= sizeof (struct artdata
);
1568 bfd_ardata (abfd
) = (struct artdata
*) bfd_zalloc (abfd
, amt
);
1569 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1570 goto error_ret_restore
;
1572 /* Cleared by bfd_zalloc above.
1573 bfd_ardata (abfd)->cache = NULL;
1574 bfd_ardata (abfd)->archive_head = NULL;
1575 bfd_ardata (abfd)->symdefs = NULL;
1576 bfd_ardata (abfd)->extended_names = NULL;
1577 bfd_ardata (abfd)->extended_names_size = 0; */
1579 /* Now handle the two formats. */
1580 if (magic
[1] != 'b')
1582 /* This is the old format. */
1583 struct xcoff_ar_file_hdr hdr
;
1585 /* Copy over the magic string. */
1586 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1588 /* Now read the rest of the file header. */
1589 amt
= SIZEOF_AR_FILE_HDR
- SXCOFFARMAG
;
1590 if (bfd_bread (&hdr
.memoff
, amt
, abfd
) != amt
)
1592 if (bfd_get_error () != bfd_error_system_call
)
1593 bfd_set_error (bfd_error_wrong_format
);
1597 GET_VALUE_IN_FIELD (bfd_ardata (abfd
)->first_file_filepos
,
1598 hdr
.firstmemoff
, 10);
1600 amt
= SIZEOF_AR_FILE_HDR
;
1601 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, amt
);
1602 if (bfd_ardata (abfd
)->tdata
== NULL
)
1605 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR
);
1609 /* This is the new format. */
1610 struct xcoff_ar_file_hdr_big hdr
;
1612 /* Copy over the magic string. */
1613 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1615 /* Now read the rest of the file header. */
1616 amt
= SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
;
1617 if (bfd_bread (&hdr
.memoff
, amt
, abfd
) != amt
)
1619 if (bfd_get_error () != bfd_error_system_call
)
1620 bfd_set_error (bfd_error_wrong_format
);
1624 bfd_ardata (abfd
)->first_file_filepos
= bfd_scan_vma (hdr
.firstmemoff
,
1628 amt
= SIZEOF_AR_FILE_HDR_BIG
;
1629 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, amt
);
1630 if (bfd_ardata (abfd
)->tdata
== NULL
)
1633 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1636 if (! _bfd_xcoff_slurp_armap (abfd
))
1639 bfd_release (abfd
, bfd_ardata (abfd
));
1641 bfd_ardata (abfd
) = tdata_hold
;
1645 return _bfd_no_cleanup
;
1648 /* Read the archive header in an XCOFF archive. */
1651 _bfd_xcoff_read_ar_hdr (bfd
*abfd
)
1653 bfd_size_type namlen
;
1654 struct areltdata
*ret
;
1657 if (! xcoff_big_format_p (abfd
))
1659 struct xcoff_ar_hdr hdr
;
1660 struct xcoff_ar_hdr
*hdrp
;
1662 if (bfd_bread (&hdr
, SIZEOF_AR_HDR
, abfd
) != SIZEOF_AR_HDR
)
1665 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1666 amt
= sizeof (struct areltdata
) + SIZEOF_AR_HDR
+ namlen
+ 1;
1667 ret
= (struct areltdata
*) bfd_malloc (amt
);
1671 hdrp
= (struct xcoff_ar_hdr
*) (ret
+ 1);
1672 memcpy (hdrp
, &hdr
, SIZEOF_AR_HDR
);
1673 if (bfd_bread ((char *) hdrp
+ SIZEOF_AR_HDR
, namlen
, abfd
) != namlen
)
1678 ((char *) hdrp
)[SIZEOF_AR_HDR
+ namlen
] = '\0';
1680 ret
->arch_header
= (char *) hdrp
;
1681 GET_VALUE_IN_FIELD (ret
->parsed_size
, hdr
.size
, 10);
1682 ret
->filename
= (char *) hdrp
+ SIZEOF_AR_HDR
;
1686 struct xcoff_ar_hdr_big hdr
;
1687 struct xcoff_ar_hdr_big
*hdrp
;
1689 if (bfd_bread (&hdr
, SIZEOF_AR_HDR_BIG
, abfd
) != SIZEOF_AR_HDR_BIG
)
1692 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1693 amt
= sizeof (struct areltdata
) + SIZEOF_AR_HDR_BIG
+ namlen
+ 1;
1694 ret
= (struct areltdata
*) bfd_malloc (amt
);
1698 hdrp
= (struct xcoff_ar_hdr_big
*) (ret
+ 1);
1699 memcpy (hdrp
, &hdr
, SIZEOF_AR_HDR_BIG
);
1700 if (bfd_bread ((char *) hdrp
+ SIZEOF_AR_HDR_BIG
, namlen
, abfd
) != namlen
)
1705 ((char *) hdrp
)[SIZEOF_AR_HDR_BIG
+ namlen
] = '\0';
1707 ret
->arch_header
= (char *) hdrp
;
1708 GET_VALUE_IN_FIELD (ret
->parsed_size
, hdr
.size
, 10);
1709 ret
->filename
= (char *) hdrp
+ SIZEOF_AR_HDR_BIG
;
1712 /* Skip over the XCOFFARFMAG at the end of the file name. */
1713 if (bfd_seek (abfd
, (file_ptr
) ((namlen
& 1) + SXCOFFARFMAG
), SEEK_CUR
) != 0)
1719 /* Open the next element in an XCOFF archive. */
1722 _bfd_xcoff_openr_next_archived_file (bfd
*archive
, bfd
*last_file
)
1726 if (xcoff_ardata (archive
) == NULL
)
1728 bfd_set_error (bfd_error_invalid_operation
);
1732 if (! xcoff_big_format_p (archive
))
1734 if (last_file
== NULL
)
1735 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1737 GET_VALUE_IN_FIELD (filestart
, arch_xhdr (last_file
)->nextoff
, 10);
1740 || EQ_VALUE_IN_FIELD (filestart
, xcoff_ardata (archive
)->memoff
, 10)
1741 || EQ_VALUE_IN_FIELD (filestart
, xcoff_ardata (archive
)->symoff
, 10))
1743 bfd_set_error (bfd_error_no_more_archived_files
);
1749 if (last_file
== NULL
)
1750 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1752 GET_VALUE_IN_FIELD (filestart
, arch_xhdr_big (last_file
)->nextoff
, 10);
1755 || EQ_VALUE_IN_FIELD (filestart
, xcoff_ardata_big (archive
)->memoff
, 10)
1756 || EQ_VALUE_IN_FIELD (filestart
, xcoff_ardata_big (archive
)->symoff
, 10))
1758 bfd_set_error (bfd_error_no_more_archived_files
);
1763 return _bfd_get_elt_at_filepos (archive
, filestart
);
1766 /* Stat an element in an XCOFF archive. */
1769 _bfd_xcoff_stat_arch_elt (bfd
*abfd
, struct stat
*s
)
1771 if (abfd
->arelt_data
== NULL
)
1773 bfd_set_error (bfd_error_invalid_operation
);
1777 if (! xcoff_big_format_p (abfd
->my_archive
))
1779 struct xcoff_ar_hdr
*hdrp
= arch_xhdr (abfd
);
1781 GET_VALUE_IN_FIELD (s
->st_mtime
, hdrp
->date
, 10);
1782 GET_VALUE_IN_FIELD (s
->st_uid
, hdrp
->uid
, 10);
1783 GET_VALUE_IN_FIELD (s
->st_gid
, hdrp
->gid
, 10);
1784 GET_VALUE_IN_FIELD (s
->st_mode
, hdrp
->mode
, 8);
1785 s
->st_size
= arch_eltdata (abfd
)->parsed_size
;
1789 struct xcoff_ar_hdr_big
*hdrp
= arch_xhdr_big (abfd
);
1791 GET_VALUE_IN_FIELD (s
->st_mtime
, hdrp
->date
, 10);
1792 GET_VALUE_IN_FIELD (s
->st_uid
, hdrp
->uid
, 10);
1793 GET_VALUE_IN_FIELD (s
->st_gid
, hdrp
->gid
, 10);
1794 GET_VALUE_IN_FIELD (s
->st_mode
, hdrp
->mode
, 8);
1795 s
->st_size
= arch_eltdata (abfd
)->parsed_size
;
1801 /* Normalize a file name for inclusion in an archive. */
1804 normalize_filename (bfd
*abfd
)
1807 const char *filename
;
1809 file
= bfd_get_filename (abfd
);
1810 filename
= strrchr (file
, '/');
1811 if (filename
!= NULL
)
1818 /* Write out an XCOFF armap. */
1821 xcoff_write_armap_old (bfd
*abfd
, unsigned int elength ATTRIBUTE_UNUSED
,
1822 struct orl
*map
, unsigned int orl_count
, int stridx
)
1824 struct archive_iterator iterator
;
1825 struct xcoff_ar_hdr hdr
;
1827 unsigned char buf
[4];
1830 memset (&hdr
, 0, sizeof hdr
);
1831 sprintf (hdr
.size
, "%ld", (long) (4 + orl_count
* 4 + stridx
));
1832 sprintf (hdr
.nextoff
, "%d", 0);
1833 memcpy (hdr
.prevoff
, xcoff_ardata (abfd
)->memoff
, XCOFFARMAG_ELEMENT_SIZE
);
1834 sprintf (hdr
.date
, "%d", 0);
1835 sprintf (hdr
.uid
, "%d", 0);
1836 sprintf (hdr
.gid
, "%d", 0);
1837 sprintf (hdr
.mode
, "%d", 0);
1838 sprintf (hdr
.namlen
, "%d", 0);
1840 /* We need spaces, not null bytes, in the header. */
1841 for (p
= (char *) &hdr
; p
< (char *) &hdr
+ SIZEOF_AR_HDR
; p
++)
1845 if (bfd_bwrite (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR
, abfd
)
1847 || (bfd_bwrite (XCOFFARFMAG
, (bfd_size_type
) SXCOFFARFMAG
, abfd
)
1851 H_PUT_32 (abfd
, orl_count
, buf
);
1852 if (bfd_bwrite (buf
, (bfd_size_type
) 4, abfd
) != 4)
1856 archive_iterator_begin (&iterator
, abfd
);
1857 while (i
< orl_count
&& archive_iterator_next (&iterator
))
1858 while (map
[i
].u
.abfd
== iterator
.current
.member
)
1860 H_PUT_32 (abfd
, iterator
.current
.offset
, buf
);
1861 if (bfd_bwrite (buf
, (bfd_size_type
) 4, abfd
) != 4)
1866 for (i
= 0; i
< orl_count
; i
++)
1871 name
= *map
[i
].name
;
1872 namlen
= strlen (name
);
1873 if (bfd_bwrite (name
, (bfd_size_type
) (namlen
+ 1), abfd
) != namlen
+ 1)
1877 if ((stridx
& 1) != 0)
1882 if (bfd_bwrite (&b
, (bfd_size_type
) 1, abfd
) != 1)
1889 static char buff20
[XCOFFARMAGBIG_ELEMENT_SIZE
+ 1];
1890 #if BFD_HOST_64BIT_LONG
1891 #define FMT20 "%-20ld"
1892 #elif defined (__MSVCRT__)
1893 #define FMT20 "%-20I64d"
1895 #define FMT20 "%-20lld"
1897 #define FMT12 "%-12d"
1898 #define FMT12_OCTAL "%-12o"
1900 #define PRINT20(d, v) \
1901 sprintf (buff20, FMT20, (bfd_uint64_t)(v)), \
1902 memcpy ((void *) (d), buff20, 20)
1904 #define PRINT12(d, v) \
1905 sprintf (buff20, FMT12, (int)(v)), \
1906 memcpy ((void *) (d), buff20, 12)
1908 #define PRINT12_OCTAL(d, v) \
1909 sprintf (buff20, FMT12_OCTAL, (unsigned int)(v)), \
1910 memcpy ((void *) (d), buff20, 12)
1912 #define PRINT4(d, v) \
1913 sprintf (buff20, FMT4, (int)(v)), \
1914 memcpy ((void *) (d), buff20, 4)
1916 #define READ20(d, v) \
1918 memcpy (buff20, (d), 20), \
1919 (v) = bfd_scan_vma (buff20, (const char **) NULL, 10)
1922 do_pad (bfd
*abfd
, unsigned int number
)
1926 /* Limit pad to <= 4096. */
1931 if (bfd_bwrite (&b
, (bfd_size_type
) 1, abfd
) != 1)
1938 do_copy (bfd
*out_bfd
, bfd
*in_bfd
)
1940 bfd_size_type remaining
;
1941 bfd_byte buffer
[DEFAULT_BUFFERSIZE
];
1943 if (bfd_seek (in_bfd
, (file_ptr
) 0, SEEK_SET
) != 0)
1946 remaining
= arelt_size (in_bfd
);
1948 while (remaining
>= DEFAULT_BUFFERSIZE
)
1950 if (bfd_bread (buffer
, DEFAULT_BUFFERSIZE
, in_bfd
) != DEFAULT_BUFFERSIZE
1951 || bfd_bwrite (buffer
, DEFAULT_BUFFERSIZE
, out_bfd
) != DEFAULT_BUFFERSIZE
)
1954 remaining
-= DEFAULT_BUFFERSIZE
;
1959 if (bfd_bread (buffer
, remaining
, in_bfd
) != remaining
1960 || bfd_bwrite (buffer
, remaining
, out_bfd
) != remaining
)
1968 xcoff_write_armap_big (bfd
*abfd
, unsigned int elength ATTRIBUTE_UNUSED
,
1969 struct orl
*map
, unsigned int orl_count
, int stridx
)
1971 struct archive_iterator iterator
;
1972 struct xcoff_ar_file_hdr_big
*fhdr
;
1973 bfd_vma i
, sym_32
, sym_64
, str_32
, str_64
;
1974 const bfd_arch_info_type
*arch_info
;
1976 size_t string_length
;
1977 file_ptr nextoff
, prevoff
;
1979 /* First, we look through the symbols and work out which are
1980 from 32-bit objects and which from 64-bit ones. */
1981 sym_32
= sym_64
= str_32
= str_64
= 0;
1984 for (current_bfd
= abfd
->archive_head
;
1985 current_bfd
!= NULL
&& i
< orl_count
;
1986 current_bfd
= current_bfd
->archive_next
)
1988 arch_info
= bfd_get_arch_info (current_bfd
);
1989 while (map
[i
].u
.abfd
== current_bfd
)
1991 string_length
= strlen (*map
[i
].name
) + 1;
1992 if (arch_info
->bits_per_address
== 64)
1995 str_64
+= string_length
;
2000 str_32
+= string_length
;
2006 /* A quick sanity check... */
2007 BFD_ASSERT (sym_64
+ sym_32
== orl_count
);
2008 /* Explicit cast to int for compiler. */
2009 BFD_ASSERT ((int)(str_64
+ str_32
) == stridx
);
2011 fhdr
= xcoff_ardata_big (abfd
);
2013 /* xcoff_write_archive_contents_big passes nextoff in symoff. */
2014 READ20 (fhdr
->memoff
, prevoff
);
2015 READ20 (fhdr
->symoff
, nextoff
);
2017 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2019 /* Write out the symbol table.
2022 standard big archive header
2023 0x0000 ar_size [0x14]
2024 0x0014 ar_nxtmem [0x14]
2025 0x0028 ar_prvmem [0x14]
2026 0x003C ar_date [0x0C]
2027 0x0048 ar_uid [0x0C]
2028 0x0054 ar_gid [0x0C]
2029 0x0060 ar_mod [0x0C]
2030 0x006C ar_namelen[0x04]
2031 0x0070 ar_fmag [SXCOFFARFMAG]
2034 0x0072 num_syms [0x08], binary
2035 0x0078 offsets [0x08 * num_syms], binary
2036 0x0086 + 0x08 * num_syms names [??]
2037 ?? pad to even bytes.
2042 struct xcoff_ar_hdr_big
*hdr
;
2046 bfd_vma symbol_table_size
=
2051 + str_32
+ (str_32
& 1);
2053 symbol_table
= bfd_zmalloc (symbol_table_size
);
2054 if (symbol_table
== NULL
)
2057 hdr
= (struct xcoff_ar_hdr_big
*) symbol_table
;
2059 PRINT20 (hdr
->size
, 8 + 8 * sym_32
+ str_32
+ (str_32
& 1));
2062 PRINT20 (hdr
->nextoff
, nextoff
+ symbol_table_size
);
2064 PRINT20 (hdr
->nextoff
, 0);
2066 PRINT20 (hdr
->prevoff
, prevoff
);
2067 PRINT12 (hdr
->date
, 0);
2068 PRINT12 (hdr
->uid
, 0);
2069 PRINT12 (hdr
->gid
, 0);
2070 PRINT12 (hdr
->mode
, 0);
2071 PRINT4 (hdr
->namlen
, 0) ;
2073 st
= symbol_table
+ SIZEOF_AR_HDR_BIG
;
2074 memcpy (st
, XCOFFARFMAG
, SXCOFFARFMAG
);
2077 bfd_h_put_64 (abfd
, sym_32
, st
);
2080 /* loop over the 32 bit offsets */
2082 archive_iterator_begin (&iterator
, abfd
);
2083 while (i
< orl_count
&& archive_iterator_next (&iterator
))
2085 arch_info
= bfd_get_arch_info (iterator
.current
.member
);
2086 while (map
[i
].u
.abfd
== iterator
.current
.member
)
2088 if (arch_info
->bits_per_address
== 32)
2090 bfd_h_put_64 (abfd
, iterator
.current
.offset
, st
);
2097 /* loop over the 32 bit symbol names */
2099 for (current_bfd
= abfd
->archive_head
;
2100 current_bfd
!= NULL
&& i
< orl_count
;
2101 current_bfd
= current_bfd
->archive_next
)
2103 arch_info
= bfd_get_arch_info (current_bfd
);
2104 while (map
[i
].u
.abfd
== current_bfd
)
2106 if (arch_info
->bits_per_address
== 32)
2108 string_length
= sprintf (st
, "%s", *map
[i
].name
);
2109 st
+= string_length
+ 1;
2115 bfd_bwrite (symbol_table
, symbol_table_size
, abfd
);
2117 free (symbol_table
);
2120 nextoff
= nextoff
+ symbol_table_size
;
2123 PRINT20 (fhdr
->symoff
, 0);
2127 struct xcoff_ar_hdr_big
*hdr
;
2131 bfd_vma symbol_table_size
=
2136 + str_64
+ (str_64
& 1);
2138 symbol_table
= bfd_zmalloc (symbol_table_size
);
2139 if (symbol_table
== NULL
)
2142 hdr
= (struct xcoff_ar_hdr_big
*) symbol_table
;
2144 PRINT20 (hdr
->size
, 8 + 8 * sym_64
+ str_64
+ (str_64
& 1));
2145 PRINT20 (hdr
->nextoff
, 0);
2146 PRINT20 (hdr
->prevoff
, prevoff
);
2147 PRINT12 (hdr
->date
, 0);
2148 PRINT12 (hdr
->uid
, 0);
2149 PRINT12 (hdr
->gid
, 0);
2150 PRINT12 (hdr
->mode
, 0);
2151 PRINT4 (hdr
->namlen
, 0);
2153 st
= symbol_table
+ SIZEOF_AR_HDR_BIG
;
2154 memcpy (st
, XCOFFARFMAG
, SXCOFFARFMAG
);
2157 bfd_h_put_64 (abfd
, sym_64
, st
);
2160 /* loop over the 64 bit offsets */
2162 archive_iterator_begin (&iterator
, abfd
);
2163 while (i
< orl_count
&& archive_iterator_next (&iterator
))
2165 arch_info
= bfd_get_arch_info (iterator
.current
.member
);
2166 while (map
[i
].u
.abfd
== iterator
.current
.member
)
2168 if (arch_info
->bits_per_address
== 64)
2170 bfd_h_put_64 (abfd
, iterator
.current
.offset
, st
);
2177 /* loop over the 64 bit symbol names */
2179 for (current_bfd
= abfd
->archive_head
;
2180 current_bfd
!= NULL
&& i
< orl_count
;
2181 current_bfd
= current_bfd
->archive_next
)
2183 arch_info
= bfd_get_arch_info (current_bfd
);
2184 while (map
[i
].u
.abfd
== current_bfd
)
2186 if (arch_info
->bits_per_address
== 64)
2188 string_length
= sprintf (st
, "%s", *map
[i
].name
);
2189 st
+= string_length
+ 1;
2195 bfd_bwrite (symbol_table
, symbol_table_size
, abfd
);
2197 free (symbol_table
);
2199 PRINT20 (fhdr
->symoff64
, nextoff
);
2202 PRINT20 (fhdr
->symoff64
, 0);
2208 _bfd_xcoff_write_armap (bfd
*abfd
, unsigned int elength ATTRIBUTE_UNUSED
,
2209 struct orl
*map
, unsigned int orl_count
, int stridx
)
2211 if (! xcoff_big_format_p (abfd
))
2212 return xcoff_write_armap_old (abfd
, elength
, map
, orl_count
, stridx
);
2214 return xcoff_write_armap_big (abfd
, elength
, map
, orl_count
, stridx
);
2217 /* Write out an XCOFF archive. We always write an entire archive,
2218 rather than fussing with the freelist and so forth. */
2221 xcoff_write_archive_contents_old (bfd
*abfd
)
2223 struct archive_iterator iterator
;
2224 struct xcoff_ar_file_hdr fhdr
;
2225 bfd_size_type count
;
2226 bfd_size_type total_namlen
;
2230 file_ptr prevoff
, nextoff
;
2233 struct xcoff_ar_hdr ahdr
;
2236 char decbuf
[XCOFFARMAG_ELEMENT_SIZE
+ 1];
2238 memset (&fhdr
, 0, sizeof fhdr
);
2239 (void) memcpy (fhdr
.magic
, XCOFFARMAG
, SXCOFFARMAG
);
2240 sprintf (fhdr
.firstmemoff
, "%d", SIZEOF_AR_FILE_HDR
);
2241 sprintf (fhdr
.freeoff
, "%d", 0);
2245 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->archive_next
)
2248 total_namlen
+= strlen (normalize_filename (sub
)) + 1;
2249 if (sub
->arelt_data
== NULL
)
2251 sub
->arelt_data
= bfd_zmalloc (sizeof (struct areltdata
));
2252 if (sub
->arelt_data
== NULL
)
2255 if (arch_xhdr (sub
) == NULL
)
2257 struct xcoff_ar_hdr
*ahdrp
;
2260 if ((sub
->flags
& BFD_IN_MEMORY
) != 0)
2262 /* Assume we just "made" the member, and fake it. */
2263 struct bfd_in_memory
*bim
2264 = (struct bfd_in_memory
*) sub
->iostream
;
2266 s
.st_uid
= getuid ();
2267 s
.st_gid
= getgid ();
2269 s
.st_size
= bim
->size
;
2271 else if (stat (bfd_get_filename (sub
), &s
) != 0)
2273 bfd_set_input_error (sub
, bfd_error_system_call
);
2277 if ((abfd
->flags
& BFD_DETERMINISTIC_OUTPUT
) != 0)
2285 ahdrp
= bfd_zalloc (sub
, sizeof (*ahdrp
));
2289 sprintf (ahdrp
->size
, "%ld", (long) s
.st_size
);
2290 sprintf (ahdrp
->date
, "%ld", (long) s
.st_mtime
);
2291 sprintf (ahdrp
->uid
, "%ld", (long) s
.st_uid
);
2292 sprintf (ahdrp
->gid
, "%ld", (long) s
.st_gid
);
2293 sprintf (ahdrp
->mode
, "%o", (unsigned int) s
.st_mode
);
2295 arch_eltdata (sub
)->arch_header
= (char *) ahdrp
;
2296 arch_eltdata (sub
)->parsed_size
= s
.st_size
;
2299 offsets
= (file_ptr
*) bfd_alloc (abfd
, count
* sizeof (file_ptr
));
2300 if (offsets
== NULL
)
2303 if (bfd_seek (abfd
, (file_ptr
) SIZEOF_AR_FILE_HDR
, SEEK_SET
) != 0)
2306 makemap
= bfd_has_map (abfd
);
2309 for (archive_iterator_begin (&iterator
, abfd
), i
= 0;
2310 archive_iterator_next (&iterator
);
2313 bfd_size_type namlen
;
2314 struct xcoff_ar_hdr
*ahdrp
;
2316 if (makemap
&& ! hasobjects
)
2318 if (bfd_check_format (iterator
.current
.member
, bfd_object
))
2322 ahdrp
= arch_xhdr (iterator
.current
.member
);
2323 sprintf (ahdrp
->prevoff
, "%ld", (long) prevoff
);
2324 sprintf (ahdrp
->namlen
, "%ld", (long) iterator
.current
.namlen
);
2325 sprintf (ahdrp
->nextoff
, "%ld", (long) iterator
.next
.offset
);
2327 /* We need spaces, not null bytes, in the header. */
2328 for (p
= (char *) ahdrp
; p
< (char *) ahdrp
+ SIZEOF_AR_HDR
; p
++)
2332 if (!do_pad (abfd
, iterator
.current
.leading_padding
))
2335 BFD_ASSERT (iterator
.current
.offset
== bfd_tell (abfd
));
2336 namlen
= iterator
.current
.padded_namlen
;
2337 if (bfd_bwrite (ahdrp
, SIZEOF_AR_HDR
, abfd
) != SIZEOF_AR_HDR
2338 || bfd_bwrite (iterator
.current
.name
, namlen
, abfd
) != namlen
2339 || bfd_bwrite (XCOFFARFMAG
, SXCOFFARFMAG
, abfd
) != SXCOFFARFMAG
2340 || bfd_seek (iterator
.current
.member
, 0, SEEK_SET
) != 0
2341 || !do_copy (abfd
, iterator
.current
.member
)
2342 || !do_pad (abfd
, iterator
.current
.trailing_padding
))
2345 offsets
[i
] = iterator
.current
.offset
;
2346 prevoff
= iterator
.current
.offset
;
2349 sprintf (fhdr
.lastmemoff
, "%ld", (long) prevoff
);
2351 /* Write out the member table. */
2353 nextoff
= iterator
.next
.offset
;
2354 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2355 sprintf (fhdr
.memoff
, "%ld", (long) nextoff
);
2357 memset (&ahdr
, 0, sizeof ahdr
);
2358 sprintf (ahdr
.size
, "%ld", (long) (XCOFFARMAG_ELEMENT_SIZE
2359 + count
* XCOFFARMAG_ELEMENT_SIZE
2361 sprintf (ahdr
.prevoff
, "%ld", (long) prevoff
);
2362 sprintf (ahdr
.date
, "%d", 0);
2363 sprintf (ahdr
.uid
, "%d", 0);
2364 sprintf (ahdr
.gid
, "%d", 0);
2365 sprintf (ahdr
.mode
, "%d", 0);
2366 sprintf (ahdr
.namlen
, "%d", 0);
2368 size
= (SIZEOF_AR_HDR
2369 + XCOFFARMAG_ELEMENT_SIZE
2370 + count
* XCOFFARMAG_ELEMENT_SIZE
2375 nextoff
+= size
+ (size
& 1);
2377 if (makemap
&& hasobjects
)
2378 sprintf (ahdr
.nextoff
, "%ld", (long) nextoff
);
2380 sprintf (ahdr
.nextoff
, "%d", 0);
2382 /* We need spaces, not null bytes, in the header. */
2383 for (p
= (char *) &ahdr
; p
< (char *) &ahdr
+ SIZEOF_AR_HDR
; p
++)
2387 if ((bfd_bwrite (&ahdr
, (bfd_size_type
) SIZEOF_AR_HDR
, abfd
)
2389 || (bfd_bwrite (XCOFFARFMAG
, (bfd_size_type
) SXCOFFARFMAG
, abfd
)
2393 sprintf (decbuf
, "%-12ld", (long) count
);
2394 if (bfd_bwrite (decbuf
, (bfd_size_type
) XCOFFARMAG_ELEMENT_SIZE
, abfd
)
2395 != XCOFFARMAG_ELEMENT_SIZE
)
2397 for (i
= 0; i
< (size_t) count
; i
++)
2399 sprintf (decbuf
, "%-12ld", (long) offsets
[i
]);
2400 if (bfd_bwrite (decbuf
, (bfd_size_type
) XCOFFARMAG_ELEMENT_SIZE
,
2401 abfd
) != XCOFFARMAG_ELEMENT_SIZE
)
2404 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->archive_next
)
2407 bfd_size_type namlen
;
2409 name
= normalize_filename (sub
);
2410 namlen
= strlen (name
);
2411 if (bfd_bwrite (name
, namlen
+ 1, abfd
) != namlen
+ 1)
2415 if (! do_pad (abfd
, size
& 1))
2418 /* Write out the armap, if appropriate. */
2419 if (! makemap
|| ! hasobjects
)
2420 sprintf (fhdr
.symoff
, "%d", 0);
2423 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2424 sprintf (fhdr
.symoff
, "%ld", (long) nextoff
);
2425 bfd_ardata (abfd
)->tdata
= &fhdr
;
2426 if (! _bfd_compute_and_write_armap (abfd
, 0))
2430 /* Write out the archive file header. */
2432 /* We need spaces, not null bytes, in the header. */
2433 for (p
= (char *) &fhdr
; p
< (char *) &fhdr
+ SIZEOF_AR_FILE_HDR
; p
++)
2437 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
2438 || (bfd_bwrite (&fhdr
, (bfd_size_type
) SIZEOF_AR_FILE_HDR
, abfd
)
2439 != SIZEOF_AR_FILE_HDR
))
2446 xcoff_write_archive_contents_big (bfd
*abfd
)
2448 struct xcoff_ar_file_hdr_big fhdr
;
2449 bfd_size_type count
;
2450 bfd_size_type total_namlen
;
2454 file_ptr prevoff
, nextoff
;
2457 struct xcoff_ar_hdr_big
*hdr
;
2459 char *member_table
, *mt
;
2460 bfd_vma member_table_size
;
2461 struct archive_iterator iterator
;
2463 memset (&fhdr
, 0, SIZEOF_AR_FILE_HDR_BIG
);
2464 memcpy (fhdr
.magic
, XCOFFARMAGBIG
, SXCOFFARMAG
);
2466 if (bfd_seek (abfd
, (file_ptr
) SIZEOF_AR_FILE_HDR_BIG
, SEEK_SET
) != 0)
2469 /* Calculate count and total_namlen. */
2470 makemap
= bfd_has_map (abfd
);
2472 for (current_bfd
= abfd
->archive_head
, count
= 0, total_namlen
= 0;
2473 current_bfd
!= NULL
;
2474 current_bfd
= current_bfd
->archive_next
, count
++)
2476 total_namlen
+= strlen (normalize_filename (current_bfd
)) + 1;
2480 && bfd_check_format (current_bfd
, bfd_object
))
2483 if (current_bfd
->arelt_data
== NULL
)
2485 size
= sizeof (struct areltdata
);
2486 current_bfd
->arelt_data
= bfd_zmalloc (size
);
2487 if (current_bfd
->arelt_data
== NULL
)
2491 if (arch_xhdr_big (current_bfd
) == NULL
)
2493 struct xcoff_ar_hdr_big
*ahdrp
;
2496 if ((current_bfd
->flags
& BFD_IN_MEMORY
) != 0)
2498 /* Assume we just "made" the member, and fake it. */
2499 struct bfd_in_memory
*bim
2500 = (struct bfd_in_memory
*) current_bfd
->iostream
;
2502 s
.st_uid
= getuid ();
2503 s
.st_gid
= getgid ();
2505 s
.st_size
= bim
->size
;
2507 else if (stat (bfd_get_filename (current_bfd
), &s
) != 0)
2509 bfd_set_input_error (current_bfd
, bfd_error_system_call
);
2513 if ((abfd
->flags
& BFD_DETERMINISTIC_OUTPUT
) != 0)
2521 ahdrp
= bfd_zalloc (current_bfd
, sizeof (*ahdrp
));
2525 PRINT20 (ahdrp
->size
, s
.st_size
);
2526 PRINT12 (ahdrp
->date
, s
.st_mtime
);
2527 PRINT12 (ahdrp
->uid
, s
.st_uid
);
2528 PRINT12 (ahdrp
->gid
, s
.st_gid
);
2529 PRINT12_OCTAL (ahdrp
->mode
, s
.st_mode
);
2531 arch_eltdata (current_bfd
)->arch_header
= (char *) ahdrp
;
2532 arch_eltdata (current_bfd
)->parsed_size
= s
.st_size
;
2539 offsets
= (file_ptr
*) bfd_malloc (count
* sizeof (file_ptr
));
2540 if (offsets
== NULL
)
2545 for (archive_iterator_begin (&iterator
, abfd
), i
= 0;
2546 archive_iterator_next (&iterator
);
2549 bfd_size_type namlen
;
2550 struct xcoff_ar_hdr_big
*ahdrp
;
2552 ahdrp
= arch_xhdr_big (iterator
.current
.member
);
2553 PRINT20 (ahdrp
->prevoff
, prevoff
);
2554 PRINT4 (ahdrp
->namlen
, iterator
.current
.namlen
);
2555 PRINT20 (ahdrp
->nextoff
, iterator
.next
.offset
);
2557 if (!do_pad (abfd
, iterator
.current
.leading_padding
))
2563 BFD_ASSERT (iterator
.current
.offset
== bfd_tell (abfd
));
2564 namlen
= iterator
.current
.padded_namlen
;
2565 if (bfd_bwrite (ahdrp
, SIZEOF_AR_HDR_BIG
, abfd
) != SIZEOF_AR_HDR_BIG
2566 || bfd_bwrite (iterator
.current
.name
, namlen
, abfd
) != namlen
2567 || bfd_bwrite (XCOFFARFMAG
, SXCOFFARFMAG
, abfd
) != SXCOFFARFMAG
2568 || bfd_seek (iterator
.current
.member
, 0, SEEK_SET
) != 0
2569 || !do_copy (abfd
, iterator
.current
.member
)
2570 || !do_pad (abfd
, iterator
.current
.trailing_padding
))
2576 offsets
[i
] = iterator
.current
.offset
;
2577 prevoff
= iterator
.current
.offset
;
2582 PRINT20 (fhdr
.firstmemoff
, offsets
[0]);
2583 PRINT20 (fhdr
.lastmemoff
, prevoff
);
2586 /* Write out the member table.
2589 standard big archive header
2590 0x0000 ar_size [0x14]
2591 0x0014 ar_nxtmem [0x14]
2592 0x0028 ar_prvmem [0x14]
2593 0x003C ar_date [0x0C]
2594 0x0048 ar_uid [0x0C]
2595 0x0054 ar_gid [0x0C]
2596 0x0060 ar_mod [0x0C]
2597 0x006C ar_namelen[0x04]
2598 0x0070 ar_fmag [0x02]
2602 0x0086 offsets [0x14 * counts]
2603 0x0086 + 0x14 * counts names [??]
2604 ?? pad to even bytes.
2607 nextoff
= iterator
.next
.offset
;
2608 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2610 member_table_size
= (SIZEOF_AR_HDR_BIG
2612 + XCOFFARMAGBIG_ELEMENT_SIZE
2613 + count
* XCOFFARMAGBIG_ELEMENT_SIZE
2616 member_table_size
+= member_table_size
& 1;
2617 member_table
= bfd_zmalloc (member_table_size
);
2618 if (member_table
== NULL
)
2624 hdr
= (struct xcoff_ar_hdr_big
*) member_table
;
2626 PRINT20 (hdr
->size
, (XCOFFARMAGBIG_ELEMENT_SIZE
2627 + count
* XCOFFARMAGBIG_ELEMENT_SIZE
2628 + total_namlen
+ (total_namlen
& 1)));
2629 if (makemap
&& hasobjects
)
2630 PRINT20 (hdr
->nextoff
, nextoff
+ member_table_size
);
2632 PRINT20 (hdr
->nextoff
, 0);
2633 PRINT20 (hdr
->prevoff
, prevoff
);
2634 PRINT12 (hdr
->date
, 0);
2635 PRINT12 (hdr
->uid
, 0);
2636 PRINT12 (hdr
->gid
, 0);
2637 PRINT12 (hdr
->mode
, 0);
2638 PRINT4 (hdr
->namlen
, 0);
2640 mt
= member_table
+ SIZEOF_AR_HDR_BIG
;
2641 memcpy (mt
, XCOFFARFMAG
, SXCOFFARFMAG
);
2644 PRINT20 (mt
, count
);
2645 mt
+= XCOFFARMAGBIG_ELEMENT_SIZE
;
2646 for (i
= 0; i
< (size_t) count
; i
++)
2648 PRINT20 (mt
, offsets
[i
]);
2649 mt
+= XCOFFARMAGBIG_ELEMENT_SIZE
;
2658 for (current_bfd
= abfd
->archive_head
;
2659 current_bfd
!= NULL
;
2660 current_bfd
= current_bfd
->archive_next
)
2665 name
= normalize_filename (current_bfd
);
2666 namlen
= sprintf (mt
, "%s", name
);
2670 if (bfd_bwrite (member_table
, member_table_size
, abfd
) != member_table_size
)
2673 free (member_table
);
2675 PRINT20 (fhdr
.memoff
, nextoff
);
2678 nextoff
+= member_table_size
;
2680 /* Write out the armap, if appropriate. */
2682 if (! makemap
|| ! hasobjects
)
2683 PRINT20 (fhdr
.symoff
, 0);
2686 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2688 /* Save nextoff in fhdr.symoff so the armap routine can use it. */
2689 PRINT20 (fhdr
.symoff
, nextoff
);
2691 bfd_ardata (abfd
)->tdata
= &fhdr
;
2692 if (! _bfd_compute_and_write_armap (abfd
, 0))
2696 /* Write out the archive file header. */
2698 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
2699 || (bfd_bwrite (&fhdr
, (bfd_size_type
) SIZEOF_AR_FILE_HDR_BIG
,
2700 abfd
) != SIZEOF_AR_FILE_HDR_BIG
))
2707 _bfd_xcoff_write_archive_contents (bfd
*abfd
)
2709 if (! xcoff_big_format_p (abfd
))
2710 return xcoff_write_archive_contents_old (abfd
);
2712 return xcoff_write_archive_contents_big (abfd
);
2715 /* We can't use the usual coff_sizeof_headers routine, because AIX
2716 always uses an a.out header. */
2719 _bfd_xcoff_sizeof_headers (bfd
*abfd
,
2720 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
2725 if (xcoff_data (abfd
)->full_aouthdr
)
2728 size
+= SMALL_AOUTSZ
;
2729 size
+= abfd
->section_count
* SCNHSZ
;
2731 if (info
->strip
!= strip_all
)
2733 /* There can be additional sections just for dealing with overflow in
2734 reloc and lineno counts. But the numbers of relocs and lineno aren't
2735 known when bfd_sizeof_headers is called, so we compute them by
2736 summing the numbers from input sections. */
2737 struct nbr_reloc_lineno
2739 unsigned int reloc_count
;
2740 unsigned int lineno_count
;
2742 struct nbr_reloc_lineno
*n_rl
;
2744 unsigned int max_index
;
2747 /* Although the number of sections is known, the maximum value of
2748 section->index isn't (because some sections may have been removed).
2749 Don't try to renumber sections, just compute the upper bound. */
2751 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
2752 if (s
->index
> max_index
)
2753 max_index
= s
->index
;
2755 /* Allocate the per section counters. It could be possible to use a
2756 preallocated array as the number of sections is limited on XCOFF,
2757 but this creates a maintainance issue. */
2758 n_rl
= bfd_zmalloc ((max_index
+ 1) * sizeof (*n_rl
));
2763 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
2764 for (s
= sub
->sections
; s
!= NULL
; s
= s
->next
)
2765 if (s
->output_section
->owner
== abfd
2766 && !bfd_section_removed_from_list (abfd
, s
->output_section
))
2768 struct nbr_reloc_lineno
*e
= &n_rl
[s
->output_section
->index
];
2769 e
->reloc_count
+= s
->reloc_count
;
2770 e
->lineno_count
+= s
->lineno_count
;
2773 /* Add the size of a section for each section with an overflow. */
2774 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
2776 struct nbr_reloc_lineno
*e
= &n_rl
[s
->index
];
2778 if (e
->reloc_count
>= 0xffff
2779 || (e
->lineno_count
>= 0xffff && info
->strip
!= strip_debugger
))
2789 /* Routines to swap information in the XCOFF .loader section. If we
2790 ever need to write an XCOFF loader, this stuff will need to be
2791 moved to another file shared by the linker (which XCOFF calls the
2792 ``binder'') and the loader. */
2794 /* Swap in the ldhdr structure. */
2797 xcoff_swap_ldhdr_in (bfd
*abfd
, const void * s
, struct internal_ldhdr
*dst
)
2799 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
2801 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
2802 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
2803 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
2804 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
2805 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
2806 dst
->l_impoff
= bfd_get_32 (abfd
, src
->l_impoff
);
2807 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
2808 dst
->l_stoff
= bfd_get_32 (abfd
, src
->l_stoff
);
2811 /* Swap out the ldhdr structure. */
2814 xcoff_swap_ldhdr_out (bfd
*abfd
, const struct internal_ldhdr
*src
, void * d
)
2816 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
2818 bfd_put_32 (abfd
, (bfd_vma
) src
->l_version
, dst
->l_version
);
2819 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
2820 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
2821 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
2822 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
2823 bfd_put_32 (abfd
, src
->l_impoff
, dst
->l_impoff
);
2824 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
2825 bfd_put_32 (abfd
, src
->l_stoff
, dst
->l_stoff
);
2828 /* Swap in the ldsym structure. */
2831 xcoff_swap_ldsym_in (bfd
*abfd
, const void * s
, struct internal_ldsym
*dst
)
2833 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
2835 if (bfd_get_32 (abfd
, src
->_l
._l_l
._l_zeroes
) != 0) {
2836 memcpy (dst
->_l
._l_name
, src
->_l
._l_name
, SYMNMLEN
);
2838 dst
->_l
._l_l
._l_zeroes
= 0;
2839 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->_l
._l_l
._l_offset
);
2841 dst
->l_value
= bfd_get_32 (abfd
, src
->l_value
);
2842 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
2843 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
2844 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
2845 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
2846 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
2849 /* Swap out the ldsym structure. */
2852 xcoff_swap_ldsym_out (bfd
*abfd
, const struct internal_ldsym
*src
, void * d
)
2854 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
2856 if (src
->_l
._l_l
._l_zeroes
!= 0)
2857 memcpy (dst
->_l
._l_name
, src
->_l
._l_name
, SYMNMLEN
);
2860 bfd_put_32 (abfd
, (bfd_vma
) 0, dst
->_l
._l_l
._l_zeroes
);
2861 bfd_put_32 (abfd
, (bfd_vma
) src
->_l
._l_l
._l_offset
,
2862 dst
->_l
._l_l
._l_offset
);
2864 bfd_put_32 (abfd
, src
->l_value
, dst
->l_value
);
2865 bfd_put_16 (abfd
, (bfd_vma
) src
->l_scnum
, dst
->l_scnum
);
2866 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
2867 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
2868 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
2869 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
2873 xcoff_swap_reloc_in (bfd
*abfd
, void * s
, void * d
)
2875 struct external_reloc
*src
= (struct external_reloc
*) s
;
2876 struct internal_reloc
*dst
= (struct internal_reloc
*) d
;
2878 memset (dst
, 0, sizeof (struct internal_reloc
));
2880 dst
->r_vaddr
= bfd_get_32 (abfd
, src
->r_vaddr
);
2881 dst
->r_symndx
= bfd_get_32 (abfd
, src
->r_symndx
);
2882 dst
->r_size
= bfd_get_8 (abfd
, src
->r_size
);
2883 dst
->r_type
= bfd_get_8 (abfd
, src
->r_type
);
2887 xcoff_swap_reloc_out (bfd
*abfd
, void * s
, void * d
)
2889 struct internal_reloc
*src
= (struct internal_reloc
*) s
;
2890 struct external_reloc
*dst
= (struct external_reloc
*) d
;
2892 bfd_put_32 (abfd
, src
->r_vaddr
, dst
->r_vaddr
);
2893 bfd_put_32 (abfd
, src
->r_symndx
, dst
->r_symndx
);
2894 bfd_put_8 (abfd
, src
->r_type
, dst
->r_type
);
2895 bfd_put_8 (abfd
, src
->r_size
, dst
->r_size
);
2897 return bfd_coff_relsz (abfd
);
2900 /* Swap in the ldrel structure. */
2903 xcoff_swap_ldrel_in (bfd
*abfd
, const void * s
, struct internal_ldrel
*dst
)
2905 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
2907 dst
->l_vaddr
= bfd_get_32 (abfd
, src
->l_vaddr
);
2908 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
2909 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
2910 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
2913 /* Swap out the ldrel structure. */
2916 xcoff_swap_ldrel_out (bfd
*abfd
, const struct internal_ldrel
*src
, void * d
)
2918 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
2920 bfd_put_32 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
2921 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
2922 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rtype
, dst
->l_rtype
);
2923 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rsecnm
, dst
->l_rsecnm
);
2928 xcoff_reloc_type_noop (bfd
*input_bfd ATTRIBUTE_UNUSED
,
2929 asection
*input_section ATTRIBUTE_UNUSED
,
2930 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2931 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
2932 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2933 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
2934 bfd_vma val ATTRIBUTE_UNUSED
,
2935 bfd_vma addend ATTRIBUTE_UNUSED
,
2936 bfd_vma
*relocation ATTRIBUTE_UNUSED
,
2937 bfd_byte
*contents ATTRIBUTE_UNUSED
)
2943 xcoff_reloc_type_fail (bfd
*input_bfd
,
2944 asection
*input_section ATTRIBUTE_UNUSED
,
2945 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2946 struct internal_reloc
*rel
,
2947 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2948 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
2949 bfd_vma val ATTRIBUTE_UNUSED
,
2950 bfd_vma addend ATTRIBUTE_UNUSED
,
2951 bfd_vma
*relocation ATTRIBUTE_UNUSED
,
2952 bfd_byte
*contents ATTRIBUTE_UNUSED
)
2955 /* xgettext: c-format */
2956 (_("%pB: unsupported relocation type %#x"),
2957 input_bfd
, (unsigned int) rel
->r_type
);
2958 bfd_set_error (bfd_error_bad_value
);
2963 xcoff_reloc_type_pos (bfd
*input_bfd ATTRIBUTE_UNUSED
,
2964 asection
*input_section ATTRIBUTE_UNUSED
,
2965 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2966 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
2967 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2968 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
2971 bfd_vma
*relocation
,
2972 bfd_byte
*contents ATTRIBUTE_UNUSED
)
2974 *relocation
= val
+ addend
;
2979 xcoff_reloc_type_neg (bfd
*input_bfd ATTRIBUTE_UNUSED
,
2980 asection
*input_section ATTRIBUTE_UNUSED
,
2981 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2982 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
2983 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2984 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
2987 bfd_vma
*relocation
,
2988 bfd_byte
*contents ATTRIBUTE_UNUSED
)
2990 *relocation
= - val
- addend
;
2995 xcoff_reloc_type_rel (bfd
*input_bfd ATTRIBUTE_UNUSED
,
2996 asection
*input_section
,
2997 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2998 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
2999 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3000 struct reloc_howto_struct
*howto
,
3003 bfd_vma
*relocation
,
3004 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3006 howto
->pc_relative
= true;
3008 /* A PC relative reloc includes the section address. */
3009 addend
+= input_section
->vma
;
3011 *relocation
= val
+ addend
;
3012 *relocation
-= (input_section
->output_section
->vma
3013 + input_section
->output_offset
);
3018 xcoff_reloc_type_toc (bfd
*input_bfd
,
3019 asection
*input_section ATTRIBUTE_UNUSED
,
3021 struct internal_reloc
*rel
,
3022 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3023 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
3025 bfd_vma addend ATTRIBUTE_UNUSED
,
3026 bfd_vma
*relocation
,
3027 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3029 struct xcoff_link_hash_entry
*h
;
3031 if (0 > rel
->r_symndx
)
3034 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
3036 if (h
!= NULL
&& h
->smclas
!= XMC_TD
)
3038 if (h
->toc_section
== NULL
)
3041 /* xgettext: c-format */
3042 (_("%pB: TOC reloc at %#" PRIx64
" to symbol `%s' with no TOC entry"),
3043 input_bfd
, (uint64_t) rel
->r_vaddr
, h
->root
.root
.string
);
3044 bfd_set_error (bfd_error_bad_value
);
3048 BFD_ASSERT ((h
->flags
& XCOFF_SET_TOC
) == 0);
3049 val
= (h
->toc_section
->output_section
->vma
3050 + h
->toc_section
->output_offset
);
3053 /* We can't use the preexisting value written down by the
3054 assembly, as R_TOCU needs to be adjusted when the final
3055 R_TOCL value is signed. */
3056 *relocation
= val
- xcoff_data (output_bfd
)->toc
;
3058 if (rel
->r_type
== R_TOCU
)
3059 *relocation
= ((*relocation
+ 0x8000) >> 16) & 0xffff;
3060 if (rel
->r_type
== R_TOCL
)
3061 *relocation
= *relocation
& 0x0000ffff;
3067 xcoff_reloc_type_ba (bfd
*input_bfd ATTRIBUTE_UNUSED
,
3068 asection
*input_section ATTRIBUTE_UNUSED
,
3069 bfd
*output_bfd ATTRIBUTE_UNUSED
,
3070 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
3071 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3072 struct reloc_howto_struct
*howto
,
3075 bfd_vma
*relocation
,
3076 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3078 howto
->src_mask
&= ~3;
3079 howto
->dst_mask
= howto
->src_mask
;
3081 *relocation
= val
+ addend
;
3087 xcoff_reloc_type_br (bfd
*input_bfd
,
3088 asection
*input_section
,
3089 bfd
*output_bfd ATTRIBUTE_UNUSED
,
3090 struct internal_reloc
*rel
,
3091 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3092 struct reloc_howto_struct
*howto
,
3095 bfd_vma
*relocation
,
3098 struct xcoff_link_hash_entry
*h
;
3099 bfd_vma section_offset
;
3101 if (0 > rel
->r_symndx
)
3104 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
3105 section_offset
= rel
->r_vaddr
- input_section
->vma
;
3107 /* If we see an R_BR or R_RBR reloc which is jumping to global
3108 linkage code, and it is followed by an appropriate cror nop
3109 instruction, we replace the cror with lwz r2,20(r1). This
3110 restores the TOC after the glink code. Contrariwise, if the
3111 call is followed by a lwz r2,20(r1), but the call is not
3112 going to global linkage code, we can replace the load with a
3115 && (bfd_link_hash_defined
== h
->root
.type
3116 || bfd_link_hash_defweak
== h
->root
.type
)
3117 && section_offset
+ 8 <= input_section
->size
)
3122 pnext
= contents
+ section_offset
+ 4;
3123 next
= bfd_get_32 (input_bfd
, pnext
);
3125 /* The _ptrgl function is magic. It is used by the AIX
3126 compiler to call a function through a pointer. */
3127 if (h
->smclas
== XMC_GL
|| strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
3129 if (next
== 0x4def7b82 /* cror 15,15,15 */
3130 || next
== 0x4ffffb82 /* cror 31,31,31 */
3131 || next
== 0x60000000) /* ori r0,r0,0 */
3132 bfd_put_32 (input_bfd
, 0x80410014, pnext
); /* lwz r2,20(r1) */
3137 if (next
== 0x80410014) /* lwz r2,20(r1) */
3138 bfd_put_32 (input_bfd
, 0x60000000, pnext
); /* ori r0,r0,0 */
3141 else if (NULL
!= h
&& bfd_link_hash_undefined
== h
->root
.type
)
3143 /* Normally, this relocation is against a defined symbol. In the
3144 case where this is a partial link and the output section offset
3145 is greater than 2^25, the linker will return an invalid error
3146 message that the relocation has been truncated. Yes it has been
3147 truncated but no it not important. For this case, disable the
3148 overflow checking. */
3150 howto
->complain_on_overflow
= complain_overflow_dont
;
3153 /* The original PC-relative relocation is biased by -r_vaddr, so adding
3154 the value below will give the absolute target address. */
3155 *relocation
= val
+ addend
+ rel
->r_vaddr
;
3157 howto
->src_mask
&= ~3;
3158 howto
->dst_mask
= howto
->src_mask
;
3161 && (h
->root
.type
== bfd_link_hash_defined
3162 || h
->root
.type
== bfd_link_hash_defweak
)
3163 && bfd_is_abs_section (h
->root
.u
.def
.section
)
3164 && section_offset
+ 4 <= input_section
->size
)
3169 /* Turn the relative branch into an absolute one by setting the
3171 ptr
= contents
+ section_offset
;
3172 insn
= bfd_get_32 (input_bfd
, ptr
);
3174 bfd_put_32 (input_bfd
, insn
, ptr
);
3176 /* Make the howto absolute too. */
3177 howto
->pc_relative
= false;
3178 howto
->complain_on_overflow
= complain_overflow_bitfield
;
3182 /* Use a PC-relative howto and subtract the instruction's address
3183 from the target address we calculated above. */
3184 howto
->pc_relative
= true;
3185 *relocation
-= (input_section
->output_section
->vma
3186 + input_section
->output_offset
3193 xcoff_reloc_type_crel (bfd
*input_bfd ATTRIBUTE_UNUSED
,
3194 asection
*input_section
,
3195 bfd
*output_bfd ATTRIBUTE_UNUSED
,
3196 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
3197 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3198 struct reloc_howto_struct
*howto
,
3199 bfd_vma val ATTRIBUTE_UNUSED
,
3201 bfd_vma
*relocation
,
3202 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3204 howto
->pc_relative
= true;
3205 howto
->src_mask
&= ~3;
3206 howto
->dst_mask
= howto
->src_mask
;
3208 /* A PC relative reloc includes the section address. */
3209 addend
+= input_section
->vma
;
3211 *relocation
= val
+ addend
;
3212 *relocation
-= (input_section
->output_section
->vma
3213 + input_section
->output_offset
);
3218 xcoff_reloc_type_tls (bfd
*input_bfd ATTRIBUTE_UNUSED
,
3219 asection
*input_section ATTRIBUTE_UNUSED
,
3220 bfd
*output_bfd ATTRIBUTE_UNUSED
,
3221 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
3222 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3223 struct reloc_howto_struct
*howto
,
3226 bfd_vma
*relocation
,
3227 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3229 struct xcoff_link_hash_entry
*h
;
3231 if (0 > rel
->r_symndx
)
3234 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
3236 /* FIXME: R_TLSML is targeting a internal TOC symbol, which will
3237 make the following checks failing. It should be moved with
3238 R_TLSM bellow once it works. */
3239 if (howto
->type
== R_TLSML
)
3245 /* FIXME: h is sometimes null, if the TLS symbol is not exported. */
3249 (_("%pB: TLS relocation at (0x%" BFD_VMA_FMT
"x) over "
3250 "internal symbols (C_HIDEXT) not yet possible\n"),
3251 input_bfd
, rel
->r_vaddr
);
3256 /* TLS relocations must target a TLS symbol. */
3257 if (h
->smclas
!= XMC_TL
&& h
->smclas
!= XMC_UL
)
3260 (_("%pB: TLS relocation at (0x%" BFD_VMA_FMT
"x) over "
3261 "non-TLS symbol %s (0x%x)\n"),
3262 input_bfd
, rel
->r_vaddr
, h
->root
.root
.string
, h
->smclas
);
3266 /* Local TLS relocations must target a local symbol, ie
3268 if ((rel
->r_type
== R_TLS_LD
|| rel
->r_type
== R_TLS_LE
)
3269 && (((h
->flags
& XCOFF_DEF_REGULAR
) == 0
3270 && (h
->flags
& XCOFF_DEF_DYNAMIC
) != 0)
3271 || (h
->flags
& XCOFF_IMPORT
) != 0))
3274 (_("%pB: TLS local relocation at (0x%" BFD_VMA_FMT
"x) over "
3275 "imported symbol %s\n"),
3276 input_bfd
, rel
->r_vaddr
, h
->root
.root
.string
);
3280 /* R_TLSM and R_TLSML are relocations used by the loader.
3281 The value must be 0.
3282 FIXME: move R_TLSML here. */
3283 if (howto
->type
== R_TLSM
)
3289 /* Other TLS relocations aims to put offsets from TLS pointers
3290 starting at -0x7c00 (or -0x7800 in XCOFF64). It becomes a
3291 simple R_POS relocation as long as .tdata and .tbss addresses
3292 start at the same value. This is done in aix ld scripts.
3293 TODO: implement optimization when tls size is < 62K. */
3294 *relocation
= val
+ addend
;
3300 xcoff_complain_overflow_dont_func (bfd
*input_bfd ATTRIBUTE_UNUSED
,
3301 bfd_vma val ATTRIBUTE_UNUSED
,
3302 bfd_vma relocation ATTRIBUTE_UNUSED
,
3303 struct reloc_howto_struct
*
3304 howto ATTRIBUTE_UNUSED
)
3310 xcoff_complain_overflow_bitfield_func (bfd
*input_bfd
,
3313 struct reloc_howto_struct
*howto
)
3315 bfd_vma fieldmask
, signmask
, ss
;
3318 /* Get the values to be added together. For signed and unsigned
3319 relocations, we assume that all values should be truncated to
3320 the size of an address. For bitfields, all the bits matter.
3321 See also bfd_check_overflow. */
3322 fieldmask
= N_ONES (howto
->bitsize
);
3324 b
= val
& howto
->src_mask
;
3326 /* Much like unsigned, except no trimming with addrmask. In
3327 addition, the sum overflows if there is a carry out of
3328 the bfd_vma, i.e., the sum is less than either input
3330 a
>>= howto
->rightshift
;
3331 b
>>= howto
->bitpos
;
3333 /* Bitfields are sometimes used for signed numbers; for
3334 example, a 13-bit field sometimes represents values in
3335 0..8191 and sometimes represents values in -4096..4095.
3336 If the field is signed and a is -4095 (0x1001) and b is
3337 -1 (0x1fff), the sum is -4096 (0x1000), but (0x1001 +
3338 0x1fff is 0x3000). It's not clear how to handle this
3339 everywhere, since there is not way to know how many bits
3340 are significant in the relocation, but the original code
3341 assumed that it was fully sign extended, and we will keep
3343 signmask
= (fieldmask
>> 1) + 1;
3345 if ((a
& ~ fieldmask
) != 0)
3347 /* Some bits out of the field are set. This might not
3348 be a problem: if this is a signed bitfield, it is OK
3349 iff all the high bits are set, including the sign
3350 bit. We'll try setting all but the most significant
3351 bit in the original relocation value: if this is all
3352 ones, we are OK, assuming a signed bitfield. */
3353 ss
= (signmask
<< howto
->rightshift
) - 1;
3354 if ((ss
| relocation
) != ~ (bfd_vma
) 0)
3359 /* We just assume (b & ~ fieldmask) == 0. */
3361 /* We explicitly permit wrap around if this relocation
3362 covers the high bit of an address. The Linux kernel
3363 relies on it, and it is the only way to write assembler
3364 code which can run when loaded at a location 0x80000000
3365 away from the location at which it is linked. */
3366 if ((unsigned) howto
->bitsize
+ howto
->rightshift
3367 == bfd_arch_bits_per_address (input_bfd
))
3371 if (sum
< a
|| (sum
& ~ fieldmask
) != 0)
3373 /* There was a carry out, or the field overflow. Test
3374 for signed operands again. Here is the overflow test
3375 is as for complain_overflow_signed. */
3376 if (((~ (a
^ b
)) & (a
^ sum
)) & signmask
)
3384 xcoff_complain_overflow_signed_func (bfd
*input_bfd
,
3387 struct reloc_howto_struct
*howto
)
3389 bfd_vma addrmask
, fieldmask
, signmask
, ss
;
3392 /* Get the values to be added together. For signed and unsigned
3393 relocations, we assume that all values should be truncated to
3394 the size of an address. For bitfields, all the bits matter.
3395 See also bfd_check_overflow. */
3396 fieldmask
= N_ONES (howto
->bitsize
);
3397 addrmask
= N_ONES (bfd_arch_bits_per_address (input_bfd
)) | fieldmask
;
3399 b
= val
& howto
->src_mask
;
3401 a
= (a
& addrmask
) >> howto
->rightshift
;
3403 /* If any sign bits are set, all sign bits must be set.
3404 That is, A must be a valid negative address after
3406 signmask
= ~ (fieldmask
>> 1);
3408 if (ss
!= 0 && ss
!= ((addrmask
>> howto
->rightshift
) & signmask
))
3411 /* We only need this next bit of code if the sign bit of B
3412 is below the sign bit of A. This would only happen if
3413 SRC_MASK had fewer bits than BITSIZE. Note that if
3414 SRC_MASK has more bits than BITSIZE, we can get into
3415 trouble; we would need to verify that B is in range, as
3416 we do for A above. */
3417 signmask
= ((~ howto
->src_mask
) >> 1) & howto
->src_mask
;
3418 if ((b
& signmask
) != 0)
3420 /* Set all the bits above the sign bit. */
3421 b
-= signmask
<<= 1;
3424 b
= (b
& addrmask
) >> howto
->bitpos
;
3426 /* Now we can do the addition. */
3429 /* See if the result has the correct sign. Bits above the
3430 sign bit are junk now; ignore them. If the sum is
3431 positive, make sure we did not have all negative inputs;
3432 if the sum is negative, make sure we did not have all
3433 positive inputs. The test below looks only at the sign
3434 bits, and it really just
3435 SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM)
3437 signmask
= (fieldmask
>> 1) + 1;
3438 if (((~ (a
^ b
)) & (a
^ sum
)) & signmask
)
3445 xcoff_complain_overflow_unsigned_func (bfd
*input_bfd
,
3448 struct reloc_howto_struct
*howto
)
3450 bfd_vma addrmask
, fieldmask
;
3453 /* Get the values to be added together. For signed and unsigned
3454 relocations, we assume that all values should be truncated to
3455 the size of an address. For bitfields, all the bits matter.
3456 See also bfd_check_overflow. */
3457 fieldmask
= N_ONES (howto
->bitsize
);
3458 addrmask
= N_ONES (bfd_arch_bits_per_address (input_bfd
)) | fieldmask
;
3460 b
= val
& howto
->src_mask
;
3462 /* Checking for an unsigned overflow is relatively easy:
3463 trim the addresses and add, and trim the result as well.
3464 Overflow is normally indicated when the result does not
3465 fit in the field. However, we also need to consider the
3466 case when, e.g., fieldmask is 0x7fffffff or smaller, an
3467 input is 0x80000000, and bfd_vma is only 32 bits; then we
3468 will get sum == 0, but there is an overflow, since the
3469 inputs did not fit in the field. Instead of doing a
3470 separate test, we can check for this by or-ing in the
3471 operands when testing for the sum overflowing its final
3473 a
= (a
& addrmask
) >> howto
->rightshift
;
3474 b
= (b
& addrmask
) >> howto
->bitpos
;
3475 sum
= (a
+ b
) & addrmask
;
3476 if ((a
| b
| sum
) & ~ fieldmask
)
3482 /* This is the relocation function for the RS/6000/POWER/PowerPC.
3483 This is currently the only processor which uses XCOFF; I hope that
3486 The original version was based on two documents:
3487 the PowerPC AIX Version 4 Application Binary Interface, First
3488 Edition (April 1992), and the PowerOpen ABI, Big-Endian
3489 32-Bit Hardware Implementation (June 30, 1994). Differences
3490 between the documents are noted below.
3491 Now, IBM has released an official documentation about XCOFF
3493 https://www.ibm.com/support/knowledgecenter/ssw_aix_72/filesreference/XCOFF.html
3495 Unsupported r_type's
3501 These relocs are defined by the PowerPC ABI to be
3502 relative branches which use half of the difference
3503 between the symbol and the program counter. I can't
3504 quite figure out when this is useful. These relocs are
3505 not defined by the PowerOpen ABI.
3510 Simple positive relocation.
3513 Simple negative relocation.
3516 Simple PC relative relocation.
3519 TOC relative relocation. The value in the instruction in
3520 the input file is the offset from the input file TOC to
3521 the desired location. We want the offset from the final
3522 TOC to the desired location. We have:
3527 so we must change insn by on - in.
3528 This relocation allows the linker to perform optimizations
3529 by transforming a load instruction into a add-immediate
3530 when possible. The relocation is, then, changed to R_TRLA
3532 TODO: Currently, the optimisation isn't implemented.
3535 TOC relative relocation. Same as R_TOC, except that
3536 the optimization isn't allowed
3539 TOC relative relocation. This is a TOC relative load
3540 address instruction which have been changed to an add-
3541 immediate instruction.
3544 GL linkage relocation. The value of this relocation
3545 is the address of the external symbol in the TOC
3549 Local object TOC address. I can't figure out the
3550 difference between this and case R_GL.
3553 The PowerPC AIX ABI describes this as a load which may be
3554 changed to a load address. The PowerOpen ABI says this
3555 is the same as case R_POS.
3558 The PowerPC AIX ABI describes this as a load address
3559 which may be changed to a load. The PowerOpen ABI says
3560 this is the same as R_POS.
3563 Not a relocation but a way to prevent the garbage
3564 collector of AIX linker to remove symbols.
3565 This is not needed in our case.
3568 The PowerOpen ABI says this is the same as R_RBA.
3571 Absolute branch which may be modified to become a
3575 The PowerOpen ABI says this is the same as R_RBR.
3578 A relative branch which may be modified to become an
3582 The PowerPC ABI defines this as an absolute call which
3583 may be modified to become a relative call. The PowerOpen
3584 ABI does not define this relocation type.
3587 The PowerPC ABI defines this as a relative call which may
3588 be modified to become an absolute call. The PowerOpen
3589 ABI does not define this relocation type.
3592 The PowerPC ABI defines this as an absolute branch to a
3593 fixed address which may be modified to an absolute branch
3594 to a symbol. The PowerOpen ABI does not define this
3598 The PowerPC ABI defines this as an absolute branch to a
3599 fixed address which may be modified to a relative branch.
3600 The PowerOpen ABI does not define this relocation type.
3603 Thread-local storage relocation using general-dynamic
3607 Thread-local storage relocation using initial-exec model.
3610 Thread-local storage relocation using local-dynamic model.
3613 Thread-local storage relocation using local-exec model.
3616 Tread-local storage relocation used by the loader.
3619 Tread-local storage relocation used by the loader.
3622 Upper TOC relative relocation. The value is the
3623 high-order 16 bit of a TOC relative relocation.
3626 Lower TOC relative relocation. The value is the
3627 low-order 16 bit of a TOC relative relocation.
3631 xcoff_ppc_relocate_section (bfd
*output_bfd
,
3632 struct bfd_link_info
*info
,
3634 asection
*input_section
,
3636 struct internal_reloc
*relocs
,
3637 struct internal_syment
*syms
,
3638 asection
**sections
)
3640 struct internal_reloc
*rel
;
3641 struct internal_reloc
*relend
;
3644 relend
= rel
+ input_section
->reloc_count
;
3645 for (; rel
< relend
; rel
++)
3648 struct xcoff_link_hash_entry
*h
;
3649 struct internal_syment
*sym
;
3652 struct reloc_howto_struct howto
;
3654 bfd_vma value_to_relocate
;
3658 /* Relocation type R_REF is a special relocation type which is
3659 merely used to prevent garbage collection from occurring for
3660 the csect including the symbol which it references. */
3661 if (rel
->r_type
== R_REF
)
3664 /* Retrieve default value in HOWTO table and fix up according
3665 to r_size field, if it can be different.
3666 This should be made during relocation reading but the algorithms
3667 are expecting constant howtos. */
3668 memcpy (&howto
, &xcoff_howto_table
[rel
->r_type
], sizeof (howto
));
3669 if (howto
.bitsize
!= (rel
->r_size
& 0x1f) + 1)
3671 switch (rel
->r_type
)
3675 howto
.bitsize
= (rel
->r_size
& 0x1f) + 1;
3676 howto
.size
= howto
.bitsize
> 16 ? 2 : 1;
3677 howto
.src_mask
= howto
.dst_mask
= N_ONES (howto
.bitsize
);
3682 (_("%pB: relocatation (%d) at (0x%" BFD_VMA_FMT
"x) has wrong"
3683 " r_rsize (0x%x)\n"),
3684 input_bfd
, rel
->r_type
, rel
->r_vaddr
, rel
->r_size
);
3689 howto
.complain_on_overflow
= (rel
->r_size
& 0x80
3690 ? complain_overflow_signed
3691 : complain_overflow_bitfield
);
3698 symndx
= rel
->r_symndx
;
3704 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
3705 sym
= syms
+ symndx
;
3706 addend
= - sym
->n_value
;
3710 sec
= sections
[symndx
];
3711 /* Hack to make sure we use the right TOC anchor value
3712 if this reloc is against the TOC anchor. */
3713 if (sec
->name
[3] == '0'
3714 && strcmp (sec
->name
, ".tc0") == 0)
3715 val
= xcoff_data (output_bfd
)->toc
;
3717 val
= (sec
->output_section
->vma
3718 + sec
->output_offset
3724 if (info
->unresolved_syms_in_objects
!= RM_IGNORE
3725 && (h
->flags
& XCOFF_WAS_UNDEFINED
) != 0)
3726 (*info
->callbacks
->undefined_symbol
)
3727 (info
, h
->root
.root
.string
,
3728 input_bfd
, input_section
,
3729 rel
->r_vaddr
- input_section
->vma
,
3730 info
->unresolved_syms_in_objects
== RM_DIAGNOSE
&&
3731 !info
->warn_unresolved_syms
);
3733 if (h
->root
.type
== bfd_link_hash_defined
3734 || h
->root
.type
== bfd_link_hash_defweak
)
3736 sec
= h
->root
.u
.def
.section
;
3737 val
= (h
->root
.u
.def
.value
3738 + sec
->output_section
->vma
3739 + sec
->output_offset
);
3741 else if (h
->root
.type
== bfd_link_hash_common
)
3743 sec
= h
->root
.u
.c
.p
->section
;
3744 val
= (sec
->output_section
->vma
3745 + sec
->output_offset
);
3750 BFD_ASSERT (bfd_link_relocatable (info
)
3751 || (info
->static_link
3752 && (h
->flags
& XCOFF_WAS_UNDEFINED
) != 0)
3753 || (h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
3754 || (h
->flags
& XCOFF_IMPORT
) != 0);
3759 if (rel
->r_type
>= XCOFF_MAX_CALCULATE_RELOCATION
3760 || !((*xcoff_calculate_relocation
[rel
->r_type
])
3761 (input_bfd
, input_section
, output_bfd
, rel
, sym
, &howto
, val
,
3762 addend
, &relocation
, contents
)))
3766 address
= rel
->r_vaddr
- input_section
->vma
;
3767 location
= contents
+ address
;
3769 if (address
> input_section
->size
)
3772 /* Get the value we are going to relocate. */
3773 if (1 == howto
.size
)
3774 value_to_relocate
= bfd_get_16 (input_bfd
, location
);
3776 value_to_relocate
= bfd_get_32 (input_bfd
, location
);
3780 FIXME: We may drop bits during the addition
3781 which we don't check for. We must either check at every single
3782 operation, which would be tedious, or we must do the computations
3783 in a type larger than bfd_vma, which would be inefficient. */
3785 if (((*xcoff_complain_overflow
[howto
.complain_on_overflow
])
3786 (input_bfd
, value_to_relocate
, relocation
, &howto
)))
3789 char buf
[SYMNMLEN
+ 1];
3790 char reloc_type_name
[10];
3802 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
3806 sprintf (reloc_type_name
, "0x%02x", rel
->r_type
);
3808 (*info
->callbacks
->reloc_overflow
)
3809 (info
, (h
? &h
->root
: NULL
), name
, reloc_type_name
,
3810 (bfd_vma
) 0, input_bfd
, input_section
,
3811 rel
->r_vaddr
- input_section
->vma
);
3814 /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */
3815 value_to_relocate
= ((value_to_relocate
& ~howto
.dst_mask
)
3816 | (((value_to_relocate
& howto
.src_mask
)
3817 + relocation
) & howto
.dst_mask
));
3819 /* Put the value back in the object file. */
3820 if (1 == howto
.size
)
3821 bfd_put_16 (input_bfd
, value_to_relocate
, location
);
3823 bfd_put_32 (input_bfd
, value_to_relocate
, location
);
3829 /* gcc-8 warns (*) on all the strncpy calls in this function about
3830 possible string truncation. The "truncation" is not a bug. We
3831 have an external representation of structs with fields that are not
3832 necessarily NULL terminated and corresponding internal
3833 representation fields that are one larger so that they can always
3835 gcc versions between 4.2 and 4.6 do not allow pragma control of
3836 diagnostics inside functions, giving a hard error if you try to use
3837 the finer control available with later versions.
3838 gcc prior to 4.2 warns about diagnostic push and pop.
3839 gcc-5, gcc-6 and gcc-7 warn that -Wstringop-truncation is unknown,
3840 unless you also add #pragma GCC diagnostic ignored "-Wpragma".
3841 (*) Depending on your system header files! */
3842 #if GCC_VERSION >= 8000
3843 # pragma GCC diagnostic push
3844 # pragma GCC diagnostic ignored "-Wstringop-truncation"
3847 _bfd_xcoff_put_ldsymbol_name (bfd
*abfd ATTRIBUTE_UNUSED
,
3848 struct xcoff_loader_info
*ldinfo
,
3849 struct internal_ldsym
*ldsym
,
3853 len
= strlen (name
);
3855 if (len
<= SYMNMLEN
)
3856 strncpy (ldsym
->_l
._l_name
, name
, SYMNMLEN
);
3859 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
)
3861 bfd_size_type newalc
;
3864 newalc
= ldinfo
->string_alc
* 2;
3867 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
3870 newstrings
= bfd_realloc (ldinfo
->strings
, newalc
);
3871 if (newstrings
== NULL
)
3873 ldinfo
->failed
= true;
3876 ldinfo
->string_alc
= newalc
;
3877 ldinfo
->strings
= newstrings
;
3880 bfd_put_16 (ldinfo
->output_bfd
, (bfd_vma
) (len
+ 1),
3881 ldinfo
->strings
+ ldinfo
->string_size
);
3882 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
3883 ldsym
->_l
._l_l
._l_zeroes
= 0;
3884 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
3885 ldinfo
->string_size
+= len
+ 3;
3892 _bfd_xcoff_put_symbol_name (struct bfd_link_info
*info
,
3893 struct bfd_strtab_hash
*strtab
,
3894 struct internal_syment
*sym
,
3897 if (strlen (name
) <= SYMNMLEN
)
3899 strncpy (sym
->_n
._n_name
, name
, SYMNMLEN
);
3906 hash
= !info
->traditional_format
;
3907 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
3908 if (indx
== (bfd_size_type
) -1)
3910 sym
->_n
._n_n
._n_zeroes
= 0;
3911 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
3915 #if GCC_VERSION >= 8000
3916 # pragma GCC diagnostic pop
3920 xcoff_create_csect_from_smclas (bfd
*abfd
,
3921 union internal_auxent
*aux
,
3922 const char *symbol_name
)
3924 asection
*return_value
= NULL
;
3926 /* .sv64 = x_smclas == 17
3927 This is an invalid csect for 32 bit apps. */
3928 static const char * const names
[] =
3930 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo", /* 0 - 7 */
3931 ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL
, ".tc0", /* 8 - 15 */
3932 ".td", NULL
, ".sv3264", NULL
, ".tl", ".ul", ".te"
3935 if ((aux
->x_csect
.x_smclas
< ARRAY_SIZE (names
))
3936 && (NULL
!= names
[aux
->x_csect
.x_smclas
]))
3938 return_value
= bfd_make_section_anyway
3939 (abfd
, names
[aux
->x_csect
.x_smclas
]);
3944 /* xgettext: c-format */
3945 (_("%pB: symbol `%s' has unrecognized smclas %d"),
3946 abfd
, symbol_name
, aux
->x_csect
.x_smclas
);
3947 bfd_set_error (bfd_error_bad_value
);
3950 return return_value
;
3954 xcoff_is_lineno_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
, bfd_vma value
)
3956 if (0xffff <= value
)
3963 xcoff_is_reloc_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
, bfd_vma value
)
3965 if (0xffff <= value
)
3972 xcoff_loader_symbol_offset (bfd
*abfd
,
3973 struct internal_ldhdr
*ldhdr ATTRIBUTE_UNUSED
)
3975 return bfd_xcoff_ldhdrsz (abfd
);
3979 xcoff_loader_reloc_offset (bfd
*abfd
, struct internal_ldhdr
*ldhdr
)
3981 return bfd_xcoff_ldhdrsz (abfd
) + ldhdr
->l_nsyms
* bfd_xcoff_ldsymsz (abfd
);
3985 xcoff_generate_rtinit (bfd
*abfd
, const char *init
, const char *fini
,
3988 bfd_byte filehdr_ext
[FILHSZ
];
3989 bfd_byte scnhdr_ext
[SCNHSZ
];
3990 bfd_byte syment_ext
[SYMESZ
* 10];
3991 bfd_byte reloc_ext
[RELSZ
* 3];
3992 bfd_byte
*data_buffer
;
3993 bfd_size_type data_buffer_size
;
3994 bfd_byte
*string_table
= NULL
, *st_tmp
= NULL
;
3995 bfd_size_type string_table_size
;
3997 size_t initsz
, finisz
;
3998 struct internal_filehdr filehdr
;
3999 struct internal_scnhdr scnhdr
;
4000 struct internal_syment syment
;
4001 union internal_auxent auxent
;
4002 struct internal_reloc reloc
;
4004 char *data_name
= ".data";
4005 char *rtinit_name
= "__rtinit";
4006 char *rtld_name
= "__rtld";
4008 if (! bfd_xcoff_rtinit_size (abfd
))
4011 initsz
= (init
== NULL
? 0 : 1 + strlen (init
));
4012 finisz
= (fini
== NULL
? 0 : 1 + strlen (fini
));
4015 memset (filehdr_ext
, 0, FILHSZ
);
4016 memset (&filehdr
, 0, sizeof (struct internal_filehdr
));
4017 filehdr
.f_magic
= bfd_xcoff_magic_number (abfd
);
4018 filehdr
.f_nscns
= 1;
4019 filehdr
.f_timdat
= 0;
4020 filehdr
.f_nsyms
= 0; /* at least 6, no more than 10 */
4021 filehdr
.f_symptr
= 0; /* set below */
4022 filehdr
.f_opthdr
= 0;
4023 filehdr
.f_flags
= 0;
4025 /* section header */
4026 memset (scnhdr_ext
, 0, SCNHSZ
);
4027 memset (&scnhdr
, 0, sizeof (struct internal_scnhdr
));
4028 memcpy (scnhdr
.s_name
, data_name
, strlen (data_name
));
4031 scnhdr
.s_size
= 0; /* set below */
4032 scnhdr
.s_scnptr
= FILHSZ
+ SCNHSZ
;
4033 scnhdr
.s_relptr
= 0; /* set below */
4034 scnhdr
.s_lnnoptr
= 0;
4035 scnhdr
.s_nreloc
= 0; /* either 1 or 2 */
4037 scnhdr
.s_flags
= STYP_DATA
;
4040 0x0000 0x00000000 : rtl
4041 0x0004 0x00000010 : offset to init, or 0
4042 0x0008 0x00000028 : offset to fini, or 0
4043 0x000C 0x0000000C : size of descriptor
4044 0x0010 0x00000000 : init, needs a reloc
4045 0x0014 0x00000040 : offset to init name
4046 0x0018 0x00000000 : flags, padded to a word
4047 0x001C 0x00000000 : empty init
4050 0x0028 0x00000000 : fini, needs a reloc
4051 0x002C 0x00000??? : offset to fini name
4052 0x0030 0x00000000 : flags, padded to a word
4053 0x0034 0x00000000 : empty fini
4057 0x0040 + initsz fini name */
4059 data_buffer_size
= 0x0040 + initsz
+ finisz
;
4060 data_buffer_size
= (data_buffer_size
+ 7) &~ (bfd_size_type
) 7;
4062 data_buffer
= (bfd_byte
*) bfd_zmalloc (data_buffer_size
);
4063 if (data_buffer
== NULL
)
4069 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x04]);
4071 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x14]);
4072 memcpy (&data_buffer
[val
], init
, initsz
);
4078 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x08]);
4079 val
= 0x40 + initsz
;
4080 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x2C]);
4081 memcpy (&data_buffer
[val
], fini
, finisz
);
4085 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x0C]);
4087 scnhdr
.s_size
= data_buffer_size
;
4090 string_table_size
= 0;
4092 string_table_size
+= initsz
;
4094 string_table_size
+= finisz
;
4095 if (string_table_size
)
4097 string_table_size
+= 4;
4098 string_table
= (bfd_byte
*) bfd_zmalloc (string_table_size
);
4099 if (string_table
== NULL
)
4102 val
= string_table_size
;
4103 bfd_h_put_32 (abfd
, val
, &string_table
[0]);
4104 st_tmp
= string_table
+ 4;
4113 memset (syment_ext
, 0, 10 * SYMESZ
);
4114 memset (reloc_ext
, 0, 3 * RELSZ
);
4117 memset (&syment
, 0, sizeof (struct internal_syment
));
4118 memset (&auxent
, 0, sizeof (union internal_auxent
));
4119 memcpy (syment
._n
._n_name
, data_name
, strlen (data_name
));
4121 syment
.n_sclass
= C_HIDEXT
;
4122 syment
.n_numaux
= 1;
4123 auxent
.x_csect
.x_scnlen
.l
= data_buffer_size
;
4124 auxent
.x_csect
.x_smtyp
= 3 << 3 | XTY_SD
;
4125 auxent
.x_csect
.x_smclas
= XMC_RW
;
4126 bfd_coff_swap_sym_out (abfd
, &syment
,
4127 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4128 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4130 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4131 filehdr
.f_nsyms
+= 2;
4134 memset (&syment
, 0, sizeof (struct internal_syment
));
4135 memset (&auxent
, 0, sizeof (union internal_auxent
));
4136 memcpy (syment
._n
._n_name
, rtinit_name
, strlen (rtinit_name
));
4138 syment
.n_sclass
= C_EXT
;
4139 syment
.n_numaux
= 1;
4140 auxent
.x_csect
.x_smtyp
= XTY_LD
;
4141 auxent
.x_csect
.x_smclas
= XMC_RW
;
4142 bfd_coff_swap_sym_out (abfd
, &syment
,
4143 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4144 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4146 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4147 filehdr
.f_nsyms
+= 2;
4152 memset (&syment
, 0, sizeof (struct internal_syment
));
4153 memset (&auxent
, 0, sizeof (union internal_auxent
));
4157 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
4158 memcpy (st_tmp
, init
, initsz
);
4162 memcpy (syment
._n
._n_name
, init
, initsz
- 1);
4164 syment
.n_sclass
= C_EXT
;
4165 syment
.n_numaux
= 1;
4166 bfd_coff_swap_sym_out (abfd
, &syment
,
4167 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4168 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4170 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4173 memset (&reloc
, 0, sizeof (struct internal_reloc
));
4174 reloc
.r_vaddr
= 0x0010;
4175 reloc
.r_symndx
= filehdr
.f_nsyms
;
4176 reloc
.r_type
= R_POS
;
4178 bfd_coff_swap_reloc_out (abfd
, &reloc
, &reloc_ext
[0]);
4180 filehdr
.f_nsyms
+= 2;
4181 scnhdr
.s_nreloc
+= 1;
4187 memset (&syment
, 0, sizeof (struct internal_syment
));
4188 memset (&auxent
, 0, sizeof (union internal_auxent
));
4192 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
4193 memcpy (st_tmp
, fini
, finisz
);
4197 memcpy (syment
._n
._n_name
, fini
, finisz
- 1);
4199 syment
.n_sclass
= C_EXT
;
4200 syment
.n_numaux
= 1;
4201 bfd_coff_swap_sym_out (abfd
, &syment
,
4202 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4203 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4205 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4208 memset (&reloc
, 0, sizeof (struct internal_reloc
));
4209 reloc
.r_vaddr
= 0x0028;
4210 reloc
.r_symndx
= filehdr
.f_nsyms
;
4211 reloc
.r_type
= R_POS
;
4213 bfd_coff_swap_reloc_out (abfd
, &reloc
,
4214 &reloc_ext
[scnhdr
.s_nreloc
* RELSZ
]);
4216 filehdr
.f_nsyms
+= 2;
4217 scnhdr
.s_nreloc
+= 1;
4222 memset (&syment
, 0, sizeof (struct internal_syment
));
4223 memset (&auxent
, 0, sizeof (union internal_auxent
));
4224 memcpy (syment
._n
._n_name
, rtld_name
, strlen (rtld_name
));
4225 syment
.n_sclass
= C_EXT
;
4226 syment
.n_numaux
= 1;
4227 bfd_coff_swap_sym_out (abfd
, &syment
,
4228 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4229 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4231 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4234 memset (&reloc
, 0, sizeof (struct internal_reloc
));
4235 reloc
.r_vaddr
= 0x0000;
4236 reloc
.r_symndx
= filehdr
.f_nsyms
;
4237 reloc
.r_type
= R_POS
;
4239 bfd_coff_swap_reloc_out (abfd
, &reloc
,
4240 &reloc_ext
[scnhdr
.s_nreloc
* RELSZ
]);
4242 filehdr
.f_nsyms
+= 2;
4243 scnhdr
.s_nreloc
+= 1;
4246 scnhdr
.s_relptr
= scnhdr
.s_scnptr
+ data_buffer_size
;
4247 filehdr
.f_symptr
= scnhdr
.s_relptr
+ scnhdr
.s_nreloc
* RELSZ
;
4249 bfd_coff_swap_filehdr_out (abfd
, &filehdr
, filehdr_ext
);
4250 bfd_bwrite (filehdr_ext
, FILHSZ
, abfd
);
4251 bfd_coff_swap_scnhdr_out (abfd
, &scnhdr
, scnhdr_ext
);
4252 bfd_bwrite (scnhdr_ext
, SCNHSZ
, abfd
);
4253 bfd_bwrite (data_buffer
, data_buffer_size
, abfd
);
4254 bfd_bwrite (reloc_ext
, scnhdr
.s_nreloc
* RELSZ
, abfd
);
4255 bfd_bwrite (syment_ext
, filehdr
.f_nsyms
* SYMESZ
, abfd
);
4256 bfd_bwrite (string_table
, string_table_size
, abfd
);
4265 static reloc_howto_type xcoff_dynamic_reloc
=
4266 HOWTO (0, /* type */
4268 2, /* size (0 = byte, 1 = short, 2 = long) */
4270 false, /* pc_relative */
4272 complain_overflow_bitfield
, /* complain_on_overflow */
4273 0, /* special_function */
4275 true, /* partial_inplace */
4276 0xffffffff, /* src_mask */
4277 0xffffffff, /* dst_mask */
4278 false); /* pcrel_offset */
4282 The first word of global linkage code must be modified by filling in
4283 the correct TOC offset. */
4285 static const unsigned long xcoff_glink_code
[9] =
4287 0x81820000, /* lwz r12,0(r2) */
4288 0x90410014, /* stw r2,20(r1) */
4289 0x800c0000, /* lwz r0,0(r12) */
4290 0x804c0004, /* lwz r2,4(r12) */
4291 0x7c0903a6, /* mtctr r0 */
4292 0x4e800420, /* bctr */
4293 0x00000000, /* start of traceback table */
4294 0x000c8000, /* traceback table */
4295 0x00000000, /* traceback table */
4298 /* Table to convert DWARF flags to section names. */
4300 const struct xcoff_dwsect_name xcoff_dwsect_names
[] = {
4301 { SSUBTYP_DWINFO
, ".dwinfo", true },
4302 { SSUBTYP_DWLINE
, ".dwline", true },
4303 { SSUBTYP_DWPBNMS
, ".dwpbnms", true },
4304 { SSUBTYP_DWPBTYP
, ".dwpbtyp", true },
4305 { SSUBTYP_DWARNGE
, ".dwarnge", true },
4306 { SSUBTYP_DWABREV
, ".dwabrev", false },
4307 { SSUBTYP_DWSTR
, ".dwstr", true },
4308 { SSUBTYP_DWRNGES
, ".dwrnges", true }
4311 /* For generic entry points. */
4312 #define _bfd_xcoff_close_and_cleanup _bfd_archive_close_and_cleanup
4313 #define _bfd_xcoff_bfd_free_cached_info _bfd_bool_bfd_true
4314 #define _bfd_xcoff_new_section_hook coff_new_section_hook
4315 #define _bfd_xcoff_get_section_contents _bfd_generic_get_section_contents
4316 #define _bfd_xcoff_get_section_contents_in_window \
4317 _bfd_generic_get_section_contents_in_window
4319 /* For copy private data entry points. */
4320 #define _bfd_xcoff_bfd_copy_private_bfd_data \
4321 _bfd_xcoff_copy_private_bfd_data
4322 #define _bfd_xcoff_bfd_merge_private_bfd_data \
4323 _bfd_generic_bfd_merge_private_bfd_data
4324 #define _bfd_xcoff_bfd_copy_private_section_data \
4325 _bfd_generic_bfd_copy_private_section_data
4326 #define _bfd_xcoff_bfd_copy_private_symbol_data \
4327 _bfd_generic_bfd_copy_private_symbol_data
4328 #define _bfd_xcoff_bfd_copy_private_header_data \
4329 _bfd_generic_bfd_copy_private_header_data
4330 #define _bfd_xcoff_bfd_set_private_flags \
4331 _bfd_generic_bfd_set_private_flags
4332 #define _bfd_xcoff_bfd_print_private_bfd_data \
4333 _bfd_generic_bfd_print_private_bfd_data
4335 /* For archive entry points. */
4336 #define _bfd_xcoff_slurp_extended_name_table \
4337 _bfd_noarchive_slurp_extended_name_table
4338 #define _bfd_xcoff_construct_extended_name_table \
4339 _bfd_noarchive_construct_extended_name_table
4340 #define _bfd_xcoff_truncate_arname bfd_dont_truncate_arname
4341 #define _bfd_xcoff_write_ar_hdr _bfd_generic_write_ar_hdr
4342 #define _bfd_xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
4343 #define _bfd_xcoff_generic_stat_arch_elt _bfd_xcoff_stat_arch_elt
4344 #define _bfd_xcoff_update_armap_timestamp _bfd_bool_bfd_true
4346 /* For symbols entry points. */
4347 #define _bfd_xcoff_get_symtab_upper_bound coff_get_symtab_upper_bound
4348 #define _bfd_xcoff_canonicalize_symtab coff_canonicalize_symtab
4349 #define _bfd_xcoff_make_empty_symbol coff_make_empty_symbol
4350 #define _bfd_xcoff_print_symbol coff_print_symbol
4351 #define _bfd_xcoff_get_symbol_info coff_get_symbol_info
4352 #define _bfd_xcoff_get_symbol_version_string \
4353 _bfd_nosymbols_get_symbol_version_string
4354 #define _bfd_xcoff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
4355 #define _bfd_xcoff_bfd_is_target_special_symbol \
4356 coff_bfd_is_target_special_symbol
4357 #define _bfd_xcoff_get_lineno coff_get_lineno
4358 #define _bfd_xcoff_find_nearest_line coff_find_nearest_line
4359 #define _bfd_xcoff_find_line coff_find_line
4360 #define _bfd_xcoff_find_inliner_info coff_find_inliner_info
4361 #define _bfd_xcoff_bfd_make_debug_symbol coff_bfd_make_debug_symbol
4362 #define _bfd_xcoff_read_minisymbols _bfd_generic_read_minisymbols
4363 #define _bfd_xcoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
4365 /* For reloc entry points. */
4366 #define _bfd_xcoff_get_reloc_upper_bound coff_get_reloc_upper_bound
4367 #define _bfd_xcoff_canonicalize_reloc coff_canonicalize_reloc
4368 #define _bfd_xcoff_set_reloc _bfd_generic_set_reloc
4369 #define _bfd_xcoff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
4370 #define _bfd_xcoff_bfd_reloc_name_lookup _bfd_xcoff_reloc_name_lookup
4372 /* For link entry points. */
4373 #define _bfd_xcoff_bfd_get_relocated_section_contents \
4374 bfd_generic_get_relocated_section_contents
4375 #define _bfd_xcoff_bfd_relax_section bfd_generic_relax_section
4376 #define _bfd_xcoff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
4377 #define _bfd_xcoff_bfd_link_just_syms _bfd_generic_link_just_syms
4378 #define _bfd_xcoff_bfd_copy_link_hash_symbol_type \
4379 _bfd_generic_copy_link_hash_symbol_type
4380 #define _bfd_xcoff_bfd_link_split_section _bfd_generic_link_split_section
4381 #define _bfd_xcoff_bfd_gc_sections bfd_generic_gc_sections
4382 #define _bfd_xcoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags
4383 #define _bfd_xcoff_bfd_merge_sections bfd_generic_merge_sections
4384 #define _bfd_xcoff_bfd_is_group_section bfd_generic_is_group_section
4385 #define _bfd_xcoff_bfd_group_name bfd_generic_group_name
4386 #define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
4387 #define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked
4388 #define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol
4389 #define _bfd_xcoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
4390 #define _bfd_xcoff_bfd_define_start_stop bfd_generic_define_start_stop
4391 #define _bfd_xcoff_bfd_link_check_relocs _bfd_generic_link_check_relocs
4393 /* For dynamic symbols and relocs entry points. */
4394 #define _bfd_xcoff_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
4396 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
4398 { /* COFF backend, defined in libcoff.h. */
4399 _bfd_xcoff_swap_aux_in
,
4400 _bfd_xcoff_swap_sym_in
,
4401 coff_swap_lineno_in
,
4402 _bfd_xcoff_swap_aux_out
,
4403 _bfd_xcoff_swap_sym_out
,
4404 coff_swap_lineno_out
,
4405 xcoff_swap_reloc_out
,
4406 coff_swap_filehdr_out
,
4407 coff_swap_aouthdr_out
,
4408 coff_swap_scnhdr_out
,
4417 true, /* _bfd_coff_long_filenames */
4418 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
4419 3, /* _bfd_coff_default_section_alignment_power */
4420 false, /* _bfd_coff_force_symnames_in_strings */
4421 2, /* _bfd_coff_debug_string_prefix_length */
4422 32768, /* _bfd_coff_max_nscns */
4423 coff_swap_filehdr_in
,
4424 coff_swap_aouthdr_in
,
4425 coff_swap_scnhdr_in
,
4426 xcoff_swap_reloc_in
,
4427 coff_bad_format_hook
,
4428 coff_set_arch_mach_hook
,
4431 coff_set_alignment_hook
,
4432 coff_slurp_symbol_table
,
4433 symname_in_debug_hook
,
4434 coff_pointerize_aux_hook
,
4436 dummy_reloc16_extra_cases
,
4437 dummy_reloc16_estimate
,
4438 NULL
, /* bfd_coff_sym_is_global */
4439 coff_compute_section_file_positions
,
4440 NULL
, /* _bfd_coff_start_final_link */
4441 xcoff_ppc_relocate_section
,
4442 coff_rtype_to_howto
,
4443 NULL
, /* _bfd_coff_adjust_symndx */
4444 _bfd_generic_link_add_one_symbol
,
4445 coff_link_output_has_begun
,
4446 coff_final_link_postscript
,
4447 NULL
/* print_pdata. */
4450 0x01DF, /* magic number */
4454 /* Function pointers to xcoff specific swap routines. */
4455 xcoff_swap_ldhdr_in
,
4456 xcoff_swap_ldhdr_out
,
4457 xcoff_swap_ldsym_in
,
4458 xcoff_swap_ldsym_out
,
4459 xcoff_swap_ldrel_in
,
4460 xcoff_swap_ldrel_out
,
4466 12, /* _xcoff_function_descriptor_size */
4470 1, /* _xcoff_ldhdr_version */
4472 _bfd_xcoff_put_symbol_name
,
4473 _bfd_xcoff_put_ldsymbol_name
,
4474 &xcoff_dynamic_reloc
,
4475 xcoff_create_csect_from_smclas
,
4477 /* Lineno and reloc count overflow. */
4478 xcoff_is_lineno_count_overflow
,
4479 xcoff_is_reloc_count_overflow
,
4481 xcoff_loader_symbol_offset
,
4482 xcoff_loader_reloc_offset
,
4485 &xcoff_glink_code
[0],
4486 36, /* _xcoff_glink_size */
4489 64, /* _xcoff_rtinit_size */
4490 xcoff_generate_rtinit
,
4493 /* The transfer vector that leads the outside world to all of the above. */
4494 const bfd_target rs6000_xcoff_vec
=
4497 bfd_target_xcoff_flavour
,
4498 BFD_ENDIAN_BIG
, /* data byte order is big */
4499 BFD_ENDIAN_BIG
, /* header byte order is big */
4501 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
4502 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
4504 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
4505 0, /* leading char */
4506 '/', /* ar_pad_char */
4507 15, /* ar_max_namelen */
4508 0, /* match priority. */
4509 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
4533 { /* bfd_check_format */
4536 _bfd_xcoff_archive_p
,
4540 { /* bfd_set_format */
4541 _bfd_bool_bfd_false_error
,
4543 _bfd_generic_mkarchive
,
4544 _bfd_bool_bfd_false_error
4547 {/* bfd_write_contents */
4548 _bfd_bool_bfd_false_error
,
4549 coff_write_object_contents
,
4550 _bfd_xcoff_write_archive_contents
,
4551 _bfd_bool_bfd_false_error
4554 BFD_JUMP_TABLE_GENERIC (_bfd_xcoff
),
4555 BFD_JUMP_TABLE_COPY (_bfd_xcoff
),
4556 BFD_JUMP_TABLE_CORE (coff
),
4557 BFD_JUMP_TABLE_ARCHIVE (_bfd_xcoff
),
4558 BFD_JUMP_TABLE_SYMBOLS (_bfd_xcoff
),
4559 BFD_JUMP_TABLE_RELOCS (_bfd_xcoff
),
4560 BFD_JUMP_TABLE_WRITE (coff
),
4561 BFD_JUMP_TABLE_LINK (_bfd_xcoff
),
4562 BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff
),
4564 /* Opposite endian version, none exists */
4567 & bfd_xcoff_backend_data
,
4570 /* xcoff-powermac target
4572 Only difference between this target and the rs6000 target is the
4573 the default architecture and machine type used in coffcode.h
4575 PowerPC Macs use the same magic numbers as RS/6000
4576 (because that's how they were bootstrapped originally),
4577 but they are always PowerPC architecture. */
4578 static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data
=
4580 { /* COFF backend, defined in libcoff.h. */
4581 _bfd_xcoff_swap_aux_in
,
4582 _bfd_xcoff_swap_sym_in
,
4583 coff_swap_lineno_in
,
4584 _bfd_xcoff_swap_aux_out
,
4585 _bfd_xcoff_swap_sym_out
,
4586 coff_swap_lineno_out
,
4587 xcoff_swap_reloc_out
,
4588 coff_swap_filehdr_out
,
4589 coff_swap_aouthdr_out
,
4590 coff_swap_scnhdr_out
,
4599 true, /* _bfd_coff_long_filenames */
4600 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
4601 3, /* _bfd_coff_default_section_alignment_power */
4602 false, /* _bfd_coff_force_symnames_in_strings */
4603 2, /* _bfd_coff_debug_string_prefix_length */
4604 32768, /* _bfd_coff_max_nscns */
4605 coff_swap_filehdr_in
,
4606 coff_swap_aouthdr_in
,
4607 coff_swap_scnhdr_in
,
4608 xcoff_swap_reloc_in
,
4609 coff_bad_format_hook
,
4610 coff_set_arch_mach_hook
,
4613 coff_set_alignment_hook
,
4614 coff_slurp_symbol_table
,
4615 symname_in_debug_hook
,
4616 coff_pointerize_aux_hook
,
4618 dummy_reloc16_extra_cases
,
4619 dummy_reloc16_estimate
,
4620 NULL
, /* bfd_coff_sym_is_global */
4621 coff_compute_section_file_positions
,
4622 NULL
, /* _bfd_coff_start_final_link */
4623 xcoff_ppc_relocate_section
,
4624 coff_rtype_to_howto
,
4625 NULL
, /* _bfd_coff_adjust_symndx */
4626 _bfd_generic_link_add_one_symbol
,
4627 coff_link_output_has_begun
,
4628 coff_final_link_postscript
,
4629 NULL
/* print_pdata. */
4632 0x01DF, /* magic number */
4636 /* Function pointers to xcoff specific swap routines. */
4637 xcoff_swap_ldhdr_in
,
4638 xcoff_swap_ldhdr_out
,
4639 xcoff_swap_ldsym_in
,
4640 xcoff_swap_ldsym_out
,
4641 xcoff_swap_ldrel_in
,
4642 xcoff_swap_ldrel_out
,
4648 12, /* _xcoff_function_descriptor_size */
4652 1, /* _xcoff_ldhdr_version */
4654 _bfd_xcoff_put_symbol_name
,
4655 _bfd_xcoff_put_ldsymbol_name
,
4656 &xcoff_dynamic_reloc
,
4657 xcoff_create_csect_from_smclas
,
4659 /* Lineno and reloc count overflow. */
4660 xcoff_is_lineno_count_overflow
,
4661 xcoff_is_reloc_count_overflow
,
4663 xcoff_loader_symbol_offset
,
4664 xcoff_loader_reloc_offset
,
4667 &xcoff_glink_code
[0],
4668 36, /* _xcoff_glink_size */
4671 0, /* _xcoff_rtinit_size */
4672 xcoff_generate_rtinit
,
4675 /* The transfer vector that leads the outside world to all of the above. */
4676 const bfd_target powerpc_xcoff_vec
=
4679 bfd_target_xcoff_flavour
,
4680 BFD_ENDIAN_BIG
, /* data byte order is big */
4681 BFD_ENDIAN_BIG
, /* header byte order is big */
4683 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
4684 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
4686 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
4687 0, /* leading char */
4688 '/', /* ar_pad_char */
4689 15, /* ar_max_namelen */
4690 0, /* match priority. */
4691 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
4715 { /* bfd_check_format */
4718 _bfd_xcoff_archive_p
,
4722 { /* bfd_set_format */
4723 _bfd_bool_bfd_false_error
,
4725 _bfd_generic_mkarchive
,
4726 _bfd_bool_bfd_false_error
4729 {/* bfd_write_contents */
4730 _bfd_bool_bfd_false_error
,
4731 coff_write_object_contents
,
4732 _bfd_xcoff_write_archive_contents
,
4733 _bfd_bool_bfd_false_error
4736 BFD_JUMP_TABLE_GENERIC (_bfd_xcoff
),
4737 BFD_JUMP_TABLE_COPY (_bfd_xcoff
),
4738 BFD_JUMP_TABLE_CORE (coff
),
4739 BFD_JUMP_TABLE_ARCHIVE (_bfd_xcoff
),
4740 BFD_JUMP_TABLE_SYMBOLS (_bfd_xcoff
),
4741 BFD_JUMP_TABLE_RELOCS (_bfd_xcoff
),
4742 BFD_JUMP_TABLE_WRITE (coff
),
4743 BFD_JUMP_TABLE_LINK (_bfd_xcoff
),
4744 BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff
),
4746 /* Opposite endian version, none exists */
4749 & bfd_pmac_xcoff_backend_data
,