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_TLSGD
:
1257 return &xcoff_howto_table
[0x20];
1258 case BFD_RELOC_PPC_TLSIE
:
1259 return &xcoff_howto_table
[0x21];
1260 case BFD_RELOC_PPC_TLSLD
:
1261 return &xcoff_howto_table
[0x22];
1262 case BFD_RELOC_PPC_TLSLE
:
1263 return &xcoff_howto_table
[0x23];
1264 case BFD_RELOC_PPC_TLSM
:
1265 return &xcoff_howto_table
[0x24];
1266 case BFD_RELOC_PPC_TLSML
:
1267 return &xcoff_howto_table
[0x25];
1273 static reloc_howto_type
*
1274 _bfd_xcoff_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1280 i
< sizeof (xcoff_howto_table
) / sizeof (xcoff_howto_table
[0]);
1282 if (xcoff_howto_table
[i
].name
!= NULL
1283 && strcasecmp (xcoff_howto_table
[i
].name
, r_name
) == 0)
1284 return &xcoff_howto_table
[i
];
1289 /* XCOFF archive support. The original version of this code was by
1290 Damon A. Permezel. It was enhanced to permit cross support, and
1291 writing archive files, by Ian Lance Taylor, Cygnus Support.
1293 XCOFF uses its own archive format. Everything is hooked together
1294 with file offset links, so it is possible to rapidly update an
1295 archive in place. Of course, we don't do that. An XCOFF archive
1296 has a real file header, not just an ARMAG string. The structure of
1297 the file header and of each archive header appear below.
1299 An XCOFF archive also has a member table, which is a list of
1300 elements in the archive (you can get that by looking through the
1301 linked list, but you have to read a lot more of the file). The
1302 member table has a normal archive header with an empty name. It is
1303 normally (and perhaps must be) the second to last entry in the
1304 archive. The member table data is almost printable ASCII. It
1305 starts with a 12 character decimal string which is the number of
1306 entries in the table. For each entry it has a 12 character decimal
1307 string which is the offset in the archive of that member. These
1308 entries are followed by a series of null terminated strings which
1309 are the member names for each entry.
1311 Finally, an XCOFF archive has a global symbol table, which is what
1312 we call the armap. The global symbol table has a normal archive
1313 header with an empty name. It is normally (and perhaps must be)
1314 the last entry in the archive. The contents start with a four byte
1315 binary number which is the number of entries. This is followed by
1316 a that many four byte binary numbers; each is the file offset of an
1317 entry in the archive. These numbers are followed by a series of
1318 null terminated strings, which are symbol names.
1320 AIX 4.3 introduced a new archive format which can handle larger
1321 files and also 32- and 64-bit objects in the same archive. The
1322 things said above remain true except that there is now more than
1323 one global symbol table. The one is used to index 32-bit objects,
1324 the other for 64-bit objects.
1326 The new archives (recognizable by the new ARMAG string) has larger
1327 field lengths so that we cannot really share any code. Also we have
1328 to take care that we are not generating the new form of archives
1329 on AIX 4.2 or earlier systems. */
1331 /* PR 21786: The PE/COFF standard does not require NUL termination for any of
1332 the ASCII fields in the archive headers. So in order to be able to extract
1333 numerical values we provide our own versions of strtol and strtoll which
1334 take a maximum length as an additional parameter. Also - just to save space,
1335 we omit the endptr return parameter, since we know that it is never used. */
1338 _bfd_strntol (const char * nptr
, int base
, unsigned int maxlen
)
1340 char buf
[24]; /* Should be enough. */
1342 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1344 memcpy (buf
, nptr
, maxlen
);
1346 return strtol (buf
, NULL
, base
);
1350 _bfd_strntoll (const char * nptr
, int base
, unsigned int maxlen
)
1352 char buf
[32]; /* Should be enough. */
1354 BFD_ASSERT (maxlen
< (sizeof (buf
) - 1));
1356 memcpy (buf
, nptr
, maxlen
);
1358 return strtoll (buf
, NULL
, base
);
1361 /* Macro to read an ASCII value stored in an archive header field. */
1362 #define GET_VALUE_IN_FIELD(VAR, FIELD, BASE) \
1365 (VAR) = (sizeof (VAR) > sizeof (long) \
1366 ? _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
1367 : _bfd_strntol (FIELD, BASE, sizeof FIELD)); \
1371 #define EQ_VALUE_IN_FIELD(VAR, FIELD, BASE) \
1372 (sizeof (VAR) > sizeof (long) \
1373 ? (VAR) == _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
1374 : (VAR) == _bfd_strntol (FIELD, BASE, sizeof FIELD))
1376 /* Read in the armap of an XCOFF archive. */
1379 _bfd_xcoff_slurp_armap (bfd
*abfd
)
1384 bfd_byte
*contents
, *cend
;
1389 if (xcoff_ardata (abfd
) == NULL
)
1391 abfd
->has_armap
= false;
1395 if (! xcoff_big_format_p (abfd
))
1397 /* This is for the old format. */
1398 struct xcoff_ar_hdr hdr
;
1400 GET_VALUE_IN_FIELD (off
, xcoff_ardata (abfd
)->symoff
, 10);
1403 abfd
->has_armap
= false;
1407 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1410 /* The symbol table starts with a normal archive header. */
1411 if (bfd_bread (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR
, abfd
)
1415 /* Skip the name (normally empty). */
1416 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1417 off
= ((namlen
+ 1) & ~ (size_t) 1) + SXCOFFARFMAG
;
1418 if (bfd_seek (abfd
, off
, SEEK_CUR
) != 0)
1421 GET_VALUE_IN_FIELD (sz
, hdr
.size
, 10);
1424 bfd_set_error (bfd_error_bad_value
);
1428 /* Read in the entire symbol table. */
1429 contents
= (bfd_byte
*) _bfd_alloc_and_read (abfd
, sz
+ 1, sz
);
1430 if (contents
== NULL
)
1433 /* Ensure strings are NULL terminated so we don't wander off the
1434 end of the buffer. */
1437 /* The symbol table starts with a four byte count. */
1438 c
= H_GET_32 (abfd
, contents
);
1442 bfd_set_error (bfd_error_bad_value
);
1446 bfd_ardata (abfd
)->symdefs
=
1447 ((carsym
*) bfd_alloc (abfd
, c
* sizeof (carsym
)));
1448 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1451 /* After the count comes a list of four byte file offsets. */
1452 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 4;
1454 ++i
, ++arsym
, p
+= 4)
1455 arsym
->file_offset
= H_GET_32 (abfd
, p
);
1459 /* This is for the new format. */
1460 struct xcoff_ar_hdr_big hdr
;
1462 GET_VALUE_IN_FIELD (off
, xcoff_ardata_big (abfd
)->symoff
, 10);
1465 abfd
->has_armap
= false;
1469 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1472 /* The symbol table starts with a normal archive header. */
1473 if (bfd_bread (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR_BIG
, abfd
)
1474 != SIZEOF_AR_HDR_BIG
)
1477 /* Skip the name (normally empty). */
1478 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1479 off
= ((namlen
+ 1) & ~ (size_t) 1) + SXCOFFARFMAG
;
1480 if (bfd_seek (abfd
, off
, SEEK_CUR
) != 0)
1483 GET_VALUE_IN_FIELD (sz
, hdr
.size
, 10);
1486 bfd_set_error (bfd_error_bad_value
);
1490 /* Read in the entire symbol table. */
1491 contents
= (bfd_byte
*) _bfd_alloc_and_read (abfd
, sz
+ 1, sz
);
1492 if (contents
== NULL
)
1495 /* Ensure strings are NULL terminated so we don't wander off the
1496 end of the buffer. */
1499 /* The symbol table starts with an eight byte count. */
1500 c
= H_GET_64 (abfd
, contents
);
1504 bfd_set_error (bfd_error_bad_value
);
1508 bfd_ardata (abfd
)->symdefs
=
1509 ((carsym
*) bfd_alloc (abfd
, c
* sizeof (carsym
)));
1510 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1513 /* After the count comes a list of eight byte file offsets. */
1514 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1516 ++i
, ++arsym
, p
+= 8)
1517 arsym
->file_offset
= H_GET_64 (abfd
, p
);
1520 /* After the file offsets come null terminated symbol names. */
1521 cend
= contents
+ sz
;
1522 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1524 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1528 bfd_set_error (bfd_error_bad_value
);
1531 arsym
->name
= (char *) p
;
1534 bfd_ardata (abfd
)->symdef_count
= c
;
1535 abfd
->has_armap
= true;
1540 /* See if this is an XCOFF archive. */
1543 _bfd_xcoff_archive_p (bfd
*abfd
)
1545 struct artdata
*tdata_hold
;
1546 char magic
[SXCOFFARMAG
];
1547 size_t amt
= SXCOFFARMAG
;
1549 if (bfd_bread (magic
, amt
, abfd
) != amt
)
1551 if (bfd_get_error () != bfd_error_system_call
)
1552 bfd_set_error (bfd_error_wrong_format
);
1556 if (strncmp (magic
, XCOFFARMAG
, SXCOFFARMAG
) != 0
1557 && strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0)
1559 bfd_set_error (bfd_error_wrong_format
);
1563 tdata_hold
= bfd_ardata (abfd
);
1565 amt
= sizeof (struct artdata
);
1566 bfd_ardata (abfd
) = (struct artdata
*) bfd_zalloc (abfd
, amt
);
1567 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1568 goto error_ret_restore
;
1570 /* Cleared by bfd_zalloc above.
1571 bfd_ardata (abfd)->cache = NULL;
1572 bfd_ardata (abfd)->archive_head = NULL;
1573 bfd_ardata (abfd)->symdefs = NULL;
1574 bfd_ardata (abfd)->extended_names = NULL;
1575 bfd_ardata (abfd)->extended_names_size = 0; */
1577 /* Now handle the two formats. */
1578 if (magic
[1] != 'b')
1580 /* This is the old format. */
1581 struct xcoff_ar_file_hdr hdr
;
1583 /* Copy over the magic string. */
1584 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1586 /* Now read the rest of the file header. */
1587 amt
= SIZEOF_AR_FILE_HDR
- SXCOFFARMAG
;
1588 if (bfd_bread (&hdr
.memoff
, amt
, abfd
) != amt
)
1590 if (bfd_get_error () != bfd_error_system_call
)
1591 bfd_set_error (bfd_error_wrong_format
);
1595 GET_VALUE_IN_FIELD (bfd_ardata (abfd
)->first_file_filepos
,
1596 hdr
.firstmemoff
, 10);
1598 amt
= SIZEOF_AR_FILE_HDR
;
1599 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, amt
);
1600 if (bfd_ardata (abfd
)->tdata
== NULL
)
1603 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR
);
1607 /* This is the new format. */
1608 struct xcoff_ar_file_hdr_big hdr
;
1610 /* Copy over the magic string. */
1611 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1613 /* Now read the rest of the file header. */
1614 amt
= SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
;
1615 if (bfd_bread (&hdr
.memoff
, amt
, abfd
) != amt
)
1617 if (bfd_get_error () != bfd_error_system_call
)
1618 bfd_set_error (bfd_error_wrong_format
);
1622 bfd_ardata (abfd
)->first_file_filepos
= bfd_scan_vma (hdr
.firstmemoff
,
1626 amt
= SIZEOF_AR_FILE_HDR_BIG
;
1627 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, amt
);
1628 if (bfd_ardata (abfd
)->tdata
== NULL
)
1631 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1634 if (! _bfd_xcoff_slurp_armap (abfd
))
1637 bfd_release (abfd
, bfd_ardata (abfd
));
1639 bfd_ardata (abfd
) = tdata_hold
;
1643 return _bfd_no_cleanup
;
1646 /* Read the archive header in an XCOFF archive. */
1649 _bfd_xcoff_read_ar_hdr (bfd
*abfd
)
1651 bfd_size_type namlen
;
1652 struct areltdata
*ret
;
1655 if (! xcoff_big_format_p (abfd
))
1657 struct xcoff_ar_hdr hdr
;
1658 struct xcoff_ar_hdr
*hdrp
;
1660 if (bfd_bread (&hdr
, SIZEOF_AR_HDR
, abfd
) != SIZEOF_AR_HDR
)
1663 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1664 amt
= sizeof (struct areltdata
) + SIZEOF_AR_HDR
+ namlen
+ 1;
1665 ret
= (struct areltdata
*) bfd_malloc (amt
);
1669 hdrp
= (struct xcoff_ar_hdr
*) (ret
+ 1);
1670 memcpy (hdrp
, &hdr
, SIZEOF_AR_HDR
);
1671 if (bfd_bread ((char *) hdrp
+ SIZEOF_AR_HDR
, namlen
, abfd
) != namlen
)
1676 ((char *) hdrp
)[SIZEOF_AR_HDR
+ namlen
] = '\0';
1678 ret
->arch_header
= (char *) hdrp
;
1679 GET_VALUE_IN_FIELD (ret
->parsed_size
, hdr
.size
, 10);
1680 ret
->filename
= (char *) hdrp
+ SIZEOF_AR_HDR
;
1684 struct xcoff_ar_hdr_big hdr
;
1685 struct xcoff_ar_hdr_big
*hdrp
;
1687 if (bfd_bread (&hdr
, SIZEOF_AR_HDR_BIG
, abfd
) != SIZEOF_AR_HDR_BIG
)
1690 GET_VALUE_IN_FIELD (namlen
, hdr
.namlen
, 10);
1691 amt
= sizeof (struct areltdata
) + SIZEOF_AR_HDR_BIG
+ namlen
+ 1;
1692 ret
= (struct areltdata
*) bfd_malloc (amt
);
1696 hdrp
= (struct xcoff_ar_hdr_big
*) (ret
+ 1);
1697 memcpy (hdrp
, &hdr
, SIZEOF_AR_HDR_BIG
);
1698 if (bfd_bread ((char *) hdrp
+ SIZEOF_AR_HDR_BIG
, namlen
, abfd
) != namlen
)
1703 ((char *) hdrp
)[SIZEOF_AR_HDR_BIG
+ namlen
] = '\0';
1705 ret
->arch_header
= (char *) hdrp
;
1706 GET_VALUE_IN_FIELD (ret
->parsed_size
, hdr
.size
, 10);
1707 ret
->filename
= (char *) hdrp
+ SIZEOF_AR_HDR_BIG
;
1710 /* Skip over the XCOFFARFMAG at the end of the file name. */
1711 if (bfd_seek (abfd
, (file_ptr
) ((namlen
& 1) + SXCOFFARFMAG
), SEEK_CUR
) != 0)
1717 /* Open the next element in an XCOFF archive. */
1720 _bfd_xcoff_openr_next_archived_file (bfd
*archive
, bfd
*last_file
)
1724 if (xcoff_ardata (archive
) == NULL
)
1726 bfd_set_error (bfd_error_invalid_operation
);
1730 if (! xcoff_big_format_p (archive
))
1732 if (last_file
== NULL
)
1733 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1735 GET_VALUE_IN_FIELD (filestart
, arch_xhdr (last_file
)->nextoff
, 10);
1738 || EQ_VALUE_IN_FIELD (filestart
, xcoff_ardata (archive
)->memoff
, 10)
1739 || EQ_VALUE_IN_FIELD (filestart
, xcoff_ardata (archive
)->symoff
, 10))
1741 bfd_set_error (bfd_error_no_more_archived_files
);
1747 if (last_file
== NULL
)
1748 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1750 GET_VALUE_IN_FIELD (filestart
, arch_xhdr_big (last_file
)->nextoff
, 10);
1753 || EQ_VALUE_IN_FIELD (filestart
, xcoff_ardata_big (archive
)->memoff
, 10)
1754 || EQ_VALUE_IN_FIELD (filestart
, xcoff_ardata_big (archive
)->symoff
, 10))
1756 bfd_set_error (bfd_error_no_more_archived_files
);
1761 return _bfd_get_elt_at_filepos (archive
, filestart
);
1764 /* Stat an element in an XCOFF archive. */
1767 _bfd_xcoff_stat_arch_elt (bfd
*abfd
, struct stat
*s
)
1769 if (abfd
->arelt_data
== NULL
)
1771 bfd_set_error (bfd_error_invalid_operation
);
1775 if (! xcoff_big_format_p (abfd
->my_archive
))
1777 struct xcoff_ar_hdr
*hdrp
= arch_xhdr (abfd
);
1779 GET_VALUE_IN_FIELD (s
->st_mtime
, hdrp
->date
, 10);
1780 GET_VALUE_IN_FIELD (s
->st_uid
, hdrp
->uid
, 10);
1781 GET_VALUE_IN_FIELD (s
->st_gid
, hdrp
->gid
, 10);
1782 GET_VALUE_IN_FIELD (s
->st_mode
, hdrp
->mode
, 8);
1783 s
->st_size
= arch_eltdata (abfd
)->parsed_size
;
1787 struct xcoff_ar_hdr_big
*hdrp
= arch_xhdr_big (abfd
);
1789 GET_VALUE_IN_FIELD (s
->st_mtime
, hdrp
->date
, 10);
1790 GET_VALUE_IN_FIELD (s
->st_uid
, hdrp
->uid
, 10);
1791 GET_VALUE_IN_FIELD (s
->st_gid
, hdrp
->gid
, 10);
1792 GET_VALUE_IN_FIELD (s
->st_mode
, hdrp
->mode
, 8);
1793 s
->st_size
= arch_eltdata (abfd
)->parsed_size
;
1799 /* Normalize a file name for inclusion in an archive. */
1802 normalize_filename (bfd
*abfd
)
1805 const char *filename
;
1807 file
= bfd_get_filename (abfd
);
1808 filename
= strrchr (file
, '/');
1809 if (filename
!= NULL
)
1816 /* Write out an XCOFF armap. */
1819 xcoff_write_armap_old (bfd
*abfd
, unsigned int elength ATTRIBUTE_UNUSED
,
1820 struct orl
*map
, unsigned int orl_count
, int stridx
)
1822 struct archive_iterator iterator
;
1823 struct xcoff_ar_hdr hdr
;
1825 unsigned char buf
[4];
1828 memset (&hdr
, 0, sizeof hdr
);
1829 sprintf (hdr
.size
, "%ld", (long) (4 + orl_count
* 4 + stridx
));
1830 sprintf (hdr
.nextoff
, "%d", 0);
1831 memcpy (hdr
.prevoff
, xcoff_ardata (abfd
)->memoff
, XCOFFARMAG_ELEMENT_SIZE
);
1832 sprintf (hdr
.date
, "%d", 0);
1833 sprintf (hdr
.uid
, "%d", 0);
1834 sprintf (hdr
.gid
, "%d", 0);
1835 sprintf (hdr
.mode
, "%d", 0);
1836 sprintf (hdr
.namlen
, "%d", 0);
1838 /* We need spaces, not null bytes, in the header. */
1839 for (p
= (char *) &hdr
; p
< (char *) &hdr
+ SIZEOF_AR_HDR
; p
++)
1843 if (bfd_bwrite (&hdr
, (bfd_size_type
) SIZEOF_AR_HDR
, abfd
)
1845 || (bfd_bwrite (XCOFFARFMAG
, (bfd_size_type
) SXCOFFARFMAG
, abfd
)
1849 H_PUT_32 (abfd
, orl_count
, buf
);
1850 if (bfd_bwrite (buf
, (bfd_size_type
) 4, abfd
) != 4)
1854 archive_iterator_begin (&iterator
, abfd
);
1855 while (i
< orl_count
&& archive_iterator_next (&iterator
))
1856 while (map
[i
].u
.abfd
== iterator
.current
.member
)
1858 H_PUT_32 (abfd
, iterator
.current
.offset
, buf
);
1859 if (bfd_bwrite (buf
, (bfd_size_type
) 4, abfd
) != 4)
1864 for (i
= 0; i
< orl_count
; i
++)
1869 name
= *map
[i
].name
;
1870 namlen
= strlen (name
);
1871 if (bfd_bwrite (name
, (bfd_size_type
) (namlen
+ 1), abfd
) != namlen
+ 1)
1875 if ((stridx
& 1) != 0)
1880 if (bfd_bwrite (&b
, (bfd_size_type
) 1, abfd
) != 1)
1887 static char buff20
[XCOFFARMAGBIG_ELEMENT_SIZE
+ 1];
1888 #if BFD_HOST_64BIT_LONG
1889 #define FMT20 "%-20ld"
1890 #elif defined (__MSVCRT__)
1891 #define FMT20 "%-20I64d"
1893 #define FMT20 "%-20lld"
1895 #define FMT12 "%-12d"
1896 #define FMT12_OCTAL "%-12o"
1898 #define PRINT20(d, v) \
1899 sprintf (buff20, FMT20, (bfd_uint64_t)(v)), \
1900 memcpy ((void *) (d), buff20, 20)
1902 #define PRINT12(d, v) \
1903 sprintf (buff20, FMT12, (int)(v)), \
1904 memcpy ((void *) (d), buff20, 12)
1906 #define PRINT12_OCTAL(d, v) \
1907 sprintf (buff20, FMT12_OCTAL, (unsigned int)(v)), \
1908 memcpy ((void *) (d), buff20, 12)
1910 #define PRINT4(d, v) \
1911 sprintf (buff20, FMT4, (int)(v)), \
1912 memcpy ((void *) (d), buff20, 4)
1914 #define READ20(d, v) \
1916 memcpy (buff20, (d), 20), \
1917 (v) = bfd_scan_vma (buff20, (const char **) NULL, 10)
1920 do_pad (bfd
*abfd
, unsigned int number
)
1924 /* Limit pad to <= 4096. */
1929 if (bfd_bwrite (&b
, (bfd_size_type
) 1, abfd
) != 1)
1936 do_copy (bfd
*out_bfd
, bfd
*in_bfd
)
1938 bfd_size_type remaining
;
1939 bfd_byte buffer
[DEFAULT_BUFFERSIZE
];
1941 if (bfd_seek (in_bfd
, (file_ptr
) 0, SEEK_SET
) != 0)
1944 remaining
= arelt_size (in_bfd
);
1946 while (remaining
>= DEFAULT_BUFFERSIZE
)
1948 if (bfd_bread (buffer
, DEFAULT_BUFFERSIZE
, in_bfd
) != DEFAULT_BUFFERSIZE
1949 || bfd_bwrite (buffer
, DEFAULT_BUFFERSIZE
, out_bfd
) != DEFAULT_BUFFERSIZE
)
1952 remaining
-= DEFAULT_BUFFERSIZE
;
1957 if (bfd_bread (buffer
, remaining
, in_bfd
) != remaining
1958 || bfd_bwrite (buffer
, remaining
, out_bfd
) != remaining
)
1966 xcoff_write_armap_big (bfd
*abfd
, unsigned int elength ATTRIBUTE_UNUSED
,
1967 struct orl
*map
, unsigned int orl_count
, int stridx
)
1969 struct archive_iterator iterator
;
1970 struct xcoff_ar_file_hdr_big
*fhdr
;
1971 bfd_vma i
, sym_32
, sym_64
, str_32
, str_64
;
1972 const bfd_arch_info_type
*arch_info
;
1974 size_t string_length
;
1975 file_ptr nextoff
, prevoff
;
1977 /* First, we look through the symbols and work out which are
1978 from 32-bit objects and which from 64-bit ones. */
1979 sym_32
= sym_64
= str_32
= str_64
= 0;
1982 for (current_bfd
= abfd
->archive_head
;
1983 current_bfd
!= NULL
&& i
< orl_count
;
1984 current_bfd
= current_bfd
->archive_next
)
1986 arch_info
= bfd_get_arch_info (current_bfd
);
1987 while (map
[i
].u
.abfd
== current_bfd
)
1989 string_length
= strlen (*map
[i
].name
) + 1;
1990 if (arch_info
->bits_per_address
== 64)
1993 str_64
+= string_length
;
1998 str_32
+= string_length
;
2004 /* A quick sanity check... */
2005 BFD_ASSERT (sym_64
+ sym_32
== orl_count
);
2006 /* Explicit cast to int for compiler. */
2007 BFD_ASSERT ((int)(str_64
+ str_32
) == stridx
);
2009 fhdr
= xcoff_ardata_big (abfd
);
2011 /* xcoff_write_archive_contents_big passes nextoff in symoff. */
2012 READ20 (fhdr
->memoff
, prevoff
);
2013 READ20 (fhdr
->symoff
, nextoff
);
2015 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2017 /* Write out the symbol table.
2020 standard big archive header
2021 0x0000 ar_size [0x14]
2022 0x0014 ar_nxtmem [0x14]
2023 0x0028 ar_prvmem [0x14]
2024 0x003C ar_date [0x0C]
2025 0x0048 ar_uid [0x0C]
2026 0x0054 ar_gid [0x0C]
2027 0x0060 ar_mod [0x0C]
2028 0x006C ar_namelen[0x04]
2029 0x0070 ar_fmag [SXCOFFARFMAG]
2032 0x0072 num_syms [0x08], binary
2033 0x0078 offsets [0x08 * num_syms], binary
2034 0x0086 + 0x08 * num_syms names [??]
2035 ?? pad to even bytes.
2040 struct xcoff_ar_hdr_big
*hdr
;
2044 bfd_vma symbol_table_size
=
2049 + str_32
+ (str_32
& 1);
2051 symbol_table
= bfd_zmalloc (symbol_table_size
);
2052 if (symbol_table
== NULL
)
2055 hdr
= (struct xcoff_ar_hdr_big
*) symbol_table
;
2057 PRINT20 (hdr
->size
, 8 + 8 * sym_32
+ str_32
+ (str_32
& 1));
2060 PRINT20 (hdr
->nextoff
, nextoff
+ symbol_table_size
);
2062 PRINT20 (hdr
->nextoff
, 0);
2064 PRINT20 (hdr
->prevoff
, prevoff
);
2065 PRINT12 (hdr
->date
, 0);
2066 PRINT12 (hdr
->uid
, 0);
2067 PRINT12 (hdr
->gid
, 0);
2068 PRINT12 (hdr
->mode
, 0);
2069 PRINT4 (hdr
->namlen
, 0) ;
2071 st
= symbol_table
+ SIZEOF_AR_HDR_BIG
;
2072 memcpy (st
, XCOFFARFMAG
, SXCOFFARFMAG
);
2075 bfd_h_put_64 (abfd
, sym_32
, st
);
2078 /* loop over the 32 bit offsets */
2080 archive_iterator_begin (&iterator
, abfd
);
2081 while (i
< orl_count
&& archive_iterator_next (&iterator
))
2083 arch_info
= bfd_get_arch_info (iterator
.current
.member
);
2084 while (map
[i
].u
.abfd
== iterator
.current
.member
)
2086 if (arch_info
->bits_per_address
== 32)
2088 bfd_h_put_64 (abfd
, iterator
.current
.offset
, st
);
2095 /* loop over the 32 bit symbol names */
2097 for (current_bfd
= abfd
->archive_head
;
2098 current_bfd
!= NULL
&& i
< orl_count
;
2099 current_bfd
= current_bfd
->archive_next
)
2101 arch_info
= bfd_get_arch_info (current_bfd
);
2102 while (map
[i
].u
.abfd
== current_bfd
)
2104 if (arch_info
->bits_per_address
== 32)
2106 string_length
= sprintf (st
, "%s", *map
[i
].name
);
2107 st
+= string_length
+ 1;
2113 bfd_bwrite (symbol_table
, symbol_table_size
, abfd
);
2115 free (symbol_table
);
2118 nextoff
= nextoff
+ symbol_table_size
;
2121 PRINT20 (fhdr
->symoff
, 0);
2125 struct xcoff_ar_hdr_big
*hdr
;
2129 bfd_vma symbol_table_size
=
2134 + str_64
+ (str_64
& 1);
2136 symbol_table
= bfd_zmalloc (symbol_table_size
);
2137 if (symbol_table
== NULL
)
2140 hdr
= (struct xcoff_ar_hdr_big
*) symbol_table
;
2142 PRINT20 (hdr
->size
, 8 + 8 * sym_64
+ str_64
+ (str_64
& 1));
2143 PRINT20 (hdr
->nextoff
, 0);
2144 PRINT20 (hdr
->prevoff
, prevoff
);
2145 PRINT12 (hdr
->date
, 0);
2146 PRINT12 (hdr
->uid
, 0);
2147 PRINT12 (hdr
->gid
, 0);
2148 PRINT12 (hdr
->mode
, 0);
2149 PRINT4 (hdr
->namlen
, 0);
2151 st
= symbol_table
+ SIZEOF_AR_HDR_BIG
;
2152 memcpy (st
, XCOFFARFMAG
, SXCOFFARFMAG
);
2155 bfd_h_put_64 (abfd
, sym_64
, st
);
2158 /* loop over the 64 bit offsets */
2160 archive_iterator_begin (&iterator
, abfd
);
2161 while (i
< orl_count
&& archive_iterator_next (&iterator
))
2163 arch_info
= bfd_get_arch_info (iterator
.current
.member
);
2164 while (map
[i
].u
.abfd
== iterator
.current
.member
)
2166 if (arch_info
->bits_per_address
== 64)
2168 bfd_h_put_64 (abfd
, iterator
.current
.offset
, st
);
2175 /* loop over the 64 bit symbol names */
2177 for (current_bfd
= abfd
->archive_head
;
2178 current_bfd
!= NULL
&& i
< orl_count
;
2179 current_bfd
= current_bfd
->archive_next
)
2181 arch_info
= bfd_get_arch_info (current_bfd
);
2182 while (map
[i
].u
.abfd
== current_bfd
)
2184 if (arch_info
->bits_per_address
== 64)
2186 string_length
= sprintf (st
, "%s", *map
[i
].name
);
2187 st
+= string_length
+ 1;
2193 bfd_bwrite (symbol_table
, symbol_table_size
, abfd
);
2195 free (symbol_table
);
2197 PRINT20 (fhdr
->symoff64
, nextoff
);
2200 PRINT20 (fhdr
->symoff64
, 0);
2206 _bfd_xcoff_write_armap (bfd
*abfd
, unsigned int elength ATTRIBUTE_UNUSED
,
2207 struct orl
*map
, unsigned int orl_count
, int stridx
)
2209 if (! xcoff_big_format_p (abfd
))
2210 return xcoff_write_armap_old (abfd
, elength
, map
, orl_count
, stridx
);
2212 return xcoff_write_armap_big (abfd
, elength
, map
, orl_count
, stridx
);
2215 /* Write out an XCOFF archive. We always write an entire archive,
2216 rather than fussing with the freelist and so forth. */
2219 xcoff_write_archive_contents_old (bfd
*abfd
)
2221 struct archive_iterator iterator
;
2222 struct xcoff_ar_file_hdr fhdr
;
2223 bfd_size_type count
;
2224 bfd_size_type total_namlen
;
2228 file_ptr prevoff
, nextoff
;
2231 struct xcoff_ar_hdr ahdr
;
2234 char decbuf
[XCOFFARMAG_ELEMENT_SIZE
+ 1];
2236 memset (&fhdr
, 0, sizeof fhdr
);
2237 (void) memcpy (fhdr
.magic
, XCOFFARMAG
, SXCOFFARMAG
);
2238 sprintf (fhdr
.firstmemoff
, "%d", SIZEOF_AR_FILE_HDR
);
2239 sprintf (fhdr
.freeoff
, "%d", 0);
2243 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->archive_next
)
2246 total_namlen
+= strlen (normalize_filename (sub
)) + 1;
2247 if (sub
->arelt_data
== NULL
)
2249 sub
->arelt_data
= bfd_zmalloc (sizeof (struct areltdata
));
2250 if (sub
->arelt_data
== NULL
)
2253 if (arch_xhdr (sub
) == NULL
)
2255 struct xcoff_ar_hdr
*ahdrp
;
2258 if ((sub
->flags
& BFD_IN_MEMORY
) != 0)
2260 /* Assume we just "made" the member, and fake it. */
2261 struct bfd_in_memory
*bim
2262 = (struct bfd_in_memory
*) sub
->iostream
;
2264 s
.st_uid
= getuid ();
2265 s
.st_gid
= getgid ();
2267 s
.st_size
= bim
->size
;
2269 else if (stat (bfd_get_filename (sub
), &s
) != 0)
2271 bfd_set_input_error (sub
, bfd_error_system_call
);
2275 if ((abfd
->flags
& BFD_DETERMINISTIC_OUTPUT
) != 0)
2283 ahdrp
= bfd_zalloc (sub
, sizeof (*ahdrp
));
2287 sprintf (ahdrp
->size
, "%ld", (long) s
.st_size
);
2288 sprintf (ahdrp
->date
, "%ld", (long) s
.st_mtime
);
2289 sprintf (ahdrp
->uid
, "%ld", (long) s
.st_uid
);
2290 sprintf (ahdrp
->gid
, "%ld", (long) s
.st_gid
);
2291 sprintf (ahdrp
->mode
, "%o", (unsigned int) s
.st_mode
);
2293 arch_eltdata (sub
)->arch_header
= (char *) ahdrp
;
2294 arch_eltdata (sub
)->parsed_size
= s
.st_size
;
2297 offsets
= (file_ptr
*) bfd_alloc (abfd
, count
* sizeof (file_ptr
));
2298 if (offsets
== NULL
)
2301 if (bfd_seek (abfd
, (file_ptr
) SIZEOF_AR_FILE_HDR
, SEEK_SET
) != 0)
2304 makemap
= bfd_has_map (abfd
);
2307 for (archive_iterator_begin (&iterator
, abfd
), i
= 0;
2308 archive_iterator_next (&iterator
);
2311 bfd_size_type namlen
;
2312 struct xcoff_ar_hdr
*ahdrp
;
2314 if (makemap
&& ! hasobjects
)
2316 if (bfd_check_format (iterator
.current
.member
, bfd_object
))
2320 ahdrp
= arch_xhdr (iterator
.current
.member
);
2321 sprintf (ahdrp
->prevoff
, "%ld", (long) prevoff
);
2322 sprintf (ahdrp
->namlen
, "%ld", (long) iterator
.current
.namlen
);
2323 sprintf (ahdrp
->nextoff
, "%ld", (long) iterator
.next
.offset
);
2325 /* We need spaces, not null bytes, in the header. */
2326 for (p
= (char *) ahdrp
; p
< (char *) ahdrp
+ SIZEOF_AR_HDR
; p
++)
2330 if (!do_pad (abfd
, iterator
.current
.leading_padding
))
2333 BFD_ASSERT (iterator
.current
.offset
== bfd_tell (abfd
));
2334 namlen
= iterator
.current
.padded_namlen
;
2335 if (bfd_bwrite (ahdrp
, SIZEOF_AR_HDR
, abfd
) != SIZEOF_AR_HDR
2336 || bfd_bwrite (iterator
.current
.name
, namlen
, abfd
) != namlen
2337 || bfd_bwrite (XCOFFARFMAG
, SXCOFFARFMAG
, abfd
) != SXCOFFARFMAG
2338 || bfd_seek (iterator
.current
.member
, 0, SEEK_SET
) != 0
2339 || !do_copy (abfd
, iterator
.current
.member
)
2340 || !do_pad (abfd
, iterator
.current
.trailing_padding
))
2343 offsets
[i
] = iterator
.current
.offset
;
2344 prevoff
= iterator
.current
.offset
;
2347 sprintf (fhdr
.lastmemoff
, "%ld", (long) prevoff
);
2349 /* Write out the member table. */
2351 nextoff
= iterator
.next
.offset
;
2352 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2353 sprintf (fhdr
.memoff
, "%ld", (long) nextoff
);
2355 memset (&ahdr
, 0, sizeof ahdr
);
2356 sprintf (ahdr
.size
, "%ld", (long) (XCOFFARMAG_ELEMENT_SIZE
2357 + count
* XCOFFARMAG_ELEMENT_SIZE
2359 sprintf (ahdr
.prevoff
, "%ld", (long) prevoff
);
2360 sprintf (ahdr
.date
, "%d", 0);
2361 sprintf (ahdr
.uid
, "%d", 0);
2362 sprintf (ahdr
.gid
, "%d", 0);
2363 sprintf (ahdr
.mode
, "%d", 0);
2364 sprintf (ahdr
.namlen
, "%d", 0);
2366 size
= (SIZEOF_AR_HDR
2367 + XCOFFARMAG_ELEMENT_SIZE
2368 + count
* XCOFFARMAG_ELEMENT_SIZE
2373 nextoff
+= size
+ (size
& 1);
2375 if (makemap
&& hasobjects
)
2376 sprintf (ahdr
.nextoff
, "%ld", (long) nextoff
);
2378 sprintf (ahdr
.nextoff
, "%d", 0);
2380 /* We need spaces, not null bytes, in the header. */
2381 for (p
= (char *) &ahdr
; p
< (char *) &ahdr
+ SIZEOF_AR_HDR
; p
++)
2385 if ((bfd_bwrite (&ahdr
, (bfd_size_type
) SIZEOF_AR_HDR
, abfd
)
2387 || (bfd_bwrite (XCOFFARFMAG
, (bfd_size_type
) SXCOFFARFMAG
, abfd
)
2391 sprintf (decbuf
, "%-12ld", (long) count
);
2392 if (bfd_bwrite (decbuf
, (bfd_size_type
) XCOFFARMAG_ELEMENT_SIZE
, abfd
)
2393 != XCOFFARMAG_ELEMENT_SIZE
)
2395 for (i
= 0; i
< (size_t) count
; i
++)
2397 sprintf (decbuf
, "%-12ld", (long) offsets
[i
]);
2398 if (bfd_bwrite (decbuf
, (bfd_size_type
) XCOFFARMAG_ELEMENT_SIZE
,
2399 abfd
) != XCOFFARMAG_ELEMENT_SIZE
)
2402 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->archive_next
)
2405 bfd_size_type namlen
;
2407 name
= normalize_filename (sub
);
2408 namlen
= strlen (name
);
2409 if (bfd_bwrite (name
, namlen
+ 1, abfd
) != namlen
+ 1)
2413 if (! do_pad (abfd
, size
& 1))
2416 /* Write out the armap, if appropriate. */
2417 if (! makemap
|| ! hasobjects
)
2418 sprintf (fhdr
.symoff
, "%d", 0);
2421 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2422 sprintf (fhdr
.symoff
, "%ld", (long) nextoff
);
2423 bfd_ardata (abfd
)->tdata
= &fhdr
;
2424 if (! _bfd_compute_and_write_armap (abfd
, 0))
2428 /* Write out the archive file header. */
2430 /* We need spaces, not null bytes, in the header. */
2431 for (p
= (char *) &fhdr
; p
< (char *) &fhdr
+ SIZEOF_AR_FILE_HDR
; p
++)
2435 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
2436 || (bfd_bwrite (&fhdr
, (bfd_size_type
) SIZEOF_AR_FILE_HDR
, abfd
)
2437 != SIZEOF_AR_FILE_HDR
))
2444 xcoff_write_archive_contents_big (bfd
*abfd
)
2446 struct xcoff_ar_file_hdr_big fhdr
;
2447 bfd_size_type count
;
2448 bfd_size_type total_namlen
;
2452 file_ptr prevoff
, nextoff
;
2455 struct xcoff_ar_hdr_big
*hdr
;
2457 char *member_table
, *mt
;
2458 bfd_vma member_table_size
;
2459 struct archive_iterator iterator
;
2461 memset (&fhdr
, 0, SIZEOF_AR_FILE_HDR_BIG
);
2462 memcpy (fhdr
.magic
, XCOFFARMAGBIG
, SXCOFFARMAG
);
2464 if (bfd_seek (abfd
, (file_ptr
) SIZEOF_AR_FILE_HDR_BIG
, SEEK_SET
) != 0)
2467 /* Calculate count and total_namlen. */
2468 makemap
= bfd_has_map (abfd
);
2470 for (current_bfd
= abfd
->archive_head
, count
= 0, total_namlen
= 0;
2471 current_bfd
!= NULL
;
2472 current_bfd
= current_bfd
->archive_next
, count
++)
2474 total_namlen
+= strlen (normalize_filename (current_bfd
)) + 1;
2478 && bfd_check_format (current_bfd
, bfd_object
))
2481 if (current_bfd
->arelt_data
== NULL
)
2483 size
= sizeof (struct areltdata
);
2484 current_bfd
->arelt_data
= bfd_zmalloc (size
);
2485 if (current_bfd
->arelt_data
== NULL
)
2489 if (arch_xhdr_big (current_bfd
) == NULL
)
2491 struct xcoff_ar_hdr_big
*ahdrp
;
2494 if ((current_bfd
->flags
& BFD_IN_MEMORY
) != 0)
2496 /* Assume we just "made" the member, and fake it. */
2497 struct bfd_in_memory
*bim
2498 = (struct bfd_in_memory
*) current_bfd
->iostream
;
2500 s
.st_uid
= getuid ();
2501 s
.st_gid
= getgid ();
2503 s
.st_size
= bim
->size
;
2505 else if (stat (bfd_get_filename (current_bfd
), &s
) != 0)
2507 bfd_set_input_error (current_bfd
, bfd_error_system_call
);
2511 if ((abfd
->flags
& BFD_DETERMINISTIC_OUTPUT
) != 0)
2519 ahdrp
= bfd_zalloc (current_bfd
, sizeof (*ahdrp
));
2523 PRINT20 (ahdrp
->size
, s
.st_size
);
2524 PRINT12 (ahdrp
->date
, s
.st_mtime
);
2525 PRINT12 (ahdrp
->uid
, s
.st_uid
);
2526 PRINT12 (ahdrp
->gid
, s
.st_gid
);
2527 PRINT12_OCTAL (ahdrp
->mode
, s
.st_mode
);
2529 arch_eltdata (current_bfd
)->arch_header
= (char *) ahdrp
;
2530 arch_eltdata (current_bfd
)->parsed_size
= s
.st_size
;
2537 offsets
= (file_ptr
*) bfd_malloc (count
* sizeof (file_ptr
));
2538 if (offsets
== NULL
)
2543 for (archive_iterator_begin (&iterator
, abfd
), i
= 0;
2544 archive_iterator_next (&iterator
);
2547 bfd_size_type namlen
;
2548 struct xcoff_ar_hdr_big
*ahdrp
;
2550 ahdrp
= arch_xhdr_big (iterator
.current
.member
);
2551 PRINT20 (ahdrp
->prevoff
, prevoff
);
2552 PRINT4 (ahdrp
->namlen
, iterator
.current
.namlen
);
2553 PRINT20 (ahdrp
->nextoff
, iterator
.next
.offset
);
2555 if (!do_pad (abfd
, iterator
.current
.leading_padding
))
2561 BFD_ASSERT (iterator
.current
.offset
== bfd_tell (abfd
));
2562 namlen
= iterator
.current
.padded_namlen
;
2563 if (bfd_bwrite (ahdrp
, SIZEOF_AR_HDR_BIG
, abfd
) != SIZEOF_AR_HDR_BIG
2564 || bfd_bwrite (iterator
.current
.name
, namlen
, abfd
) != namlen
2565 || bfd_bwrite (XCOFFARFMAG
, SXCOFFARFMAG
, abfd
) != SXCOFFARFMAG
2566 || bfd_seek (iterator
.current
.member
, 0, SEEK_SET
) != 0
2567 || !do_copy (abfd
, iterator
.current
.member
)
2568 || !do_pad (abfd
, iterator
.current
.trailing_padding
))
2574 offsets
[i
] = iterator
.current
.offset
;
2575 prevoff
= iterator
.current
.offset
;
2580 PRINT20 (fhdr
.firstmemoff
, offsets
[0]);
2581 PRINT20 (fhdr
.lastmemoff
, prevoff
);
2584 /* Write out the member table.
2587 standard big archive header
2588 0x0000 ar_size [0x14]
2589 0x0014 ar_nxtmem [0x14]
2590 0x0028 ar_prvmem [0x14]
2591 0x003C ar_date [0x0C]
2592 0x0048 ar_uid [0x0C]
2593 0x0054 ar_gid [0x0C]
2594 0x0060 ar_mod [0x0C]
2595 0x006C ar_namelen[0x04]
2596 0x0070 ar_fmag [0x02]
2600 0x0086 offsets [0x14 * counts]
2601 0x0086 + 0x14 * counts names [??]
2602 ?? pad to even bytes.
2605 nextoff
= iterator
.next
.offset
;
2606 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2608 member_table_size
= (SIZEOF_AR_HDR_BIG
2610 + XCOFFARMAGBIG_ELEMENT_SIZE
2611 + count
* XCOFFARMAGBIG_ELEMENT_SIZE
2614 member_table_size
+= member_table_size
& 1;
2615 member_table
= bfd_zmalloc (member_table_size
);
2616 if (member_table
== NULL
)
2622 hdr
= (struct xcoff_ar_hdr_big
*) member_table
;
2624 PRINT20 (hdr
->size
, (XCOFFARMAGBIG_ELEMENT_SIZE
2625 + count
* XCOFFARMAGBIG_ELEMENT_SIZE
2626 + total_namlen
+ (total_namlen
& 1)));
2627 if (makemap
&& hasobjects
)
2628 PRINT20 (hdr
->nextoff
, nextoff
+ member_table_size
);
2630 PRINT20 (hdr
->nextoff
, 0);
2631 PRINT20 (hdr
->prevoff
, prevoff
);
2632 PRINT12 (hdr
->date
, 0);
2633 PRINT12 (hdr
->uid
, 0);
2634 PRINT12 (hdr
->gid
, 0);
2635 PRINT12 (hdr
->mode
, 0);
2636 PRINT4 (hdr
->namlen
, 0);
2638 mt
= member_table
+ SIZEOF_AR_HDR_BIG
;
2639 memcpy (mt
, XCOFFARFMAG
, SXCOFFARFMAG
);
2642 PRINT20 (mt
, count
);
2643 mt
+= XCOFFARMAGBIG_ELEMENT_SIZE
;
2644 for (i
= 0; i
< (size_t) count
; i
++)
2646 PRINT20 (mt
, offsets
[i
]);
2647 mt
+= XCOFFARMAGBIG_ELEMENT_SIZE
;
2656 for (current_bfd
= abfd
->archive_head
;
2657 current_bfd
!= NULL
;
2658 current_bfd
= current_bfd
->archive_next
)
2663 name
= normalize_filename (current_bfd
);
2664 namlen
= sprintf (mt
, "%s", name
);
2668 if (bfd_bwrite (member_table
, member_table_size
, abfd
) != member_table_size
)
2671 free (member_table
);
2673 PRINT20 (fhdr
.memoff
, nextoff
);
2676 nextoff
+= member_table_size
;
2678 /* Write out the armap, if appropriate. */
2680 if (! makemap
|| ! hasobjects
)
2681 PRINT20 (fhdr
.symoff
, 0);
2684 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2686 /* Save nextoff in fhdr.symoff so the armap routine can use it. */
2687 PRINT20 (fhdr
.symoff
, nextoff
);
2689 bfd_ardata (abfd
)->tdata
= &fhdr
;
2690 if (! _bfd_compute_and_write_armap (abfd
, 0))
2694 /* Write out the archive file header. */
2696 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
2697 || (bfd_bwrite (&fhdr
, (bfd_size_type
) SIZEOF_AR_FILE_HDR_BIG
,
2698 abfd
) != SIZEOF_AR_FILE_HDR_BIG
))
2705 _bfd_xcoff_write_archive_contents (bfd
*abfd
)
2707 if (! xcoff_big_format_p (abfd
))
2708 return xcoff_write_archive_contents_old (abfd
);
2710 return xcoff_write_archive_contents_big (abfd
);
2713 /* We can't use the usual coff_sizeof_headers routine, because AIX
2714 always uses an a.out header. */
2717 _bfd_xcoff_sizeof_headers (bfd
*abfd
,
2718 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
2723 if (xcoff_data (abfd
)->full_aouthdr
)
2726 size
+= SMALL_AOUTSZ
;
2727 size
+= abfd
->section_count
* SCNHSZ
;
2729 if (info
->strip
!= strip_all
)
2731 /* There can be additional sections just for dealing with overflow in
2732 reloc and lineno counts. But the numbers of relocs and lineno aren't
2733 known when bfd_sizeof_headers is called, so we compute them by
2734 summing the numbers from input sections. */
2735 struct nbr_reloc_lineno
2737 unsigned int reloc_count
;
2738 unsigned int lineno_count
;
2740 struct nbr_reloc_lineno
*n_rl
;
2742 unsigned int max_index
;
2745 /* Although the number of sections is known, the maximum value of
2746 section->index isn't (because some sections may have been removed).
2747 Don't try to renumber sections, just compute the upper bound. */
2749 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
2750 if (s
->index
> max_index
)
2751 max_index
= s
->index
;
2753 /* Allocate the per section counters. It could be possible to use a
2754 preallocated array as the number of sections is limited on XCOFF,
2755 but this creates a maintainance issue. */
2756 n_rl
= bfd_zmalloc ((max_index
+ 1) * sizeof (*n_rl
));
2761 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
2762 for (s
= sub
->sections
; s
!= NULL
; s
= s
->next
)
2763 if (s
->output_section
->owner
== abfd
2764 && !bfd_section_removed_from_list (abfd
, s
->output_section
))
2766 struct nbr_reloc_lineno
*e
= &n_rl
[s
->output_section
->index
];
2767 e
->reloc_count
+= s
->reloc_count
;
2768 e
->lineno_count
+= s
->lineno_count
;
2771 /* Add the size of a section for each section with an overflow. */
2772 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
2774 struct nbr_reloc_lineno
*e
= &n_rl
[s
->index
];
2776 if (e
->reloc_count
>= 0xffff
2777 || (e
->lineno_count
>= 0xffff && info
->strip
!= strip_debugger
))
2787 /* Routines to swap information in the XCOFF .loader section. If we
2788 ever need to write an XCOFF loader, this stuff will need to be
2789 moved to another file shared by the linker (which XCOFF calls the
2790 ``binder'') and the loader. */
2792 /* Swap in the ldhdr structure. */
2795 xcoff_swap_ldhdr_in (bfd
*abfd
, const void * s
, struct internal_ldhdr
*dst
)
2797 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
2799 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
2800 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
2801 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
2802 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
2803 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
2804 dst
->l_impoff
= bfd_get_32 (abfd
, src
->l_impoff
);
2805 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
2806 dst
->l_stoff
= bfd_get_32 (abfd
, src
->l_stoff
);
2809 /* Swap out the ldhdr structure. */
2812 xcoff_swap_ldhdr_out (bfd
*abfd
, const struct internal_ldhdr
*src
, void * d
)
2814 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
2816 bfd_put_32 (abfd
, (bfd_vma
) src
->l_version
, dst
->l_version
);
2817 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
2818 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
2819 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
2820 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
2821 bfd_put_32 (abfd
, src
->l_impoff
, dst
->l_impoff
);
2822 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
2823 bfd_put_32 (abfd
, src
->l_stoff
, dst
->l_stoff
);
2826 /* Swap in the ldsym structure. */
2829 xcoff_swap_ldsym_in (bfd
*abfd
, const void * s
, struct internal_ldsym
*dst
)
2831 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
2833 if (bfd_get_32 (abfd
, src
->_l
._l_l
._l_zeroes
) != 0) {
2834 memcpy (dst
->_l
._l_name
, src
->_l
._l_name
, SYMNMLEN
);
2836 dst
->_l
._l_l
._l_zeroes
= 0;
2837 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->_l
._l_l
._l_offset
);
2839 dst
->l_value
= bfd_get_32 (abfd
, src
->l_value
);
2840 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
2841 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
2842 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
2843 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
2844 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
2847 /* Swap out the ldsym structure. */
2850 xcoff_swap_ldsym_out (bfd
*abfd
, const struct internal_ldsym
*src
, void * d
)
2852 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
2854 if (src
->_l
._l_l
._l_zeroes
!= 0)
2855 memcpy (dst
->_l
._l_name
, src
->_l
._l_name
, SYMNMLEN
);
2858 bfd_put_32 (abfd
, (bfd_vma
) 0, dst
->_l
._l_l
._l_zeroes
);
2859 bfd_put_32 (abfd
, (bfd_vma
) src
->_l
._l_l
._l_offset
,
2860 dst
->_l
._l_l
._l_offset
);
2862 bfd_put_32 (abfd
, src
->l_value
, dst
->l_value
);
2863 bfd_put_16 (abfd
, (bfd_vma
) src
->l_scnum
, dst
->l_scnum
);
2864 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
2865 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
2866 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
2867 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
2871 xcoff_swap_reloc_in (bfd
*abfd
, void * s
, void * d
)
2873 struct external_reloc
*src
= (struct external_reloc
*) s
;
2874 struct internal_reloc
*dst
= (struct internal_reloc
*) d
;
2876 memset (dst
, 0, sizeof (struct internal_reloc
));
2878 dst
->r_vaddr
= bfd_get_32 (abfd
, src
->r_vaddr
);
2879 dst
->r_symndx
= bfd_get_32 (abfd
, src
->r_symndx
);
2880 dst
->r_size
= bfd_get_8 (abfd
, src
->r_size
);
2881 dst
->r_type
= bfd_get_8 (abfd
, src
->r_type
);
2885 xcoff_swap_reloc_out (bfd
*abfd
, void * s
, void * d
)
2887 struct internal_reloc
*src
= (struct internal_reloc
*) s
;
2888 struct external_reloc
*dst
= (struct external_reloc
*) d
;
2890 bfd_put_32 (abfd
, src
->r_vaddr
, dst
->r_vaddr
);
2891 bfd_put_32 (abfd
, src
->r_symndx
, dst
->r_symndx
);
2892 bfd_put_8 (abfd
, src
->r_type
, dst
->r_type
);
2893 bfd_put_8 (abfd
, src
->r_size
, dst
->r_size
);
2895 return bfd_coff_relsz (abfd
);
2898 /* Swap in the ldrel structure. */
2901 xcoff_swap_ldrel_in (bfd
*abfd
, const void * s
, struct internal_ldrel
*dst
)
2903 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
2905 dst
->l_vaddr
= bfd_get_32 (abfd
, src
->l_vaddr
);
2906 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
2907 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
2908 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
2911 /* Swap out the ldrel structure. */
2914 xcoff_swap_ldrel_out (bfd
*abfd
, const struct internal_ldrel
*src
, void * d
)
2916 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
2918 bfd_put_32 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
2919 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
2920 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rtype
, dst
->l_rtype
);
2921 bfd_put_16 (abfd
, (bfd_vma
) src
->l_rsecnm
, dst
->l_rsecnm
);
2926 xcoff_reloc_type_noop (bfd
*input_bfd ATTRIBUTE_UNUSED
,
2927 asection
*input_section ATTRIBUTE_UNUSED
,
2928 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2929 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
2930 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2931 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
2932 bfd_vma val ATTRIBUTE_UNUSED
,
2933 bfd_vma addend ATTRIBUTE_UNUSED
,
2934 bfd_vma
*relocation ATTRIBUTE_UNUSED
,
2935 bfd_byte
*contents ATTRIBUTE_UNUSED
)
2941 xcoff_reloc_type_fail (bfd
*input_bfd
,
2942 asection
*input_section ATTRIBUTE_UNUSED
,
2943 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2944 struct internal_reloc
*rel
,
2945 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2946 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
2947 bfd_vma val ATTRIBUTE_UNUSED
,
2948 bfd_vma addend ATTRIBUTE_UNUSED
,
2949 bfd_vma
*relocation ATTRIBUTE_UNUSED
,
2950 bfd_byte
*contents ATTRIBUTE_UNUSED
)
2953 /* xgettext: c-format */
2954 (_("%pB: unsupported relocation type %#x"),
2955 input_bfd
, (unsigned int) rel
->r_type
);
2956 bfd_set_error (bfd_error_bad_value
);
2961 xcoff_reloc_type_pos (bfd
*input_bfd ATTRIBUTE_UNUSED
,
2962 asection
*input_section ATTRIBUTE_UNUSED
,
2963 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2964 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
2965 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2966 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
2969 bfd_vma
*relocation
,
2970 bfd_byte
*contents ATTRIBUTE_UNUSED
)
2972 *relocation
= val
+ addend
;
2977 xcoff_reloc_type_neg (bfd
*input_bfd ATTRIBUTE_UNUSED
,
2978 asection
*input_section ATTRIBUTE_UNUSED
,
2979 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2980 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
2981 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2982 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
2985 bfd_vma
*relocation
,
2986 bfd_byte
*contents ATTRIBUTE_UNUSED
)
2988 *relocation
= addend
- val
;
2993 xcoff_reloc_type_rel (bfd
*input_bfd ATTRIBUTE_UNUSED
,
2994 asection
*input_section
,
2995 bfd
*output_bfd ATTRIBUTE_UNUSED
,
2996 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
2997 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
2998 struct reloc_howto_struct
*howto
,
3001 bfd_vma
*relocation
,
3002 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3004 howto
->pc_relative
= true;
3006 /* A PC relative reloc includes the section address. */
3007 addend
+= input_section
->vma
;
3009 *relocation
= val
+ addend
;
3010 *relocation
-= (input_section
->output_section
->vma
3011 + input_section
->output_offset
);
3016 xcoff_reloc_type_toc (bfd
*input_bfd
,
3017 asection
*input_section ATTRIBUTE_UNUSED
,
3019 struct internal_reloc
*rel
,
3020 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3021 struct reloc_howto_struct
*howto ATTRIBUTE_UNUSED
,
3023 bfd_vma addend ATTRIBUTE_UNUSED
,
3024 bfd_vma
*relocation
,
3025 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3027 struct xcoff_link_hash_entry
*h
;
3029 if (0 > rel
->r_symndx
)
3032 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
3034 if (h
!= NULL
&& h
->smclas
!= XMC_TD
)
3036 if (h
->toc_section
== NULL
)
3039 /* xgettext: c-format */
3040 (_("%pB: TOC reloc at %#" PRIx64
" to symbol `%s' with no TOC entry"),
3041 input_bfd
, (uint64_t) rel
->r_vaddr
, h
->root
.root
.string
);
3042 bfd_set_error (bfd_error_bad_value
);
3046 BFD_ASSERT ((h
->flags
& XCOFF_SET_TOC
) == 0);
3047 val
= (h
->toc_section
->output_section
->vma
3048 + h
->toc_section
->output_offset
);
3051 /* We can't use the preexisting value written down by the
3052 assembly, as R_TOCU needs to be adjusted when the final
3053 R_TOCL value is signed. */
3054 *relocation
= val
- xcoff_data (output_bfd
)->toc
;
3056 if (rel
->r_type
== R_TOCU
)
3057 *relocation
= ((*relocation
+ 0x8000) >> 16) & 0xffff;
3058 if (rel
->r_type
== R_TOCL
)
3059 *relocation
= *relocation
& 0x0000ffff;
3065 xcoff_reloc_type_ba (bfd
*input_bfd ATTRIBUTE_UNUSED
,
3066 asection
*input_section ATTRIBUTE_UNUSED
,
3067 bfd
*output_bfd ATTRIBUTE_UNUSED
,
3068 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
3069 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3070 struct reloc_howto_struct
*howto
,
3073 bfd_vma
*relocation
,
3074 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3076 howto
->src_mask
&= ~3;
3077 howto
->dst_mask
= howto
->src_mask
;
3079 *relocation
= val
+ addend
;
3085 xcoff_reloc_type_br (bfd
*input_bfd
,
3086 asection
*input_section
,
3087 bfd
*output_bfd ATTRIBUTE_UNUSED
,
3088 struct internal_reloc
*rel
,
3089 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3090 struct reloc_howto_struct
*howto
,
3093 bfd_vma
*relocation
,
3096 struct xcoff_link_hash_entry
*h
;
3097 bfd_vma section_offset
;
3099 if (0 > rel
->r_symndx
)
3102 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
3103 section_offset
= rel
->r_vaddr
- input_section
->vma
;
3105 /* If we see an R_BR or R_RBR reloc which is jumping to global
3106 linkage code, and it is followed by an appropriate cror nop
3107 instruction, we replace the cror with lwz r2,20(r1). This
3108 restores the TOC after the glink code. Contrariwise, if the
3109 call is followed by a lwz r2,20(r1), but the call is not
3110 going to global linkage code, we can replace the load with a
3113 && (bfd_link_hash_defined
== h
->root
.type
3114 || bfd_link_hash_defweak
== h
->root
.type
)
3115 && section_offset
+ 8 <= input_section
->size
)
3120 pnext
= contents
+ section_offset
+ 4;
3121 next
= bfd_get_32 (input_bfd
, pnext
);
3123 /* The _ptrgl function is magic. It is used by the AIX
3124 compiler to call a function through a pointer. */
3125 if (h
->smclas
== XMC_GL
|| strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
3127 if (next
== 0x4def7b82 /* cror 15,15,15 */
3128 || next
== 0x4ffffb82 /* cror 31,31,31 */
3129 || next
== 0x60000000) /* ori r0,r0,0 */
3130 bfd_put_32 (input_bfd
, 0x80410014, pnext
); /* lwz r2,20(r1) */
3135 if (next
== 0x80410014) /* lwz r2,20(r1) */
3136 bfd_put_32 (input_bfd
, 0x60000000, pnext
); /* ori r0,r0,0 */
3139 else if (NULL
!= h
&& bfd_link_hash_undefined
== h
->root
.type
)
3141 /* Normally, this relocation is against a defined symbol. In the
3142 case where this is a partial link and the output section offset
3143 is greater than 2^25, the linker will return an invalid error
3144 message that the relocation has been truncated. Yes it has been
3145 truncated but no it not important. For this case, disable the
3146 overflow checking. */
3148 howto
->complain_on_overflow
= complain_overflow_dont
;
3151 /* The original PC-relative relocation is biased by -r_vaddr, so adding
3152 the value below will give the absolute target address. */
3153 *relocation
= val
+ addend
+ rel
->r_vaddr
;
3155 howto
->src_mask
&= ~3;
3156 howto
->dst_mask
= howto
->src_mask
;
3159 && (h
->root
.type
== bfd_link_hash_defined
3160 || h
->root
.type
== bfd_link_hash_defweak
)
3161 && bfd_is_abs_section (h
->root
.u
.def
.section
)
3162 && section_offset
+ 4 <= input_section
->size
)
3167 /* Turn the relative branch into an absolute one by setting the
3169 ptr
= contents
+ section_offset
;
3170 insn
= bfd_get_32 (input_bfd
, ptr
);
3172 bfd_put_32 (input_bfd
, insn
, ptr
);
3174 /* Make the howto absolute too. */
3175 howto
->pc_relative
= false;
3176 howto
->complain_on_overflow
= complain_overflow_bitfield
;
3180 /* Use a PC-relative howto and subtract the instruction's address
3181 from the target address we calculated above. */
3182 howto
->pc_relative
= true;
3183 *relocation
-= (input_section
->output_section
->vma
3184 + input_section
->output_offset
3191 xcoff_reloc_type_crel (bfd
*input_bfd ATTRIBUTE_UNUSED
,
3192 asection
*input_section
,
3193 bfd
*output_bfd ATTRIBUTE_UNUSED
,
3194 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
3195 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3196 struct reloc_howto_struct
*howto
,
3197 bfd_vma val ATTRIBUTE_UNUSED
,
3199 bfd_vma
*relocation
,
3200 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3202 howto
->pc_relative
= true;
3203 howto
->src_mask
&= ~3;
3204 howto
->dst_mask
= howto
->src_mask
;
3206 /* A PC relative reloc includes the section address. */
3207 addend
+= input_section
->vma
;
3209 *relocation
= val
+ addend
;
3210 *relocation
-= (input_section
->output_section
->vma
3211 + input_section
->output_offset
);
3216 xcoff_reloc_type_tls (bfd
*input_bfd ATTRIBUTE_UNUSED
,
3217 asection
*input_section ATTRIBUTE_UNUSED
,
3218 bfd
*output_bfd ATTRIBUTE_UNUSED
,
3219 struct internal_reloc
*rel ATTRIBUTE_UNUSED
,
3220 struct internal_syment
*sym ATTRIBUTE_UNUSED
,
3221 struct reloc_howto_struct
*howto
,
3224 bfd_vma
*relocation
,
3225 bfd_byte
*contents ATTRIBUTE_UNUSED
)
3227 struct xcoff_link_hash_entry
*h
;
3229 if (0 > rel
->r_symndx
)
3232 h
= obj_xcoff_sym_hashes (input_bfd
)[rel
->r_symndx
];
3234 /* FIXME: R_TLSML is targeting a internal TOC symbol, which will
3235 make the following checks failing. It should be moved with
3236 R_TLSM bellow once it works. */
3237 if (howto
->type
== R_TLSML
)
3243 /* FIXME: h is sometimes null, if the TLS symbol is not exported. */
3247 (_("%pB: TLS relocation at (0x%" BFD_VMA_FMT
"x) over "
3248 "internal symbols (C_HIDEXT) not yet possible\n"),
3249 input_bfd
, rel
->r_vaddr
);
3254 /* TLS relocations must target a TLS symbol. */
3255 if (h
->smclas
!= XMC_TL
&& h
->smclas
!= XMC_UL
)
3258 (_("%pB: TLS relocation at (0x%" BFD_VMA_FMT
"x) over "
3259 "non-TLS symbol %s (0x%x)\n"),
3260 input_bfd
, rel
->r_vaddr
, h
->root
.root
.string
, h
->smclas
);
3264 /* Local TLS relocations must target a local symbol, ie
3266 if ((rel
->r_type
== R_TLS_LD
|| rel
->r_type
== R_TLS_LE
)
3267 && (((h
->flags
& XCOFF_DEF_REGULAR
) == 0
3268 && (h
->flags
& XCOFF_DEF_DYNAMIC
) != 0)
3269 || (h
->flags
& XCOFF_IMPORT
) != 0))
3272 (_("%pB: TLS local relocation at (0x%" BFD_VMA_FMT
"x) over "
3273 "imported symbol %s\n"),
3274 input_bfd
, rel
->r_vaddr
, h
->root
.root
.string
);
3278 /* R_TLSM and R_TLSML are relocations used by the loader.
3279 The value must be 0.
3280 FIXME: move R_TLSML here. */
3281 if (howto
->type
== R_TLSM
)
3287 /* Other TLS relocations aims to put offsets from TLS pointers
3288 starting at -0x7c00 (or -0x7800 in XCOFF64). It becomes a
3289 simple R_POS relocation as long as .tdata and .tbss addresses
3290 start at the same value. This is done in aix ld scripts.
3291 TODO: implement optimization when tls size is < 62K. */
3292 *relocation
= val
+ addend
;
3298 xcoff_complain_overflow_dont_func (bfd
*input_bfd ATTRIBUTE_UNUSED
,
3299 bfd_vma val ATTRIBUTE_UNUSED
,
3300 bfd_vma relocation ATTRIBUTE_UNUSED
,
3301 struct reloc_howto_struct
*
3302 howto ATTRIBUTE_UNUSED
)
3308 xcoff_complain_overflow_bitfield_func (bfd
*input_bfd
,
3311 struct reloc_howto_struct
*howto
)
3313 bfd_vma fieldmask
, signmask
, ss
;
3316 /* Get the values to be added together. For signed and unsigned
3317 relocations, we assume that all values should be truncated to
3318 the size of an address. For bitfields, all the bits matter.
3319 See also bfd_check_overflow. */
3320 fieldmask
= N_ONES (howto
->bitsize
);
3322 b
= val
& howto
->src_mask
;
3324 /* Much like unsigned, except no trimming with addrmask. In
3325 addition, the sum overflows if there is a carry out of
3326 the bfd_vma, i.e., the sum is less than either input
3328 a
>>= howto
->rightshift
;
3329 b
>>= howto
->bitpos
;
3331 /* Bitfields are sometimes used for signed numbers; for
3332 example, a 13-bit field sometimes represents values in
3333 0..8191 and sometimes represents values in -4096..4095.
3334 If the field is signed and a is -4095 (0x1001) and b is
3335 -1 (0x1fff), the sum is -4096 (0x1000), but (0x1001 +
3336 0x1fff is 0x3000). It's not clear how to handle this
3337 everywhere, since there is not way to know how many bits
3338 are significant in the relocation, but the original code
3339 assumed that it was fully sign extended, and we will keep
3341 signmask
= (fieldmask
>> 1) + 1;
3343 if ((a
& ~ fieldmask
) != 0)
3345 /* Some bits out of the field are set. This might not
3346 be a problem: if this is a signed bitfield, it is OK
3347 iff all the high bits are set, including the sign
3348 bit. We'll try setting all but the most significant
3349 bit in the original relocation value: if this is all
3350 ones, we are OK, assuming a signed bitfield. */
3351 ss
= (signmask
<< howto
->rightshift
) - 1;
3352 if ((ss
| relocation
) != ~ (bfd_vma
) 0)
3357 /* We just assume (b & ~ fieldmask) == 0. */
3359 /* We explicitly permit wrap around if this relocation
3360 covers the high bit of an address. The Linux kernel
3361 relies on it, and it is the only way to write assembler
3362 code which can run when loaded at a location 0x80000000
3363 away from the location at which it is linked. */
3364 if ((unsigned) howto
->bitsize
+ howto
->rightshift
3365 == bfd_arch_bits_per_address (input_bfd
))
3369 if (sum
< a
|| (sum
& ~ fieldmask
) != 0)
3371 /* There was a carry out, or the field overflow. Test
3372 for signed operands again. Here is the overflow test
3373 is as for complain_overflow_signed. */
3374 if (((~ (a
^ b
)) & (a
^ sum
)) & signmask
)
3382 xcoff_complain_overflow_signed_func (bfd
*input_bfd
,
3385 struct reloc_howto_struct
*howto
)
3387 bfd_vma addrmask
, fieldmask
, signmask
, ss
;
3390 /* Get the values to be added together. For signed and unsigned
3391 relocations, we assume that all values should be truncated to
3392 the size of an address. For bitfields, all the bits matter.
3393 See also bfd_check_overflow. */
3394 fieldmask
= N_ONES (howto
->bitsize
);
3395 addrmask
= N_ONES (bfd_arch_bits_per_address (input_bfd
)) | fieldmask
;
3397 b
= val
& howto
->src_mask
;
3399 a
= (a
& addrmask
) >> howto
->rightshift
;
3401 /* If any sign bits are set, all sign bits must be set.
3402 That is, A must be a valid negative address after
3404 signmask
= ~ (fieldmask
>> 1);
3406 if (ss
!= 0 && ss
!= ((addrmask
>> howto
->rightshift
) & signmask
))
3409 /* We only need this next bit of code if the sign bit of B
3410 is below the sign bit of A. This would only happen if
3411 SRC_MASK had fewer bits than BITSIZE. Note that if
3412 SRC_MASK has more bits than BITSIZE, we can get into
3413 trouble; we would need to verify that B is in range, as
3414 we do for A above. */
3415 signmask
= ((~ howto
->src_mask
) >> 1) & howto
->src_mask
;
3416 if ((b
& signmask
) != 0)
3418 /* Set all the bits above the sign bit. */
3419 b
-= signmask
<<= 1;
3422 b
= (b
& addrmask
) >> howto
->bitpos
;
3424 /* Now we can do the addition. */
3427 /* See if the result has the correct sign. Bits above the
3428 sign bit are junk now; ignore them. If the sum is
3429 positive, make sure we did not have all negative inputs;
3430 if the sum is negative, make sure we did not have all
3431 positive inputs. The test below looks only at the sign
3432 bits, and it really just
3433 SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM)
3435 signmask
= (fieldmask
>> 1) + 1;
3436 if (((~ (a
^ b
)) & (a
^ sum
)) & signmask
)
3443 xcoff_complain_overflow_unsigned_func (bfd
*input_bfd
,
3446 struct reloc_howto_struct
*howto
)
3448 bfd_vma addrmask
, fieldmask
;
3451 /* Get the values to be added together. For signed and unsigned
3452 relocations, we assume that all values should be truncated to
3453 the size of an address. For bitfields, all the bits matter.
3454 See also bfd_check_overflow. */
3455 fieldmask
= N_ONES (howto
->bitsize
);
3456 addrmask
= N_ONES (bfd_arch_bits_per_address (input_bfd
)) | fieldmask
;
3458 b
= val
& howto
->src_mask
;
3460 /* Checking for an unsigned overflow is relatively easy:
3461 trim the addresses and add, and trim the result as well.
3462 Overflow is normally indicated when the result does not
3463 fit in the field. However, we also need to consider the
3464 case when, e.g., fieldmask is 0x7fffffff or smaller, an
3465 input is 0x80000000, and bfd_vma is only 32 bits; then we
3466 will get sum == 0, but there is an overflow, since the
3467 inputs did not fit in the field. Instead of doing a
3468 separate test, we can check for this by or-ing in the
3469 operands when testing for the sum overflowing its final
3471 a
= (a
& addrmask
) >> howto
->rightshift
;
3472 b
= (b
& addrmask
) >> howto
->bitpos
;
3473 sum
= (a
+ b
) & addrmask
;
3474 if ((a
| b
| sum
) & ~ fieldmask
)
3480 /* This is the relocation function for the RS/6000/POWER/PowerPC.
3481 This is currently the only processor which uses XCOFF; I hope that
3484 The original version was based on two documents:
3485 the PowerPC AIX Version 4 Application Binary Interface, First
3486 Edition (April 1992), and the PowerOpen ABI, Big-Endian
3487 32-Bit Hardware Implementation (June 30, 1994). Differences
3488 between the documents are noted below.
3489 Now, IBM has released an official documentation about XCOFF
3491 https://www.ibm.com/support/knowledgecenter/ssw_aix_72/filesreference/XCOFF.html
3493 Unsupported r_type's
3499 These relocs are defined by the PowerPC ABI to be
3500 relative branches which use half of the difference
3501 between the symbol and the program counter. I can't
3502 quite figure out when this is useful. These relocs are
3503 not defined by the PowerOpen ABI.
3508 Simple positive relocation.
3511 Simple negative relocation.
3514 Simple PC relative relocation.
3517 TOC relative relocation. The value in the instruction in
3518 the input file is the offset from the input file TOC to
3519 the desired location. We want the offset from the final
3520 TOC to the desired location. We have:
3525 so we must change insn by on - in.
3526 This relocation allows the linker to perform optimizations
3527 by transforming a load instruction into a add-immediate
3528 when possible. The relocation is, then, changed to R_TRLA
3530 TODO: Currently, the optimisation isn't implemented.
3533 TOC relative relocation. Same as R_TOC, except that
3534 the optimization isn't allowed
3537 TOC relative relocation. This is a TOC relative load
3538 address instruction which have been changed to an add-
3539 immediate instruction.
3542 GL linkage relocation. The value of this relocation
3543 is the address of the external symbol in the TOC
3547 Local object TOC address. I can't figure out the
3548 difference between this and case R_GL.
3551 The PowerPC AIX ABI describes this as a load which may be
3552 changed to a load address. The PowerOpen ABI says this
3553 is the same as case R_POS.
3556 The PowerPC AIX ABI describes this as a load address
3557 which may be changed to a load. The PowerOpen ABI says
3558 this is the same as R_POS.
3561 Not a relocation but a way to prevent the garbage
3562 collector of AIX linker to remove symbols.
3563 This is not needed in our case.
3566 The PowerOpen ABI says this is the same as R_RBA.
3569 Absolute branch which may be modified to become a
3573 The PowerOpen ABI says this is the same as R_RBR.
3576 A relative branch which may be modified to become an
3580 The PowerPC ABI defines this as an absolute call which
3581 may be modified to become a relative call. The PowerOpen
3582 ABI does not define this relocation type.
3585 The PowerPC ABI defines this as a relative call which may
3586 be modified to become an absolute call. The PowerOpen
3587 ABI does not define this relocation type.
3590 The PowerPC ABI defines this as an absolute branch to a
3591 fixed address which may be modified to an absolute branch
3592 to a symbol. The PowerOpen ABI does not define this
3596 The PowerPC ABI defines this as an absolute branch to a
3597 fixed address which may be modified to a relative branch.
3598 The PowerOpen ABI does not define this relocation type.
3601 Thread-local storage relocation using general-dynamic
3605 Thread-local storage relocation using initial-exec model.
3608 Thread-local storage relocation using local-dynamic model.
3611 Thread-local storage relocation using local-exec model.
3614 Tread-local storage relocation used by the loader.
3617 Tread-local storage relocation used by the loader.
3620 Upper TOC relative relocation. The value is the
3621 high-order 16 bit of a TOC relative relocation.
3624 Lower TOC relative relocation. The value is the
3625 low-order 16 bit of a TOC relative relocation.
3629 xcoff_ppc_relocate_section (bfd
*output_bfd
,
3630 struct bfd_link_info
*info
,
3632 asection
*input_section
,
3634 struct internal_reloc
*relocs
,
3635 struct internal_syment
*syms
,
3636 asection
**sections
)
3638 struct internal_reloc
*rel
;
3639 struct internal_reloc
*relend
;
3642 relend
= rel
+ input_section
->reloc_count
;
3643 for (; rel
< relend
; rel
++)
3646 struct xcoff_link_hash_entry
*h
;
3647 struct internal_syment
*sym
;
3650 struct reloc_howto_struct howto
;
3652 bfd_vma value_to_relocate
;
3656 /* Relocation type R_REF is a special relocation type which is
3657 merely used to prevent garbage collection from occurring for
3658 the csect including the symbol which it references. */
3659 if (rel
->r_type
== R_REF
)
3662 /* Retrieve default value in HOWTO table and fix up according
3663 to r_size field, if it can be different.
3664 This should be made during relocation reading but the algorithms
3665 are expecting constant howtos. */
3666 memcpy (&howto
, &xcoff_howto_table
[rel
->r_type
], sizeof (howto
));
3667 if (howto
.bitsize
!= (rel
->r_size
& 0x1f) + 1)
3669 switch (rel
->r_type
)
3673 howto
.bitsize
= (rel
->r_size
& 0x1f) + 1;
3674 howto
.size
= howto
.bitsize
> 16 ? 2 : 1;
3675 howto
.src_mask
= howto
.dst_mask
= N_ONES (howto
.bitsize
);
3680 (_("%pB: relocatation (%d) at (0x%" BFD_VMA_FMT
"x) has wrong"
3681 " r_rsize (0x%x)\n"),
3682 input_bfd
, rel
->r_type
, rel
->r_vaddr
, rel
->r_size
);
3687 howto
.complain_on_overflow
= (rel
->r_size
& 0x80
3688 ? complain_overflow_signed
3689 : complain_overflow_bitfield
);
3696 symndx
= rel
->r_symndx
;
3702 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
3703 sym
= syms
+ symndx
;
3704 addend
= - sym
->n_value
;
3708 sec
= sections
[symndx
];
3709 /* Hack to make sure we use the right TOC anchor value
3710 if this reloc is against the TOC anchor. */
3711 if (sec
->name
[3] == '0'
3712 && strcmp (sec
->name
, ".tc0") == 0)
3713 val
= xcoff_data (output_bfd
)->toc
;
3715 val
= (sec
->output_section
->vma
3716 + sec
->output_offset
3722 if (info
->unresolved_syms_in_objects
!= RM_IGNORE
3723 && (h
->flags
& XCOFF_WAS_UNDEFINED
) != 0)
3724 (*info
->callbacks
->undefined_symbol
)
3725 (info
, h
->root
.root
.string
,
3726 input_bfd
, input_section
,
3727 rel
->r_vaddr
- input_section
->vma
,
3728 info
->unresolved_syms_in_objects
== RM_DIAGNOSE
&&
3729 !info
->warn_unresolved_syms
);
3731 if (h
->root
.type
== bfd_link_hash_defined
3732 || h
->root
.type
== bfd_link_hash_defweak
)
3734 sec
= h
->root
.u
.def
.section
;
3735 val
= (h
->root
.u
.def
.value
3736 + sec
->output_section
->vma
3737 + sec
->output_offset
);
3739 else if (h
->root
.type
== bfd_link_hash_common
)
3741 sec
= h
->root
.u
.c
.p
->section
;
3742 val
= (sec
->output_section
->vma
3743 + sec
->output_offset
);
3748 BFD_ASSERT (bfd_link_relocatable (info
)
3749 || (info
->static_link
3750 && (h
->flags
& XCOFF_WAS_UNDEFINED
) != 0)
3751 || (h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
3752 || (h
->flags
& XCOFF_IMPORT
) != 0);
3757 if (rel
->r_type
>= XCOFF_MAX_CALCULATE_RELOCATION
3758 || !((*xcoff_calculate_relocation
[rel
->r_type
])
3759 (input_bfd
, input_section
, output_bfd
, rel
, sym
, &howto
, val
,
3760 addend
, &relocation
, contents
)))
3764 address
= rel
->r_vaddr
- input_section
->vma
;
3765 location
= contents
+ address
;
3767 if (address
> input_section
->size
)
3770 /* Get the value we are going to relocate. */
3771 if (1 == howto
.size
)
3772 value_to_relocate
= bfd_get_16 (input_bfd
, location
);
3774 value_to_relocate
= bfd_get_32 (input_bfd
, location
);
3778 FIXME: We may drop bits during the addition
3779 which we don't check for. We must either check at every single
3780 operation, which would be tedious, or we must do the computations
3781 in a type larger than bfd_vma, which would be inefficient. */
3783 if (((*xcoff_complain_overflow
[howto
.complain_on_overflow
])
3784 (input_bfd
, value_to_relocate
, relocation
, &howto
)))
3787 char buf
[SYMNMLEN
+ 1];
3788 char reloc_type_name
[10];
3800 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
3804 sprintf (reloc_type_name
, "0x%02x", rel
->r_type
);
3806 (*info
->callbacks
->reloc_overflow
)
3807 (info
, (h
? &h
->root
: NULL
), name
, reloc_type_name
,
3808 (bfd_vma
) 0, input_bfd
, input_section
,
3809 rel
->r_vaddr
- input_section
->vma
);
3812 /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */
3813 value_to_relocate
= ((value_to_relocate
& ~howto
.dst_mask
)
3814 | (((value_to_relocate
& howto
.src_mask
)
3815 + relocation
) & howto
.dst_mask
));
3817 /* Put the value back in the object file. */
3818 if (1 == howto
.size
)
3819 bfd_put_16 (input_bfd
, value_to_relocate
, location
);
3821 bfd_put_32 (input_bfd
, value_to_relocate
, location
);
3827 /* gcc-8 warns (*) on all the strncpy calls in this function about
3828 possible string truncation. The "truncation" is not a bug. We
3829 have an external representation of structs with fields that are not
3830 necessarily NULL terminated and corresponding internal
3831 representation fields that are one larger so that they can always
3833 gcc versions between 4.2 and 4.6 do not allow pragma control of
3834 diagnostics inside functions, giving a hard error if you try to use
3835 the finer control available with later versions.
3836 gcc prior to 4.2 warns about diagnostic push and pop.
3837 gcc-5, gcc-6 and gcc-7 warn that -Wstringop-truncation is unknown,
3838 unless you also add #pragma GCC diagnostic ignored "-Wpragma".
3839 (*) Depending on your system header files! */
3840 #if GCC_VERSION >= 8000
3841 # pragma GCC diagnostic push
3842 # pragma GCC diagnostic ignored "-Wstringop-truncation"
3845 _bfd_xcoff_put_ldsymbol_name (bfd
*abfd ATTRIBUTE_UNUSED
,
3846 struct xcoff_loader_info
*ldinfo
,
3847 struct internal_ldsym
*ldsym
,
3851 len
= strlen (name
);
3853 if (len
<= SYMNMLEN
)
3854 strncpy (ldsym
->_l
._l_name
, name
, SYMNMLEN
);
3857 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
)
3859 bfd_size_type newalc
;
3862 newalc
= ldinfo
->string_alc
* 2;
3865 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
3868 newstrings
= bfd_realloc (ldinfo
->strings
, newalc
);
3869 if (newstrings
== NULL
)
3871 ldinfo
->failed
= true;
3874 ldinfo
->string_alc
= newalc
;
3875 ldinfo
->strings
= newstrings
;
3878 bfd_put_16 (ldinfo
->output_bfd
, (bfd_vma
) (len
+ 1),
3879 ldinfo
->strings
+ ldinfo
->string_size
);
3880 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
3881 ldsym
->_l
._l_l
._l_zeroes
= 0;
3882 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
3883 ldinfo
->string_size
+= len
+ 3;
3890 _bfd_xcoff_put_symbol_name (struct bfd_link_info
*info
,
3891 struct bfd_strtab_hash
*strtab
,
3892 struct internal_syment
*sym
,
3895 if (strlen (name
) <= SYMNMLEN
)
3897 strncpy (sym
->_n
._n_name
, name
, SYMNMLEN
);
3904 hash
= !info
->traditional_format
;
3905 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
3906 if (indx
== (bfd_size_type
) -1)
3908 sym
->_n
._n_n
._n_zeroes
= 0;
3909 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
3913 #if GCC_VERSION >= 8000
3914 # pragma GCC diagnostic pop
3918 xcoff_create_csect_from_smclas (bfd
*abfd
,
3919 union internal_auxent
*aux
,
3920 const char *symbol_name
)
3922 asection
*return_value
= NULL
;
3924 /* .sv64 = x_smclas == 17
3925 This is an invalid csect for 32 bit apps. */
3926 static const char * const names
[] =
3928 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo", /* 0 - 7 */
3929 ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL
, ".tc0", /* 8 - 15 */
3930 ".td", NULL
, ".sv3264", NULL
, ".tl", ".ul", ".te"
3933 if ((aux
->x_csect
.x_smclas
< ARRAY_SIZE (names
))
3934 && (NULL
!= names
[aux
->x_csect
.x_smclas
]))
3936 return_value
= bfd_make_section_anyway
3937 (abfd
, names
[aux
->x_csect
.x_smclas
]);
3942 /* xgettext: c-format */
3943 (_("%pB: symbol `%s' has unrecognized smclas %d"),
3944 abfd
, symbol_name
, aux
->x_csect
.x_smclas
);
3945 bfd_set_error (bfd_error_bad_value
);
3948 return return_value
;
3952 xcoff_is_lineno_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
, bfd_vma value
)
3954 if (0xffff <= value
)
3961 xcoff_is_reloc_count_overflow (bfd
*abfd ATTRIBUTE_UNUSED
, bfd_vma value
)
3963 if (0xffff <= value
)
3970 xcoff_loader_symbol_offset (bfd
*abfd
,
3971 struct internal_ldhdr
*ldhdr ATTRIBUTE_UNUSED
)
3973 return bfd_xcoff_ldhdrsz (abfd
);
3977 xcoff_loader_reloc_offset (bfd
*abfd
, struct internal_ldhdr
*ldhdr
)
3979 return bfd_xcoff_ldhdrsz (abfd
) + ldhdr
->l_nsyms
* bfd_xcoff_ldsymsz (abfd
);
3983 xcoff_generate_rtinit (bfd
*abfd
, const char *init
, const char *fini
,
3986 bfd_byte filehdr_ext
[FILHSZ
];
3987 bfd_byte scnhdr_ext
[SCNHSZ
];
3988 bfd_byte syment_ext
[SYMESZ
* 10];
3989 bfd_byte reloc_ext
[RELSZ
* 3];
3990 bfd_byte
*data_buffer
;
3991 bfd_size_type data_buffer_size
;
3992 bfd_byte
*string_table
= NULL
, *st_tmp
= NULL
;
3993 bfd_size_type string_table_size
;
3995 size_t initsz
, finisz
;
3996 struct internal_filehdr filehdr
;
3997 struct internal_scnhdr scnhdr
;
3998 struct internal_syment syment
;
3999 union internal_auxent auxent
;
4000 struct internal_reloc reloc
;
4002 char *data_name
= ".data";
4003 char *rtinit_name
= "__rtinit";
4004 char *rtld_name
= "__rtld";
4006 if (! bfd_xcoff_rtinit_size (abfd
))
4009 initsz
= (init
== NULL
? 0 : 1 + strlen (init
));
4010 finisz
= (fini
== NULL
? 0 : 1 + strlen (fini
));
4013 memset (filehdr_ext
, 0, FILHSZ
);
4014 memset (&filehdr
, 0, sizeof (struct internal_filehdr
));
4015 filehdr
.f_magic
= bfd_xcoff_magic_number (abfd
);
4016 filehdr
.f_nscns
= 1;
4017 filehdr
.f_timdat
= 0;
4018 filehdr
.f_nsyms
= 0; /* at least 6, no more than 10 */
4019 filehdr
.f_symptr
= 0; /* set below */
4020 filehdr
.f_opthdr
= 0;
4021 filehdr
.f_flags
= 0;
4023 /* section header */
4024 memset (scnhdr_ext
, 0, SCNHSZ
);
4025 memset (&scnhdr
, 0, sizeof (struct internal_scnhdr
));
4026 memcpy (scnhdr
.s_name
, data_name
, strlen (data_name
));
4029 scnhdr
.s_size
= 0; /* set below */
4030 scnhdr
.s_scnptr
= FILHSZ
+ SCNHSZ
;
4031 scnhdr
.s_relptr
= 0; /* set below */
4032 scnhdr
.s_lnnoptr
= 0;
4033 scnhdr
.s_nreloc
= 0; /* either 1 or 2 */
4035 scnhdr
.s_flags
= STYP_DATA
;
4038 0x0000 0x00000000 : rtl
4039 0x0004 0x00000010 : offset to init, or 0
4040 0x0008 0x00000028 : offset to fini, or 0
4041 0x000C 0x0000000C : size of descriptor
4042 0x0010 0x00000000 : init, needs a reloc
4043 0x0014 0x00000040 : offset to init name
4044 0x0018 0x00000000 : flags, padded to a word
4045 0x001C 0x00000000 : empty init
4048 0x0028 0x00000000 : fini, needs a reloc
4049 0x002C 0x00000??? : offset to fini name
4050 0x0030 0x00000000 : flags, padded to a word
4051 0x0034 0x00000000 : empty fini
4055 0x0040 + initsz fini name */
4057 data_buffer_size
= 0x0040 + initsz
+ finisz
;
4058 data_buffer_size
= (data_buffer_size
+ 7) &~ (bfd_size_type
) 7;
4060 data_buffer
= (bfd_byte
*) bfd_zmalloc (data_buffer_size
);
4061 if (data_buffer
== NULL
)
4067 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x04]);
4069 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x14]);
4070 memcpy (&data_buffer
[val
], init
, initsz
);
4076 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x08]);
4077 val
= 0x40 + initsz
;
4078 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x2C]);
4079 memcpy (&data_buffer
[val
], fini
, finisz
);
4083 bfd_h_put_32 (abfd
, val
, &data_buffer
[0x0C]);
4085 scnhdr
.s_size
= data_buffer_size
;
4088 string_table_size
= 0;
4090 string_table_size
+= initsz
;
4092 string_table_size
+= finisz
;
4093 if (string_table_size
)
4095 string_table_size
+= 4;
4096 string_table
= (bfd_byte
*) bfd_zmalloc (string_table_size
);
4097 if (string_table
== NULL
)
4100 val
= string_table_size
;
4101 bfd_h_put_32 (abfd
, val
, &string_table
[0]);
4102 st_tmp
= string_table
+ 4;
4111 memset (syment_ext
, 0, 10 * SYMESZ
);
4112 memset (reloc_ext
, 0, 3 * RELSZ
);
4115 memset (&syment
, 0, sizeof (struct internal_syment
));
4116 memset (&auxent
, 0, sizeof (union internal_auxent
));
4117 memcpy (syment
._n
._n_name
, data_name
, strlen (data_name
));
4119 syment
.n_sclass
= C_HIDEXT
;
4120 syment
.n_numaux
= 1;
4121 auxent
.x_csect
.x_scnlen
.l
= data_buffer_size
;
4122 auxent
.x_csect
.x_smtyp
= 3 << 3 | XTY_SD
;
4123 auxent
.x_csect
.x_smclas
= XMC_RW
;
4124 bfd_coff_swap_sym_out (abfd
, &syment
,
4125 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4126 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4128 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4129 filehdr
.f_nsyms
+= 2;
4132 memset (&syment
, 0, sizeof (struct internal_syment
));
4133 memset (&auxent
, 0, sizeof (union internal_auxent
));
4134 memcpy (syment
._n
._n_name
, rtinit_name
, strlen (rtinit_name
));
4136 syment
.n_sclass
= C_EXT
;
4137 syment
.n_numaux
= 1;
4138 auxent
.x_csect
.x_smtyp
= XTY_LD
;
4139 auxent
.x_csect
.x_smclas
= XMC_RW
;
4140 bfd_coff_swap_sym_out (abfd
, &syment
,
4141 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4142 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4144 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4145 filehdr
.f_nsyms
+= 2;
4150 memset (&syment
, 0, sizeof (struct internal_syment
));
4151 memset (&auxent
, 0, sizeof (union internal_auxent
));
4155 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
4156 memcpy (st_tmp
, init
, initsz
);
4160 memcpy (syment
._n
._n_name
, init
, initsz
- 1);
4162 syment
.n_sclass
= C_EXT
;
4163 syment
.n_numaux
= 1;
4164 bfd_coff_swap_sym_out (abfd
, &syment
,
4165 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4166 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4168 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4171 memset (&reloc
, 0, sizeof (struct internal_reloc
));
4172 reloc
.r_vaddr
= 0x0010;
4173 reloc
.r_symndx
= filehdr
.f_nsyms
;
4174 reloc
.r_type
= R_POS
;
4176 bfd_coff_swap_reloc_out (abfd
, &reloc
, &reloc_ext
[0]);
4178 filehdr
.f_nsyms
+= 2;
4179 scnhdr
.s_nreloc
+= 1;
4185 memset (&syment
, 0, sizeof (struct internal_syment
));
4186 memset (&auxent
, 0, sizeof (union internal_auxent
));
4190 syment
._n
._n_n
._n_offset
= st_tmp
- string_table
;
4191 memcpy (st_tmp
, fini
, finisz
);
4195 memcpy (syment
._n
._n_name
, fini
, finisz
- 1);
4197 syment
.n_sclass
= C_EXT
;
4198 syment
.n_numaux
= 1;
4199 bfd_coff_swap_sym_out (abfd
, &syment
,
4200 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4201 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4203 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4206 memset (&reloc
, 0, sizeof (struct internal_reloc
));
4207 reloc
.r_vaddr
= 0x0028;
4208 reloc
.r_symndx
= filehdr
.f_nsyms
;
4209 reloc
.r_type
= R_POS
;
4211 bfd_coff_swap_reloc_out (abfd
, &reloc
,
4212 &reloc_ext
[scnhdr
.s_nreloc
* RELSZ
]);
4214 filehdr
.f_nsyms
+= 2;
4215 scnhdr
.s_nreloc
+= 1;
4220 memset (&syment
, 0, sizeof (struct internal_syment
));
4221 memset (&auxent
, 0, sizeof (union internal_auxent
));
4222 memcpy (syment
._n
._n_name
, rtld_name
, strlen (rtld_name
));
4223 syment
.n_sclass
= C_EXT
;
4224 syment
.n_numaux
= 1;
4225 bfd_coff_swap_sym_out (abfd
, &syment
,
4226 &syment_ext
[filehdr
.f_nsyms
* SYMESZ
]);
4227 bfd_coff_swap_aux_out (abfd
, &auxent
, syment
.n_type
, syment
.n_sclass
, 0,
4229 &syment_ext
[(filehdr
.f_nsyms
+ 1) * SYMESZ
]);
4232 memset (&reloc
, 0, sizeof (struct internal_reloc
));
4233 reloc
.r_vaddr
= 0x0000;
4234 reloc
.r_symndx
= filehdr
.f_nsyms
;
4235 reloc
.r_type
= R_POS
;
4237 bfd_coff_swap_reloc_out (abfd
, &reloc
,
4238 &reloc_ext
[scnhdr
.s_nreloc
* RELSZ
]);
4240 filehdr
.f_nsyms
+= 2;
4241 scnhdr
.s_nreloc
+= 1;
4244 scnhdr
.s_relptr
= scnhdr
.s_scnptr
+ data_buffer_size
;
4245 filehdr
.f_symptr
= scnhdr
.s_relptr
+ scnhdr
.s_nreloc
* RELSZ
;
4247 bfd_coff_swap_filehdr_out (abfd
, &filehdr
, filehdr_ext
);
4248 bfd_bwrite (filehdr_ext
, FILHSZ
, abfd
);
4249 bfd_coff_swap_scnhdr_out (abfd
, &scnhdr
, scnhdr_ext
);
4250 bfd_bwrite (scnhdr_ext
, SCNHSZ
, abfd
);
4251 bfd_bwrite (data_buffer
, data_buffer_size
, abfd
);
4252 bfd_bwrite (reloc_ext
, scnhdr
.s_nreloc
* RELSZ
, abfd
);
4253 bfd_bwrite (syment_ext
, filehdr
.f_nsyms
* SYMESZ
, abfd
);
4254 bfd_bwrite (string_table
, string_table_size
, abfd
);
4263 static reloc_howto_type xcoff_dynamic_reloc
=
4264 HOWTO (0, /* type */
4266 2, /* size (0 = byte, 1 = short, 2 = long) */
4268 false, /* pc_relative */
4270 complain_overflow_bitfield
, /* complain_on_overflow */
4271 0, /* special_function */
4273 true, /* partial_inplace */
4274 0xffffffff, /* src_mask */
4275 0xffffffff, /* dst_mask */
4276 false); /* pcrel_offset */
4280 The first word of global linkage code must be modified by filling in
4281 the correct TOC offset. */
4283 static const unsigned long xcoff_glink_code
[9] =
4285 0x81820000, /* lwz r12,0(r2) */
4286 0x90410014, /* stw r2,20(r1) */
4287 0x800c0000, /* lwz r0,0(r12) */
4288 0x804c0004, /* lwz r2,4(r12) */
4289 0x7c0903a6, /* mtctr r0 */
4290 0x4e800420, /* bctr */
4291 0x00000000, /* start of traceback table */
4292 0x000c8000, /* traceback table */
4293 0x00000000, /* traceback table */
4296 /* Table to convert DWARF flags to section names. */
4298 const struct xcoff_dwsect_name xcoff_dwsect_names
[] = {
4299 { SSUBTYP_DWINFO
, ".dwinfo", true },
4300 { SSUBTYP_DWLINE
, ".dwline", true },
4301 { SSUBTYP_DWPBNMS
, ".dwpbnms", true },
4302 { SSUBTYP_DWPBTYP
, ".dwpbtyp", true },
4303 { SSUBTYP_DWARNGE
, ".dwarnge", true },
4304 { SSUBTYP_DWABREV
, ".dwabrev", false },
4305 { SSUBTYP_DWSTR
, ".dwstr", true },
4306 { SSUBTYP_DWRNGES
, ".dwrnges", true }
4309 /* For generic entry points. */
4310 #define _bfd_xcoff_close_and_cleanup _bfd_archive_close_and_cleanup
4311 #define _bfd_xcoff_bfd_free_cached_info _bfd_bool_bfd_true
4312 #define _bfd_xcoff_new_section_hook coff_new_section_hook
4313 #define _bfd_xcoff_get_section_contents _bfd_generic_get_section_contents
4314 #define _bfd_xcoff_get_section_contents_in_window \
4315 _bfd_generic_get_section_contents_in_window
4317 /* For copy private data entry points. */
4318 #define _bfd_xcoff_bfd_copy_private_bfd_data \
4319 _bfd_xcoff_copy_private_bfd_data
4320 #define _bfd_xcoff_bfd_merge_private_bfd_data \
4321 _bfd_generic_bfd_merge_private_bfd_data
4322 #define _bfd_xcoff_bfd_copy_private_section_data \
4323 _bfd_generic_bfd_copy_private_section_data
4324 #define _bfd_xcoff_bfd_copy_private_symbol_data \
4325 _bfd_generic_bfd_copy_private_symbol_data
4326 #define _bfd_xcoff_bfd_copy_private_header_data \
4327 _bfd_generic_bfd_copy_private_header_data
4328 #define _bfd_xcoff_bfd_set_private_flags \
4329 _bfd_generic_bfd_set_private_flags
4330 #define _bfd_xcoff_bfd_print_private_bfd_data \
4331 _bfd_generic_bfd_print_private_bfd_data
4333 /* For archive entry points. */
4334 #define _bfd_xcoff_slurp_extended_name_table \
4335 _bfd_noarchive_slurp_extended_name_table
4336 #define _bfd_xcoff_construct_extended_name_table \
4337 _bfd_noarchive_construct_extended_name_table
4338 #define _bfd_xcoff_truncate_arname bfd_dont_truncate_arname
4339 #define _bfd_xcoff_write_ar_hdr _bfd_generic_write_ar_hdr
4340 #define _bfd_xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
4341 #define _bfd_xcoff_generic_stat_arch_elt _bfd_xcoff_stat_arch_elt
4342 #define _bfd_xcoff_update_armap_timestamp _bfd_bool_bfd_true
4344 /* For symbols entry points. */
4345 #define _bfd_xcoff_get_symtab_upper_bound coff_get_symtab_upper_bound
4346 #define _bfd_xcoff_canonicalize_symtab coff_canonicalize_symtab
4347 #define _bfd_xcoff_make_empty_symbol coff_make_empty_symbol
4348 #define _bfd_xcoff_print_symbol coff_print_symbol
4349 #define _bfd_xcoff_get_symbol_info coff_get_symbol_info
4350 #define _bfd_xcoff_get_symbol_version_string \
4351 _bfd_nosymbols_get_symbol_version_string
4352 #define _bfd_xcoff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
4353 #define _bfd_xcoff_bfd_is_target_special_symbol \
4354 coff_bfd_is_target_special_symbol
4355 #define _bfd_xcoff_get_lineno coff_get_lineno
4356 #define _bfd_xcoff_find_nearest_line coff_find_nearest_line
4357 #define _bfd_xcoff_find_line coff_find_line
4358 #define _bfd_xcoff_find_inliner_info coff_find_inliner_info
4359 #define _bfd_xcoff_bfd_make_debug_symbol coff_bfd_make_debug_symbol
4360 #define _bfd_xcoff_read_minisymbols _bfd_generic_read_minisymbols
4361 #define _bfd_xcoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
4363 /* For reloc entry points. */
4364 #define _bfd_xcoff_get_reloc_upper_bound coff_get_reloc_upper_bound
4365 #define _bfd_xcoff_canonicalize_reloc coff_canonicalize_reloc
4366 #define _bfd_xcoff_set_reloc _bfd_generic_set_reloc
4367 #define _bfd_xcoff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
4368 #define _bfd_xcoff_bfd_reloc_name_lookup _bfd_xcoff_reloc_name_lookup
4370 /* For link entry points. */
4371 #define _bfd_xcoff_bfd_get_relocated_section_contents \
4372 bfd_generic_get_relocated_section_contents
4373 #define _bfd_xcoff_bfd_relax_section bfd_generic_relax_section
4374 #define _bfd_xcoff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
4375 #define _bfd_xcoff_bfd_link_just_syms _bfd_generic_link_just_syms
4376 #define _bfd_xcoff_bfd_copy_link_hash_symbol_type \
4377 _bfd_generic_copy_link_hash_symbol_type
4378 #define _bfd_xcoff_bfd_link_split_section _bfd_generic_link_split_section
4379 #define _bfd_xcoff_bfd_gc_sections bfd_generic_gc_sections
4380 #define _bfd_xcoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags
4381 #define _bfd_xcoff_bfd_merge_sections bfd_generic_merge_sections
4382 #define _bfd_xcoff_bfd_is_group_section bfd_generic_is_group_section
4383 #define _bfd_xcoff_bfd_group_name bfd_generic_group_name
4384 #define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
4385 #define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked
4386 #define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol
4387 #define _bfd_xcoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
4388 #define _bfd_xcoff_bfd_define_start_stop bfd_generic_define_start_stop
4389 #define _bfd_xcoff_bfd_link_check_relocs _bfd_generic_link_check_relocs
4391 /* For dynamic symbols and relocs entry points. */
4392 #define _bfd_xcoff_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
4394 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
4396 { /* COFF backend, defined in libcoff.h. */
4397 _bfd_xcoff_swap_aux_in
,
4398 _bfd_xcoff_swap_sym_in
,
4399 coff_swap_lineno_in
,
4400 _bfd_xcoff_swap_aux_out
,
4401 _bfd_xcoff_swap_sym_out
,
4402 coff_swap_lineno_out
,
4403 xcoff_swap_reloc_out
,
4404 coff_swap_filehdr_out
,
4405 coff_swap_aouthdr_out
,
4406 coff_swap_scnhdr_out
,
4415 true, /* _bfd_coff_long_filenames */
4416 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
4417 3, /* _bfd_coff_default_section_alignment_power */
4418 false, /* _bfd_coff_force_symnames_in_strings */
4419 2, /* _bfd_coff_debug_string_prefix_length */
4420 32768, /* _bfd_coff_max_nscns */
4421 coff_swap_filehdr_in
,
4422 coff_swap_aouthdr_in
,
4423 coff_swap_scnhdr_in
,
4424 xcoff_swap_reloc_in
,
4425 coff_bad_format_hook
,
4426 coff_set_arch_mach_hook
,
4429 coff_set_alignment_hook
,
4430 coff_slurp_symbol_table
,
4431 symname_in_debug_hook
,
4432 coff_pointerize_aux_hook
,
4434 dummy_reloc16_extra_cases
,
4435 dummy_reloc16_estimate
,
4436 NULL
, /* bfd_coff_sym_is_global */
4437 coff_compute_section_file_positions
,
4438 NULL
, /* _bfd_coff_start_final_link */
4439 xcoff_ppc_relocate_section
,
4440 coff_rtype_to_howto
,
4441 NULL
, /* _bfd_coff_adjust_symndx */
4442 _bfd_generic_link_add_one_symbol
,
4443 coff_link_output_has_begun
,
4444 coff_final_link_postscript
,
4445 NULL
/* print_pdata. */
4448 0x01DF, /* magic number */
4452 /* Function pointers to xcoff specific swap routines. */
4453 xcoff_swap_ldhdr_in
,
4454 xcoff_swap_ldhdr_out
,
4455 xcoff_swap_ldsym_in
,
4456 xcoff_swap_ldsym_out
,
4457 xcoff_swap_ldrel_in
,
4458 xcoff_swap_ldrel_out
,
4464 12, /* _xcoff_function_descriptor_size */
4468 1, /* _xcoff_ldhdr_version */
4470 _bfd_xcoff_put_symbol_name
,
4471 _bfd_xcoff_put_ldsymbol_name
,
4472 &xcoff_dynamic_reloc
,
4473 xcoff_create_csect_from_smclas
,
4475 /* Lineno and reloc count overflow. */
4476 xcoff_is_lineno_count_overflow
,
4477 xcoff_is_reloc_count_overflow
,
4479 xcoff_loader_symbol_offset
,
4480 xcoff_loader_reloc_offset
,
4483 &xcoff_glink_code
[0],
4484 36, /* _xcoff_glink_size */
4487 64, /* _xcoff_rtinit_size */
4488 xcoff_generate_rtinit
,
4491 /* The transfer vector that leads the outside world to all of the above. */
4492 const bfd_target rs6000_xcoff_vec
=
4495 bfd_target_xcoff_flavour
,
4496 BFD_ENDIAN_BIG
, /* data byte order is big */
4497 BFD_ENDIAN_BIG
, /* header byte order is big */
4499 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
4500 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
4502 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
4503 0, /* leading char */
4504 '/', /* ar_pad_char */
4505 15, /* ar_max_namelen */
4506 0, /* match priority. */
4507 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
4531 { /* bfd_check_format */
4534 _bfd_xcoff_archive_p
,
4538 { /* bfd_set_format */
4539 _bfd_bool_bfd_false_error
,
4541 _bfd_generic_mkarchive
,
4542 _bfd_bool_bfd_false_error
4545 {/* bfd_write_contents */
4546 _bfd_bool_bfd_false_error
,
4547 coff_write_object_contents
,
4548 _bfd_xcoff_write_archive_contents
,
4549 _bfd_bool_bfd_false_error
4552 BFD_JUMP_TABLE_GENERIC (_bfd_xcoff
),
4553 BFD_JUMP_TABLE_COPY (_bfd_xcoff
),
4554 BFD_JUMP_TABLE_CORE (coff
),
4555 BFD_JUMP_TABLE_ARCHIVE (_bfd_xcoff
),
4556 BFD_JUMP_TABLE_SYMBOLS (_bfd_xcoff
),
4557 BFD_JUMP_TABLE_RELOCS (_bfd_xcoff
),
4558 BFD_JUMP_TABLE_WRITE (coff
),
4559 BFD_JUMP_TABLE_LINK (_bfd_xcoff
),
4560 BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff
),
4562 /* Opposite endian version, none exists */
4565 & bfd_xcoff_backend_data
,
4568 /* xcoff-powermac target
4570 Only difference between this target and the rs6000 target is the
4571 the default architecture and machine type used in coffcode.h
4573 PowerPC Macs use the same magic numbers as RS/6000
4574 (because that's how they were bootstrapped originally),
4575 but they are always PowerPC architecture. */
4576 static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data
=
4578 { /* COFF backend, defined in libcoff.h. */
4579 _bfd_xcoff_swap_aux_in
,
4580 _bfd_xcoff_swap_sym_in
,
4581 coff_swap_lineno_in
,
4582 _bfd_xcoff_swap_aux_out
,
4583 _bfd_xcoff_swap_sym_out
,
4584 coff_swap_lineno_out
,
4585 xcoff_swap_reloc_out
,
4586 coff_swap_filehdr_out
,
4587 coff_swap_aouthdr_out
,
4588 coff_swap_scnhdr_out
,
4597 true, /* _bfd_coff_long_filenames */
4598 XCOFF_NO_LONG_SECTION_NAMES
, /* _bfd_coff_long_section_names */
4599 3, /* _bfd_coff_default_section_alignment_power */
4600 false, /* _bfd_coff_force_symnames_in_strings */
4601 2, /* _bfd_coff_debug_string_prefix_length */
4602 32768, /* _bfd_coff_max_nscns */
4603 coff_swap_filehdr_in
,
4604 coff_swap_aouthdr_in
,
4605 coff_swap_scnhdr_in
,
4606 xcoff_swap_reloc_in
,
4607 coff_bad_format_hook
,
4608 coff_set_arch_mach_hook
,
4611 coff_set_alignment_hook
,
4612 coff_slurp_symbol_table
,
4613 symname_in_debug_hook
,
4614 coff_pointerize_aux_hook
,
4616 dummy_reloc16_extra_cases
,
4617 dummy_reloc16_estimate
,
4618 NULL
, /* bfd_coff_sym_is_global */
4619 coff_compute_section_file_positions
,
4620 NULL
, /* _bfd_coff_start_final_link */
4621 xcoff_ppc_relocate_section
,
4622 coff_rtype_to_howto
,
4623 NULL
, /* _bfd_coff_adjust_symndx */
4624 _bfd_generic_link_add_one_symbol
,
4625 coff_link_output_has_begun
,
4626 coff_final_link_postscript
,
4627 NULL
/* print_pdata. */
4630 0x01DF, /* magic number */
4634 /* Function pointers to xcoff specific swap routines. */
4635 xcoff_swap_ldhdr_in
,
4636 xcoff_swap_ldhdr_out
,
4637 xcoff_swap_ldsym_in
,
4638 xcoff_swap_ldsym_out
,
4639 xcoff_swap_ldrel_in
,
4640 xcoff_swap_ldrel_out
,
4646 12, /* _xcoff_function_descriptor_size */
4650 1, /* _xcoff_ldhdr_version */
4652 _bfd_xcoff_put_symbol_name
,
4653 _bfd_xcoff_put_ldsymbol_name
,
4654 &xcoff_dynamic_reloc
,
4655 xcoff_create_csect_from_smclas
,
4657 /* Lineno and reloc count overflow. */
4658 xcoff_is_lineno_count_overflow
,
4659 xcoff_is_reloc_count_overflow
,
4661 xcoff_loader_symbol_offset
,
4662 xcoff_loader_reloc_offset
,
4665 &xcoff_glink_code
[0],
4666 36, /* _xcoff_glink_size */
4669 0, /* _xcoff_rtinit_size */
4670 xcoff_generate_rtinit
,
4673 /* The transfer vector that leads the outside world to all of the above. */
4674 const bfd_target powerpc_xcoff_vec
=
4677 bfd_target_xcoff_flavour
,
4678 BFD_ENDIAN_BIG
, /* data byte order is big */
4679 BFD_ENDIAN_BIG
, /* header byte order is big */
4681 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| DYNAMIC
4682 | HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
4684 SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_CODE
| SEC_DATA
,
4685 0, /* leading char */
4686 '/', /* ar_pad_char */
4687 15, /* ar_max_namelen */
4688 0, /* match priority. */
4689 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
4713 { /* bfd_check_format */
4716 _bfd_xcoff_archive_p
,
4720 { /* bfd_set_format */
4721 _bfd_bool_bfd_false_error
,
4723 _bfd_generic_mkarchive
,
4724 _bfd_bool_bfd_false_error
4727 {/* bfd_write_contents */
4728 _bfd_bool_bfd_false_error
,
4729 coff_write_object_contents
,
4730 _bfd_xcoff_write_archive_contents
,
4731 _bfd_bool_bfd_false_error
4734 BFD_JUMP_TABLE_GENERIC (_bfd_xcoff
),
4735 BFD_JUMP_TABLE_COPY (_bfd_xcoff
),
4736 BFD_JUMP_TABLE_CORE (coff
),
4737 BFD_JUMP_TABLE_ARCHIVE (_bfd_xcoff
),
4738 BFD_JUMP_TABLE_SYMBOLS (_bfd_xcoff
),
4739 BFD_JUMP_TABLE_RELOCS (_bfd_xcoff
),
4740 BFD_JUMP_TABLE_WRITE (coff
),
4741 BFD_JUMP_TABLE_LINK (_bfd_xcoff
),
4742 BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff
),
4744 /* Opposite endian version, none exists */
4747 & bfd_pmac_xcoff_backend_data
,