1 /* BFD back-end for IBM RS/6000 "XCOFF" files.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 Free Software Foundation, Inc.
5 FIXME: Can someone provide a transliteration of this name into ASCII?
6 Using the following chars caused a compiler warning on HIUX (so I replaced
7 them with octal escapes), and isn't useful without an understanding of what
9 Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
11 Archive support from Damon A. Permezel.
12 Contributed by IBM Corporation and Cygnus Support.
14 This file is part of BFD, the Binary File Descriptor library.
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
34 #include "coff/internal.h"
35 #include "coff/xcoff.h"
36 #include "coff/rs6000.h"
40 extern boolean _bfd_xcoff_mkobject
PARAMS ((bfd
*));
41 extern boolean _bfd_xcoff_copy_private_bfd_data
PARAMS ((bfd
*, bfd
*));
42 extern boolean _bfd_xcoff_is_local_label_name
PARAMS ((bfd
*, const char *));
43 extern reloc_howto_type
*_bfd_xcoff_reloc_type_lookup
44 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
45 extern boolean _bfd_xcoff_slurp_armap
PARAMS ((bfd
*));
46 extern const bfd_target
*_bfd_xcoff_archive_p
PARAMS ((bfd
*));
47 extern PTR _bfd_xcoff_read_ar_hdr
PARAMS ((bfd
*));
48 extern bfd
*_bfd_xcoff_openr_next_archived_file
PARAMS ((bfd
*, bfd
*));
49 extern int _bfd_xcoff_generic_stat_arch_elt
PARAMS ((bfd
*, struct stat
*));
50 extern boolean _bfd_xcoff_write_armap
51 PARAMS ((bfd
*, unsigned int, struct orl
*, unsigned int, int));
52 extern boolean _bfd_xcoff_write_archive_contents
PARAMS ((bfd
*));
53 extern int _bfd_xcoff_sizeof_headers
PARAMS ((bfd
*, boolean
));
54 extern void _bfd_xcoff_swap_sym_in
PARAMS ((bfd
*, PTR
, PTR
));
55 extern unsigned int _bfd_xcoff_swap_sym_out
PARAMS ((bfd
*, PTR
, PTR
));
56 extern void _bfd_xcoff_swap_aux_in
PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
57 extern unsigned int _bfd_xcoff_swap_aux_out
PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
59 /* Forward declare _bfd_xcoff_rtype2howto for coffcode.h macro. */
60 void _bfd_xcoff_rtype2howto
PARAMS ((arelent
*, struct internal_reloc
*));
62 /* coffcode.h needs these to be defined. */
63 #define RS6000COFF_C 1
65 #define SELECT_RELOC(internal, howto) \
67 internal.r_type = howto->type; \
69 ((howto->complain_on_overflow == complain_overflow_signed \
72 | (howto->bitsize - 1)); \
75 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
76 #define COFF_LONG_FILENAMES
77 #define NO_COFF_SYMBOLS
78 #define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst)
79 #define coff_mkobject _bfd_xcoff_mkobject
80 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
81 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
82 #define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
84 extern const bfd_target
* rs6000coff_core_p ();
85 extern boolean
rs6000coff_core_file_matches_executable_p ();
86 extern char *rs6000coff_core_file_failing_command
PARAMS ((bfd
*abfd
));
87 extern int rs6000coff_core_file_failing_signal
PARAMS ((bfd
*abfd
));
88 #define CORE_FILE_P rs6000coff_core_p
89 #define coff_core_file_failing_command \
90 rs6000coff_core_file_failing_command
91 #define coff_core_file_failing_signal \
92 rs6000coff_core_file_failing_signal
93 #define coff_core_file_matches_executable_p \
94 rs6000coff_core_file_matches_executable_p
96 #define CORE_FILE_P _bfd_dummy_target
97 #define coff_core_file_failing_command \
98 _bfd_nocore_core_file_failing_command
99 #define coff_core_file_failing_signal \
100 _bfd_nocore_core_file_failing_signal
101 #define coff_core_file_matches_executable_p \
102 _bfd_nocore_core_file_matches_executable_p
104 #define coff_SWAP_sym_in _bfd_xcoff_swap_sym_in
105 #define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out
106 #define coff_SWAP_aux_in _bfd_xcoff_swap_aux_in
107 #define coff_SWAP_aux_out _bfd_xcoff_swap_aux_out
109 #include "coffcode.h"
111 /* The main body of code is in coffcode.h. */
113 static const char *normalize_filename
PARAMS ((bfd
*));
114 static boolean xcoff_write_armap_old
115 PARAMS ((bfd
*, unsigned int, struct orl
*, unsigned int, int));
116 static boolean xcoff_write_one_armap_big
117 PARAMS ((bfd
*, struct orl
*, unsigned int, unsigned int, unsigned int,
118 int, const char *, char *));
119 static boolean xcoff_write_armap_big
120 PARAMS ((bfd
*, unsigned int, struct orl
*, unsigned int, int));
121 static boolean xcoff_write_archive_contents_old
PARAMS ((bfd
*));
122 static boolean xcoff_write_archive_contents_big
PARAMS ((bfd
*));
123 static void xcoff_swap_ldhdr_in
124 PARAMS ((bfd
*, const PTR
, struct internal_ldhdr
*));
125 static void xcoff_swap_ldhdr_out
126 PARAMS ((bfd
*, const struct internal_ldhdr
*, PTR
));
127 static void xcoff_swap_ldsym_in
128 PARAMS ((bfd
*, const PTR
, struct internal_ldsym
*));
129 static void xcoff_swap_ldsym_out
130 PARAMS ((bfd
*, const struct internal_ldsym
*, PTR
));
131 static void xcoff_swap_ldrel_in
132 PARAMS ((bfd
*, const PTR
, struct internal_ldrel
*));
133 static void xcoff_swap_ldrel_out
134 PARAMS ((bfd
*, const struct internal_ldrel
*, PTR
));
135 static boolean xcoff_ppc_relocate_section
136 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
137 struct internal_reloc
*, struct internal_syment
*, asection
**));
138 static boolean _bfd_xcoff_put_ldsymbol_name
139 PARAMS ((bfd
*, struct xcoff_loader_info
*, struct internal_ldsym
*,
141 static asection
*xcoff_create_csect_from_smclas
142 PARAMS ((bfd
*, union internal_auxent
*, const char *));
143 static boolean xcoff_is_lineno_count_overflow
PARAMS ((bfd
*, bfd_vma
));
144 static boolean xcoff_is_reloc_count_overflow
PARAMS ((bfd
*, bfd_vma
));
145 static bfd_vma xcoff_loader_symbol_offset
146 PARAMS ((bfd
*, struct internal_ldhdr
*));
147 static bfd_vma xcoff_loader_reloc_offset
148 PARAMS ((bfd
*, struct internal_ldhdr
*));
150 /* We use our own tdata type. Its first field is the COFF tdata type,
151 so the COFF routines are compatible. */
154 _bfd_xcoff_mkobject (abfd
)
157 coff_data_type
*coff
;
159 abfd
->tdata
.xcoff_obj_data
=
160 ((struct xcoff_tdata
*)
161 bfd_zalloc (abfd
, sizeof (struct xcoff_tdata
)));
162 if (abfd
->tdata
.xcoff_obj_data
== NULL
)
164 coff
= coff_data (abfd
);
165 coff
->symbols
= (coff_symbol_type
*) NULL
;
166 coff
->conversion_table
= (unsigned int *) NULL
;
167 coff
->raw_syments
= (struct coff_ptr_struct
*) NULL
;
170 xcoff_data (abfd
)->modtype
= ('1' << 8) | 'L';
172 /* We set cputype to -1 to indicate that it has not been
174 xcoff_data (abfd
)->cputype
= -1;
176 xcoff_data (abfd
)->csects
= NULL
;
177 xcoff_data (abfd
)->debug_indices
= NULL
;
179 /* text section alignment is different than the default */
180 /* xcoff_data (abfd)->text_align_power = 5; */
185 /* Copy XCOFF data from one BFD to another. */
188 _bfd_xcoff_copy_private_bfd_data (ibfd
, obfd
)
192 struct xcoff_tdata
*ix
, *ox
;
195 if (ibfd
->xvec
!= obfd
->xvec
)
197 ix
= xcoff_data (ibfd
);
198 ox
= xcoff_data (obfd
);
199 ox
->full_aouthdr
= ix
->full_aouthdr
;
205 sec
= coff_section_from_bfd_index (ibfd
, ix
->sntoc
);
209 ox
->sntoc
= sec
->output_section
->target_index
;
211 if (ix
->snentry
== 0)
215 sec
= coff_section_from_bfd_index (ibfd
, ix
->snentry
);
219 ox
->snentry
= sec
->output_section
->target_index
;
221 ox
->text_align_power
= ix
->text_align_power
;
222 ox
->data_align_power
= ix
->data_align_power
;
223 ox
->modtype
= ix
->modtype
;
224 ox
->cputype
= ix
->cputype
;
225 ox
->maxdata
= ix
->maxdata
;
226 ox
->maxstack
= ix
->maxstack
;
230 /* I don't think XCOFF really has a notion of local labels based on
231 name. This will mean that ld -X doesn't actually strip anything.
232 The AIX native linker does not have a -X option, and it ignores the
236 _bfd_xcoff_is_local_label_name (abfd
, name
)
237 bfd
*abfd ATTRIBUTE_UNUSED
;
238 const char *name ATTRIBUTE_UNUSED
;
246 _bfd_xcoff_swap_sym_in (abfd
, ext1
, in1
)
251 SYMENT
*ext
= (SYMENT
*)ext1
;
252 struct internal_syment
* in
= (struct internal_syment
*)in1
;
254 if (ext
->e
.e_name
[0] != 0)
256 memcpy(in
->_n
._n_name
, ext
->e
.e_name
, SYMNMLEN
);
260 in
->_n
._n_n
._n_zeroes
= 0;
261 in
->_n
._n_n
._n_offset
=
262 bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->e
.e
.e_offset
);
265 in
->n_value
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->e_value
);
266 in
->n_scnum
= bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->e_scnum
);
267 in
->n_type
= bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->e_type
);
268 in
->n_sclass
= bfd_h_get_8 (abfd
, ext
->e_sclass
);
269 in
->n_numaux
= bfd_h_get_8 (abfd
, ext
->e_numaux
);
273 _bfd_xcoff_swap_sym_out (abfd
, inp
, extp
)
278 struct internal_syment
*in
= (struct internal_syment
*)inp
;
279 SYMENT
*ext
=(SYMENT
*)extp
;
281 if (in
->_n
._n_name
[0] != 0)
283 memcpy(ext
->e
.e_name
, in
->_n
._n_name
, SYMNMLEN
);
287 bfd_h_put_32 (abfd
, 0, (bfd_byte
*) ext
->e
.e
.e_zeroes
);
288 bfd_h_put_32 (abfd
, in
->_n
._n_n
._n_offset
,
289 (bfd_byte
*) ext
->e
.e
.e_offset
);
292 bfd_h_put_32 (abfd
, in
->n_value
, (bfd_byte
*) ext
->e_value
);
293 bfd_h_put_16 (abfd
, in
->n_scnum
, (bfd_byte
*) ext
->e_scnum
);
294 bfd_h_put_16 (abfd
, in
->n_type
, (bfd_byte
*) ext
->e_type
);
295 bfd_h_put_8 (abfd
, in
->n_sclass
, ext
->e_sclass
);
296 bfd_h_put_8 (abfd
, in
->n_numaux
, ext
->e_numaux
);
297 return bfd_coff_symesz (abfd
);
300 #define PUTWORD bfd_h_put_32
301 #define PUTHALF bfd_h_put_16
302 #define PUTBYTE bfd_h_put_8
303 #define GETWORD bfd_h_get_32
304 #define GETHALF bfd_h_get_16
305 #define GETBYTE bfd_h_get_8
308 _bfd_xcoff_swap_aux_in (abfd
, ext1
, type
, class, indx
, numaux
, in1
)
317 AUXENT
* ext
= (AUXENT
*)ext1
;
318 union internal_auxent
*in
= (union internal_auxent
*)in1
;
323 if (ext
->x_file
.x_fname
[0] == 0)
325 in
->x_file
.x_n
.x_zeroes
= 0;
326 in
->x_file
.x_n
.x_offset
=
327 bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->x_file
.x_n
.x_offset
);
334 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_fname
,
335 numaux
* sizeof (AUXENT
));
339 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_fname
, FILNMLEN
);
344 /* RS/6000 "csect" auxents */
347 if (indx
+ 1 == numaux
)
349 in
->x_csect
.x_scnlen
.l
=
350 bfd_h_get_32 (abfd
, ext
->x_csect
.x_scnlen
);
351 in
->x_csect
.x_parmhash
= bfd_h_get_32 (abfd
,
352 ext
->x_csect
.x_parmhash
);
353 in
->x_csect
.x_snhash
= bfd_h_get_16 (abfd
, ext
->x_csect
.x_snhash
);
354 /* We don't have to hack bitfields in x_smtyp because it's
355 defined by shifts-and-ands, which are equivalent on all
357 in
->x_csect
.x_smtyp
= bfd_h_get_8 (abfd
, ext
->x_csect
.x_smtyp
);
358 in
->x_csect
.x_smclas
= bfd_h_get_8 (abfd
, ext
->x_csect
.x_smclas
);
359 in
->x_csect
.x_stab
= bfd_h_get_32 (abfd
, ext
->x_csect
.x_stab
);
360 in
->x_csect
.x_snstab
= bfd_h_get_16 (abfd
, ext
->x_csect
.x_snstab
);
370 in
->x_scn
.x_scnlen
= bfd_h_get_32(abfd
,
371 (bfd_byte
*) ext
->x_scn
.x_scnlen
);
372 in
->x_scn
.x_nreloc
= bfd_h_get_16(abfd
,
373 (bfd_byte
*) ext
->x_scn
.x_nreloc
);
374 in
->x_scn
.x_nlinno
= bfd_h_get_16(abfd
,
375 (bfd_byte
*) ext
->x_scn
.x_nlinno
);
376 /* PE defines some extra fields; we zero them out for
378 in
->x_scn
.x_checksum
= 0;
379 in
->x_scn
.x_associated
= 0;
380 in
->x_scn
.x_comdat
= 0;
387 in
->x_sym
.x_tagndx
.l
= bfd_h_get_32(abfd
, (bfd_byte
*) ext
->x_sym
.x_tagndx
);
388 in
->x_sym
.x_tvndx
= bfd_h_get_16(abfd
, (bfd_byte
*) ext
->x_sym
.x_tvndx
);
390 if (class == C_BLOCK
|| class == C_FCN
|| ISFCN (type
) || ISTAG (class))
392 in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
= bfd_h_get_32(abfd
, (bfd_byte
*)
393 ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
394 in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
= bfd_h_get_32(abfd
, (bfd_byte
*)
395 ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
399 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0] =
400 bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0]);
401 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1] =
402 bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1]);
403 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2] =
404 bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2]);
405 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3] =
406 bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3]);
411 in
->x_sym
.x_misc
.x_fsize
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->x_sym
.x_misc
.x_fsize
);
415 in
->x_sym
.x_misc
.x_lnsz
.x_lnno
= bfd_h_get_16 (abfd
, (bfd_byte
*)
416 ext
->x_sym
.x_misc
.x_lnsz
.x_lnno
);
417 in
->x_sym
.x_misc
.x_lnsz
.x_size
= bfd_h_get_16 (abfd
, (bfd_byte
*)
418 ext
->x_sym
.x_misc
.x_lnsz
.x_size
);
422 /* The semicolon is because MSVC doesn't like labels at
427 unsigned int _bfd_xcoff_swap_aux_out
PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
430 _bfd_xcoff_swap_aux_out (abfd
, inp
, type
, class, indx
, numaux
, extp
)
435 int indx ATTRIBUTE_UNUSED
;
436 int numaux ATTRIBUTE_UNUSED
;
439 union internal_auxent
*in
= (union internal_auxent
*)inp
;
440 AUXENT
*ext
= (AUXENT
*)extp
;
442 memset((PTR
)ext
, 0, bfd_coff_auxesz (abfd
));
446 if (in
->x_file
.x_fname
[0] == 0)
448 PUTWORD (abfd
, 0, (bfd_byte
*) ext
->x_file
.x_n
.x_zeroes
);
450 in
->x_file
.x_n
.x_offset
,
451 (bfd_byte
*) ext
->x_file
.x_n
.x_offset
);
455 memcpy (ext
->x_file
.x_fname
, in
->x_file
.x_fname
, FILNMLEN
);
459 /* RS/6000 "csect" auxents */
462 if (indx
+ 1 == numaux
)
464 PUTWORD (abfd
, in
->x_csect
.x_scnlen
.l
,ext
->x_csect
.x_scnlen
);
465 PUTWORD (abfd
, in
->x_csect
.x_parmhash
, ext
->x_csect
.x_parmhash
);
466 PUTHALF (abfd
, in
->x_csect
.x_snhash
, ext
->x_csect
.x_snhash
);
467 /* We don't have to hack bitfields in x_smtyp because it's
468 defined by shifts-and-ands, which are equivalent on all
470 PUTBYTE (abfd
, in
->x_csect
.x_smtyp
, ext
->x_csect
.x_smtyp
);
471 PUTBYTE (abfd
, in
->x_csect
.x_smclas
, ext
->x_csect
.x_smclas
);
472 PUTWORD (abfd
, in
->x_csect
.x_stab
, ext
->x_csect
.x_stab
);
473 PUTHALF (abfd
, in
->x_csect
.x_snstab
, ext
->x_csect
.x_snstab
);
483 bfd_h_put_32(abfd
, in
->x_scn
.x_scnlen
, (bfd_byte
*) ext
->x_scn
.x_scnlen
);
484 bfd_h_put_16(abfd
, in
->x_scn
.x_nreloc
, (bfd_byte
*) ext
->x_scn
.x_nreloc
);
485 bfd_h_put_16(abfd
, in
->x_scn
.x_nlinno
, (bfd_byte
*) ext
->x_scn
.x_nlinno
);
491 PUTWORD (abfd
, in
->x_sym
.x_tagndx
.l
, (bfd_byte
*) ext
->x_sym
.x_tagndx
);
492 bfd_h_put_16 (abfd
, in
->x_sym
.x_tvndx
, (bfd_byte
*) ext
->x_sym
.x_tvndx
);
494 if (class == C_BLOCK
|| class == C_FCN
|| ISFCN (type
) || ISTAG (class))
496 bfd_h_put_32 (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
,
497 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
498 PUTWORD (abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
,
499 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
503 bfd_h_put_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0],
504 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0]);
505 bfd_h_put_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1],
506 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1]);
507 bfd_h_put_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2],
508 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2]);
509 bfd_h_put_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3],
510 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3]);
514 PUTWORD (abfd
, in
->x_sym
.x_misc
.x_fsize
,
515 (bfd_byte
*) ext
->x_sym
.x_misc
.x_fsize
);
518 bfd_h_put_16 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_lnno
,
519 (bfd_byte
*)ext
->x_sym
.x_misc
.x_lnsz
.x_lnno
);
520 bfd_h_put_16 (abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_size
,
521 (bfd_byte
*)ext
->x_sym
.x_misc
.x_lnsz
.x_size
);
525 return bfd_coff_auxesz (abfd
);
530 /* The XCOFF reloc table. Actually, XCOFF relocations specify the
531 bitsize and whether they are signed or not, along with a
532 conventional type. This table is for the types, which are used for
533 different algorithms for putting in the reloc. Many of these
534 relocs need special_function entries, which I have not written. */
537 reloc_howto_type xcoff_howto_table
[] =
539 /* Standard 32 bit relocation. */
542 2, /* size (0 = byte, 1 = short, 2 = long) */
544 false, /* pc_relative */
546 complain_overflow_bitfield
, /* complain_on_overflow */
547 0, /* special_function */
549 true, /* partial_inplace */
550 0xffffffff, /* src_mask */
551 0xffffffff, /* dst_mask */
552 false), /* pcrel_offset */
554 /* 32 bit relocation, but store negative value. */
557 -2, /* size (0 = byte, 1 = short, 2 = long) */
559 false, /* pc_relative */
561 complain_overflow_bitfield
, /* complain_on_overflow */
562 0, /* special_function */
564 true, /* partial_inplace */
565 0xffffffff, /* src_mask */
566 0xffffffff, /* dst_mask */
567 false), /* pcrel_offset */
569 /* 32 bit PC relative relocation. */
572 2, /* size (0 = byte, 1 = short, 2 = long) */
574 true, /* pc_relative */
576 complain_overflow_signed
, /* complain_on_overflow */
577 0, /* special_function */
579 true, /* partial_inplace */
580 0xffffffff, /* src_mask */
581 0xffffffff, /* dst_mask */
582 false), /* pcrel_offset */
584 /* 16 bit TOC relative relocation. */
587 1, /* size (0 = byte, 1 = short, 2 = long) */
589 false, /* pc_relative */
591 complain_overflow_bitfield
, /* complain_on_overflow */
592 0, /* special_function */
594 true, /* partial_inplace */
595 0xffff, /* src_mask */
596 0xffff, /* dst_mask */
597 false), /* pcrel_offset */
599 /* I don't really know what this is. */
602 2, /* size (0 = byte, 1 = short, 2 = long) */
604 false, /* pc_relative */
606 complain_overflow_bitfield
, /* complain_on_overflow */
607 0, /* special_function */
609 true, /* partial_inplace */
610 0xffffffff, /* src_mask */
611 0xffffffff, /* dst_mask */
612 false), /* pcrel_offset */
614 /* External TOC relative symbol. */
617 2, /* size (0 = byte, 1 = short, 2 = long) */
619 false, /* pc_relative */
621 complain_overflow_bitfield
, /* complain_on_overflow */
622 0, /* special_function */
624 true, /* partial_inplace */
625 0xffff, /* src_mask */
626 0xffff, /* dst_mask */
627 false), /* pcrel_offset */
629 /* Local TOC relative symbol. */
632 2, /* size (0 = byte, 1 = short, 2 = long) */
634 false, /* pc_relative */
636 complain_overflow_bitfield
, /* complain_on_overflow */
637 0, /* special_function */
639 true, /* partial_inplace */
640 0xffff, /* src_mask */
641 0xffff, /* dst_mask */
642 false), /* pcrel_offset */
646 /* Non modifiable absolute branch. */
649 2, /* size (0 = byte, 1 = short, 2 = long) */
651 false, /* pc_relative */
653 complain_overflow_bitfield
, /* complain_on_overflow */
654 0, /* special_function */
656 true, /* partial_inplace */
657 0x3fffffc, /* src_mask */
658 0x3fffffc, /* dst_mask */
659 false), /* pcrel_offset */
663 /* Non modifiable relative branch. */
664 HOWTO (0xa, /* type */
666 2, /* size (0 = byte, 1 = short, 2 = long) */
668 true, /* pc_relative */
670 complain_overflow_signed
, /* complain_on_overflow */
671 0, /* special_function */
673 true, /* partial_inplace */
674 0x3fffffc, /* src_mask */
675 0x3fffffc, /* dst_mask */
676 false), /* pcrel_offset */
681 HOWTO (0xc, /* type */
683 2, /* size (0 = byte, 1 = short, 2 = long) */
685 false, /* pc_relative */
687 complain_overflow_bitfield
, /* complain_on_overflow */
688 0, /* special_function */
690 true, /* partial_inplace */
691 0xffff, /* src_mask */
692 0xffff, /* dst_mask */
693 false), /* pcrel_offset */
696 HOWTO (0xd, /* type */
698 2, /* size (0 = byte, 1 = short, 2 = long) */
700 false, /* pc_relative */
702 complain_overflow_bitfield
, /* complain_on_overflow */
703 0, /* special_function */
705 true, /* partial_inplace */
706 0xffff, /* src_mask */
707 0xffff, /* dst_mask */
708 false), /* pcrel_offset */
712 /* Non-relocating reference. */
713 HOWTO (0xf, /* type */
715 2, /* size (0 = byte, 1 = short, 2 = long) */
717 false, /* pc_relative */
719 complain_overflow_bitfield
, /* complain_on_overflow */
720 0, /* special_function */
722 false, /* partial_inplace */
725 false), /* pcrel_offset */
730 /* TOC relative indirect load. */
731 HOWTO (0x12, /* type */
733 2, /* size (0 = byte, 1 = short, 2 = long) */
735 false, /* pc_relative */
737 complain_overflow_bitfield
, /* complain_on_overflow */
738 0, /* special_function */
740 true, /* partial_inplace */
741 0xffff, /* src_mask */
742 0xffff, /* dst_mask */
743 false), /* pcrel_offset */
745 /* TOC relative load address. */
746 HOWTO (0x13, /* type */
748 2, /* size (0 = byte, 1 = short, 2 = long) */
750 false, /* pc_relative */
752 complain_overflow_bitfield
, /* complain_on_overflow */
753 0, /* special_function */
755 true, /* partial_inplace */
756 0xffff, /* src_mask */
757 0xffff, /* dst_mask */
758 false), /* pcrel_offset */
760 /* Modifiable relative branch. */
761 HOWTO (0x14, /* type */
763 2, /* size (0 = byte, 1 = short, 2 = long) */
765 false, /* pc_relative */
767 complain_overflow_bitfield
, /* complain_on_overflow */
768 0, /* special_function */
769 "R_RRTBI", /* name */
770 true, /* partial_inplace */
771 0xffffffff, /* src_mask */
772 0xffffffff, /* dst_mask */
773 false), /* pcrel_offset */
775 /* Modifiable absolute branch. */
776 HOWTO (0x15, /* type */
778 2, /* size (0 = byte, 1 = short, 2 = long) */
780 false, /* pc_relative */
782 complain_overflow_bitfield
, /* complain_on_overflow */
783 0, /* special_function */
784 "R_RRTBA", /* name */
785 true, /* partial_inplace */
786 0xffffffff, /* src_mask */
787 0xffffffff, /* dst_mask */
788 false), /* pcrel_offset */
790 /* Modifiable call absolute indirect. */
791 HOWTO (0x16, /* type */
793 2, /* size (0 = byte, 1 = short, 2 = long) */
795 false, /* pc_relative */
797 complain_overflow_bitfield
, /* complain_on_overflow */
798 0, /* special_function */
800 true, /* partial_inplace */
801 0xffff, /* src_mask */
802 0xffff, /* dst_mask */
803 false), /* pcrel_offset */
805 /* Modifiable call relative. */
806 HOWTO (0x17, /* type */
808 2, /* size (0 = byte, 1 = short, 2 = long) */
810 false, /* pc_relative */
812 complain_overflow_bitfield
, /* complain_on_overflow */
813 0, /* special_function */
815 true, /* partial_inplace */
816 0xffff, /* src_mask */
817 0xffff, /* dst_mask */
818 false), /* pcrel_offset */
820 /* Modifiable branch absolute. */
821 HOWTO (0x18, /* type */
823 2, /* size (0 = byte, 1 = short, 2 = long) */
825 false, /* pc_relative */
827 complain_overflow_bitfield
, /* complain_on_overflow */
828 0, /* special_function */
830 true, /* partial_inplace */
831 0xffff, /* src_mask */
832 0xffff, /* dst_mask */
833 false), /* pcrel_offset */
835 /* Modifiable branch absolute. */
836 HOWTO (0x19, /* type */
838 2, /* size (0 = byte, 1 = short, 2 = long) */
840 false, /* pc_relative */
842 complain_overflow_bitfield
, /* complain_on_overflow */
843 0, /* special_function */
845 true, /* partial_inplace */
846 0xffff, /* src_mask */
847 0xffff, /* dst_mask */
848 false), /* pcrel_offset */
850 /* Modifiable branch relative. */
851 HOWTO (0x1a, /* type */
853 2, /* size (0 = byte, 1 = short, 2 = long) */
855 false, /* pc_relative */
857 complain_overflow_signed
, /* complain_on_overflow */
858 0, /* special_function */
860 true, /* partial_inplace */
861 0xffff, /* src_mask */
862 0xffff, /* dst_mask */
863 false), /* pcrel_offset */
865 /* Modifiable branch absolute. */
866 HOWTO (0x1b, /* type */
868 2, /* size (0 = byte, 1 = short, 2 = long) */
870 false, /* pc_relative */
872 complain_overflow_bitfield
, /* complain_on_overflow */
873 0, /* special_function */
875 true, /* partial_inplace */
876 0xffff, /* src_mask */
877 0xffff, /* dst_mask */
878 false), /* pcrel_offset */
882 4, /* size (0 = byte, 1 = short, 2 = long) */
884 false, /* pc_relative */
886 complain_overflow_bitfield
, /* complain_on_overflow */
887 0, /* special_function */
889 true, /* partial_inplace */
890 MINUS_ONE
, /* src_mask */
891 MINUS_ONE
, /* dst_mask */
892 false) /* pcrel_offset */
897 _bfd_xcoff_rtype2howto (relent
, internal
)
899 struct internal_reloc
*internal
;
901 relent
->howto
= xcoff_howto_table
+ internal
->r_type
;
903 /* Check for relocs we don't know of. */
905 >= sizeof (xcoff_howto_table
) / sizeof (xcoff_howto_table
[0]))
907 if (internal
->r_type
!= relent
->howto
->type
)
910 /* The r_size field of an XCOFF reloc encodes the bitsize of the
911 relocation, as well as indicating whether it is signed or not.
912 Doublecheck that the relocation information gathered from the
913 type matches this information. The bitsize is not significant
915 if (relent
->howto
->dst_mask
!= 0
916 && (relent
->howto
->bitsize
917 != ((unsigned int) internal
->r_size
& 0x3f) + 1))
920 if ((internal
->r_size
& 0x80) != 0
921 ? (relent
->howto
->complain_on_overflow
!= complain_overflow_signed
)
922 : (relent
->howto
->complain_on_overflow
!= complain_overflow_bitfield
))
928 _bfd_xcoff_reloc_type_lookup (abfd
, code
)
929 bfd
*abfd ATTRIBUTE_UNUSED
;
930 bfd_reloc_code_real_type code
;
934 case BFD_RELOC_PPC_B26
:
935 return &xcoff_howto_table
[0xa];
936 case BFD_RELOC_PPC_BA26
:
937 return &xcoff_howto_table
[8];
938 case BFD_RELOC_PPC_TOC16
:
939 return &xcoff_howto_table
[3];
942 return &xcoff_howto_table
[0];
944 return &xcoff_howto_table
[0x1c];
951 /* XCOFF archive support. The original version of this code was by
952 Damon A. Permezel. It was enhanced to permit cross support, and
953 writing archive files, by Ian Lance Taylor, Cygnus Support.
955 XCOFF uses its own archive format. Everything is hooked together
956 with file offset links, so it is possible to rapidly update an
957 archive in place. Of course, we don't do that. An XCOFF archive
958 has a real file header, not just an ARMAG string. The structure of
959 the file header and of each archive header appear below.
961 An XCOFF archive also has a member table, which is a list of
962 elements in the archive (you can get that by looking through the
963 linked list, but you have to read a lot more of the file). The
964 member table has a normal archive header with an empty name. It is
965 normally (and perhaps must be) the second to last entry in the
966 archive. The member table data is almost printable ASCII. It
967 starts with a 12 character decimal string which is the number of
968 entries in the table. For each entry it has a 12 character decimal
969 string which is the offset in the archive of that member. These
970 entries are followed by a series of null terminated strings which
971 are the member names for each entry.
973 Finally, an XCOFF archive has a global symbol table, which is what
974 we call the armap. The global symbol table has a normal archive
975 header with an empty name. It is normally (and perhaps must be)
976 the last entry in the archive. The contents start with a four byte
977 binary number which is the number of entries. This is followed by
978 a that many four byte binary numbers; each is the file offset of an
979 entry in the archive. These numbers are followed by a series of
980 null terminated strings, which are symbol names.
982 AIX 4.3 introduced a new archive format which can handle larger
983 files and also 32- and 64-bit objects in the same archive. The
984 things said above remain true except that there is now more than
985 one global symbol table. The one is used to index 32-bit objects,
986 the other for 64-bit objects.
988 The new archives (recognizable by the new ARMAG string) has larger
989 field lengths so that we cannot really share any code. Also we have
990 to take care that we are not generating the new form of archives
991 on AIX 4.2 or earlier systems. */
993 /* XCOFF archives use this as a magic string. Note that both strings
994 have the same length. */
998 /* Read in the armap of an XCOFF archive. */
1001 _bfd_xcoff_slurp_armap (abfd
)
1007 bfd_byte
*contents
, *cend
;
1012 if (xcoff_ardata (abfd
) == NULL
)
1014 bfd_has_map (abfd
) = false;
1018 if (! xcoff_big_format_p (abfd
))
1020 /* This is for the old format. */
1021 struct xcoff_ar_hdr hdr
;
1023 off
= strtol (xcoff_ardata (abfd
)->symoff
, (char **) NULL
, 10);
1026 bfd_has_map (abfd
) = false;
1030 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1033 /* The symbol table starts with a normal archive header. */
1034 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR
, 1, abfd
) != SIZEOF_AR_HDR
)
1037 /* Skip the name (normally empty). */
1038 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1039 if (bfd_seek (abfd
, ((namlen
+ 1) & ~1) + SXCOFFARFMAG
, SEEK_CUR
) != 0)
1042 sz
= strtol (hdr
.size
, (char **) NULL
, 10);
1044 /* Read in the entire symbol table. */
1045 contents
= (bfd_byte
*) bfd_alloc (abfd
, sz
);
1046 if (contents
== NULL
)
1048 if (bfd_read ((PTR
) contents
, 1, sz
, abfd
) != sz
)
1051 /* The symbol table starts with a four byte count. */
1052 c
= bfd_h_get_32 (abfd
, contents
);
1056 bfd_set_error (bfd_error_bad_value
);
1060 bfd_ardata (abfd
)->symdefs
= ((carsym
*)
1061 bfd_alloc (abfd
, c
* sizeof (carsym
)));
1062 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1065 /* After the count comes a list of four byte file offsets. */
1066 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 4;
1068 ++i
, ++arsym
, p
+= 4)
1069 arsym
->file_offset
= bfd_h_get_32 (abfd
, p
);
1073 /* This is for the new format. */
1074 struct xcoff_ar_hdr_big hdr
;
1076 off
= strtol (xcoff_ardata_big (abfd
)->symoff
, (char **) NULL
, 10);
1079 bfd_has_map (abfd
) = false;
1083 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1086 /* The symbol table starts with a normal archive header. */
1087 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR_BIG
, 1, abfd
)
1088 != SIZEOF_AR_HDR_BIG
)
1091 /* Skip the name (normally empty). */
1092 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1093 if (bfd_seek (abfd
, ((namlen
+ 1) & ~1) + SXCOFFARFMAG
, SEEK_CUR
) != 0)
1096 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1097 machines) since the field width is 20 and there numbers with more
1098 than 32 bits can be represented. */
1099 sz
= strtol (hdr
.size
, (char **) NULL
, 10);
1101 /* Read in the entire symbol table. */
1102 contents
= (bfd_byte
*) bfd_alloc (abfd
, sz
);
1103 if (contents
== NULL
)
1105 if (bfd_read ((PTR
) contents
, 1, sz
, abfd
) != sz
)
1108 /* The symbol table starts with an eight byte count. */
1109 c
= bfd_h_get_64 (abfd
, contents
);
1113 bfd_set_error (bfd_error_bad_value
);
1117 bfd_ardata (abfd
)->symdefs
= ((carsym
*)
1118 bfd_alloc (abfd
, c
* sizeof (carsym
)));
1119 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1122 /* After the count comes a list of eight byte file offsets. */
1123 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1125 ++i
, ++arsym
, p
+= 8)
1126 arsym
->file_offset
= bfd_h_get_64 (abfd
, p
);
1129 /* After the file offsets come null terminated symbol names. */
1130 cend
= contents
+ sz
;
1131 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1133 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1137 bfd_set_error (bfd_error_bad_value
);
1140 arsym
->name
= (char *) p
;
1143 bfd_ardata (abfd
)->symdef_count
= c
;
1144 bfd_has_map (abfd
) = true;
1149 /* See if this is an XCOFF archive. */
1152 _bfd_xcoff_archive_p (abfd
)
1155 char magic
[SXCOFFARMAG
];
1157 if (bfd_read ((PTR
) magic
, SXCOFFARMAG
, 1, abfd
) != SXCOFFARMAG
)
1159 if (bfd_get_error () != bfd_error_system_call
)
1160 bfd_set_error (bfd_error_wrong_format
);
1164 if (strncmp (magic
, XCOFFARMAG
, SXCOFFARMAG
) != 0
1165 && strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0)
1167 bfd_set_error (bfd_error_wrong_format
);
1171 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
1172 involves a cast, we can't do it as the left operand of
1174 abfd
->tdata
.aout_ar_data
=
1175 (struct artdata
*) bfd_zalloc (abfd
, sizeof (struct artdata
));
1177 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1180 bfd_ardata (abfd
)->cache
= NULL
;
1181 bfd_ardata (abfd
)->archive_head
= NULL
;
1182 bfd_ardata (abfd
)->symdefs
= NULL
;
1183 bfd_ardata (abfd
)->extended_names
= NULL
;
1185 /* Now handle the two formats. */
1186 if (magic
[1] != 'b')
1188 /* This is the old format. */
1189 struct xcoff_ar_file_hdr hdr
;
1191 /* Copy over the magic string. */
1192 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1194 /* Now read the rest of the file header. */
1195 if (bfd_read ((PTR
) &hdr
.memoff
, SIZEOF_AR_FILE_HDR
- SXCOFFARMAG
, 1,
1196 abfd
) != SIZEOF_AR_FILE_HDR
- SXCOFFARMAG
)
1198 if (bfd_get_error () != bfd_error_system_call
)
1199 bfd_set_error (bfd_error_wrong_format
);
1203 bfd_ardata (abfd
)->first_file_filepos
= strtol (hdr
.firstmemoff
,
1204 (char **) NULL
, 10);
1206 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, SIZEOF_AR_FILE_HDR
);
1207 if (bfd_ardata (abfd
)->tdata
== NULL
)
1210 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR
);
1214 /* This is the new format. */
1215 struct xcoff_ar_file_hdr_big hdr
;
1217 /* Copy over the magic string. */
1218 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1220 /* Now read the rest of the file header. */
1221 if (bfd_read ((PTR
) &hdr
.memoff
, SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
, 1,
1222 abfd
) != SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
)
1224 if (bfd_get_error () != bfd_error_system_call
)
1225 bfd_set_error (bfd_error_wrong_format
);
1229 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1230 machines) since the field width is 20 and there numbers with more
1231 than 32 bits can be represented. */
1232 bfd_ardata (abfd
)->first_file_filepos
= strtol (hdr
.firstmemoff
,
1233 (char **) NULL
, 10);
1235 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, SIZEOF_AR_FILE_HDR_BIG
);
1236 if (bfd_ardata (abfd
)->tdata
== NULL
)
1239 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1242 if (! _bfd_xcoff_slurp_armap (abfd
))
1244 bfd_release (abfd
, bfd_ardata (abfd
));
1245 abfd
->tdata
.aout_ar_data
= (struct artdata
*) NULL
;
1252 /* Read the archive header in an XCOFF archive. */
1255 _bfd_xcoff_read_ar_hdr (abfd
)
1259 struct areltdata
*ret
;
1261 ret
= (struct areltdata
*) bfd_alloc (abfd
, sizeof (struct areltdata
));
1265 if (! xcoff_big_format_p (abfd
))
1267 struct xcoff_ar_hdr hdr
;
1268 struct xcoff_ar_hdr
*hdrp
;
1270 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR
, 1, abfd
) != SIZEOF_AR_HDR
)
1276 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1277 hdrp
= (struct xcoff_ar_hdr
*) bfd_alloc (abfd
,
1278 SIZEOF_AR_HDR
+ namlen
+ 1);
1284 memcpy (hdrp
, &hdr
, SIZEOF_AR_HDR
);
1285 if (bfd_read ((char *) hdrp
+ SIZEOF_AR_HDR
, 1, namlen
, abfd
) != namlen
)
1290 ((char *) hdrp
)[SIZEOF_AR_HDR
+ namlen
] = '\0';
1292 ret
->arch_header
= (char *) hdrp
;
1293 ret
->parsed_size
= strtol (hdr
.size
, (char **) NULL
, 10);
1294 ret
->filename
= (char *) hdrp
+ SIZEOF_AR_HDR
;
1298 struct xcoff_ar_hdr_big hdr
;
1299 struct xcoff_ar_hdr_big
*hdrp
;
1301 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR_BIG
, 1, abfd
)
1302 != SIZEOF_AR_HDR_BIG
)
1308 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1309 hdrp
= (struct xcoff_ar_hdr_big
*) bfd_alloc (abfd
,
1317 memcpy (hdrp
, &hdr
, SIZEOF_AR_HDR_BIG
);
1318 if (bfd_read ((char *) hdrp
+ SIZEOF_AR_HDR_BIG
, 1, namlen
, abfd
) != namlen
)
1323 ((char *) hdrp
)[SIZEOF_AR_HDR_BIG
+ namlen
] = '\0';
1325 ret
->arch_header
= (char *) hdrp
;
1326 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1327 machines) since the field width is 20 and there numbers with more
1328 than 32 bits can be represented. */
1329 ret
->parsed_size
= strtol (hdr
.size
, (char **) NULL
, 10);
1330 ret
->filename
= (char *) hdrp
+ SIZEOF_AR_HDR_BIG
;
1333 /* Skip over the XCOFFARFMAG at the end of the file name. */
1334 if (bfd_seek (abfd
, (namlen
& 1) + SXCOFFARFMAG
, SEEK_CUR
) != 0)
1340 /* Open the next element in an XCOFF archive. */
1343 _bfd_xcoff_openr_next_archived_file (archive
, last_file
)
1349 if (xcoff_ardata (archive
) == NULL
)
1351 bfd_set_error (bfd_error_invalid_operation
);
1355 if (! xcoff_big_format_p (archive
))
1357 if (last_file
== NULL
)
1358 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1360 filestart
= strtol (arch_xhdr (last_file
)->nextoff
, (char **) NULL
,
1364 || filestart
== strtol (xcoff_ardata (archive
)->memoff
,
1366 || filestart
== strtol (xcoff_ardata (archive
)->symoff
,
1367 (char **) NULL
, 10))
1369 bfd_set_error (bfd_error_no_more_archived_files
);
1375 if (last_file
== NULL
)
1376 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1378 /* XXX These actually have to be a calls to strtoll (at least
1379 on 32-bit machines) since the fields's width is 20 and
1380 there numbers with more than 32 bits can be represented. */
1381 filestart
= strtol (arch_xhdr_big (last_file
)->nextoff
, (char **) NULL
,
1384 /* XXX These actually have to be calls to strtoll (at least on 32-bit
1385 machines) since the fields's width is 20 and there numbers with more
1386 than 32 bits can be represented. */
1388 || filestart
== strtol (xcoff_ardata_big (archive
)->memoff
,
1390 || filestart
== strtol (xcoff_ardata_big (archive
)->symoff
,
1391 (char **) NULL
, 10))
1393 bfd_set_error (bfd_error_no_more_archived_files
);
1398 return _bfd_get_elt_at_filepos (archive
, filestart
);
1401 /* Stat an element in an XCOFF archive. */
1404 _bfd_xcoff_generic_stat_arch_elt (abfd
, s
)
1408 if (abfd
->arelt_data
== NULL
)
1410 bfd_set_error (bfd_error_invalid_operation
);
1414 if (! xcoff_big_format_p (abfd
))
1416 struct xcoff_ar_hdr
*hdrp
= arch_xhdr (abfd
);
1418 s
->st_mtime
= strtol (hdrp
->date
, (char **) NULL
, 10);
1419 s
->st_uid
= strtol (hdrp
->uid
, (char **) NULL
, 10);
1420 s
->st_gid
= strtol (hdrp
->gid
, (char **) NULL
, 10);
1421 s
->st_mode
= strtol (hdrp
->mode
, (char **) NULL
, 8);
1422 s
->st_size
= arch_eltdata (abfd
)->parsed_size
;
1426 struct xcoff_ar_hdr_big
*hdrp
= arch_xhdr_big (abfd
);
1428 s
->st_mtime
= strtol (hdrp
->date
, (char **) NULL
, 10);
1429 s
->st_uid
= strtol (hdrp
->uid
, (char **) NULL
, 10);
1430 s
->st_gid
= strtol (hdrp
->gid
, (char **) NULL
, 10);
1431 s
->st_mode
= strtol (hdrp
->mode
, (char **) NULL
, 8);
1432 s
->st_size
= arch_eltdata (abfd
)->parsed_size
;
1438 /* Normalize a file name for inclusion in an archive. */
1441 normalize_filename (abfd
)
1445 const char *filename
;
1447 file
= bfd_get_filename (abfd
);
1448 filename
= strrchr (file
, '/');
1449 if (filename
!= NULL
)
1456 /* Write out an XCOFF armap. */
1460 xcoff_write_armap_old (abfd
, elength
, map
, orl_count
, stridx
)
1462 unsigned int elength ATTRIBUTE_UNUSED
;
1464 unsigned int orl_count
;
1467 struct xcoff_ar_hdr hdr
;
1469 unsigned char buf
[4];
1474 memset (&hdr
, 0, sizeof hdr
);
1475 sprintf (hdr
.size
, "%ld", (long) (4 + orl_count
* 4 + stridx
));
1476 sprintf (hdr
.nextoff
, "%d", 0);
1477 memcpy (hdr
.prevoff
, xcoff_ardata (abfd
)->memoff
, 12);
1478 sprintf (hdr
.date
, "%d", 0);
1479 sprintf (hdr
.uid
, "%d", 0);
1480 sprintf (hdr
.gid
, "%d", 0);
1481 sprintf (hdr
.mode
, "%d", 0);
1482 sprintf (hdr
.namlen
, "%d", 0);
1484 /* We need spaces, not null bytes, in the header. */
1485 for (p
= (char *) &hdr
; p
< (char *) &hdr
+ SIZEOF_AR_HDR
; p
++)
1489 if (bfd_write ((PTR
) &hdr
, SIZEOF_AR_HDR
, 1, abfd
) != SIZEOF_AR_HDR
1490 || bfd_write (XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
) != SXCOFFARFMAG
)
1493 bfd_h_put_32 (abfd
, orl_count
, buf
);
1494 if (bfd_write (buf
, 1, 4, abfd
) != 4)
1497 sub
= abfd
->archive_head
;
1498 fileoff
= SIZEOF_AR_FILE_HDR
;
1500 while (sub
!= NULL
&& i
< orl_count
)
1504 while (((bfd
*) (map
[i
]).pos
) == sub
)
1506 bfd_h_put_32 (abfd
, fileoff
, buf
);
1507 if (bfd_write (buf
, 1, 4, abfd
) != 4)
1511 namlen
= strlen (normalize_filename (sub
));
1512 namlen
= (namlen
+ 1) &~ 1;
1513 fileoff
+= (SIZEOF_AR_HDR
1516 + arelt_size (sub
));
1517 fileoff
= (fileoff
+ 1) &~ 1;
1521 for (i
= 0; i
< orl_count
; i
++)
1526 name
= *map
[i
].name
;
1527 namlen
= strlen (name
);
1528 if (bfd_write (name
, 1, namlen
+ 1, abfd
) != namlen
+ 1)
1532 if ((stridx
& 1) != 0)
1537 if (bfd_write (&b
, 1, 1, abfd
) != 1)
1544 /* Write a single armap in the big format. */
1547 xcoff_write_one_armap_big (abfd
, map
, orl_count
, orl_ccount
, stridx
, bits64
,
1551 unsigned int orl_count
;
1552 unsigned int orl_ccount
;
1553 unsigned int stridx
;
1555 const char *prevoff
;
1558 struct xcoff_ar_hdr_big hdr
;
1560 unsigned char buf
[4];
1563 const bfd_arch_info_type
*arch_info
= NULL
;
1567 memset (&hdr
, 0, sizeof hdr
);
1568 /* XXX This call actually should use %lld (at least on 32-bit
1569 machines) since the fields's width is 20 and there numbers with
1570 more than 32 bits can be represented. */
1571 sprintf (hdr
.size
, "%ld", (long) (4 + orl_ccount
* 4 + stridx
));
1574 sprintf (hdr
.nextoff
, "%d", 0);
1578 /* Do explict cast to long to remove compiler warning. */
1579 sprintf (hdr
.nextoff
, "%ld", (strtol (prevoff
, (char **) NULL
, 10)
1580 + (long) (4 + orl_ccount
* 4 + stridx
)));
1583 memcpy (hdr
.prevoff
, prevoff
, sizeof (hdr
.prevoff
));
1584 sprintf (hdr
.date
, "%d", 0);
1585 sprintf (hdr
.uid
, "%d", 0);
1586 sprintf (hdr
.gid
, "%d", 0);
1587 sprintf (hdr
.mode
, "%d", 0);
1588 sprintf (hdr
.namlen
, "%d", 0);
1590 /* We need spaces, not null bytes, in the header. */
1591 for (p
= (char *) &hdr
; p
< (char *) &hdr
+ SIZEOF_AR_HDR_BIG
; p
++)
1595 memcpy (nextoff
, hdr
.nextoff
, sizeof (hdr
.nextoff
));
1597 if (bfd_write ((PTR
) &hdr
, SIZEOF_AR_HDR_BIG
, 1, abfd
) != SIZEOF_AR_HDR_BIG
1598 || bfd_write (XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
) != SXCOFFARFMAG
)
1601 bfd_h_put_32 (abfd
, orl_ccount
, buf
);
1602 if (bfd_write (buf
, 1, 4, abfd
) != 4)
1605 sub
= abfd
->archive_head
;
1606 fileoff
= SIZEOF_AR_FILE_HDR_BIG
;
1608 while (sub
!= NULL
&& i
< orl_count
)
1612 if ((bfd_arch_bits_per_address ((bfd
*) map
[i
].pos
) == 64) == bits64
)
1613 while (((bfd
*) (map
[i
]).pos
) == sub
)
1615 bfd_h_put_32 (abfd
, fileoff
, buf
);
1616 if (bfd_write (buf
, 1, 4, abfd
) != 4)
1621 while (((bfd
*) (map
[i
]).pos
) == sub
)
1624 namlen
= strlen (normalize_filename (sub
));
1625 namlen
= (namlen
+ 1) &~ 1;
1626 fileoff
+= (SIZEOF_AR_HDR_BIG
1629 + arelt_size (sub
));
1630 fileoff
= (fileoff
+ 1) &~ 1;
1635 for (i
= 0; i
< orl_count
; i
++)
1639 bfd
*ob
= (bfd
*)map
[i
].pos
;
1641 if (ob
!= object_bfd
)
1642 arch_info
= bfd_get_arch_info (ob
);
1643 if ((arch_info
->bits_per_address
== 64) != bits64
)
1646 name
= *map
[i
].name
;
1647 namlen
= strlen (name
);
1648 if (bfd_write (name
, 1, namlen
+ 1, abfd
) != namlen
+ 1)
1652 if ((stridx
& 1) != 0)
1657 if (bfd_write (&b
, 1, 1, abfd
) != 1)
1665 xcoff_write_armap_big (abfd
, elength
, map
, orl_count
, stridx
)
1667 unsigned int elength ATTRIBUTE_UNUSED
;
1669 unsigned int orl_count
;
1673 unsigned int orl_count_32
, orl_count_64
;
1674 unsigned int stridx_32
, stridx_64
;
1675 const bfd_arch_info_type
*arch_info
= NULL
;
1678 /* First, we look through the symbols and work out which are
1679 from 32-bit objects and which from 64-bit ones. */
1685 for (i
= 0; i
< orl_count
; i
++)
1687 bfd
*ob
= (bfd
*)map
[i
].pos
;
1689 if (ob
!= object_bfd
)
1690 arch_info
= bfd_get_arch_info (ob
);
1691 len
= strlen (*map
[i
].name
) + 1;
1692 if (arch_info
->bits_per_address
== 64)
1704 /* A quick sanity check... */
1705 BFD_ASSERT (orl_count_64
+ orl_count_32
== orl_count
);
1706 /* Explicit cast to int for compiler. */
1707 BFD_ASSERT ((int)(stridx_64
+ stridx_32
) == stridx
);
1709 /* Now write out each map. */
1710 if (! xcoff_write_one_armap_big (abfd
, map
, orl_count
, orl_count_32
,
1712 xcoff_ardata_big (abfd
)->memoff
,
1713 xcoff_ardata_big (abfd
)->symoff
))
1715 if (! xcoff_write_one_armap_big (abfd
, map
, orl_count
, orl_count_64
,
1717 xcoff_ardata_big (abfd
)->symoff
,
1718 xcoff_ardata_big (abfd
)->symoff64
))
1725 _bfd_xcoff_write_armap (abfd
, elength
, map
, orl_count
, stridx
)
1727 unsigned int elength ATTRIBUTE_UNUSED
;
1729 unsigned int orl_count
;
1732 if (! xcoff_big_format_p (abfd
))
1733 return xcoff_write_armap_old (abfd
, elength
, map
, orl_count
, stridx
);
1735 return xcoff_write_armap_big (abfd
, elength
, map
, orl_count
, stridx
);
1738 /* Write out an XCOFF archive. We always write an entire archive,
1739 rather than fussing with the freelist and so forth. */
1742 xcoff_write_archive_contents_old (abfd
)
1745 struct xcoff_ar_file_hdr fhdr
;
1747 size_t total_namlen
;
1751 file_ptr prevoff
, nextoff
;
1754 struct xcoff_ar_hdr ahdr
;
1759 memset (&fhdr
, 0, sizeof fhdr
);
1760 strncpy (fhdr
.magic
, XCOFFARMAG
, SXCOFFARMAG
);
1761 sprintf (fhdr
.firstmemoff
, "%d", SIZEOF_AR_FILE_HDR
);
1762 sprintf (fhdr
.freeoff
, "%d", 0);
1766 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->next
)
1769 total_namlen
+= strlen (normalize_filename (sub
)) + 1;
1771 offsets
= (file_ptr
*) bfd_alloc (abfd
, count
* sizeof (file_ptr
));
1772 if (offsets
== NULL
)
1775 if (bfd_seek (abfd
, SIZEOF_AR_FILE_HDR
, SEEK_SET
) != 0)
1778 makemap
= bfd_has_map (abfd
);
1781 nextoff
= SIZEOF_AR_FILE_HDR
;
1782 for (sub
= abfd
->archive_head
, i
= 0; sub
!= NULL
; sub
= sub
->next
, i
++)
1786 struct xcoff_ar_hdr
*ahdrp
;
1787 bfd_size_type remaining
;
1789 if (makemap
&& ! hasobjects
)
1791 if (bfd_check_format (sub
, bfd_object
))
1795 name
= normalize_filename (sub
);
1796 namlen
= strlen (name
);
1798 if (sub
->arelt_data
!= NULL
)
1799 ahdrp
= arch_xhdr (sub
);
1807 memset (&ahdr
, 0, sizeof ahdr
);
1809 if (stat (bfd_get_filename (sub
), &s
) != 0)
1811 bfd_set_error (bfd_error_system_call
);
1815 sprintf (ahdrp
->size
, "%ld", (long) s
.st_size
);
1816 sprintf (ahdrp
->date
, "%ld", (long) s
.st_mtime
);
1817 sprintf (ahdrp
->uid
, "%ld", (long) s
.st_uid
);
1818 sprintf (ahdrp
->gid
, "%ld", (long) s
.st_gid
);
1819 sprintf (ahdrp
->mode
, "%o", (unsigned int) s
.st_mode
);
1821 if (sub
->arelt_data
== NULL
)
1823 sub
->arelt_data
= bfd_alloc (sub
, sizeof (struct areltdata
));
1824 if (sub
->arelt_data
== NULL
)
1828 arch_eltdata (sub
)->parsed_size
= s
.st_size
;
1831 sprintf (ahdrp
->prevoff
, "%ld", (long) prevoff
);
1832 sprintf (ahdrp
->namlen
, "%ld", (long) namlen
);
1834 /* If the length of the name is odd, we write out the null byte
1835 after the name as well. */
1836 namlen
= (namlen
+ 1) &~ 1;
1838 remaining
= arelt_size (sub
);
1839 size
= (SIZEOF_AR_HDR
1844 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
1846 offsets
[i
] = nextoff
;
1849 nextoff
+= size
+ (size
& 1);
1851 sprintf (ahdrp
->nextoff
, "%ld", (long) nextoff
);
1853 /* We need spaces, not null bytes, in the header. */
1854 for (p
= (char *) ahdrp
; p
< (char *) ahdrp
+ SIZEOF_AR_HDR
; p
++)
1858 if (bfd_write ((PTR
) ahdrp
, 1, SIZEOF_AR_HDR
, abfd
) != SIZEOF_AR_HDR
1859 || bfd_write ((PTR
) name
, 1, namlen
, abfd
) != namlen
1860 || (bfd_write ((PTR
) XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
)
1864 if (bfd_seek (sub
, (file_ptr
) 0, SEEK_SET
) != 0)
1866 while (remaining
!= 0)
1869 bfd_byte buffer
[DEFAULT_BUFFERSIZE
];
1871 amt
= sizeof buffer
;
1872 if (amt
> remaining
)
1874 if (bfd_read (buffer
, 1, amt
, sub
) != amt
1875 || bfd_write (buffer
, 1, amt
, abfd
) != amt
)
1880 if ((size
& 1) != 0)
1885 if (bfd_write (&b
, 1, 1, abfd
) != 1)
1890 sprintf (fhdr
.lastmemoff
, "%ld", (long) prevoff
);
1892 /* Write out the member table. */
1894 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
1895 sprintf (fhdr
.memoff
, "%ld", (long) nextoff
);
1897 memset (&ahdr
, 0, sizeof ahdr
);
1898 sprintf (ahdr
.size
, "%ld", (long) (12 + count
* 12 + total_namlen
));
1899 sprintf (ahdr
.prevoff
, "%ld", (long) prevoff
);
1900 sprintf (ahdr
.date
, "%d", 0);
1901 sprintf (ahdr
.uid
, "%d", 0);
1902 sprintf (ahdr
.gid
, "%d", 0);
1903 sprintf (ahdr
.mode
, "%d", 0);
1904 sprintf (ahdr
.namlen
, "%d", 0);
1906 size
= (SIZEOF_AR_HDR
1913 nextoff
+= size
+ (size
& 1);
1915 if (makemap
&& hasobjects
)
1916 sprintf (ahdr
.nextoff
, "%ld", (long) nextoff
);
1918 sprintf (ahdr
.nextoff
, "%d", 0);
1920 /* We need spaces, not null bytes, in the header. */
1921 for (p
= (char *) &ahdr
; p
< (char *) &ahdr
+ SIZEOF_AR_HDR
; p
++)
1925 if (bfd_write ((PTR
) &ahdr
, 1, SIZEOF_AR_HDR
, abfd
) != SIZEOF_AR_HDR
1926 || (bfd_write ((PTR
) XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
)
1930 sprintf (decbuf
, "%-12ld", (long) count
);
1931 if (bfd_write ((PTR
) decbuf
, 1, 12, abfd
) != 12)
1933 for (i
= 0; i
< count
; i
++)
1935 sprintf (decbuf
, "%-12ld", (long) offsets
[i
]);
1936 if (bfd_write ((PTR
) decbuf
, 1, 12, abfd
) != 12)
1939 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->next
)
1944 name
= normalize_filename (sub
);
1945 namlen
= strlen (name
);
1946 if (bfd_write ((PTR
) name
, 1, namlen
+ 1, abfd
) != namlen
+ 1)
1949 if ((size
& 1) != 0)
1954 if (bfd_write ((PTR
) &b
, 1, 1, abfd
) != 1)
1958 /* Write out the armap, if appropriate. */
1960 if (! makemap
|| ! hasobjects
)
1961 sprintf (fhdr
.symoff
, "%d", 0);
1964 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
1965 sprintf (fhdr
.symoff
, "%ld", (long) nextoff
);
1966 bfd_ardata (abfd
)->tdata
= (PTR
) &fhdr
;
1967 if (! _bfd_compute_and_write_armap (abfd
, 0))
1971 /* Write out the archive file header. */
1973 /* We need spaces, not null bytes, in the header. */
1974 for (p
= (char *) &fhdr
; p
< (char *) &fhdr
+ SIZEOF_AR_FILE_HDR
; p
++)
1978 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
1979 || (bfd_write ((PTR
) &fhdr
, SIZEOF_AR_FILE_HDR
, 1, abfd
) !=
1980 SIZEOF_AR_FILE_HDR
))
1987 xcoff_write_archive_contents_big (abfd
)
1990 struct xcoff_ar_file_hdr_big fhdr
;
1992 size_t total_namlen
;
1996 file_ptr prevoff
, nextoff
;
1999 struct xcoff_ar_hdr_big ahdr
;
2004 memset (&fhdr
, 0, sizeof fhdr
);
2005 strncpy (fhdr
.magic
, XCOFFARMAGBIG
, SXCOFFARMAG
);
2006 sprintf (fhdr
.firstmemoff
, "%d", SIZEOF_AR_FILE_HDR_BIG
);
2007 sprintf (fhdr
.freeoff
, "%d", 0);
2011 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->next
)
2014 total_namlen
+= strlen (normalize_filename (sub
)) + 1;
2016 offsets
= (file_ptr
*) bfd_alloc (abfd
, count
* sizeof (file_ptr
));
2017 if (offsets
== NULL
)
2020 if (bfd_seek (abfd
, SIZEOF_AR_FILE_HDR_BIG
, SEEK_SET
) != 0)
2023 makemap
= bfd_has_map (abfd
);
2026 nextoff
= SIZEOF_AR_FILE_HDR_BIG
;
2027 for (sub
= abfd
->archive_head
, i
= 0; sub
!= NULL
; sub
= sub
->next
, i
++)
2031 struct xcoff_ar_hdr_big
*ahdrp
;
2032 bfd_size_type remaining
;
2034 if (makemap
&& ! hasobjects
)
2036 if (bfd_check_format (sub
, bfd_object
))
2040 name
= normalize_filename (sub
);
2041 namlen
= strlen (name
);
2043 if (sub
->arelt_data
!= NULL
)
2044 ahdrp
= arch_xhdr_big (sub
);
2052 memset (&ahdr
, 0, sizeof ahdr
);
2054 /* XXX This should actually be a call to stat64 (at least on
2055 32-bit machines). */
2056 if (stat (bfd_get_filename (sub
), &s
) != 0)
2058 bfd_set_error (bfd_error_system_call
);
2062 /* XXX This call actually should use %lld (at least on 32-bit
2063 machines) since the fields's width is 20 and there numbers with
2064 more than 32 bits can be represented. */
2065 sprintf (ahdrp
->size
, "%ld", (long) s
.st_size
);
2066 sprintf (ahdrp
->date
, "%ld", (long) s
.st_mtime
);
2067 sprintf (ahdrp
->uid
, "%ld", (long) s
.st_uid
);
2068 sprintf (ahdrp
->gid
, "%ld", (long) s
.st_gid
);
2069 sprintf (ahdrp
->mode
, "%o", (unsigned int) s
.st_mode
);
2071 if (sub
->arelt_data
== NULL
)
2073 sub
->arelt_data
= bfd_alloc (sub
, sizeof (struct areltdata
));
2074 if (sub
->arelt_data
== NULL
)
2078 arch_eltdata (sub
)->parsed_size
= s
.st_size
;
2081 /* XXX These calls actually should use %lld (at least on 32-bit
2082 machines) since the fields's width is 20 and there numbers with
2083 more than 32 bits can be represented. */
2084 sprintf (ahdrp
->prevoff
, "%ld", (long) prevoff
);
2085 sprintf (ahdrp
->namlen
, "%ld", (long) namlen
);
2087 /* If the length of the name is odd, we write out the null byte
2088 after the name as well. */
2089 namlen
= (namlen
+ 1) &~ 1;
2091 remaining
= arelt_size (sub
);
2092 size
= (SIZEOF_AR_HDR_BIG
2097 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2099 offsets
[i
] = nextoff
;
2102 nextoff
+= size
+ (size
& 1);
2104 sprintf (ahdrp
->nextoff
, "%ld", (long) nextoff
);
2106 /* We need spaces, not null bytes, in the header. */
2107 for (p
= (char *) ahdrp
; p
< (char *) ahdrp
+ SIZEOF_AR_HDR_BIG
; p
++)
2111 if (bfd_write ((PTR
) ahdrp
, 1, SIZEOF_AR_HDR_BIG
, abfd
)
2112 != SIZEOF_AR_HDR_BIG
2113 || bfd_write ((PTR
) name
, 1, namlen
, abfd
) != namlen
2114 || (bfd_write ((PTR
) XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
)
2118 if (bfd_seek (sub
, (file_ptr
) 0, SEEK_SET
) != 0)
2120 while (remaining
!= 0)
2123 bfd_byte buffer
[DEFAULT_BUFFERSIZE
];
2125 amt
= sizeof buffer
;
2126 if (amt
> remaining
)
2128 if (bfd_read (buffer
, 1, amt
, sub
) != amt
2129 || bfd_write (buffer
, 1, amt
, abfd
) != amt
)
2134 if ((size
& 1) != 0)
2139 if (bfd_write (&b
, 1, 1, abfd
) != 1)
2144 /* XXX This call actually should use %lld (at least on 32-bit
2145 machines) since the fields's width is 20 and there numbers with
2146 more than 32 bits can be represented. */
2147 sprintf (fhdr
.lastmemoff
, "%ld", (long) prevoff
);
2149 /* Write out the member table. */
2151 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2152 /* XXX This call actually should use %lld (at least on 32-bit
2153 machines) since the fields's width is 20 and there numbers with
2154 more than 32 bits can be represented. */
2155 sprintf (fhdr
.memoff
, "%ld", (long) nextoff
);
2157 memset (&ahdr
, 0, sizeof ahdr
);
2158 /* XXX The next two calls actually should use %lld (at least on 32-bit
2159 machines) since the fields's width is 20 and there numbers with
2160 more than 32 bits can be represented. */
2161 sprintf (ahdr
.size
, "%ld", (long) (12 + count
* 12 + total_namlen
));
2162 sprintf (ahdr
.prevoff
, "%ld", (long) prevoff
);
2163 sprintf (ahdr
.date
, "%d", 0);
2164 sprintf (ahdr
.uid
, "%d", 0);
2165 sprintf (ahdr
.gid
, "%d", 0);
2166 sprintf (ahdr
.mode
, "%d", 0);
2167 sprintf (ahdr
.namlen
, "%d", 0);
2169 size
= (SIZEOF_AR_HDR_BIG
2176 nextoff
+= size
+ (size
& 1);
2178 if (makemap
&& hasobjects
)
2179 /* XXX This call actually should use %lld (at least on 32-bit
2180 machines) since the fields's width is 20 and there numbers with
2181 more than 32 bits can be represented. */
2182 sprintf (ahdr
.nextoff
, "%ld", (long) nextoff
);
2184 sprintf (ahdr
.nextoff
, "%d", 0);
2186 /* We need spaces, not null bytes, in the header. */
2187 for (p
= (char *) &ahdr
; p
< (char *) &ahdr
+ SIZEOF_AR_HDR_BIG
; p
++)
2191 if (bfd_write ((PTR
) &ahdr
, 1, SIZEOF_AR_HDR_BIG
, abfd
) != SIZEOF_AR_HDR_BIG
2192 || (bfd_write ((PTR
) XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
)
2196 sprintf (decbuf
, "%-12ld", (long) count
);
2197 if (bfd_write ((PTR
) decbuf
, 1, 12, abfd
) != 12)
2199 for (i
= 0; i
< count
; i
++)
2201 sprintf (decbuf
, "%-12ld", (long) offsets
[i
]);
2202 if (bfd_write ((PTR
) decbuf
, 1, 12, abfd
) != 12)
2205 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->next
)
2210 name
= normalize_filename (sub
);
2211 namlen
= strlen (name
);
2212 if (bfd_write ((PTR
) name
, 1, namlen
+ 1, abfd
) != namlen
+ 1)
2215 if ((size
& 1) != 0)
2220 if (bfd_write ((PTR
) &b
, 1, 1, abfd
) != 1)
2224 /* Write out the armap, if appropriate. */
2226 if (! makemap
|| ! hasobjects
)
2227 sprintf (fhdr
.symoff
, "%d", 0);
2230 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2231 /* XXX This call actually should use %lld (at least on 32-bit
2232 machines) since the fields's width is 20 and there numbers with
2233 more than 32 bits can be represented. */
2234 bfd_ardata (abfd
)->tdata
= (PTR
) &fhdr
;
2235 if (! _bfd_compute_and_write_armap (abfd
, 0))
2239 /* Write out the archive file header. */
2241 /* We need spaces, not null bytes, in the header. */
2242 for (p
= (char *) &fhdr
; p
< (char *) &fhdr
+ SIZEOF_AR_FILE_HDR_BIG
; p
++)
2246 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
2247 || (bfd_write ((PTR
) &fhdr
, SIZEOF_AR_FILE_HDR_BIG
, 1, abfd
) !=
2248 SIZEOF_AR_FILE_HDR_BIG
))
2255 _bfd_xcoff_write_archive_contents (abfd
)
2258 if (! xcoff_big_format_p (abfd
))
2259 return xcoff_write_archive_contents_old (abfd
);
2261 return xcoff_write_archive_contents_big (abfd
);
2264 /* We can't use the usual coff_sizeof_headers routine, because AIX
2265 always uses an a.out header. */
2268 _bfd_xcoff_sizeof_headers (abfd
, reloc
)
2270 boolean reloc ATTRIBUTE_UNUSED
;
2275 if (xcoff_data (abfd
)->full_aouthdr
)
2278 size
+= SMALL_AOUTSZ
;
2279 size
+= abfd
->section_count
* SCNHSZ
;
2283 /* Routines to swap information in the XCOFF .loader section. If we
2284 ever need to write an XCOFF loader, this stuff will need to be
2285 moved to another file shared by the linker (which XCOFF calls the
2286 ``binder'') and the loader. */
2288 /* Swap in the ldhdr structure. */
2291 xcoff_swap_ldhdr_in (abfd
, s
, dst
)
2294 struct internal_ldhdr
*dst
;
2296 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
2298 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
2299 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
2300 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
2301 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
2302 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
2303 dst
->l_impoff
= bfd_get_32 (abfd
, src
->l_impoff
);
2304 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
2305 dst
->l_stoff
= bfd_get_32 (abfd
, src
->l_stoff
);
2308 /* Swap out the ldhdr structure. */
2311 xcoff_swap_ldhdr_out (abfd
, src
, d
)
2313 const struct internal_ldhdr
*src
;
2316 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
2318 bfd_put_32 (abfd
, src
->l_version
, dst
->l_version
);
2319 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
2320 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
2321 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
2322 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
2323 bfd_put_32 (abfd
, src
->l_impoff
, dst
->l_impoff
);
2324 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
2325 bfd_put_32 (abfd
, src
->l_stoff
, dst
->l_stoff
);
2328 /* Swap in the ldsym structure. */
2331 xcoff_swap_ldsym_in (abfd
, s
, dst
)
2334 struct internal_ldsym
*dst
;
2336 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
2338 if (bfd_get_32 (abfd
, src
->_l
._l_l
._l_zeroes
) != 0) {
2339 memcpy (dst
->_l
._l_name
, src
->_l
._l_name
, SYMNMLEN
);
2341 dst
->_l
._l_l
._l_zeroes
= 0;
2342 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->_l
._l_l
._l_offset
);
2344 dst
->l_value
= bfd_get_32 (abfd
, src
->l_value
);
2345 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
2346 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
2347 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
2348 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
2349 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
2352 /* Swap out the ldsym structure. */
2355 xcoff_swap_ldsym_out (abfd
, src
, d
)
2357 const struct internal_ldsym
*src
;
2360 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
2362 if (src
->_l
._l_l
._l_zeroes
!= 0)
2363 memcpy (dst
->_l
._l_name
, src
->_l
._l_name
, SYMNMLEN
);
2366 bfd_put_32 (abfd
, 0, dst
->_l
._l_l
._l_zeroes
);
2367 bfd_put_32 (abfd
, src
->_l
._l_l
._l_offset
, dst
->_l
._l_l
._l_offset
);
2369 bfd_put_32 (abfd
, src
->l_value
, dst
->l_value
);
2370 bfd_put_16 (abfd
, src
->l_scnum
, dst
->l_scnum
);
2371 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
2372 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
2373 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
2374 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
2377 /* Swap in the ldrel structure. */
2380 xcoff_swap_ldrel_in (abfd
, s
, dst
)
2383 struct internal_ldrel
*dst
;
2385 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
2387 dst
->l_vaddr
= bfd_get_32 (abfd
, src
->l_vaddr
);
2388 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
2389 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
2390 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
2393 /* Swap out the ldrel structure. */
2396 xcoff_swap_ldrel_out (abfd
, src
, d
)
2398 const struct internal_ldrel
*src
;
2401 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
2403 bfd_put_32 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
2404 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
2405 bfd_put_16 (abfd
, src
->l_rtype
, dst
->l_rtype
);
2406 bfd_put_16 (abfd
, src
->l_rsecnm
, dst
->l_rsecnm
);
2411 /* This is the relocation function for the RS/6000/POWER/PowerPC.
2412 This is currently the only processor which uses XCOFF; I hope that
2413 will never change. */
2416 xcoff_ppc_relocate_section (output_bfd
, info
, input_bfd
,
2417 input_section
, contents
, relocs
, syms
,
2420 struct bfd_link_info
*info
;
2422 asection
*input_section
;
2424 struct internal_reloc
*relocs
;
2425 struct internal_syment
*syms
;
2426 asection
**sections
;
2428 struct internal_reloc
*rel
;
2429 struct internal_reloc
*relend
;
2432 relend
= rel
+ input_section
->reloc_count
;
2434 for (; rel
< relend
; rel
++)
2437 struct xcoff_link_hash_entry
*h
;
2438 struct internal_syment
*sym
;
2441 struct reloc_howto_struct howto
;
2442 bfd_reloc_status_type rstat
;
2444 /* Relocation type R_REF is a special relocation type which is
2445 merely used to prevent garbage collection from occurring for
2446 the csect including the symbol which it references. */
2447 if (rel
->r_type
== R_REF
)
2450 symndx
= rel
->r_symndx
;
2460 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
2461 sym
= syms
+ symndx
;
2462 addend
= - sym
->n_value
;
2466 /* We build the howto information on the fly. */
2468 howto
.type
= rel
->r_type
;
2469 howto
.rightshift
= 0;
2471 howto
.bitsize
= (rel
->r_size
& 0x1f) + 1;
2472 howto
.pc_relative
= false;
2474 if ((rel
->r_size
& 0x80) != 0)
2475 howto
.complain_on_overflow
= complain_overflow_signed
;
2477 howto
.complain_on_overflow
= complain_overflow_bitfield
;
2478 howto
.special_function
= NULL
;
2479 howto
.name
= "internal";
2480 howto
.partial_inplace
= true;
2481 if (howto
.bitsize
== 32)
2482 howto
.src_mask
= howto
.dst_mask
= 0xffffffff;
2485 howto
.src_mask
= howto
.dst_mask
= (1 << howto
.bitsize
) - 1;
2486 if (howto
.bitsize
== 16)
2489 howto
.pcrel_offset
= false;
2499 sec
= bfd_abs_section_ptr
;
2504 sec
= sections
[symndx
];
2505 /* Hack to make sure we use the right TOC anchor value
2506 if this reloc is against the TOC anchor. */
2508 if (sec
->name
[3] == '0'
2509 && strcmp (sec
->name
, ".tc0") == 0)
2511 val
= xcoff_data (output_bfd
)->toc
;
2515 val
= (sec
->output_section
->vma
2516 + sec
->output_offset
2524 if (h
->root
.type
== bfd_link_hash_defined
2525 || h
->root
.type
== bfd_link_hash_defweak
)
2529 sec
= h
->root
.u
.def
.section
;
2530 val
= (h
->root
.u
.def
.value
2531 + sec
->output_section
->vma
2532 + sec
->output_offset
);
2534 else if (h
->root
.type
== bfd_link_hash_common
)
2538 sec
= h
->root
.u
.c
.p
->section
;
2539 val
= (sec
->output_section
->vma
2540 + sec
->output_offset
);
2542 else if ((h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
2543 || (h
->flags
& XCOFF_IMPORT
) != 0)
2545 /* Every symbol in a shared object is defined somewhere. */
2548 else if (! info
->relocateable
)
2550 if (! ((*info
->callbacks
->undefined_symbol
)
2551 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
2552 rel
->r_vaddr
- input_section
->vma
, true)))
2555 /* Don't try to process the reloc. It can't help, and
2556 it may generate another error. */
2561 /* I took the relocation type definitions from two documents:
2562 the PowerPC AIX Version 4 Application Binary Interface, First
2563 Edition (April 1992), and the PowerOpen ABI, Big-Endian
2564 32-Bit Hardware Implementation (June 30, 1994). Differences
2565 between the documents are noted below. */
2567 switch (rel
->r_type
)
2572 /* These relocs are defined by the PowerPC ABI to be
2573 relative branches which use half of the difference
2574 between the symbol and the program counter. I can't
2575 quite figure out when this is useful. These relocs are
2576 not defined by the PowerOpen ABI. */
2578 (*_bfd_error_handler
)
2579 (_("%s: unsupported relocation type 0x%02x"),
2580 bfd_get_filename (input_bfd
), (unsigned int) rel
->r_type
);
2581 bfd_set_error (bfd_error_bad_value
);
2584 /* Simple positive relocation. */
2587 /* Simple negative relocation. */
2591 /* Simple PC relative relocation. */
2592 howto
.pc_relative
= true;
2595 /* TOC relative relocation. The value in the instruction in
2596 the input file is the offset from the input file TOC to
2597 the desired location. We want the offset from the final
2598 TOC to the desired location. We have:
2603 so we must change insn by on - in.
2606 /* Global linkage relocation. The value of this relocation
2607 is the address of the entry in the TOC section. */
2609 /* Local object TOC address. I can't figure out the
2610 difference between this and case R_GL. */
2612 /* TOC relative relocation. A TOC relative load instruction
2613 which may be changed to a load address instruction.
2614 FIXME: We don't currently implement this optimization. */
2616 /* TOC relative relocation. This is a TOC relative load
2617 address instruction which may be changed to a load
2618 instruction. FIXME: I don't know if this is the correct
2620 if (h
!= NULL
&& h
->smclas
!= XMC_TD
)
2622 if (h
->toc_section
== NULL
)
2624 (*_bfd_error_handler
)
2625 (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
2626 bfd_get_filename (input_bfd
), rel
->r_vaddr
,
2627 h
->root
.root
.string
);
2628 bfd_set_error (bfd_error_bad_value
);
2632 BFD_ASSERT ((h
->flags
& XCOFF_SET_TOC
) == 0);
2633 val
= (h
->toc_section
->output_section
->vma
2634 + h
->toc_section
->output_offset
);
2637 val
= ((val
- xcoff_data (output_bfd
)->toc
)
2638 - (sym
->n_value
- xcoff_data (input_bfd
)->toc
));
2642 /* Absolute branch. We don't want to mess with the lower
2643 two bits of the instruction. */
2645 /* The PowerPC ABI defines this as an absolute call which
2646 may be modified to become a relative call. The PowerOpen
2647 ABI does not define this relocation type. */
2649 /* Absolute branch which may be modified to become a
2652 /* The PowerPC ABI defines this as an absolute branch to a
2653 fixed address which may be modified to an absolute branch
2654 to a symbol. The PowerOpen ABI does not define this
2657 /* The PowerPC ABI defines this as an absolute branch to a
2658 fixed address which may be modified to a relative branch.
2659 The PowerOpen ABI does not define this relocation type. */
2660 howto
.src_mask
&= ~3;
2661 howto
.dst_mask
= howto
.src_mask
;
2664 /* Relative branch. We don't want to mess with the lower
2665 two bits of the instruction. */
2667 /* The PowerPC ABI defines this as a relative call which may
2668 be modified to become an absolute call. The PowerOpen
2669 ABI does not define this relocation type. */
2671 /* A relative branch which may be modified to become an
2672 absolute branch. FIXME: We don't implement this,
2673 although we should for symbols of storage mapping class
2675 howto
.pc_relative
= true;
2676 howto
.src_mask
&= ~3;
2677 howto
.dst_mask
= howto
.src_mask
;
2680 /* The PowerPC AIX ABI describes this as a load which may be
2681 changed to a load address. The PowerOpen ABI says this
2682 is the same as case R_POS. */
2685 /* The PowerPC AIX ABI describes this as a load address
2686 which may be changed to a load. The PowerOpen ABI says
2687 this is the same as R_POS. */
2691 /* If we see an R_BR or R_RBR reloc which is jumping to global
2692 linkage code, and it is followed by an appropriate cror nop
2693 instruction, we replace the cror with lwz r2,20(r1). This
2694 restores the TOC after the glink code. Contrariwise, if the
2695 call is followed by a lwz r2,20(r1), but the call is not
2696 going to global linkage code, we can replace the load with a
2698 if ((rel
->r_type
== R_BR
|| rel
->r_type
== R_RBR
)
2700 && h
->root
.type
== bfd_link_hash_defined
2701 && (rel
->r_vaddr
- input_section
->vma
+ 8
2702 <= input_section
->_cooked_size
))
2707 pnext
= contents
+ (rel
->r_vaddr
- input_section
->vma
) + 4;
2708 next
= bfd_get_32 (input_bfd
, pnext
);
2710 /* The _ptrgl function is magic. It is used by the AIX
2711 compiler to call a function through a pointer. */
2712 if (h
->smclas
== XMC_GL
2713 || strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
2715 if (next
== 0x4def7b82 /* cror 15,15,15 */
2716 || next
== 0x4ffffb82 /* cror 31,31,31 */
2717 || next
== 0x60000000) /* ori r0,r0,0 */
2718 bfd_put_32 (input_bfd
, 0x80410014, pnext
); /* lwz r1,20(r1) */
2722 if (next
== 0x80410014) /* lwz r1,20(r1) */
2723 bfd_put_32 (input_bfd
, 0x60000000, pnext
); /* ori r0,r0,0 */
2727 /* A PC relative reloc includes the section address. */
2728 if (howto
.pc_relative
)
2729 addend
+= input_section
->vma
;
2731 rstat
= _bfd_final_link_relocate (&howto
, input_bfd
, input_section
,
2733 rel
->r_vaddr
- input_section
->vma
,
2742 case bfd_reloc_overflow
:
2745 char buf
[SYMNMLEN
+ 1];
2746 char howto_name
[10];
2751 name
= h
->root
.root
.string
;
2754 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
2759 sprintf (howto_name
, "0x%02x", rel
->r_type
);
2761 if (! ((*info
->callbacks
->reloc_overflow
)
2762 (info
, name
, howto_name
, (bfd_vma
) 0, input_bfd
,
2763 input_section
, rel
->r_vaddr
- input_section
->vma
)))
2773 _bfd_xcoff_put_ldsymbol_name (abfd
, ldinfo
, ldsym
, name
)
2774 bfd
*abfd ATTRIBUTE_UNUSED
;
2775 struct xcoff_loader_info
*ldinfo
;
2776 struct internal_ldsym
*ldsym
;
2780 len
= strlen (name
);
2782 if (len
<= SYMNMLEN
)
2783 strncpy (ldsym
->_l
._l_name
, name
, SYMNMLEN
);
2786 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
)
2789 bfd_byte
*newstrings
;
2791 newalc
= ldinfo
->string_alc
* 2;
2794 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
2797 newstrings
= ((bfd_byte
*)
2798 bfd_realloc ((PTR
) ldinfo
->strings
, newalc
));
2799 if (newstrings
== NULL
)
2801 ldinfo
->failed
= true;
2804 ldinfo
->string_alc
= newalc
;
2805 ldinfo
->strings
= newstrings
;
2808 bfd_put_16 (ldinfo
->output_bfd
, len
+ 1,
2809 ldinfo
->strings
+ ldinfo
->string_size
);
2810 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
2811 ldsym
->_l
._l_l
._l_zeroes
= 0;
2812 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
2813 ldinfo
->string_size
+= len
+ 3;
2820 _bfd_xcoff_put_symbol_name (bfd
*abfd
, struct bfd_strtab_hash
*strtab
,
2821 struct internal_syment
*sym
,
2824 if (strlen (name
) <= SYMNMLEN
)
2826 strncpy (sym
->_n
._n_name
, name
, SYMNMLEN
);
2834 if ((abfd
->flags
& BFD_TRADITIONAL_FORMAT
) != 0)
2836 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
2837 if (indx
== (bfd_size_type
) -1)
2839 sym
->_n
._n_n
._n_zeroes
= 0;
2840 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
2846 xcoff_create_csect_from_smclas (abfd
, aux
, symbol_name
)
2848 union internal_auxent
*aux
;
2849 const char *symbol_name
;
2851 asection
*return_value
= NULL
;
2853 /* .sv64 = x_smclas == 17
2854 This is an invalid csect for 32 bit apps. */
2855 static const char *names
[19] =
2857 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
2858 ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL
, ".tc0",
2859 ".td", NULL
, ".sv3264"
2862 if ((19 >= aux
->x_csect
.x_smclas
) &&
2863 (NULL
!= names
[aux
->x_csect
.x_smclas
]))
2865 return_value
= bfd_make_section_anyway
2866 (abfd
, names
[aux
->x_csect
.x_smclas
]);
2870 (*_bfd_error_handler
)
2871 (_("%s: symbol `%s' has unrecognized smclas %d"),
2872 bfd_get_filename (abfd
), symbol_name
, aux
->x_csect
.x_smclas
);
2873 bfd_set_error (bfd_error_bad_value
);
2876 return return_value
;
2880 xcoff_is_lineno_count_overflow (abfd
, value
)
2881 bfd
*abfd ATTRIBUTE_UNUSED
;
2884 if (0xffff <= value
)
2891 xcoff_is_reloc_count_overflow (abfd
, value
)
2892 bfd
*abfd ATTRIBUTE_UNUSED
;
2895 if (0xffff <= value
)
2902 xcoff_loader_symbol_offset (abfd
, ldhdr
)
2904 struct internal_ldhdr
*ldhdr ATTRIBUTE_UNUSED
;
2906 return bfd_xcoff_ldhdrsz(abfd
);
2910 xcoff_loader_reloc_offset (abfd
, ldhdr
)
2912 struct internal_ldhdr
*ldhdr
;
2914 return bfd_xcoff_ldhdrsz(abfd
) +
2915 (ldhdr
->l_nsyms
* bfd_xcoff_ldsymsz(abfd
));
2919 static reloc_howto_type xcoff_dynamic_reloc
=
2920 HOWTO (0, /* type */
2922 2, /* size (0 = byte, 1 = short, 2 = long) */
2924 false, /* pc_relative */
2926 complain_overflow_bitfield
, /* complain_on_overflow */
2927 0, /* special_function */
2929 true, /* partial_inplace */
2930 0xffffffff, /* src_mask */
2931 0xffffffff, /* dst_mask */
2932 false); /* pcrel_offset */
2936 The first word of global linkage code must be modified by filling in
2937 the correct TOC offset. */
2939 static unsigned long xcoff_glink_code
[9] =
2941 0x81820000, /* lwz r12,0(r2) */
2942 0x90410014, /* stw r2,20(r1) */
2943 0x800c0000, /* lwz r0,0(r12) */
2944 0x804c0004, /* lwz r2,4(r12) */
2945 0x7c0903a6, /* mtctr r0 */
2946 0x4e800420, /* bctr */
2947 0x00000000, /* start of traceback table */
2948 0x000c8000, /* traceback table */
2949 0x00000000, /* traceback table */
2953 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
2955 { /* COFF backend, defined in libcoff.h. */
2956 _bfd_xcoff_swap_aux_in
, /* _bfd_coff_swap_aux_in */
2957 _bfd_xcoff_swap_sym_in
, /* _bfd_coff_swap_sym_in */
2958 coff_swap_lineno_in
, /* _bfd_coff_swap_lineno_in */
2959 _bfd_xcoff_swap_aux_out
, /* _bfd_swap_aux_out */
2960 _bfd_xcoff_swap_sym_out
, /* _bfd_swap_sym_out */
2961 coff_swap_lineno_out
, /* _bfd_swap_lineno_out */
2962 coff_swap_reloc_out
, /* _bfd_swap_reloc_out */
2963 coff_swap_filehdr_out
, /* _bfd_swap_filehdr_out */
2964 coff_swap_aouthdr_out
, /* _bfd_swap_aouthdr_out */
2965 coff_swap_scnhdr_out
, /* _bfd_swap_scnhdr_out */
2966 FILHSZ
, /* _bfd_filhsz */
2967 AOUTSZ
, /* _bfd_aoutsz */
2968 SCNHSZ
, /* _bfd_scnhsz */
2969 SYMESZ
, /* _bfd_symesz */
2970 AUXESZ
, /* _bfd_auxesz */
2971 RELSZ
, /* _bfd_relsz */
2972 LINESZ
, /* _bfd_linesz */
2973 FILNMLEN
, /* _bfd_filnmlen */
2974 true, /* _bfd_coff_long_filenames */
2975 false, /* _bfd_coff_long_section_names */
2976 (3), /* _bfd_coff_default_section_alignment_power */
2977 false, /* _bfd_coff_force_symnames_in_strings */
2978 2, /* _bfd_coff_debug_string_prefix_length */
2979 coff_swap_filehdr_in
, /* _bfd_coff_swap_filehdr_in */
2980 coff_swap_aouthdr_in
, /* _bfd_swap_aouthdr_in */
2981 coff_swap_scnhdr_in
, /* _bfd_swap_scnhdr_in */
2982 coff_swap_reloc_in
, /* _bfd_reloc_in */
2983 coff_bad_format_hook
, /* _bfd_bad_format_hook */
2984 coff_set_arch_mach_hook
, /* _bfd_set_arch_mach_hook */
2985 coff_mkobject_hook
, /* _bfd_mkobject_hook */
2986 styp_to_sec_flags
, /* _bfd_syp_to_sec_flags */
2987 coff_set_alignment_hook
, /* _bfd_set_alignment_hook */
2988 coff_slurp_symbol_table
, /* _bfd_coff_slurp_symbol_table */
2989 symname_in_debug_hook
, /* _coff_symname_in_debug_hook */
2990 coff_pointerize_aux_hook
, /* _bfd_coff_pointerize_aux_hook */
2991 coff_print_aux
, /* bfd_coff_print_aux */
2992 dummy_reloc16_extra_cases
, /* _bfd_coff_reloc16_extra_cases */
2993 dummy_reloc16_estimate
, /* _bfd_coff_reloc16_estimate */
2994 NULL
, /* bfd_coff_sym_is_global */
2995 coff_compute_section_file_positions
, /* _bfd_coff_compute_section_file_positions */
2996 NULL
, /* _bfd_coff_start_final_link */
2997 xcoff_ppc_relocate_section
, /* _bfd_coff_relocate_section */
2998 coff_rtype_to_howto
, /* _bfd_coff_rtype_to_howto */
2999 NULL
, /* _bfd_coff_addust_symndx */
3000 _bfd_generic_link_add_one_symbol
, /* _bfd_coff_add_one_symbol */
3001 coff_link_output_has_begun
, /* _bfd_coff_link_output_has_begun */
3002 coff_final_link_postscript
/* _bfd_coff_final_link_postscript */
3005 0x01DF, /* magic number */
3006 bfd_arch_rs6000
, /* architecture */
3007 bfd_mach_rs6k
, /* machine */
3009 /* Function pointers to xcoff specific swap routines. */
3010 xcoff_swap_ldhdr_in
, /* _xcoff_swap_ldhdr_in */
3011 xcoff_swap_ldhdr_out
, /* _xcoff_swap_ldhdr_out */
3012 xcoff_swap_ldsym_in
, /* _xcoff_swap_ldsym_in */
3013 xcoff_swap_ldsym_out
, /* _xcoff_swap_ldsym_out */
3014 xcoff_swap_ldrel_in
, /* _xcoff_swap_ldrel_in */
3015 xcoff_swap_ldrel_out
, /* _xcoff_swap_ldrel_out */
3018 LDHDRSZ
, /* _xcoff_ldhdrsz */
3019 LDSYMSZ
, /* _xcoff_ldsymsz */
3020 LDRELSZ
, /* _xcoff_ldrelsz */
3021 12, /* _xcoff_function_descriptor_size */
3022 SMALL_AOUTSZ
, /* _xcoff_small_aout_header_size */
3025 1, /* _xcoff_ldhdr_version */
3027 /* Xcoff vs xcoff64 putting symbol names. */
3028 _bfd_xcoff_put_symbol_name
, /* _xcoff_put_symbol_name */
3029 _bfd_xcoff_put_ldsymbol_name
, /* _xcoff_put_ldsymbol_name */
3031 & xcoff_dynamic_reloc
, /* dynamic reloc howto */
3033 xcoff_create_csect_from_smclas
, /* _xcoff_create_csect_from_smclas */
3035 /* Lineno and reloc count overflow. */
3036 xcoff_is_lineno_count_overflow
,
3037 xcoff_is_reloc_count_overflow
,
3039 xcoff_loader_symbol_offset
,
3040 xcoff_loader_reloc_offset
,
3043 & xcoff_glink_code
[0],
3044 (36), /* _xcoff_glink_size */
3047 /* The transfer vector that leads the outside world to all of the above. */
3048 const bfd_target rs6000coff_vec
=
3051 bfd_target_xcoff_flavour
,
3052 BFD_ENDIAN_BIG
, /* data byte order is big */
3053 BFD_ENDIAN_BIG
, /* header byte order is big */
3055 (HAS_RELOC
| EXEC_P
| /* object flags */
3056 HAS_LINENO
| HAS_DEBUG
| DYNAMIC
|
3057 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
3059 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
3060 0, /* leading char */
3061 '/', /* ar_pad_char */
3062 15, /* ar_max_namelen??? FIXMEmgo */
3065 bfd_getb64
, /* bfd_getx64 */
3066 bfd_getb_signed_64
, /* bfd_getx_signed_64 */
3067 bfd_putb64
, /* bfd_putx64 */
3068 bfd_getb32
, /* bfd_getx32 */
3069 bfd_getb_signed_32
, /* bfd_getx_signed_32 */
3070 bfd_putb32
, /* bfd_putx32 */
3071 bfd_getb16
, /* bfd_getx16 */
3072 bfd_getb_signed_16
, /* bfd_getx_signed_16 */
3073 bfd_putb16
, /* bfd_putx16 */
3076 bfd_getb64
, /* bfd_h_getx64 */
3077 bfd_getb_signed_64
, /* bfd_h_getx_signed_64 */
3078 bfd_putb64
, /* bfd_h_putx64 */
3079 bfd_getb32
, /* bfd_h_getx32 */
3080 bfd_getb_signed_32
, /* bfd_h_getx_signed_32 */
3081 bfd_putb32
, /* bfd_h_putx32 */
3082 bfd_getb16
, /* bfd_h_getx16 */
3083 bfd_getb_signed_16
, /* bfd_h_getx_signed_16 */
3084 bfd_putb16
, /* bfd_h_putx16 */
3086 { /* bfd_check_format */
3089 _bfd_xcoff_archive_p
,
3093 { /* bfd_set_format */
3096 _bfd_generic_mkarchive
,
3100 {/* bfd_write_contents */
3102 coff_write_object_contents
,
3103 _bfd_xcoff_write_archive_contents
,
3108 bfd_true
, /* _close_and_cleanup */
3109 bfd_true
, /* _bfd_free_cached_info */
3110 coff_new_section_hook
, /* _new_section_hook */
3111 _bfd_generic_get_section_contents
, /* _bfd_get_section_contents */
3112 /* _bfd_get_section_contents_in_window */
3113 _bfd_generic_get_section_contents_in_window
,
3116 _bfd_xcoff_copy_private_bfd_data
, /* _bfd_copy_private_bfd */
3117 /* _bfd_merge_private_bfd_data */
3118 ((boolean (*) (bfd
*, bfd
*)) bfd_true
),
3119 /* _bfd_copy_pivate_section_data */
3120 ((boolean (*) (bfd
*, asection
*, bfd
*, asection
*)) bfd_true
),
3121 /* _bfd_copy_private_symbol_data */
3122 ((boolean (*) (bfd
*, asymbol
*, bfd
*, asymbol
*)) bfd_true
),
3123 ((boolean (*) (bfd
*, flagword
)) bfd_true
), /* _bfd_set_private_flags */
3124 ((boolean (*) (bfd
*, void * )) bfd_true
), /* _bfd_print_private_bfd_data */
3127 coff_core_file_failing_command
, /* _core_file_failing_command */
3128 coff_core_file_failing_signal
, /* _core_file_failing_signal */
3129 /* _core_file_matches_executable_p */
3130 coff_core_file_matches_executable_p
,
3133 _bfd_xcoff_slurp_armap
, /* _slurp_armap */
3134 /* XCOFF archives do not have
3135 anything which corresponds to
3136 an extended name table. */
3137 bfd_false
, /* _slurp_extended_name_table */
3138 /* _construct_extended_name_table */
3139 ((boolean (*) (bfd
*, char **, bfd_size_type
*, const char **)) bfd_false
),
3140 bfd_dont_truncate_arname
, /* _truncate_arname */
3141 _bfd_xcoff_write_armap
, /* _write_armap */
3142 _bfd_xcoff_read_ar_hdr
, /* _read_ar_hdr */
3143 _bfd_xcoff_openr_next_archived_file
, /* _openr_next_archived_file */
3144 _bfd_generic_get_elt_at_index
, /* _get_elt_at_index */
3145 _bfd_xcoff_generic_stat_arch_elt
, /* _generic_dtat_arch_elt */
3146 /* XCOFF archives do not have
3148 bfd_true
, /* _update_armap_timestamp */
3151 coff_get_symtab_upper_bound
, /* _get_symtab_upper_bound */
3152 coff_get_symtab
, /* _get_symtab */
3153 coff_make_empty_symbol
, /* _make_empty_symbol */
3154 coff_print_symbol
, /* _print_symbol */
3155 coff_get_symbol_info
, /* _get_symbol_info */
3156 _bfd_xcoff_is_local_label_name
, /* _bfd_is_local_label_name */
3157 coff_get_lineno
, /* _get_lineno */
3158 coff_find_nearest_line
, /* _find_nearest_line */
3159 coff_bfd_make_debug_symbol
, /* _bfd_make_debug_symbol */
3160 _bfd_generic_read_minisymbols
, /* _read_minisymbols */
3161 _bfd_generic_minisymbol_to_symbol
, /* _minsymbol_to_symbol */
3164 coff_get_reloc_upper_bound
, /* _get_reloc_upper_bound */
3165 coff_canonicalize_reloc
, /* _cononicalize_reloc */
3166 _bfd_xcoff_reloc_type_lookup
, /* _bfd_reloc_type_lookup */
3169 coff_set_arch_mach
, /* _set_arch_mach */
3170 coff_set_section_contents
, /* _set_section_contents */
3173 _bfd_xcoff_sizeof_headers
, /* _sizeof_headers */
3174 /* _bfd_get_relocated_section_contents */
3175 bfd_generic_get_relocated_section_contents
,
3176 bfd_generic_relax_section
, /* _bfd_relax_section */
3177 _bfd_xcoff_bfd_link_hash_table_create
, /* _bfd_link_hash_table_create */
3178 _bfd_xcoff_bfd_link_add_symbols
, /* _bfd_link_add_symbols */
3179 _bfd_xcoff_bfd_final_link
, /* _bfd_filnal_link */
3180 _bfd_generic_link_split_section
, /* _bfd_link_split_section */
3181 bfd_generic_gc_sections
, /* _bfd_gc_sections */
3182 bfd_generic_merge_sections
, /* _bfd_merge_sections */
3185 /* _get_dynamic_symtab_upper_bound */
3186 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
3187 _bfd_xcoff_canonicalize_dynamic_symtab
, /* _cononicalize_dynamic_symtab */
3188 _bfd_xcoff_get_dynamic_reloc_upper_bound
,/* _get_dynamic_reloc_upper_bound */
3189 _bfd_xcoff_canonicalize_dynamic_reloc
, /* _cononicalize_dynamic_reloc */
3191 /* Opposite endian version, none exists */
3195 (void *) &bfd_xcoff_backend_data
,
3199 * xcoff-powermac target
3201 * Only difference between this target and the rs6000 target is the
3202 * the default architecture and machine type used in coffcode.h
3204 * PowerPC Macs use the same magic numbers as RS/6000
3205 * (because that's how they were bootstrapped originally),
3206 * but they are always PowerPC architecture.
3208 static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data
=
3210 { /* COFF backend, defined in libcoff.h */
3211 _bfd_xcoff_swap_aux_in
, /* _bfd_coff_swap_aux_in */
3212 _bfd_xcoff_swap_sym_in
, /* _bfd_coff_swap_sym_in */
3213 coff_swap_lineno_in
, /* _bfd_coff_swap_lineno_in */
3214 _bfd_xcoff_swap_aux_out
, /* _bfd_swap_aux_out */
3215 _bfd_xcoff_swap_sym_out
, /* _bfd_swap_sym_out */
3216 coff_swap_lineno_out
, /* _bfd_swap_lineno_out */
3217 coff_swap_reloc_out
, /* _bfd_swap_reloc_out */
3218 coff_swap_filehdr_out
, /* _bfd_swap_filehdr_out */
3219 coff_swap_aouthdr_out
, /* _bfd_swap_aouthdr_out */
3220 coff_swap_scnhdr_out
, /* _bfd_swap_scnhdr_out */
3221 FILHSZ
, /* _bfd_filhsz */
3222 AOUTSZ
, /* _bfd_aoutsz */
3223 SCNHSZ
, /* _bfd_scnhsz */
3224 SYMESZ
, /* _bfd_symesz */
3225 AUXESZ
, /* _bfd_auxesz */
3226 RELSZ
, /* _bfd_relsz */
3227 LINESZ
, /* _bfd_linesz */
3228 FILNMLEN
, /* _bfd_filnmlen */
3229 true, /* _bfd_coff_long_filenames */
3230 false, /* _bfd_coff_long_section_names */
3231 (3), /* _bfd_coff_default_section_alignment_power */
3232 false, /* _bfd_coff_force_symnames_in_strings */
3233 2, /* _bfd_coff_debug_string_prefix_length */
3234 coff_swap_filehdr_in
, /* _bfd_coff_swap_filehdr_in */
3235 coff_swap_aouthdr_in
, /* _bfd_swap_aouthdr_in */
3236 coff_swap_scnhdr_in
, /* _bfd_swap_scnhdr_in */
3237 coff_swap_reloc_in
, /* _bfd_reloc_in */
3238 coff_bad_format_hook
, /* _bfd_bad_format_hook */
3239 coff_set_arch_mach_hook
, /* _bfd_set_arch_mach_hook */
3240 coff_mkobject_hook
, /* _bfd_mkobject_hook */
3241 styp_to_sec_flags
, /* _bfd_syp_to_sec_flags */
3242 coff_set_alignment_hook
, /* _bfd_set_alignment_hook */
3243 coff_slurp_symbol_table
, /* _bfd_coff_slurp_symbol_table */
3244 symname_in_debug_hook
, /* _coff_symname_in_debug_hook */
3245 coff_pointerize_aux_hook
, /* _bfd_coff_pointerize_aux_hook */
3246 coff_print_aux
, /* bfd_coff_print_aux */
3247 dummy_reloc16_extra_cases
, /* _bfd_coff_reloc16_extra_cases */
3248 dummy_reloc16_estimate
, /* _bfd_coff_reloc16_estimate */
3249 NULL
, /* bfd_coff_sym_is_global */
3250 /* _bfd_coff_compute_section_file_positions */
3251 coff_compute_section_file_positions
,
3252 NULL
, /* _bfd_coff_start_final_link */
3253 xcoff_ppc_relocate_section
, /* _bfd_coff_relocate_section */
3254 coff_rtype_to_howto
, /* _bfd_coff_rtype_to_howto */
3255 NULL
, /* _bfd_coff_addust_symndx */
3256 _bfd_generic_link_add_one_symbol
, /* _bfd_coff_add_one_symbol */
3257 coff_link_output_has_begun
, /* _bfd_coff_link_output_has_begun */
3258 coff_final_link_postscript
/* _bfd_coff_final_link_postscript */
3261 0x01DF, /* magic number */
3262 bfd_arch_powerpc
, /* architecture */
3263 bfd_mach_ppc
, /* machine */
3265 /* function pointers to xcoff specific swap routines */
3266 xcoff_swap_ldhdr_in
, /* _xcoff_swap_ldhdr_in */
3267 xcoff_swap_ldhdr_out
, /* _xcoff_swap_ldhdr_out */
3268 xcoff_swap_ldsym_in
, /* _xcoff_swap_ldsym_in */
3269 xcoff_swap_ldsym_out
, /* _xcoff_swap_ldsym_out */
3270 xcoff_swap_ldrel_in
, /* _xcoff_swap_ldrel_in */
3271 xcoff_swap_ldrel_out
, /* _xcoff_swap_ldrel_out */
3274 LDHDRSZ
, /* _xcoff_ldhdrsz */
3275 LDSYMSZ
, /* _xcoff_ldsymsz */
3276 LDRELSZ
, /* _xcoff_ldrelsz */
3277 12, /* _xcoff_function_descriptor_size */
3278 SMALL_AOUTSZ
, /* _xcoff_small_aout_header_size */
3281 1, /* _xcoff_ldhdr_version */
3283 /* xcoff vs xcoff64 putting symbol names */
3284 _bfd_xcoff_put_symbol_name
, /* _xcoff_put_symbol_name */
3285 _bfd_xcoff_put_ldsymbol_name
, /* _xcoff_put_ldsymbol_name */
3287 &xcoff_dynamic_reloc
, /* dynamic reloc howto */
3289 xcoff_create_csect_from_smclas
, /* _xcoff_create_csect_from_smclas */
3291 /* lineno and reloc count overflow */
3292 xcoff_is_lineno_count_overflow
,
3293 xcoff_is_reloc_count_overflow
,
3295 xcoff_loader_symbol_offset
,
3296 xcoff_loader_reloc_offset
,
3299 &xcoff_glink_code
[0],
3300 (36), /* _xcoff_glink_size */
3304 /* The transfer vector that leads the outside world to all of the above. */
3305 const bfd_target pmac_xcoff_vec
=
3308 bfd_target_xcoff_flavour
,
3309 BFD_ENDIAN_BIG
, /* data byte order is big */
3310 BFD_ENDIAN_BIG
, /* header byte order is big */
3312 (HAS_RELOC
| EXEC_P
| /* object flags */
3313 HAS_LINENO
| HAS_DEBUG
| DYNAMIC
|
3314 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
3316 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
3317 0, /* leading char */
3318 '/', /* ar_pad_char */
3319 15, /* ar_max_namelen??? FIXMEmgo */
3322 bfd_getb64
, /* bfd_getx64 */
3323 bfd_getb_signed_64
, /* bfd_getx_signed_64 */
3324 bfd_putb64
, /* bfd_putx64 */
3325 bfd_getb32
, /* bfd_getx32 */
3326 bfd_getb_signed_32
, /* bfd_getx_signed_32 */
3327 bfd_putb32
, /* bfd_putx32 */
3328 bfd_getb16
, /* bfd_getx16 */
3329 bfd_getb_signed_16
, /* bfd_getx_signed_16 */
3330 bfd_putb16
, /* bfd_putx16 */
3333 bfd_getb64
, /* bfd_h_getx64 */
3334 bfd_getb_signed_64
, /* bfd_h_getx_signed_64 */
3335 bfd_putb64
, /* bfd_h_putx64 */
3336 bfd_getb32
, /* bfd_h_getx32 */
3337 bfd_getb_signed_32
, /* bfd_h_getx_signed_32 */
3338 bfd_putb32
, /* bfd_h_putx32 */
3339 bfd_getb16
, /* bfd_h_getx16 */
3340 bfd_getb_signed_16
, /* bfd_h_getx_signed_16 */
3341 bfd_putb16
, /* bfd_h_putx16 */
3343 { /* bfd_check_format */
3346 _bfd_xcoff_archive_p
,
3350 { /* bfd_set_format */
3353 _bfd_generic_mkarchive
,
3357 {/* bfd_write_contents */
3359 coff_write_object_contents
,
3360 _bfd_xcoff_write_archive_contents
,
3365 bfd_true
, /* _close_and_cleanup */
3366 bfd_true
, /* _bfd_free_cached_info */
3367 coff_new_section_hook
, /* _new_section_hook */
3368 _bfd_generic_get_section_contents
, /* _bfd_get_section_contents */
3369 /* _bfd_get_section_contents_in_window */
3370 _bfd_generic_get_section_contents_in_window
,
3373 _bfd_xcoff_copy_private_bfd_data
, /* _bfd_copy_private_bfd */
3374 /* _bfd_merge_private_bfd_data */
3375 ((boolean (*) (bfd
*, bfd
*)) bfd_true
),
3376 /* _bfd_copy_pivate_section_data */
3377 ((boolean (*) (bfd
*, asection
*, bfd
*, asection
*)) bfd_true
),
3378 /* _bfd_copy_private_symbol_data */
3379 ((boolean (*) (bfd
*, asymbol
*, bfd
*, asymbol
*)) bfd_true
),
3380 ((boolean (*) (bfd
*, flagword
)) bfd_true
), /* _bfd_set_private_flags */
3381 ((boolean (*) (bfd
*, void * )) bfd_true
), /* _bfd_print_private_bfd_data */
3384 coff_core_file_failing_command
, /* _core_file_failing_command */
3385 coff_core_file_failing_signal
, /* _core_file_failing_signal */
3386 /* _core_file_matches_executable_p */
3387 coff_core_file_matches_executable_p
,
3390 _bfd_xcoff_slurp_armap
, /* _slurp_armap */
3391 /* XCOFF archives do not have
3392 anything which corresponds to
3393 an extended name table. */
3394 bfd_false
, /* _slurp_extended_name_table */
3395 /* _construct_extended_name_table */
3396 ((boolean (*) (bfd
*, char **, bfd_size_type
*, const char **)) bfd_false
),
3397 bfd_dont_truncate_arname
, /* _truncate_arname */
3398 _bfd_xcoff_write_armap
, /* _write_armap */
3399 _bfd_xcoff_read_ar_hdr
, /* _read_ar_hdr */
3400 _bfd_xcoff_openr_next_archived_file
, /* _openr_next_archived_file */
3401 _bfd_generic_get_elt_at_index
, /* _get_elt_at_index */
3402 _bfd_xcoff_generic_stat_arch_elt
, /* _generic_dtat_arch_elt */
3403 /* XCOFF archives do not have
3405 bfd_true
, /* _update_armap_timestamp */
3408 coff_get_symtab_upper_bound
, /* _get_symtab_upper_bound */
3409 coff_get_symtab
, /* _get_symtab */
3410 coff_make_empty_symbol
, /* _make_empty_symbol */
3411 coff_print_symbol
, /* _print_symbol */
3412 coff_get_symbol_info
, /* _get_symbol_info */
3413 _bfd_xcoff_is_local_label_name
, /* _bfd_is_local_label_name */
3414 coff_get_lineno
, /* _get_lineno */
3415 coff_find_nearest_line
, /* _find_nearest_line */
3416 coff_bfd_make_debug_symbol
, /* _bfd_make_debug_symbol */
3417 _bfd_generic_read_minisymbols
, /* _read_minisymbols */
3418 _bfd_generic_minisymbol_to_symbol
, /* _minsymbol_to_symbol */
3421 coff_get_reloc_upper_bound
, /* _get_reloc_upper_bound */
3422 coff_canonicalize_reloc
, /* _cononicalize_reloc */
3423 _bfd_xcoff_reloc_type_lookup
, /* _bfd_reloc_type_lookup */
3426 coff_set_arch_mach
, /* _set_arch_mach */
3427 coff_set_section_contents
, /* _set_section_contents */
3430 _bfd_xcoff_sizeof_headers
, /* _sizeof_headers */
3431 /* _bfd_get_relocated_section_contents */
3432 bfd_generic_get_relocated_section_contents
,
3433 bfd_generic_relax_section
, /* _bfd_relax_section */
3434 _bfd_xcoff_bfd_link_hash_table_create
, /* _bfd_link_hash_table_create */
3435 _bfd_xcoff_bfd_link_add_symbols
, /* _bfd_link_add_symbols */
3436 _bfd_xcoff_bfd_final_link
, /* _bfd_filnal_link */
3437 _bfd_generic_link_split_section
, /* _bfd_link_split_section */
3438 bfd_generic_gc_sections
, /* _bfd_gc_sections */
3439 bfd_generic_merge_sections
, /* _bfd_merge_sections */
3442 /* _get_dynamic_symtab_upper_bound */
3443 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
3444 _bfd_xcoff_canonicalize_dynamic_symtab
, /* _cononicalize_dynamic_symtab */
3445 _bfd_xcoff_get_dynamic_reloc_upper_bound
,/* _get_dynamic_reloc_upper_bound */
3446 _bfd_xcoff_canonicalize_dynamic_reloc
, /* _cononicalize_dynamic_reloc */
3448 /* Opposite endian version, none exists */
3452 (void *) &bfd_pmac_xcoff_backend_data
,