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) {
255 memcpy(in
->_n
._n_name
, ext
->e
.e_name
, SYMNMLEN
);
257 in
->_n
._n_n
._n_zeroes
= 0;
258 in
->_n
._n_n
._n_offset
=
259 bfd_h_get_32(abfd
, (bfd_byte
*) ext
->e
.e
.e_offset
);
262 in
->n_value
= bfd_h_get_32(abfd
, (bfd_byte
*) ext
->e_value
);
263 in
->n_scnum
= bfd_h_get_16(abfd
, (bfd_byte
*) ext
->e_scnum
);
264 in
->n_type
= bfd_h_get_16(abfd
, (bfd_byte
*) ext
->e_type
);
265 in
->n_sclass
= bfd_h_get_8(abfd
, ext
->e_sclass
);
266 in
->n_numaux
= bfd_h_get_8(abfd
, ext
->e_numaux
);
270 _bfd_xcoff_swap_sym_out (abfd
, inp
, extp
)
275 struct internal_syment
*in
= (struct internal_syment
*)inp
;
276 SYMENT
*ext
=(SYMENT
*)extp
;
278 if(in
->_n
._n_name
[0] != 0) {
279 memcpy(ext
->e
.e_name
, in
->_n
._n_name
, SYMNMLEN
);
281 bfd_h_put_32(abfd
, 0, (bfd_byte
*) ext
->e
.e
.e_zeroes
);
282 bfd_h_put_32(abfd
, in
->_n
._n_n
._n_offset
,
283 (bfd_byte
*) ext
->e
.e
.e_offset
);
286 bfd_h_put_32(abfd
, in
->n_value
, (bfd_byte
*) ext
->e_value
);
287 bfd_h_put_16(abfd
, in
->n_scnum
, (bfd_byte
*) ext
->e_scnum
);
288 bfd_h_put_16(abfd
, in
->n_type
, (bfd_byte
*) ext
->e_type
);
289 bfd_h_put_8(abfd
, in
->n_sclass
, ext
->e_sclass
);
290 bfd_h_put_8(abfd
, in
->n_numaux
, ext
->e_numaux
);
291 return bfd_coff_symesz (abfd
);
294 #define PUTWORD bfd_h_put_32
295 #define PUTHALF bfd_h_put_16
296 #define PUTBYTE bfd_h_put_8
297 #define GETWORD bfd_h_get_32
298 #define GETHALF bfd_h_get_16
299 #define GETBYTE bfd_h_get_8
302 _bfd_xcoff_swap_aux_in (abfd
, ext1
, type
, class, indx
, numaux
, in1
)
311 AUXENT
*ext
= (AUXENT
*)ext1
;
312 union internal_auxent
*in
= (union internal_auxent
*)in1
;
316 if (ext
->x_file
.x_fname
[0] == 0) {
317 in
->x_file
.x_n
.x_zeroes
= 0;
318 in
->x_file
.x_n
.x_offset
=
319 bfd_h_get_32(abfd
, (bfd_byte
*) ext
->x_file
.x_n
.x_offset
);
324 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_fname
,
325 numaux
* sizeof (AUXENT
));
329 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_fname
, FILNMLEN
);
334 /* RS/6000 "csect" auxents */
337 if (indx
+ 1 == numaux
)
339 in
->x_csect
.x_scnlen
.l
=
340 bfd_h_get_32 (abfd
, ext
->x_csect
.x_scnlen
);
341 in
->x_csect
.x_parmhash
= bfd_h_get_32 (abfd
,
342 ext
->x_csect
.x_parmhash
);
343 in
->x_csect
.x_snhash
= bfd_h_get_16 (abfd
, ext
->x_csect
.x_snhash
);
344 /* We don't have to hack bitfields in x_smtyp because it's
345 defined by shifts-and-ands, which are equivalent on all
347 in
->x_csect
.x_smtyp
= bfd_h_get_8 (abfd
, ext
->x_csect
.x_smtyp
);
348 in
->x_csect
.x_smclas
= bfd_h_get_8 (abfd
, ext
->x_csect
.x_smclas
);
349 in
->x_csect
.x_stab
= bfd_h_get_32 (abfd
, ext
->x_csect
.x_stab
);
350 in
->x_csect
.x_snstab
= bfd_h_get_16 (abfd
, ext
->x_csect
.x_snstab
);
358 if (type
== T_NULL
) {
359 in
->x_scn
.x_scnlen
= bfd_h_get_32(abfd
,
360 (bfd_byte
*) ext
->x_scn
.x_scnlen
);
361 in
->x_scn
.x_nreloc
= bfd_h_get_16(abfd
,
362 (bfd_byte
*) ext
->x_scn
.x_nreloc
);
363 in
->x_scn
.x_nlinno
= bfd_h_get_16(abfd
,
364 (bfd_byte
*) ext
->x_scn
.x_nlinno
);
365 /* PE defines some extra fields; we zero them out for
367 in
->x_scn
.x_checksum
= 0;
368 in
->x_scn
.x_associated
= 0;
369 in
->x_scn
.x_comdat
= 0;
376 in
->x_sym
.x_tagndx
.l
= bfd_h_get_32(abfd
, (bfd_byte
*) ext
->x_sym
.x_tagndx
);
377 in
->x_sym
.x_tvndx
= bfd_h_get_16(abfd
, (bfd_byte
*) ext
->x_sym
.x_tvndx
);
379 if (class == C_BLOCK
|| class == C_FCN
|| ISFCN (type
) || ISTAG (class))
381 in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
= bfd_h_get_32(abfd
, (bfd_byte
*)
382 ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
383 in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
= bfd_h_get_32(abfd
, (bfd_byte
*)
384 ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
388 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0] =
389 bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0]);
390 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1] =
391 bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1]);
392 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2] =
393 bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2]);
394 in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3] =
395 bfd_h_get_16 (abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3]);
398 in
->x_sym
.x_misc
.x_fsize
= bfd_h_get_32(abfd
, (bfd_byte
*) ext
->x_sym
.x_misc
.x_fsize
);
401 in
->x_sym
.x_misc
.x_lnsz
.x_lnno
= bfd_h_get_16(abfd
, (bfd_byte
*)
402 ext
->x_sym
.x_misc
.x_lnsz
.x_lnno
);
403 in
->x_sym
.x_misc
.x_lnsz
.x_size
= bfd_h_get_16(abfd
, (bfd_byte
*)
404 ext
->x_sym
.x_misc
.x_lnsz
.x_size
);
408 /* the semicolon is because MSVC doesn't like labels at
416 _bfd_xcoff_swap_aux_out (abfd
, inp
, type
, class, indx
, numaux
, extp
)
421 int indx ATTRIBUTE_UNUSED
;
422 int numaux ATTRIBUTE_UNUSED
;
425 union internal_auxent
*in
= (union internal_auxent
*)inp
;
426 AUXENT
*ext
= (AUXENT
*)extp
;
428 memset((PTR
)ext
, 0, bfd_coff_auxesz (abfd
));
432 if (in
->x_file
.x_fname
[0] == 0)
434 PUTWORD(abfd
, 0, (bfd_byte
*) ext
->x_file
.x_n
.x_zeroes
);
436 in
->x_file
.x_n
.x_offset
,
437 (bfd_byte
*) ext
->x_file
.x_n
.x_offset
);
441 memcpy (ext
->x_file
.x_fname
, in
->x_file
.x_fname
, FILNMLEN
);
445 /* RS/6000 "csect" auxents */
448 if (indx
+ 1 == numaux
)
450 PUTWORD (abfd
, in
->x_csect
.x_scnlen
.l
,ext
->x_csect
.x_scnlen
);
451 PUTWORD (abfd
, in
->x_csect
.x_parmhash
, ext
->x_csect
.x_parmhash
);
452 PUTHALF (abfd
, in
->x_csect
.x_snhash
, ext
->x_csect
.x_snhash
);
453 /* We don't have to hack bitfields in x_smtyp because it's
454 defined by shifts-and-ands, which are equivalent on all
456 PUTBYTE (abfd
, in
->x_csect
.x_smtyp
, ext
->x_csect
.x_smtyp
);
457 PUTBYTE (abfd
, in
->x_csect
.x_smclas
, ext
->x_csect
.x_smclas
);
458 PUTWORD (abfd
, in
->x_csect
.x_stab
, ext
->x_csect
.x_stab
);
459 PUTHALF (abfd
, in
->x_csect
.x_snstab
, ext
->x_csect
.x_snstab
);
467 if (type
== T_NULL
) {
468 bfd_h_put_32(abfd
, in
->x_scn
.x_scnlen
, (bfd_byte
*) ext
->x_scn
.x_scnlen
);
469 bfd_h_put_16(abfd
, in
->x_scn
.x_nreloc
, (bfd_byte
*) ext
->x_scn
.x_nreloc
);
470 bfd_h_put_16(abfd
, in
->x_scn
.x_nlinno
, (bfd_byte
*) ext
->x_scn
.x_nlinno
);
476 PUTWORD(abfd
, in
->x_sym
.x_tagndx
.l
, (bfd_byte
*) ext
->x_sym
.x_tagndx
);
477 bfd_h_put_16 (abfd
, in
->x_sym
.x_tvndx
, (bfd_byte
*) ext
->x_sym
.x_tvndx
);
479 if (class == C_BLOCK
|| class == C_FCN
|| ISFCN (type
) || ISTAG (class))
481 bfd_h_put_32(abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
,
482 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
483 PUTWORD(abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
,
484 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
488 bfd_h_put_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0],
489 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[0]);
490 bfd_h_put_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1],
491 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[1]);
492 bfd_h_put_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2],
493 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[2]);
494 bfd_h_put_16 (abfd
, in
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3],
495 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_ary
.x_dimen
[3]);
499 PUTWORD (abfd
, in
->x_sym
.x_misc
.x_fsize
,
500 (bfd_byte
*) ext
->x_sym
.x_misc
.x_fsize
);
503 bfd_h_put_16(abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_lnno
,
504 (bfd_byte
*)ext
->x_sym
.x_misc
.x_lnsz
.x_lnno
);
505 bfd_h_put_16(abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_size
,
506 (bfd_byte
*)ext
->x_sym
.x_misc
.x_lnsz
.x_size
);
510 return bfd_coff_auxesz (abfd
);
515 /* The XCOFF reloc table. Actually, XCOFF relocations specify the
516 bitsize and whether they are signed or not, along with a
517 conventional type. This table is for the types, which are used for
518 different algorithms for putting in the reloc. Many of these
519 relocs need special_function entries, which I have not written. */
522 reloc_howto_type xcoff_howto_table
[] =
524 /* Standard 32 bit relocation. */
527 2, /* size (0 = byte, 1 = short, 2 = long) */
529 false, /* pc_relative */
531 complain_overflow_bitfield
, /* complain_on_overflow */
532 0, /* special_function */
534 true, /* partial_inplace */
535 0xffffffff, /* src_mask */
536 0xffffffff, /* dst_mask */
537 false), /* pcrel_offset */
539 /* 32 bit relocation, but store negative value. */
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 PC relative relocation. */
557 2, /* size (0 = byte, 1 = short, 2 = long) */
559 true, /* pc_relative */
561 complain_overflow_signed
, /* complain_on_overflow */
562 0, /* special_function */
564 true, /* partial_inplace */
565 0xffffffff, /* src_mask */
566 0xffffffff, /* dst_mask */
567 false), /* pcrel_offset */
569 /* 16 bit TOC relative relocation. */
572 1, /* size (0 = byte, 1 = short, 2 = long) */
574 false, /* pc_relative */
576 complain_overflow_bitfield
, /* complain_on_overflow */
577 0, /* special_function */
579 true, /* partial_inplace */
580 0xffff, /* src_mask */
581 0xffff, /* dst_mask */
582 false), /* pcrel_offset */
584 /* I don't really know what this is. */
587 2, /* 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 0xffffffff, /* src_mask */
596 0xffffffff, /* dst_mask */
597 false), /* pcrel_offset */
599 /* External TOC relative symbol. */
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 0xffff, /* src_mask */
611 0xffff, /* dst_mask */
612 false), /* pcrel_offset */
614 /* Local 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 */
631 /* Non modifiable absolute branch. */
634 2, /* size (0 = byte, 1 = short, 2 = long) */
636 false, /* pc_relative */
638 complain_overflow_bitfield
, /* complain_on_overflow */
639 0, /* special_function */
641 true, /* partial_inplace */
642 0x3fffffc, /* src_mask */
643 0x3fffffc, /* dst_mask */
644 false), /* pcrel_offset */
648 /* Non modifiable relative branch. */
649 HOWTO (0xa, /* type */
651 2, /* size (0 = byte, 1 = short, 2 = long) */
653 true, /* pc_relative */
655 complain_overflow_signed
, /* complain_on_overflow */
656 0, /* special_function */
658 true, /* partial_inplace */
659 0x3fffffc, /* src_mask */
660 0x3fffffc, /* dst_mask */
661 false), /* pcrel_offset */
666 HOWTO (0xc, /* type */
668 2, /* size (0 = byte, 1 = short, 2 = long) */
670 false, /* pc_relative */
672 complain_overflow_bitfield
, /* complain_on_overflow */
673 0, /* special_function */
675 true, /* partial_inplace */
676 0xffff, /* src_mask */
677 0xffff, /* dst_mask */
678 false), /* pcrel_offset */
681 HOWTO (0xd, /* 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 */
697 /* Non-relocating reference. */
698 HOWTO (0xf, /* type */
700 2, /* size (0 = byte, 1 = short, 2 = long) */
702 false, /* pc_relative */
704 complain_overflow_bitfield
, /* complain_on_overflow */
705 0, /* special_function */
707 false, /* partial_inplace */
710 false), /* pcrel_offset */
715 /* TOC relative indirect load. */
716 HOWTO (0x12, /* type */
718 2, /* size (0 = byte, 1 = short, 2 = long) */
720 false, /* pc_relative */
722 complain_overflow_bitfield
, /* complain_on_overflow */
723 0, /* special_function */
725 true, /* partial_inplace */
726 0xffff, /* src_mask */
727 0xffff, /* dst_mask */
728 false), /* pcrel_offset */
730 /* TOC relative load address. */
731 HOWTO (0x13, /* 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 /* Modifiable relative branch. */
746 HOWTO (0x14, /* 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 */
754 "R_RRTBI", /* name */
755 true, /* partial_inplace */
756 0xffffffff, /* src_mask */
757 0xffffffff, /* dst_mask */
758 false), /* pcrel_offset */
760 /* Modifiable absolute branch. */
761 HOWTO (0x15, /* 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_RRTBA", /* name */
770 true, /* partial_inplace */
771 0xffffffff, /* src_mask */
772 0xffffffff, /* dst_mask */
773 false), /* pcrel_offset */
775 /* Modifiable call absolute indirect. */
776 HOWTO (0x16, /* 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 */
785 true, /* partial_inplace */
786 0xffff, /* src_mask */
787 0xffff, /* dst_mask */
788 false), /* pcrel_offset */
790 /* Modifiable call relative. */
791 HOWTO (0x17, /* 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 branch absolute. */
806 HOWTO (0x18, /* 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 (0x19, /* 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 relative. */
836 HOWTO (0x1a, /* type */
838 2, /* size (0 = byte, 1 = short, 2 = long) */
840 false, /* pc_relative */
842 complain_overflow_signed
, /* 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 absolute. */
851 HOWTO (0x1b, /* type */
853 2, /* size (0 = byte, 1 = short, 2 = long) */
855 false, /* pc_relative */
857 complain_overflow_bitfield
, /* complain_on_overflow */
858 0, /* special_function */
860 true, /* partial_inplace */
861 0xffff, /* src_mask */
862 0xffff, /* dst_mask */
863 false), /* pcrel_offset */
867 4, /* size (0 = byte, 1 = short, 2 = long) */
869 false, /* pc_relative */
871 complain_overflow_bitfield
, /* complain_on_overflow */
872 0, /* special_function */
874 true, /* partial_inplace */
875 MINUS_ONE
, /* src_mask */
876 MINUS_ONE
, /* dst_mask */
877 false) /* pcrel_offset */
882 _bfd_xcoff_rtype2howto (relent
, internal
)
884 struct internal_reloc
*internal
;
886 relent
->howto
= xcoff_howto_table
+ internal
->r_type
;
888 /* Check for relocs we don't know of. */
890 >= sizeof (xcoff_howto_table
) / sizeof (xcoff_howto_table
[0]))
892 if (internal
->r_type
!= relent
->howto
->type
)
895 /* The r_size field of an XCOFF reloc encodes the bitsize of the
896 relocation, as well as indicating whether it is signed or not.
897 Doublecheck that the relocation information gathered from the
898 type matches this information. The bitsize is not significant
900 if (relent
->howto
->dst_mask
!= 0
901 && (relent
->howto
->bitsize
902 != ((unsigned int) internal
->r_size
& 0x3f) + 1))
905 if ((internal
->r_size
& 0x80) != 0
906 ? (relent
->howto
->complain_on_overflow
!= complain_overflow_signed
)
907 : (relent
->howto
->complain_on_overflow
!= complain_overflow_bitfield
))
913 _bfd_xcoff_reloc_type_lookup (abfd
, code
)
914 bfd
*abfd ATTRIBUTE_UNUSED
;
915 bfd_reloc_code_real_type code
;
919 case BFD_RELOC_PPC_B26
:
920 return &xcoff_howto_table
[0xa];
921 case BFD_RELOC_PPC_BA26
:
922 return &xcoff_howto_table
[8];
923 case BFD_RELOC_PPC_TOC16
:
924 return &xcoff_howto_table
[3];
927 return &xcoff_howto_table
[0];
929 return &xcoff_howto_table
[0x1c];
936 /* XCOFF archive support. The original version of this code was by
937 Damon A. Permezel. It was enhanced to permit cross support, and
938 writing archive files, by Ian Lance Taylor, Cygnus Support.
940 XCOFF uses its own archive format. Everything is hooked together
941 with file offset links, so it is possible to rapidly update an
942 archive in place. Of course, we don't do that. An XCOFF archive
943 has a real file header, not just an ARMAG string. The structure of
944 the file header and of each archive header appear below.
946 An XCOFF archive also has a member table, which is a list of
947 elements in the archive (you can get that by looking through the
948 linked list, but you have to read a lot more of the file). The
949 member table has a normal archive header with an empty name. It is
950 normally (and perhaps must be) the second to last entry in the
951 archive. The member table data is almost printable ASCII. It
952 starts with a 12 character decimal string which is the number of
953 entries in the table. For each entry it has a 12 character decimal
954 string which is the offset in the archive of that member. These
955 entries are followed by a series of null terminated strings which
956 are the member names for each entry.
958 Finally, an XCOFF archive has a global symbol table, which is what
959 we call the armap. The global symbol table has a normal archive
960 header with an empty name. It is normally (and perhaps must be)
961 the last entry in the archive. The contents start with a four byte
962 binary number which is the number of entries. This is followed by
963 a that many four byte binary numbers; each is the file offset of an
964 entry in the archive. These numbers are followed by a series of
965 null terminated strings, which are symbol names.
967 AIX 4.3 introduced a new archive format which can handle larger
968 files and also 32- and 64-bit objects in the same archive. The
969 things said above remain true except that there is now more than
970 one global symbol table. The one is used to index 32-bit objects,
971 the other for 64-bit objects.
973 The new archives (recognizable by the new ARMAG string) has larger
974 field lengths so that we cannot really share any code. Also we have
975 to take care that we are not generating the new form of archives
976 on AIX 4.2 or earlier systems. */
978 /* XCOFF archives use this as a magic string. Note that both strings
979 have the same length. */
983 /* Read in the armap of an XCOFF archive. */
986 _bfd_xcoff_slurp_armap (abfd
)
992 bfd_byte
*contents
, *cend
;
997 if (xcoff_ardata (abfd
) == NULL
)
999 bfd_has_map (abfd
) = false;
1003 if (! xcoff_big_format_p (abfd
))
1005 /* This is for the old format. */
1006 struct xcoff_ar_hdr hdr
;
1008 off
= strtol (xcoff_ardata (abfd
)->symoff
, (char **) NULL
, 10);
1011 bfd_has_map (abfd
) = false;
1015 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1018 /* The symbol table starts with a normal archive header. */
1019 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR
, 1, abfd
) != SIZEOF_AR_HDR
)
1022 /* Skip the name (normally empty). */
1023 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1024 if (bfd_seek (abfd
, ((namlen
+ 1) & ~1) + SXCOFFARFMAG
, SEEK_CUR
) != 0)
1027 sz
= strtol (hdr
.size
, (char **) NULL
, 10);
1029 /* Read in the entire symbol table. */
1030 contents
= (bfd_byte
*) bfd_alloc (abfd
, sz
);
1031 if (contents
== NULL
)
1033 if (bfd_read ((PTR
) contents
, 1, sz
, abfd
) != sz
)
1036 /* The symbol table starts with a four byte count. */
1037 c
= bfd_h_get_32 (abfd
, contents
);
1041 bfd_set_error (bfd_error_bad_value
);
1045 bfd_ardata (abfd
)->symdefs
= ((carsym
*)
1046 bfd_alloc (abfd
, c
* sizeof (carsym
)));
1047 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1050 /* After the count comes a list of four byte file offsets. */
1051 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 4;
1053 ++i
, ++arsym
, p
+= 4)
1054 arsym
->file_offset
= bfd_h_get_32 (abfd
, p
);
1058 /* This is for the new format. */
1059 struct xcoff_ar_hdr_big hdr
;
1061 off
= strtol (xcoff_ardata_big (abfd
)->symoff
, (char **) NULL
, 10);
1064 bfd_has_map (abfd
) = false;
1068 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1071 /* The symbol table starts with a normal archive header. */
1072 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR_BIG
, 1, abfd
)
1073 != SIZEOF_AR_HDR_BIG
)
1076 /* Skip the name (normally empty). */
1077 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1078 if (bfd_seek (abfd
, ((namlen
+ 1) & ~1) + SXCOFFARFMAG
, SEEK_CUR
) != 0)
1081 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1082 machines) since the field width is 20 and there numbers with more
1083 than 32 bits can be represented. */
1084 sz
= strtol (hdr
.size
, (char **) NULL
, 10);
1086 /* Read in the entire symbol table. */
1087 contents
= (bfd_byte
*) bfd_alloc (abfd
, sz
);
1088 if (contents
== NULL
)
1090 if (bfd_read ((PTR
) contents
, 1, sz
, abfd
) != sz
)
1093 /* The symbol table starts with an eight byte count. */
1094 c
= bfd_h_get_64 (abfd
, contents
);
1098 bfd_set_error (bfd_error_bad_value
);
1102 bfd_ardata (abfd
)->symdefs
= ((carsym
*)
1103 bfd_alloc (abfd
, c
* sizeof (carsym
)));
1104 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1107 /* After the count comes a list of eight byte file offsets. */
1108 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1110 ++i
, ++arsym
, p
+= 8)
1111 arsym
->file_offset
= bfd_h_get_64 (abfd
, p
);
1114 /* After the file offsets come null terminated symbol names. */
1115 cend
= contents
+ sz
;
1116 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1118 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1122 bfd_set_error (bfd_error_bad_value
);
1125 arsym
->name
= (char *) p
;
1128 bfd_ardata (abfd
)->symdef_count
= c
;
1129 bfd_has_map (abfd
) = true;
1134 /* See if this is an XCOFF archive. */
1137 _bfd_xcoff_archive_p (abfd
)
1140 char magic
[SXCOFFARMAG
];
1142 if (bfd_read ((PTR
) magic
, SXCOFFARMAG
, 1, abfd
) != SXCOFFARMAG
)
1144 if (bfd_get_error () != bfd_error_system_call
)
1145 bfd_set_error (bfd_error_wrong_format
);
1149 if (strncmp (magic
, XCOFFARMAG
, SXCOFFARMAG
) != 0
1150 && strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0)
1152 bfd_set_error (bfd_error_wrong_format
);
1156 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
1157 involves a cast, we can't do it as the left operand of
1159 abfd
->tdata
.aout_ar_data
=
1160 (struct artdata
*) bfd_zalloc (abfd
, sizeof (struct artdata
));
1162 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1165 bfd_ardata (abfd
)->cache
= NULL
;
1166 bfd_ardata (abfd
)->archive_head
= NULL
;
1167 bfd_ardata (abfd
)->symdefs
= NULL
;
1168 bfd_ardata (abfd
)->extended_names
= NULL
;
1170 /* Now handle the two formats. */
1171 if (magic
[1] != 'b')
1173 /* This is the old format. */
1174 struct xcoff_ar_file_hdr hdr
;
1176 /* Copy over the magic string. */
1177 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1179 /* Now read the rest of the file header. */
1180 if (bfd_read ((PTR
) &hdr
.memoff
, SIZEOF_AR_FILE_HDR
- SXCOFFARMAG
, 1,
1181 abfd
) != SIZEOF_AR_FILE_HDR
- SXCOFFARMAG
)
1183 if (bfd_get_error () != bfd_error_system_call
)
1184 bfd_set_error (bfd_error_wrong_format
);
1188 bfd_ardata (abfd
)->first_file_filepos
= strtol (hdr
.firstmemoff
,
1189 (char **) NULL
, 10);
1191 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, SIZEOF_AR_FILE_HDR
);
1192 if (bfd_ardata (abfd
)->tdata
== NULL
)
1195 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR
);
1199 /* This is the new format. */
1200 struct xcoff_ar_file_hdr_big hdr
;
1202 /* Copy over the magic string. */
1203 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1205 /* Now read the rest of the file header. */
1206 if (bfd_read ((PTR
) &hdr
.memoff
, SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
, 1,
1207 abfd
) != SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
)
1209 if (bfd_get_error () != bfd_error_system_call
)
1210 bfd_set_error (bfd_error_wrong_format
);
1214 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1215 machines) since the field width is 20 and there numbers with more
1216 than 32 bits can be represented. */
1217 bfd_ardata (abfd
)->first_file_filepos
= strtol (hdr
.firstmemoff
,
1218 (char **) NULL
, 10);
1220 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, SIZEOF_AR_FILE_HDR_BIG
);
1221 if (bfd_ardata (abfd
)->tdata
== NULL
)
1224 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1227 if (! _bfd_xcoff_slurp_armap (abfd
))
1229 bfd_release (abfd
, bfd_ardata (abfd
));
1230 abfd
->tdata
.aout_ar_data
= (struct artdata
*) NULL
;
1237 /* Read the archive header in an XCOFF archive. */
1240 _bfd_xcoff_read_ar_hdr (abfd
)
1244 struct areltdata
*ret
;
1246 ret
= (struct areltdata
*) bfd_alloc (abfd
, sizeof (struct areltdata
));
1250 if (! xcoff_big_format_p (abfd
))
1252 struct xcoff_ar_hdr hdr
;
1253 struct xcoff_ar_hdr
*hdrp
;
1255 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR
, 1, abfd
) != SIZEOF_AR_HDR
)
1261 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1262 hdrp
= (struct xcoff_ar_hdr
*) bfd_alloc (abfd
,
1263 SIZEOF_AR_HDR
+ namlen
+ 1);
1269 memcpy (hdrp
, &hdr
, SIZEOF_AR_HDR
);
1270 if (bfd_read ((char *) hdrp
+ SIZEOF_AR_HDR
, 1, namlen
, abfd
) != namlen
)
1275 ((char *) hdrp
)[SIZEOF_AR_HDR
+ namlen
] = '\0';
1277 ret
->arch_header
= (char *) hdrp
;
1278 ret
->parsed_size
= strtol (hdr
.size
, (char **) NULL
, 10);
1279 ret
->filename
= (char *) hdrp
+ SIZEOF_AR_HDR
;
1283 struct xcoff_ar_hdr_big hdr
;
1284 struct xcoff_ar_hdr_big
*hdrp
;
1286 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR_BIG
, 1, abfd
)
1287 != SIZEOF_AR_HDR_BIG
)
1293 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1294 hdrp
= (struct xcoff_ar_hdr_big
*) bfd_alloc (abfd
,
1302 memcpy (hdrp
, &hdr
, SIZEOF_AR_HDR_BIG
);
1303 if (bfd_read ((char *) hdrp
+ SIZEOF_AR_HDR_BIG
, 1, namlen
, abfd
) != namlen
)
1308 ((char *) hdrp
)[SIZEOF_AR_HDR_BIG
+ namlen
] = '\0';
1310 ret
->arch_header
= (char *) hdrp
;
1311 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1312 machines) since the field width is 20 and there numbers with more
1313 than 32 bits can be represented. */
1314 ret
->parsed_size
= strtol (hdr
.size
, (char **) NULL
, 10);
1315 ret
->filename
= (char *) hdrp
+ SIZEOF_AR_HDR_BIG
;
1318 /* Skip over the XCOFFARFMAG at the end of the file name. */
1319 if (bfd_seek (abfd
, (namlen
& 1) + SXCOFFARFMAG
, SEEK_CUR
) != 0)
1325 /* Open the next element in an XCOFF archive. */
1328 _bfd_xcoff_openr_next_archived_file (archive
, last_file
)
1334 if (xcoff_ardata (archive
) == NULL
)
1336 bfd_set_error (bfd_error_invalid_operation
);
1340 if (! xcoff_big_format_p (archive
))
1342 if (last_file
== NULL
)
1343 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1345 filestart
= strtol (arch_xhdr (last_file
)->nextoff
, (char **) NULL
,
1349 || filestart
== strtol (xcoff_ardata (archive
)->memoff
,
1351 || filestart
== strtol (xcoff_ardata (archive
)->symoff
,
1352 (char **) NULL
, 10))
1354 bfd_set_error (bfd_error_no_more_archived_files
);
1360 if (last_file
== NULL
)
1361 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1363 /* XXX These actually have to be a calls to strtoll (at least
1364 on 32-bit machines) since the fields's width is 20 and
1365 there numbers with more than 32 bits can be represented. */
1366 filestart
= strtol (arch_xhdr_big (last_file
)->nextoff
, (char **) NULL
,
1369 /* XXX These actually have to be calls to strtoll (at least on 32-bit
1370 machines) since the fields's width is 20 and there numbers with more
1371 than 32 bits can be represented. */
1373 || filestart
== strtol (xcoff_ardata_big (archive
)->memoff
,
1375 || filestart
== strtol (xcoff_ardata_big (archive
)->symoff
,
1376 (char **) NULL
, 10))
1378 bfd_set_error (bfd_error_no_more_archived_files
);
1383 return _bfd_get_elt_at_filepos (archive
, filestart
);
1386 /* Stat an element in an XCOFF archive. */
1389 _bfd_xcoff_generic_stat_arch_elt (abfd
, s
)
1393 if (abfd
->arelt_data
== NULL
)
1395 bfd_set_error (bfd_error_invalid_operation
);
1399 if (! xcoff_big_format_p (abfd
))
1401 struct xcoff_ar_hdr
*hdrp
= arch_xhdr (abfd
);
1403 s
->st_mtime
= strtol (hdrp
->date
, (char **) NULL
, 10);
1404 s
->st_uid
= strtol (hdrp
->uid
, (char **) NULL
, 10);
1405 s
->st_gid
= strtol (hdrp
->gid
, (char **) NULL
, 10);
1406 s
->st_mode
= strtol (hdrp
->mode
, (char **) NULL
, 8);
1407 s
->st_size
= arch_eltdata (abfd
)->parsed_size
;
1411 struct xcoff_ar_hdr_big
*hdrp
= arch_xhdr_big (abfd
);
1413 s
->st_mtime
= strtol (hdrp
->date
, (char **) NULL
, 10);
1414 s
->st_uid
= strtol (hdrp
->uid
, (char **) NULL
, 10);
1415 s
->st_gid
= strtol (hdrp
->gid
, (char **) NULL
, 10);
1416 s
->st_mode
= strtol (hdrp
->mode
, (char **) NULL
, 8);
1417 s
->st_size
= arch_eltdata (abfd
)->parsed_size
;
1423 /* Normalize a file name for inclusion in an archive. */
1426 normalize_filename (abfd
)
1430 const char *filename
;
1432 file
= bfd_get_filename (abfd
);
1433 filename
= strrchr (file
, '/');
1434 if (filename
!= NULL
)
1441 /* Write out an XCOFF armap. */
1445 xcoff_write_armap_old (abfd
, elength
, map
, orl_count
, stridx
)
1447 unsigned int elength ATTRIBUTE_UNUSED
;
1449 unsigned int orl_count
;
1452 struct xcoff_ar_hdr hdr
;
1454 unsigned char buf
[4];
1459 memset (&hdr
, 0, sizeof hdr
);
1460 sprintf (hdr
.size
, "%ld", (long) (4 + orl_count
* 4 + stridx
));
1461 sprintf (hdr
.nextoff
, "%d", 0);
1462 memcpy (hdr
.prevoff
, xcoff_ardata (abfd
)->memoff
, 12);
1463 sprintf (hdr
.date
, "%d", 0);
1464 sprintf (hdr
.uid
, "%d", 0);
1465 sprintf (hdr
.gid
, "%d", 0);
1466 sprintf (hdr
.mode
, "%d", 0);
1467 sprintf (hdr
.namlen
, "%d", 0);
1469 /* We need spaces, not null bytes, in the header. */
1470 for (p
= (char *) &hdr
; p
< (char *) &hdr
+ SIZEOF_AR_HDR
; p
++)
1474 if (bfd_write ((PTR
) &hdr
, SIZEOF_AR_HDR
, 1, abfd
) != SIZEOF_AR_HDR
1475 || bfd_write (XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
) != SXCOFFARFMAG
)
1478 bfd_h_put_32 (abfd
, orl_count
, buf
);
1479 if (bfd_write (buf
, 1, 4, abfd
) != 4)
1482 sub
= abfd
->archive_head
;
1483 fileoff
= SIZEOF_AR_FILE_HDR
;
1485 while (sub
!= NULL
&& i
< orl_count
)
1489 while (((bfd
*) (map
[i
]).pos
) == sub
)
1491 bfd_h_put_32 (abfd
, fileoff
, buf
);
1492 if (bfd_write (buf
, 1, 4, abfd
) != 4)
1496 namlen
= strlen (normalize_filename (sub
));
1497 namlen
= (namlen
+ 1) &~ 1;
1498 fileoff
+= (SIZEOF_AR_HDR
1501 + arelt_size (sub
));
1502 fileoff
= (fileoff
+ 1) &~ 1;
1506 for (i
= 0; i
< orl_count
; i
++)
1511 name
= *map
[i
].name
;
1512 namlen
= strlen (name
);
1513 if (bfd_write (name
, 1, namlen
+ 1, abfd
) != namlen
+ 1)
1517 if ((stridx
& 1) != 0)
1522 if (bfd_write (&b
, 1, 1, abfd
) != 1)
1529 /* Write a single armap in the big format. */
1531 xcoff_write_one_armap_big (abfd
, map
, orl_count
, orl_ccount
, stridx
, bits64
,
1535 unsigned int orl_count
;
1536 unsigned int orl_ccount
;
1537 unsigned int stridx
;
1539 const char *prevoff
;
1542 struct xcoff_ar_hdr_big hdr
;
1544 unsigned char buf
[4];
1547 const bfd_arch_info_type
*arch_info
;
1551 memset (&hdr
, 0, sizeof hdr
);
1552 /* XXX This call actually should use %lld (at least on 32-bit
1553 machines) since the fields's width is 20 and there numbers with
1554 more than 32 bits can be represented. */
1555 sprintf (hdr
.size
, "%ld", (long) (4 + orl_ccount
* 4 + stridx
));
1557 sprintf (hdr
.nextoff
, "%d", 0);
1559 /* do explict cast to long to remove compiler warning */
1560 sprintf (hdr
.nextoff
, "%ld", (strtol (prevoff
, (char **) NULL
, 10)
1561 + (long) (4 + orl_ccount
* 4 + stridx
)));
1564 memcpy (hdr
.prevoff
, prevoff
, sizeof (hdr
.prevoff
));
1565 sprintf (hdr
.date
, "%d", 0);
1566 sprintf (hdr
.uid
, "%d", 0);
1567 sprintf (hdr
.gid
, "%d", 0);
1568 sprintf (hdr
.mode
, "%d", 0);
1569 sprintf (hdr
.namlen
, "%d", 0);
1571 /* We need spaces, not null bytes, in the header. */
1572 for (p
= (char *) &hdr
; p
< (char *) &hdr
+ SIZEOF_AR_HDR_BIG
; p
++)
1576 memcpy (nextoff
, hdr
.nextoff
, sizeof (hdr
.nextoff
));
1578 if (bfd_write ((PTR
) &hdr
, SIZEOF_AR_HDR_BIG
, 1, abfd
) != SIZEOF_AR_HDR_BIG
1579 || bfd_write (XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
) != SXCOFFARFMAG
)
1582 bfd_h_put_32 (abfd
, orl_ccount
, buf
);
1583 if (bfd_write (buf
, 1, 4, abfd
) != 4)
1586 sub
= abfd
->archive_head
;
1587 fileoff
= SIZEOF_AR_FILE_HDR_BIG
;
1589 while (sub
!= NULL
&& i
< orl_count
)
1593 if ((bfd_arch_bits_per_address ((bfd
*) map
[i
].pos
) == 64) == bits64
)
1594 while (((bfd
*) (map
[i
]).pos
) == sub
)
1596 bfd_h_put_32 (abfd
, fileoff
, buf
);
1597 if (bfd_write (buf
, 1, 4, abfd
) != 4)
1602 while (((bfd
*) (map
[i
]).pos
) == sub
)
1605 namlen
= strlen (normalize_filename (sub
));
1606 namlen
= (namlen
+ 1) &~ 1;
1607 fileoff
+= (SIZEOF_AR_HDR_BIG
1610 + arelt_size (sub
));
1611 fileoff
= (fileoff
+ 1) &~ 1;
1616 for (i
= 0; i
< orl_count
; i
++)
1620 bfd
*ob
= (bfd
*)map
[i
].pos
;
1622 if (ob
!= object_bfd
)
1623 arch_info
= bfd_get_arch_info (ob
);
1624 if ((arch_info
->bits_per_address
== 64) != bits64
)
1627 name
= *map
[i
].name
;
1628 namlen
= strlen (name
);
1629 if (bfd_write (name
, 1, namlen
+ 1, abfd
) != namlen
+ 1)
1633 if ((stridx
& 1) != 0)
1638 if (bfd_write (&b
, 1, 1, abfd
) != 1)
1647 xcoff_write_armap_big (abfd
, elength
, map
, orl_count
, stridx
)
1649 unsigned int elength ATTRIBUTE_UNUSED
;
1651 unsigned int orl_count
;
1655 unsigned int orl_count_32
, orl_count_64
;
1656 unsigned int stridx_32
, stridx_64
;
1657 const bfd_arch_info_type
*arch_info
;
1660 /* First, we look through the symbols and work out which are
1661 from 32-bit objects and which from 64-bit ones. */
1667 for (i
= 0; i
< orl_count
; i
++)
1669 bfd
*ob
= (bfd
*)map
[i
].pos
;
1671 if (ob
!= object_bfd
)
1672 arch_info
= bfd_get_arch_info (ob
);
1673 len
= strlen (*map
[i
].name
) + 1;
1674 if (arch_info
->bits_per_address
== 64)
1686 /* A quick sanity check... */
1687 BFD_ASSERT (orl_count_64
+ orl_count_32
== orl_count
);
1688 /* explicit cast to int for compiler */
1689 BFD_ASSERT ((int)(stridx_64
+ stridx_32
) == stridx
);
1691 /* Now write out each map. */
1692 if (! xcoff_write_one_armap_big (abfd
, map
, orl_count
, orl_count_32
,
1694 xcoff_ardata_big (abfd
)->memoff
,
1695 xcoff_ardata_big (abfd
)->symoff
))
1697 if (! xcoff_write_one_armap_big (abfd
, map
, orl_count
, orl_count_64
,
1699 xcoff_ardata_big (abfd
)->symoff
,
1700 xcoff_ardata_big (abfd
)->symoff64
))
1708 _bfd_xcoff_write_armap (abfd
, elength
, map
, orl_count
, stridx
)
1710 unsigned int elength ATTRIBUTE_UNUSED
;
1712 unsigned int orl_count
;
1715 if (! xcoff_big_format_p (abfd
))
1716 return xcoff_write_armap_old (abfd
, elength
, map
, orl_count
, stridx
);
1718 return xcoff_write_armap_big (abfd
, elength
, map
, orl_count
, stridx
);
1721 /* Write out an XCOFF archive. We always write an entire archive,
1722 rather than fussing with the freelist and so forth. */
1725 xcoff_write_archive_contents_old (abfd
)
1728 struct xcoff_ar_file_hdr fhdr
;
1730 size_t total_namlen
;
1734 file_ptr prevoff
, nextoff
;
1737 struct xcoff_ar_hdr ahdr
;
1742 memset (&fhdr
, 0, sizeof fhdr
);
1743 strncpy (fhdr
.magic
, XCOFFARMAG
, SXCOFFARMAG
);
1744 sprintf (fhdr
.firstmemoff
, "%d", SIZEOF_AR_FILE_HDR
);
1745 sprintf (fhdr
.freeoff
, "%d", 0);
1749 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->next
)
1752 total_namlen
+= strlen (normalize_filename (sub
)) + 1;
1754 offsets
= (file_ptr
*) bfd_alloc (abfd
, count
* sizeof (file_ptr
));
1755 if (offsets
== NULL
)
1758 if (bfd_seek (abfd
, SIZEOF_AR_FILE_HDR
, SEEK_SET
) != 0)
1761 makemap
= bfd_has_map (abfd
);
1764 nextoff
= SIZEOF_AR_FILE_HDR
;
1765 for (sub
= abfd
->archive_head
, i
= 0; sub
!= NULL
; sub
= sub
->next
, i
++)
1769 struct xcoff_ar_hdr
*ahdrp
;
1770 bfd_size_type remaining
;
1772 if (makemap
&& ! hasobjects
)
1774 if (bfd_check_format (sub
, bfd_object
))
1778 name
= normalize_filename (sub
);
1779 namlen
= strlen (name
);
1781 if (sub
->arelt_data
!= NULL
)
1782 ahdrp
= arch_xhdr (sub
);
1790 memset (&ahdr
, 0, sizeof ahdr
);
1792 if (stat (bfd_get_filename (sub
), &s
) != 0)
1794 bfd_set_error (bfd_error_system_call
);
1798 sprintf (ahdrp
->size
, "%ld", (long) s
.st_size
);
1799 sprintf (ahdrp
->date
, "%ld", (long) s
.st_mtime
);
1800 sprintf (ahdrp
->uid
, "%ld", (long) s
.st_uid
);
1801 sprintf (ahdrp
->gid
, "%ld", (long) s
.st_gid
);
1802 sprintf (ahdrp
->mode
, "%o", (unsigned int) s
.st_mode
);
1804 if (sub
->arelt_data
== NULL
)
1806 sub
->arelt_data
= bfd_alloc (sub
, sizeof (struct areltdata
));
1807 if (sub
->arelt_data
== NULL
)
1811 arch_eltdata (sub
)->parsed_size
= s
.st_size
;
1814 sprintf (ahdrp
->prevoff
, "%ld", (long) prevoff
);
1815 sprintf (ahdrp
->namlen
, "%ld", (long) namlen
);
1817 /* If the length of the name is odd, we write out the null byte
1818 after the name as well. */
1819 namlen
= (namlen
+ 1) &~ 1;
1821 remaining
= arelt_size (sub
);
1822 size
= (SIZEOF_AR_HDR
1827 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
1829 offsets
[i
] = nextoff
;
1832 nextoff
+= size
+ (size
& 1);
1834 sprintf (ahdrp
->nextoff
, "%ld", (long) nextoff
);
1836 /* We need spaces, not null bytes, in the header. */
1837 for (p
= (char *) ahdrp
; p
< (char *) ahdrp
+ SIZEOF_AR_HDR
; p
++)
1841 if (bfd_write ((PTR
) ahdrp
, 1, SIZEOF_AR_HDR
, abfd
) != SIZEOF_AR_HDR
1842 || bfd_write ((PTR
) name
, 1, namlen
, abfd
) != namlen
1843 || (bfd_write ((PTR
) XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
)
1847 if (bfd_seek (sub
, (file_ptr
) 0, SEEK_SET
) != 0)
1849 while (remaining
!= 0)
1852 bfd_byte buffer
[DEFAULT_BUFFERSIZE
];
1854 amt
= sizeof buffer
;
1855 if (amt
> remaining
)
1857 if (bfd_read (buffer
, 1, amt
, sub
) != amt
1858 || bfd_write (buffer
, 1, amt
, abfd
) != amt
)
1863 if ((size
& 1) != 0)
1868 if (bfd_write (&b
, 1, 1, abfd
) != 1)
1873 sprintf (fhdr
.lastmemoff
, "%ld", (long) prevoff
);
1875 /* Write out the member table. */
1877 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
1878 sprintf (fhdr
.memoff
, "%ld", (long) nextoff
);
1880 memset (&ahdr
, 0, sizeof ahdr
);
1881 sprintf (ahdr
.size
, "%ld", (long) (12 + count
* 12 + total_namlen
));
1882 sprintf (ahdr
.prevoff
, "%ld", (long) prevoff
);
1883 sprintf (ahdr
.date
, "%d", 0);
1884 sprintf (ahdr
.uid
, "%d", 0);
1885 sprintf (ahdr
.gid
, "%d", 0);
1886 sprintf (ahdr
.mode
, "%d", 0);
1887 sprintf (ahdr
.namlen
, "%d", 0);
1889 size
= (SIZEOF_AR_HDR
1896 nextoff
+= size
+ (size
& 1);
1898 if (makemap
&& hasobjects
)
1899 sprintf (ahdr
.nextoff
, "%ld", (long) nextoff
);
1901 sprintf (ahdr
.nextoff
, "%d", 0);
1903 /* We need spaces, not null bytes, in the header. */
1904 for (p
= (char *) &ahdr
; p
< (char *) &ahdr
+ SIZEOF_AR_HDR
; p
++)
1908 if (bfd_write ((PTR
) &ahdr
, 1, SIZEOF_AR_HDR
, abfd
) != SIZEOF_AR_HDR
1909 || (bfd_write ((PTR
) XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
)
1913 sprintf (decbuf
, "%-12ld", (long) count
);
1914 if (bfd_write ((PTR
) decbuf
, 1, 12, abfd
) != 12)
1916 for (i
= 0; i
< count
; i
++)
1918 sprintf (decbuf
, "%-12ld", (long) offsets
[i
]);
1919 if (bfd_write ((PTR
) decbuf
, 1, 12, abfd
) != 12)
1922 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->next
)
1927 name
= normalize_filename (sub
);
1928 namlen
= strlen (name
);
1929 if (bfd_write ((PTR
) name
, 1, namlen
+ 1, abfd
) != namlen
+ 1)
1932 if ((size
& 1) != 0)
1937 if (bfd_write ((PTR
) &b
, 1, 1, abfd
) != 1)
1941 /* Write out the armap, if appropriate. */
1943 if (! makemap
|| ! hasobjects
)
1944 sprintf (fhdr
.symoff
, "%d", 0);
1947 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
1948 sprintf (fhdr
.symoff
, "%ld", (long) nextoff
);
1949 bfd_ardata (abfd
)->tdata
= (PTR
) &fhdr
;
1950 if (! _bfd_compute_and_write_armap (abfd
, 0))
1954 /* Write out the archive file header. */
1956 /* We need spaces, not null bytes, in the header. */
1957 for (p
= (char *) &fhdr
; p
< (char *) &fhdr
+ SIZEOF_AR_FILE_HDR
; p
++)
1961 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
1962 || (bfd_write ((PTR
) &fhdr
, SIZEOF_AR_FILE_HDR
, 1, abfd
) !=
1963 SIZEOF_AR_FILE_HDR
))
1970 xcoff_write_archive_contents_big (abfd
)
1973 struct xcoff_ar_file_hdr_big fhdr
;
1975 size_t total_namlen
;
1979 file_ptr prevoff
, nextoff
;
1982 struct xcoff_ar_hdr_big ahdr
;
1987 memset (&fhdr
, 0, sizeof fhdr
);
1988 strncpy (fhdr
.magic
, XCOFFARMAGBIG
, SXCOFFARMAG
);
1989 sprintf (fhdr
.firstmemoff
, "%d", SIZEOF_AR_FILE_HDR_BIG
);
1990 sprintf (fhdr
.freeoff
, "%d", 0);
1994 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->next
)
1997 total_namlen
+= strlen (normalize_filename (sub
)) + 1;
1999 offsets
= (file_ptr
*) bfd_alloc (abfd
, count
* sizeof (file_ptr
));
2000 if (offsets
== NULL
)
2003 if (bfd_seek (abfd
, SIZEOF_AR_FILE_HDR_BIG
, SEEK_SET
) != 0)
2006 makemap
= bfd_has_map (abfd
);
2009 nextoff
= SIZEOF_AR_FILE_HDR_BIG
;
2010 for (sub
= abfd
->archive_head
, i
= 0; sub
!= NULL
; sub
= sub
->next
, i
++)
2014 struct xcoff_ar_hdr_big
*ahdrp
;
2015 bfd_size_type remaining
;
2017 if (makemap
&& ! hasobjects
)
2019 if (bfd_check_format (sub
, bfd_object
))
2023 name
= normalize_filename (sub
);
2024 namlen
= strlen (name
);
2026 if (sub
->arelt_data
!= NULL
)
2027 ahdrp
= arch_xhdr_big (sub
);
2035 memset (&ahdr
, 0, sizeof ahdr
);
2037 /* XXX This should actually be a call to stat64 (at least on
2038 32-bit machines). */
2039 if (stat (bfd_get_filename (sub
), &s
) != 0)
2041 bfd_set_error (bfd_error_system_call
);
2045 /* XXX This call actually should use %lld (at least on 32-bit
2046 machines) since the fields's width is 20 and there numbers with
2047 more than 32 bits can be represented. */
2048 sprintf (ahdrp
->size
, "%ld", (long) s
.st_size
);
2049 sprintf (ahdrp
->date
, "%ld", (long) s
.st_mtime
);
2050 sprintf (ahdrp
->uid
, "%ld", (long) s
.st_uid
);
2051 sprintf (ahdrp
->gid
, "%ld", (long) s
.st_gid
);
2052 sprintf (ahdrp
->mode
, "%o", (unsigned int) s
.st_mode
);
2054 if (sub
->arelt_data
== NULL
)
2056 sub
->arelt_data
= bfd_alloc (sub
, sizeof (struct areltdata
));
2057 if (sub
->arelt_data
== NULL
)
2061 arch_eltdata (sub
)->parsed_size
= s
.st_size
;
2064 /* XXX These calls actually should use %lld (at least on 32-bit
2065 machines) since the fields's width is 20 and there numbers with
2066 more than 32 bits can be represented. */
2067 sprintf (ahdrp
->prevoff
, "%ld", (long) prevoff
);
2068 sprintf (ahdrp
->namlen
, "%ld", (long) namlen
);
2070 /* If the length of the name is odd, we write out the null byte
2071 after the name as well. */
2072 namlen
= (namlen
+ 1) &~ 1;
2074 remaining
= arelt_size (sub
);
2075 size
= (SIZEOF_AR_HDR_BIG
2080 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2082 offsets
[i
] = nextoff
;
2085 nextoff
+= size
+ (size
& 1);
2087 sprintf (ahdrp
->nextoff
, "%ld", (long) nextoff
);
2089 /* We need spaces, not null bytes, in the header. */
2090 for (p
= (char *) ahdrp
; p
< (char *) ahdrp
+ SIZEOF_AR_HDR_BIG
; p
++)
2094 if (bfd_write ((PTR
) ahdrp
, 1, SIZEOF_AR_HDR_BIG
, abfd
)
2095 != SIZEOF_AR_HDR_BIG
2096 || bfd_write ((PTR
) name
, 1, namlen
, abfd
) != namlen
2097 || (bfd_write ((PTR
) XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
)
2101 if (bfd_seek (sub
, (file_ptr
) 0, SEEK_SET
) != 0)
2103 while (remaining
!= 0)
2106 bfd_byte buffer
[DEFAULT_BUFFERSIZE
];
2108 amt
= sizeof buffer
;
2109 if (amt
> remaining
)
2111 if (bfd_read (buffer
, 1, amt
, sub
) != amt
2112 || bfd_write (buffer
, 1, amt
, abfd
) != amt
)
2117 if ((size
& 1) != 0)
2122 if (bfd_write (&b
, 1, 1, abfd
) != 1)
2127 /* XXX This call actually should use %lld (at least on 32-bit
2128 machines) since the fields's width is 20 and there numbers with
2129 more than 32 bits can be represented. */
2130 sprintf (fhdr
.lastmemoff
, "%ld", (long) prevoff
);
2132 /* Write out the member table. */
2134 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2135 /* XXX This call actually should use %lld (at least on 32-bit
2136 machines) since the fields's width is 20 and there numbers with
2137 more than 32 bits can be represented. */
2138 sprintf (fhdr
.memoff
, "%ld", (long) nextoff
);
2140 memset (&ahdr
, 0, sizeof ahdr
);
2141 /* XXX The next two calls actually should use %lld (at least on 32-bit
2142 machines) since the fields's width is 20 and there numbers with
2143 more than 32 bits can be represented. */
2144 sprintf (ahdr
.size
, "%ld", (long) (12 + count
* 12 + total_namlen
));
2145 sprintf (ahdr
.prevoff
, "%ld", (long) prevoff
);
2146 sprintf (ahdr
.date
, "%d", 0);
2147 sprintf (ahdr
.uid
, "%d", 0);
2148 sprintf (ahdr
.gid
, "%d", 0);
2149 sprintf (ahdr
.mode
, "%d", 0);
2150 sprintf (ahdr
.namlen
, "%d", 0);
2152 size
= (SIZEOF_AR_HDR_BIG
2159 nextoff
+= size
+ (size
& 1);
2161 if (makemap
&& hasobjects
)
2162 /* XXX This call actually should use %lld (at least on 32-bit
2163 machines) since the fields's width is 20 and there numbers with
2164 more than 32 bits can be represented. */
2165 sprintf (ahdr
.nextoff
, "%ld", (long) nextoff
);
2167 sprintf (ahdr
.nextoff
, "%d", 0);
2169 /* We need spaces, not null bytes, in the header. */
2170 for (p
= (char *) &ahdr
; p
< (char *) &ahdr
+ SIZEOF_AR_HDR_BIG
; p
++)
2174 if (bfd_write ((PTR
) &ahdr
, 1, SIZEOF_AR_HDR_BIG
, abfd
) != SIZEOF_AR_HDR_BIG
2175 || (bfd_write ((PTR
) XCOFFARFMAG
, 1, SXCOFFARFMAG
, abfd
)
2179 sprintf (decbuf
, "%-12ld", (long) count
);
2180 if (bfd_write ((PTR
) decbuf
, 1, 12, abfd
) != 12)
2182 for (i
= 0; i
< count
; i
++)
2184 sprintf (decbuf
, "%-12ld", (long) offsets
[i
]);
2185 if (bfd_write ((PTR
) decbuf
, 1, 12, abfd
) != 12)
2188 for (sub
= abfd
->archive_head
; sub
!= NULL
; sub
= sub
->next
)
2193 name
= normalize_filename (sub
);
2194 namlen
= strlen (name
);
2195 if (bfd_write ((PTR
) name
, 1, namlen
+ 1, abfd
) != namlen
+ 1)
2198 if ((size
& 1) != 0)
2203 if (bfd_write ((PTR
) &b
, 1, 1, abfd
) != 1)
2207 /* Write out the armap, if appropriate. */
2209 if (! makemap
|| ! hasobjects
)
2210 sprintf (fhdr
.symoff
, "%d", 0);
2213 BFD_ASSERT (nextoff
== bfd_tell (abfd
));
2214 /* XXX This call actually should use %lld (at least on 32-bit
2215 machines) since the fields's width is 20 and there numbers with
2216 more than 32 bits can be represented. */
2217 bfd_ardata (abfd
)->tdata
= (PTR
) &fhdr
;
2218 if (! _bfd_compute_and_write_armap (abfd
, 0))
2222 /* Write out the archive file header. */
2224 /* We need spaces, not null bytes, in the header. */
2225 for (p
= (char *) &fhdr
; p
< (char *) &fhdr
+ SIZEOF_AR_FILE_HDR_BIG
; p
++)
2229 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0
2230 || (bfd_write ((PTR
) &fhdr
, SIZEOF_AR_FILE_HDR_BIG
, 1, abfd
) !=
2231 SIZEOF_AR_FILE_HDR_BIG
))
2238 _bfd_xcoff_write_archive_contents (abfd
)
2241 if (! xcoff_big_format_p (abfd
))
2242 return xcoff_write_archive_contents_old (abfd
);
2244 return xcoff_write_archive_contents_big (abfd
);
2247 /* We can't use the usual coff_sizeof_headers routine, because AIX
2248 always uses an a.out header. */
2252 _bfd_xcoff_sizeof_headers (abfd
, reloc
)
2254 boolean reloc ATTRIBUTE_UNUSED
;
2259 if (xcoff_data (abfd
)->full_aouthdr
)
2262 size
+= SMALL_AOUTSZ
;
2263 size
+= abfd
->section_count
* SCNHSZ
;
2267 /* Routines to swap information in the XCOFF .loader section. If we
2268 ever need to write an XCOFF loader, this stuff will need to be
2269 moved to another file shared by the linker (which XCOFF calls the
2270 ``binder'') and the loader. */
2272 /* Swap in the ldhdr structure. */
2275 xcoff_swap_ldhdr_in (abfd
, s
, dst
)
2278 struct internal_ldhdr
*dst
;
2280 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
2282 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
2283 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
2284 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
2285 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
2286 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
2287 dst
->l_impoff
= bfd_get_32 (abfd
, src
->l_impoff
);
2288 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
2289 dst
->l_stoff
= bfd_get_32 (abfd
, src
->l_stoff
);
2292 /* Swap out the ldhdr structure. */
2295 xcoff_swap_ldhdr_out (abfd
, src
, d
)
2297 const struct internal_ldhdr
*src
;
2300 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
2302 bfd_put_32 (abfd
, src
->l_version
, dst
->l_version
);
2303 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
2304 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
2305 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
2306 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
2307 bfd_put_32 (abfd
, src
->l_impoff
, dst
->l_impoff
);
2308 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
2309 bfd_put_32 (abfd
, src
->l_stoff
, dst
->l_stoff
);
2312 /* Swap in the ldsym structure. */
2315 xcoff_swap_ldsym_in (abfd
, s
, dst
)
2318 struct internal_ldsym
*dst
;
2320 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
2322 if (bfd_get_32 (abfd
, src
->_l
._l_l
._l_zeroes
) != 0) {
2323 memcpy (dst
->_l
._l_name
, src
->_l
._l_name
, SYMNMLEN
);
2325 dst
->_l
._l_l
._l_zeroes
= 0;
2326 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->_l
._l_l
._l_offset
);
2328 dst
->l_value
= bfd_get_32 (abfd
, src
->l_value
);
2329 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
2330 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
2331 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
2332 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
2333 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
2336 /* Swap out the ldsym structure. */
2339 xcoff_swap_ldsym_out (abfd
, src
, d
)
2341 const struct internal_ldsym
*src
;
2344 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
2346 if (src
->_l
._l_l
._l_zeroes
!= 0)
2347 memcpy (dst
->_l
._l_name
, src
->_l
._l_name
, SYMNMLEN
);
2350 bfd_put_32 (abfd
, 0, dst
->_l
._l_l
._l_zeroes
);
2351 bfd_put_32 (abfd
, src
->_l
._l_l
._l_offset
, dst
->_l
._l_l
._l_offset
);
2353 bfd_put_32 (abfd
, src
->l_value
, dst
->l_value
);
2354 bfd_put_16 (abfd
, src
->l_scnum
, dst
->l_scnum
);
2355 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
2356 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
2357 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
2358 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
2361 /* Swap in the ldrel structure. */
2364 xcoff_swap_ldrel_in (abfd
, s
, dst
)
2367 struct internal_ldrel
*dst
;
2369 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
2371 dst
->l_vaddr
= bfd_get_32 (abfd
, src
->l_vaddr
);
2372 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
2373 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
2374 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
2377 /* Swap out the ldrel structure. */
2380 xcoff_swap_ldrel_out (abfd
, src
, d
)
2382 const struct internal_ldrel
*src
;
2385 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
2387 bfd_put_32 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
2388 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
2389 bfd_put_16 (abfd
, src
->l_rtype
, dst
->l_rtype
);
2390 bfd_put_16 (abfd
, src
->l_rsecnm
, dst
->l_rsecnm
);
2395 /* This is the relocation function for the RS/6000/POWER/PowerPC.
2396 This is currently the only processor which uses XCOFF; I hope that
2397 will never change. */
2400 xcoff_ppc_relocate_section (output_bfd
, info
, input_bfd
,
2401 input_section
, contents
, relocs
, syms
,
2404 struct bfd_link_info
*info
;
2406 asection
*input_section
;
2408 struct internal_reloc
*relocs
;
2409 struct internal_syment
*syms
;
2410 asection
**sections
;
2412 struct internal_reloc
*rel
;
2413 struct internal_reloc
*relend
;
2416 relend
= rel
+ input_section
->reloc_count
;
2418 for (; rel
< relend
; rel
++)
2421 struct xcoff_link_hash_entry
*h
;
2422 struct internal_syment
*sym
;
2425 struct reloc_howto_struct howto
;
2426 bfd_reloc_status_type rstat
;
2428 /* Relocation type R_REF is a special relocation type which is
2429 merely used to prevent garbage collection from occurring for
2430 the csect including the symbol which it references. */
2431 if (rel
->r_type
== R_REF
)
2434 symndx
= rel
->r_symndx
;
2444 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
2445 sym
= syms
+ symndx
;
2446 addend
= - sym
->n_value
;
2450 /* We build the howto information on the fly. */
2452 howto
.type
= rel
->r_type
;
2453 howto
.rightshift
= 0;
2455 howto
.bitsize
= (rel
->r_size
& 0x1f) + 1;
2456 howto
.pc_relative
= false;
2458 if ((rel
->r_size
& 0x80) != 0)
2459 howto
.complain_on_overflow
= complain_overflow_signed
;
2461 howto
.complain_on_overflow
= complain_overflow_bitfield
;
2462 howto
.special_function
= NULL
;
2463 howto
.name
= "internal";
2464 howto
.partial_inplace
= true;
2465 if (howto
.bitsize
== 32)
2466 howto
.src_mask
= howto
.dst_mask
= 0xffffffff;
2469 howto
.src_mask
= howto
.dst_mask
= (1 << howto
.bitsize
) - 1;
2470 if (howto
.bitsize
== 16)
2473 howto
.pcrel_offset
= false;
2483 sec
= bfd_abs_section_ptr
;
2488 sec
= sections
[symndx
];
2489 /* Hack to make sure we use the right TOC anchor value
2490 if this reloc is against the TOC anchor. */
2492 if (sec
->name
[3] == '0'
2493 && strcmp (sec
->name
, ".tc0") == 0) {
2495 val
= xcoff_data (output_bfd
)->toc
;
2498 val
= (sec
->output_section
->vma
2499 + sec
->output_offset
2508 if (h
->root
.type
== bfd_link_hash_defined
2509 || h
->root
.type
== bfd_link_hash_defweak
)
2513 sec
= h
->root
.u
.def
.section
;
2514 val
= (h
->root
.u
.def
.value
2515 + sec
->output_section
->vma
2516 + sec
->output_offset
);
2518 else if (h
->root
.type
== bfd_link_hash_common
)
2522 sec
= h
->root
.u
.c
.p
->section
;
2523 val
= (sec
->output_section
->vma
2524 + sec
->output_offset
);
2526 else if ((h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
2527 || (h
->flags
& XCOFF_IMPORT
) != 0)
2529 /* Every symbol in a shared object is defined somewhere. */
2532 else if (! info
->relocateable
)
2534 if (! ((*info
->callbacks
->undefined_symbol
)
2535 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
2536 rel
->r_vaddr
- input_section
->vma
, true)))
2539 /* Don't try to process the reloc. It can't help, and
2540 it may generate another error. */
2545 /* I took the relocation type definitions from two documents:
2546 the PowerPC AIX Version 4 Application Binary Interface, First
2547 Edition (April 1992), and the PowerOpen ABI, Big-Endian
2548 32-Bit Hardware Implementation (June 30, 1994). Differences
2549 between the documents are noted below. */
2551 switch (rel
->r_type
)
2556 /* These relocs are defined by the PowerPC ABI to be
2557 relative branches which use half of the difference
2558 between the symbol and the program counter. I can't
2559 quite figure out when this is useful. These relocs are
2560 not defined by the PowerOpen ABI. */
2562 (*_bfd_error_handler
)
2563 (_("%s: unsupported relocation type 0x%02x"),
2564 bfd_get_filename (input_bfd
), (unsigned int) rel
->r_type
);
2565 bfd_set_error (bfd_error_bad_value
);
2568 /* Simple positive relocation. */
2571 /* Simple negative relocation. */
2575 /* Simple PC relative relocation. */
2576 howto
.pc_relative
= true;
2579 /* TOC relative relocation. The value in the instruction in
2580 the input file is the offset from the input file TOC to
2581 the desired location. We want the offset from the final
2582 TOC to the desired location. We have:
2587 so we must change insn by on - in.
2590 /* Global linkage relocation. The value of this relocation
2591 is the address of the entry in the TOC section. */
2593 /* Local object TOC address. I can't figure out the
2594 difference between this and case R_GL. */
2596 /* TOC relative relocation. A TOC relative load instruction
2597 which may be changed to a load address instruction.
2598 FIXME: We don't currently implement this optimization. */
2600 /* TOC relative relocation. This is a TOC relative load
2601 address instruction which may be changed to a load
2602 instruction. FIXME: I don't know if this is the correct
2604 if (h
!= NULL
&& h
->smclas
!= XMC_TD
)
2606 if (h
->toc_section
== NULL
)
2608 (*_bfd_error_handler
)
2609 (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
2610 bfd_get_filename (input_bfd
), rel
->r_vaddr
,
2611 h
->root
.root
.string
);
2612 bfd_set_error (bfd_error_bad_value
);
2616 BFD_ASSERT ((h
->flags
& XCOFF_SET_TOC
) == 0);
2617 val
= (h
->toc_section
->output_section
->vma
2618 + h
->toc_section
->output_offset
);
2621 val
= ((val
- xcoff_data (output_bfd
)->toc
)
2622 - (sym
->n_value
- xcoff_data (input_bfd
)->toc
));
2626 /* Absolute branch. We don't want to mess with the lower
2627 two bits of the instruction. */
2629 /* The PowerPC ABI defines this as an absolute call which
2630 may be modified to become a relative call. The PowerOpen
2631 ABI does not define this relocation type. */
2633 /* Absolute branch which may be modified to become a
2636 /* The PowerPC ABI defines this as an absolute branch to a
2637 fixed address which may be modified to an absolute branch
2638 to a symbol. The PowerOpen ABI does not define this
2641 /* The PowerPC ABI defines this as an absolute branch to a
2642 fixed address which may be modified to a relative branch.
2643 The PowerOpen ABI does not define this relocation type. */
2644 howto
.src_mask
&= ~3;
2645 howto
.dst_mask
= howto
.src_mask
;
2648 /* Relative branch. We don't want to mess with the lower
2649 two bits of the instruction. */
2651 /* The PowerPC ABI defines this as a relative call which may
2652 be modified to become an absolute call. The PowerOpen
2653 ABI does not define this relocation type. */
2655 /* A relative branch which may be modified to become an
2656 absolute branch. FIXME: We don't implement this,
2657 although we should for symbols of storage mapping class
2659 howto
.pc_relative
= true;
2660 howto
.src_mask
&= ~3;
2661 howto
.dst_mask
= howto
.src_mask
;
2664 /* The PowerPC AIX ABI describes this as a load which may be
2665 changed to a load address. The PowerOpen ABI says this
2666 is the same as case R_POS. */
2669 /* The PowerPC AIX ABI describes this as a load address
2670 which may be changed to a load. The PowerOpen ABI says
2671 this is the same as R_POS. */
2675 /* If we see an R_BR or R_RBR reloc which is jumping to global
2676 linkage code, and it is followed by an appropriate cror nop
2677 instruction, we replace the cror with lwz r2,20(r1). This
2678 restores the TOC after the glink code. Contrariwise, if the
2679 call is followed by a lwz r2,20(r1), but the call is not
2680 going to global linkage code, we can replace the load with a
2682 if ((rel
->r_type
== R_BR
|| rel
->r_type
== R_RBR
)
2684 && h
->root
.type
== bfd_link_hash_defined
2685 && (rel
->r_vaddr
- input_section
->vma
+ 8
2686 <= input_section
->_cooked_size
))
2691 pnext
= contents
+ (rel
->r_vaddr
- input_section
->vma
) + 4;
2692 next
= bfd_get_32 (input_bfd
, pnext
);
2694 /* The _ptrgl function is magic. It is used by the AIX
2695 compiler to call a function through a pointer. */
2696 if (h
->smclas
== XMC_GL
2697 || strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
2699 if (next
== 0x4def7b82 /* cror 15,15,15 */
2700 || next
== 0x4ffffb82 /* cror 31,31,31 */
2701 || next
== 0x60000000) /* ori r0,r0,0 */
2702 bfd_put_32 (input_bfd
, 0x80410014, pnext
); /* lwz r1,20(r1) */
2706 if (next
== 0x80410014) /* lwz r1,20(r1) */
2707 bfd_put_32 (input_bfd
, 0x60000000, pnext
); /* ori r0,r0,0 */
2711 /* A PC relative reloc includes the section address. */
2712 if (howto
.pc_relative
)
2713 addend
+= input_section
->vma
;
2715 rstat
= _bfd_final_link_relocate (&howto
, input_bfd
, input_section
,
2717 rel
->r_vaddr
- input_section
->vma
,
2726 case bfd_reloc_overflow
:
2729 char buf
[SYMNMLEN
+ 1];
2730 char howto_name
[10];
2735 name
= h
->root
.root
.string
;
2739 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
2744 sprintf (howto_name
, "0x%02x", rel
->r_type
);
2746 if (! ((*info
->callbacks
->reloc_overflow
)
2747 (info
, name
, howto_name
, (bfd_vma
) 0, input_bfd
,
2748 input_section
, rel
->r_vaddr
- input_section
->vma
)))
2758 _bfd_xcoff_put_ldsymbol_name (abfd
, ldinfo
, ldsym
, name
)
2759 bfd
*abfd ATTRIBUTE_UNUSED
;
2760 struct xcoff_loader_info
*ldinfo
;
2761 struct internal_ldsym
*ldsym
;
2765 len
= strlen (name
);
2767 if (len
<= SYMNMLEN
)
2768 strncpy (ldsym
->_l
._l_name
, name
, SYMNMLEN
);
2771 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
)
2774 bfd_byte
*newstrings
;
2776 newalc
= ldinfo
->string_alc
* 2;
2779 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
2782 newstrings
= ((bfd_byte
*)
2783 bfd_realloc ((PTR
) ldinfo
->strings
, newalc
));
2784 if (newstrings
== NULL
)
2786 ldinfo
->failed
= true;
2789 ldinfo
->string_alc
= newalc
;
2790 ldinfo
->strings
= newstrings
;
2793 bfd_put_16 (ldinfo
->output_bfd
, len
+ 1,
2794 ldinfo
->strings
+ ldinfo
->string_size
);
2795 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
2796 ldsym
->_l
._l_l
._l_zeroes
= 0;
2797 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
2798 ldinfo
->string_size
+= len
+ 3;
2805 _bfd_xcoff_put_symbol_name (bfd
*abfd
, struct bfd_strtab_hash
*strtab
,
2806 struct internal_syment
*sym
,
2809 if (strlen (name
) <= SYMNMLEN
) {
2810 strncpy (sym
->_n
._n_name
, name
, SYMNMLEN
);
2816 if ((abfd
->flags
& BFD_TRADITIONAL_FORMAT
) != 0)
2818 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
2819 if (indx
== (bfd_size_type
) -1)
2821 sym
->_n
._n_n
._n_zeroes
= 0;
2822 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
2828 xcoff_create_csect_from_smclas (abfd
, aux
, symbol_name
)
2830 union internal_auxent
*aux
;
2831 const char *symbol_name
;
2834 asection
*return_value
= NULL
;
2837 * .sv64 = x_smclas == 17
2838 * This is an invalid csect for 32 bit apps.
2840 static const char *names
[19] = {
2841 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
2842 ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL
, ".tc0",
2843 ".td", NULL
, ".sv3264"
2846 if ((19 >= aux
->x_csect
.x_smclas
) &&
2847 (NULL
!= names
[aux
->x_csect
.x_smclas
])) {
2849 return_value
= bfd_make_section_anyway
2850 (abfd
, names
[aux
->x_csect
.x_smclas
]);
2854 (*_bfd_error_handler
)
2855 (_("%s: symbol `%s' has unrecognized smclas %d"),
2856 bfd_get_filename (abfd
), symbol_name
, aux
->x_csect
.x_smclas
);
2857 bfd_set_error (bfd_error_bad_value
);
2860 return return_value
;
2864 xcoff_is_lineno_count_overflow (abfd
, value
)
2865 bfd
*abfd ATTRIBUTE_UNUSED
;
2868 if (0xffff <= value
) {
2875 xcoff_is_reloc_count_overflow (abfd
, value
)
2876 bfd
*abfd ATTRIBUTE_UNUSED
;
2879 if (0xffff <= value
) {
2886 xcoff_loader_symbol_offset (abfd
, ldhdr
)
2888 struct internal_ldhdr
*ldhdr ATTRIBUTE_UNUSED
;
2890 return bfd_xcoff_ldhdrsz(abfd
);
2894 xcoff_loader_reloc_offset (abfd
, ldhdr
)
2896 struct internal_ldhdr
*ldhdr
;
2898 return bfd_xcoff_ldhdrsz(abfd
) +
2899 (ldhdr
->l_nsyms
* bfd_xcoff_ldsymsz(abfd
));
2903 static reloc_howto_type xcoff_dynamic_reloc
=
2904 HOWTO (0, /* type */
2906 2, /* size (0 = byte, 1 = short, 2 = long) */
2908 false, /* pc_relative */
2910 complain_overflow_bitfield
, /* complain_on_overflow */
2911 0, /* special_function */
2913 true, /* partial_inplace */
2914 0xffffffff, /* src_mask */
2915 0xffffffff, /* dst_mask */
2916 false); /* pcrel_offset */
2921 * The first word of global linkage code must be modified by filling in
2922 * the correct TOC offset.
2924 static unsigned long xcoff_glink_code
[9] =
2926 0x81820000, /* lwz r12,0(r2) */
2927 0x90410014, /* stw r2,20(r1) */
2928 0x800c0000, /* lwz r0,0(r12) */
2929 0x804c0004, /* lwz r2,4(r12) */
2930 0x7c0903a6, /* mtctr r0 */
2931 0x4e800420, /* bctr */
2932 0x00000000, /* start of traceback table */
2933 0x000c8000, /* traceback table */
2934 0x00000000, /* traceback table */
2938 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
2940 { /* COFF backend, defined in libcoff.h */
2941 _bfd_xcoff_swap_aux_in
, /* _bfd_coff_swap_aux_in */
2942 _bfd_xcoff_swap_sym_in
, /* _bfd_coff_swap_sym_in */
2943 coff_swap_lineno_in
, /* _bfd_coff_swap_lineno_in */
2944 _bfd_xcoff_swap_aux_out
, /* _bfd_swap_aux_out */
2945 _bfd_xcoff_swap_sym_out
, /* _bfd_swap_sym_out */
2946 coff_swap_lineno_out
, /* _bfd_swap_lineno_out */
2947 coff_swap_reloc_out
, /* _bfd_swap_reloc_out */
2948 coff_swap_filehdr_out
, /* _bfd_swap_filehdr_out */
2949 coff_swap_aouthdr_out
, /* _bfd_swap_aouthdr_out */
2950 coff_swap_scnhdr_out
, /* _bfd_swap_scnhdr_out */
2951 FILHSZ
, /* _bfd_filhsz */
2952 AOUTSZ
, /* _bfd_aoutsz */
2953 SCNHSZ
, /* _bfd_scnhsz */
2954 SYMESZ
, /* _bfd_symesz */
2955 AUXESZ
, /* _bfd_auxesz */
2956 RELSZ
, /* _bfd_relsz */
2957 LINESZ
, /* _bfd_linesz */
2958 FILNMLEN
, /* _bfd_filnmlen */
2959 true, /* _bfd_coff_long_filenames */
2960 false, /* _bfd_coff_long_section_names */
2961 (3), /* _bfd_coff_default_section_alignment_power */
2962 false, /* _bfd_coff_force_symnames_in_strings */
2963 2, /* _bfd_coff_debug_string_prefix_length */
2964 coff_swap_filehdr_in
, /* _bfd_coff_swap_filehdr_in */
2965 coff_swap_aouthdr_in
, /* _bfd_swap_aouthdr_in */
2966 coff_swap_scnhdr_in
, /* _bfd_swap_scnhdr_in */
2967 coff_swap_reloc_in
, /* _bfd_reloc_in */
2968 coff_bad_format_hook
, /* _bfd_bad_format_hook */
2969 coff_set_arch_mach_hook
, /* _bfd_set_arch_mach_hook */
2970 coff_mkobject_hook
, /* _bfd_mkobject_hook */
2971 styp_to_sec_flags
, /* _bfd_syp_to_sec_flags */
2972 coff_set_alignment_hook
, /* _bfd_set_alignment_hook */
2973 coff_slurp_symbol_table
, /* _bfd_coff_slurp_symbol_table */
2974 symname_in_debug_hook
, /* _coff_symname_in_debug_hook */
2975 coff_pointerize_aux_hook
, /* _bfd_coff_pointerize_aux_hook */
2976 coff_print_aux
, /* bfd_coff_print_aux */
2977 dummy_reloc16_extra_cases
, /* _bfd_coff_reloc16_extra_cases */
2978 dummy_reloc16_estimate
, /* _bfd_coff_reloc16_estimate */
2979 NULL
, /* bfd_coff_sym_is_global */
2980 /* _bfd_coff_compute_section_file_positions */
2981 coff_compute_section_file_positions
,
2982 NULL
, /* _bfd_coff_start_final_link */
2983 xcoff_ppc_relocate_section
, /* _bfd_coff_relocate_section */
2984 coff_rtype_to_howto
, /* _bfd_coff_rtype_to_howto */
2985 NULL
, /* _bfd_coff_addust_symndx */
2986 _bfd_generic_link_add_one_symbol
, /* _bfd_coff_add_one_symbol */
2987 coff_link_output_has_begun
, /* _bfd_coff_link_output_has_begun */
2988 coff_final_link_postscript
/* _bfd_coff_final_link_postscript */
2991 0x01DF, /* magic number */
2992 bfd_arch_rs6000
, /* architecture */
2993 bfd_mach_rs6k
, /* machine */
2996 /* function pointers to xcoff specific swap routines */
2997 xcoff_swap_ldhdr_in
, /* _xcoff_swap_ldhdr_in */
2998 xcoff_swap_ldhdr_out
, /* _xcoff_swap_ldhdr_out */
2999 xcoff_swap_ldsym_in
, /* _xcoff_swap_ldsym_in */
3000 xcoff_swap_ldsym_out
, /* _xcoff_swap_ldsym_out */
3001 xcoff_swap_ldrel_in
, /* _xcoff_swap_ldrel_in */
3002 xcoff_swap_ldrel_out
, /* _xcoff_swap_ldrel_out */
3005 LDHDRSZ
, /* _xcoff_ldhdrsz */
3006 LDSYMSZ
, /* _xcoff_ldsymsz */
3007 LDRELSZ
, /* _xcoff_ldrelsz */
3008 12, /* _xcoff_function_descriptor_size */
3009 SMALL_AOUTSZ
, /* _xcoff_small_aout_header_size */
3012 1, /* _xcoff_ldhdr_version */
3014 /* xcoff vs xcoff64 putting symbol names */
3015 _bfd_xcoff_put_symbol_name
, /* _xcoff_put_symbol_name */
3016 _bfd_xcoff_put_ldsymbol_name
, /* _xcoff_put_ldsymbol_name */
3018 &xcoff_dynamic_reloc
, /* dynamic reloc howto */
3020 xcoff_create_csect_from_smclas
, /* _xcoff_create_csect_from_smclas */
3022 /* lineno and reloc count overflow */
3023 xcoff_is_lineno_count_overflow
,
3024 xcoff_is_reloc_count_overflow
,
3026 xcoff_loader_symbol_offset
,
3027 xcoff_loader_reloc_offset
,
3030 &xcoff_glink_code
[0],
3031 (36), /* _xcoff_glink_size */
3035 /* The transfer vector that leads the outside world to all of the above. */
3036 const bfd_target rs6000coff_vec
=
3039 bfd_target_xcoff_flavour
,
3040 BFD_ENDIAN_BIG
, /* data byte order is big */
3041 BFD_ENDIAN_BIG
, /* header byte order is big */
3043 (HAS_RELOC
| EXEC_P
| /* object flags */
3044 HAS_LINENO
| HAS_DEBUG
| DYNAMIC
|
3045 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
3047 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
3048 0, /* leading char */
3049 '/', /* ar_pad_char */
3050 15, /* ar_max_namelen??? FIXMEmgo */
3053 bfd_getb64
, /* bfd_getx64 */
3054 bfd_getb_signed_64
, /* bfd_getx_signed_64 */
3055 bfd_putb64
, /* bfd_putx64 */
3056 bfd_getb32
, /* bfd_getx32 */
3057 bfd_getb_signed_32
, /* bfd_getx_signed_32 */
3058 bfd_putb32
, /* bfd_putx32 */
3059 bfd_getb16
, /* bfd_getx16 */
3060 bfd_getb_signed_16
, /* bfd_getx_signed_16 */
3061 bfd_putb16
, /* bfd_putx16 */
3064 bfd_getb64
, /* bfd_h_getx64 */
3065 bfd_getb_signed_64
, /* bfd_h_getx_signed_64 */
3066 bfd_putb64
, /* bfd_h_putx64 */
3067 bfd_getb32
, /* bfd_h_getx32 */
3068 bfd_getb_signed_32
, /* bfd_h_getx_signed_32 */
3069 bfd_putb32
, /* bfd_h_putx32 */
3070 bfd_getb16
, /* bfd_h_getx16 */
3071 bfd_getb_signed_16
, /* bfd_h_getx_signed_16 */
3072 bfd_putb16
, /* bfd_h_putx16 */
3074 { /* bfd_check_format */
3077 _bfd_xcoff_archive_p
,
3081 { /* bfd_set_format */
3084 _bfd_generic_mkarchive
,
3088 {/* bfd_write_contents */
3090 coff_write_object_contents
,
3091 _bfd_xcoff_write_archive_contents
,
3096 bfd_true
, /* _close_and_cleanup */
3097 bfd_true
, /* _bfd_free_cached_info */
3098 coff_new_section_hook
, /* _new_section_hook */
3099 _bfd_generic_get_section_contents
, /* _bfd_get_section_contents */
3100 /* _bfd_get_section_contents_in_window */
3101 _bfd_generic_get_section_contents_in_window
,
3104 _bfd_xcoff_copy_private_bfd_data
, /* _bfd_copy_private_bfd */
3105 /* _bfd_merge_private_bfd_data */
3106 ((boolean (*) (bfd
*, bfd
*)) bfd_true
),
3107 /* _bfd_copy_pivate_section_data */
3108 ((boolean (*) (bfd
*, asection
*, bfd
*, asection
*)) bfd_true
),
3109 /* _bfd_copy_private_symbol_data */
3110 ((boolean (*) (bfd
*, asymbol
*, bfd
*, asymbol
*)) bfd_true
),
3111 ((boolean (*) (bfd
*, flagword
)) bfd_true
), /* _bfd_set_private_flags */
3112 ((boolean (*) (bfd
*, void * )) bfd_true
), /* _bfd_print_private_bfd_data */
3115 coff_core_file_failing_command
, /* _core_file_failing_command */
3116 coff_core_file_failing_signal
, /* _core_file_failing_signal */
3117 /* _core_file_matches_executable_p */
3118 coff_core_file_matches_executable_p
,
3121 _bfd_xcoff_slurp_armap
, /* _slurp_armap */
3122 /* XCOFF archives do not have
3123 anything which corresponds to
3124 an extended name table. */
3125 bfd_false
, /* _slurp_extended_name_table */
3126 /* _construct_extended_name_table */
3127 ((boolean (*) (bfd
*, char **, bfd_size_type
*, const char **)) bfd_false
),
3128 bfd_dont_truncate_arname
, /* _truncate_arname */
3129 _bfd_xcoff_write_armap
, /* _write_armap */
3130 _bfd_xcoff_read_ar_hdr
, /* _read_ar_hdr */
3131 _bfd_xcoff_openr_next_archived_file
, /* _openr_next_archived_file */
3132 _bfd_generic_get_elt_at_index
, /* _get_elt_at_index */
3133 _bfd_xcoff_generic_stat_arch_elt
, /* _generic_dtat_arch_elt */
3134 /* XCOFF archives do not have
3136 bfd_true
, /* _update_armap_timestamp */
3139 coff_get_symtab_upper_bound
, /* _get_symtab_upper_bound */
3140 coff_get_symtab
, /* _get_symtab */
3141 coff_make_empty_symbol
, /* _make_empty_symbol */
3142 coff_print_symbol
, /* _print_symbol */
3143 coff_get_symbol_info
, /* _get_symbol_info */
3144 _bfd_xcoff_is_local_label_name
, /* _bfd_is_local_label_name */
3145 coff_get_lineno
, /* _get_lineno */
3146 coff_find_nearest_line
, /* _find_nearest_line */
3147 coff_bfd_make_debug_symbol
, /* _bfd_make_debug_symbol */
3148 _bfd_generic_read_minisymbols
, /* _read_minisymbols */
3149 _bfd_generic_minisymbol_to_symbol
, /* _minsymbol_to_symbol */
3152 coff_get_reloc_upper_bound
, /* _get_reloc_upper_bound */
3153 coff_canonicalize_reloc
, /* _cononicalize_reloc */
3154 _bfd_xcoff_reloc_type_lookup
, /* _bfd_reloc_type_lookup */
3157 coff_set_arch_mach
, /* _set_arch_mach */
3158 coff_set_section_contents
, /* _set_section_contents */
3161 _bfd_xcoff_sizeof_headers
, /* _sizeof_headers */
3162 /* _bfd_get_relocated_section_contents */
3163 bfd_generic_get_relocated_section_contents
,
3164 bfd_generic_relax_section
, /* _bfd_relax_section */
3165 _bfd_xcoff_bfd_link_hash_table_create
, /* _bfd_link_hash_table_create */
3166 _bfd_xcoff_bfd_link_add_symbols
, /* _bfd_link_add_symbols */
3167 _bfd_xcoff_bfd_final_link
, /* _bfd_filnal_link */
3168 _bfd_generic_link_split_section
, /* _bfd_link_split_section */
3169 bfd_generic_gc_sections
, /* _bfd_gc_sections */
3170 bfd_generic_merge_sections
, /* _bfd_merge_sections */
3173 /* _get_dynamic_symtab_upper_bound */
3174 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
3175 _bfd_xcoff_canonicalize_dynamic_symtab
, /* _cononicalize_dynamic_symtab */
3176 _bfd_xcoff_get_dynamic_reloc_upper_bound
,/* _get_dynamic_reloc_upper_bound */
3177 _bfd_xcoff_canonicalize_dynamic_reloc
, /* _cononicalize_dynamic_reloc */
3179 /* Opposite endian version, none exists */
3183 (void *) &bfd_xcoff_backend_data
,
3187 * xcoff-powermac target
3189 * Only difference between this target and the rs6000 target is the
3190 * the default architecture and machine type used in coffcode.h
3192 * PowerPC Macs use the same magic numbers as RS/6000
3193 * (because that's how they were bootstrapped originally),
3194 * but they are always PowerPC architecture.
3196 static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data
=
3198 { /* COFF backend, defined in libcoff.h */
3199 _bfd_xcoff_swap_aux_in
, /* _bfd_coff_swap_aux_in */
3200 _bfd_xcoff_swap_sym_in
, /* _bfd_coff_swap_sym_in */
3201 coff_swap_lineno_in
, /* _bfd_coff_swap_lineno_in */
3202 _bfd_xcoff_swap_aux_out
, /* _bfd_swap_aux_out */
3203 _bfd_xcoff_swap_sym_out
, /* _bfd_swap_sym_out */
3204 coff_swap_lineno_out
, /* _bfd_swap_lineno_out */
3205 coff_swap_reloc_out
, /* _bfd_swap_reloc_out */
3206 coff_swap_filehdr_out
, /* _bfd_swap_filehdr_out */
3207 coff_swap_aouthdr_out
, /* _bfd_swap_aouthdr_out */
3208 coff_swap_scnhdr_out
, /* _bfd_swap_scnhdr_out */
3209 FILHSZ
, /* _bfd_filhsz */
3210 AOUTSZ
, /* _bfd_aoutsz */
3211 SCNHSZ
, /* _bfd_scnhsz */
3212 SYMESZ
, /* _bfd_symesz */
3213 AUXESZ
, /* _bfd_auxesz */
3214 RELSZ
, /* _bfd_relsz */
3215 LINESZ
, /* _bfd_linesz */
3216 FILNMLEN
, /* _bfd_filnmlen */
3217 true, /* _bfd_coff_long_filenames */
3218 false, /* _bfd_coff_long_section_names */
3219 (3), /* _bfd_coff_default_section_alignment_power */
3220 false, /* _bfd_coff_force_symnames_in_strings */
3221 2, /* _bfd_coff_debug_string_prefix_length */
3222 coff_swap_filehdr_in
, /* _bfd_coff_swap_filehdr_in */
3223 coff_swap_aouthdr_in
, /* _bfd_swap_aouthdr_in */
3224 coff_swap_scnhdr_in
, /* _bfd_swap_scnhdr_in */
3225 coff_swap_reloc_in
, /* _bfd_reloc_in */
3226 coff_bad_format_hook
, /* _bfd_bad_format_hook */
3227 coff_set_arch_mach_hook
, /* _bfd_set_arch_mach_hook */
3228 coff_mkobject_hook
, /* _bfd_mkobject_hook */
3229 styp_to_sec_flags
, /* _bfd_syp_to_sec_flags */
3230 coff_set_alignment_hook
, /* _bfd_set_alignment_hook */
3231 coff_slurp_symbol_table
, /* _bfd_coff_slurp_symbol_table */
3232 symname_in_debug_hook
, /* _coff_symname_in_debug_hook */
3233 coff_pointerize_aux_hook
, /* _bfd_coff_pointerize_aux_hook */
3234 coff_print_aux
, /* bfd_coff_print_aux */
3235 dummy_reloc16_extra_cases
, /* _bfd_coff_reloc16_extra_cases */
3236 dummy_reloc16_estimate
, /* _bfd_coff_reloc16_estimate */
3237 NULL
, /* bfd_coff_sym_is_global */
3238 /* _bfd_coff_compute_section_file_positions */
3239 coff_compute_section_file_positions
,
3240 NULL
, /* _bfd_coff_start_final_link */
3241 xcoff_ppc_relocate_section
, /* _bfd_coff_relocate_section */
3242 coff_rtype_to_howto
, /* _bfd_coff_rtype_to_howto */
3243 NULL
, /* _bfd_coff_addust_symndx */
3244 _bfd_generic_link_add_one_symbol
, /* _bfd_coff_add_one_symbol */
3245 coff_link_output_has_begun
, /* _bfd_coff_link_output_has_begun */
3246 coff_final_link_postscript
/* _bfd_coff_final_link_postscript */
3249 0x01DF, /* magic number */
3250 bfd_arch_powerpc
, /* architecture */
3251 bfd_mach_ppc
, /* machine */
3253 /* function pointers to xcoff specific swap routines */
3254 xcoff_swap_ldhdr_in
, /* _xcoff_swap_ldhdr_in */
3255 xcoff_swap_ldhdr_out
, /* _xcoff_swap_ldhdr_out */
3256 xcoff_swap_ldsym_in
, /* _xcoff_swap_ldsym_in */
3257 xcoff_swap_ldsym_out
, /* _xcoff_swap_ldsym_out */
3258 xcoff_swap_ldrel_in
, /* _xcoff_swap_ldrel_in */
3259 xcoff_swap_ldrel_out
, /* _xcoff_swap_ldrel_out */
3262 LDHDRSZ
, /* _xcoff_ldhdrsz */
3263 LDSYMSZ
, /* _xcoff_ldsymsz */
3264 LDRELSZ
, /* _xcoff_ldrelsz */
3265 12, /* _xcoff_function_descriptor_size */
3266 SMALL_AOUTSZ
, /* _xcoff_small_aout_header_size */
3269 1, /* _xcoff_ldhdr_version */
3271 /* xcoff vs xcoff64 putting symbol names */
3272 _bfd_xcoff_put_symbol_name
, /* _xcoff_put_symbol_name */
3273 _bfd_xcoff_put_ldsymbol_name
, /* _xcoff_put_ldsymbol_name */
3275 &xcoff_dynamic_reloc
, /* dynamic reloc howto */
3277 xcoff_create_csect_from_smclas
, /* _xcoff_create_csect_from_smclas */
3279 /* lineno and reloc count overflow */
3280 xcoff_is_lineno_count_overflow
,
3281 xcoff_is_reloc_count_overflow
,
3283 xcoff_loader_symbol_offset
,
3284 xcoff_loader_reloc_offset
,
3287 &xcoff_glink_code
[0],
3288 (36), /* _xcoff_glink_size */
3292 /* The transfer vector that leads the outside world to all of the above. */
3293 const bfd_target pmac_xcoff_vec
=
3296 bfd_target_xcoff_flavour
,
3297 BFD_ENDIAN_BIG
, /* data byte order is big */
3298 BFD_ENDIAN_BIG
, /* header byte order is big */
3300 (HAS_RELOC
| EXEC_P
| /* object flags */
3301 HAS_LINENO
| HAS_DEBUG
| DYNAMIC
|
3302 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
3304 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
3305 0, /* leading char */
3306 '/', /* ar_pad_char */
3307 15, /* ar_max_namelen??? FIXMEmgo */
3310 bfd_getb64
, /* bfd_getx64 */
3311 bfd_getb_signed_64
, /* bfd_getx_signed_64 */
3312 bfd_putb64
, /* bfd_putx64 */
3313 bfd_getb32
, /* bfd_getx32 */
3314 bfd_getb_signed_32
, /* bfd_getx_signed_32 */
3315 bfd_putb32
, /* bfd_putx32 */
3316 bfd_getb16
, /* bfd_getx16 */
3317 bfd_getb_signed_16
, /* bfd_getx_signed_16 */
3318 bfd_putb16
, /* bfd_putx16 */
3321 bfd_getb64
, /* bfd_h_getx64 */
3322 bfd_getb_signed_64
, /* bfd_h_getx_signed_64 */
3323 bfd_putb64
, /* bfd_h_putx64 */
3324 bfd_getb32
, /* bfd_h_getx32 */
3325 bfd_getb_signed_32
, /* bfd_h_getx_signed_32 */
3326 bfd_putb32
, /* bfd_h_putx32 */
3327 bfd_getb16
, /* bfd_h_getx16 */
3328 bfd_getb_signed_16
, /* bfd_h_getx_signed_16 */
3329 bfd_putb16
, /* bfd_h_putx16 */
3331 { /* bfd_check_format */
3334 _bfd_xcoff_archive_p
,
3338 { /* bfd_set_format */
3341 _bfd_generic_mkarchive
,
3345 {/* bfd_write_contents */
3347 coff_write_object_contents
,
3348 _bfd_xcoff_write_archive_contents
,
3353 bfd_true
, /* _close_and_cleanup */
3354 bfd_true
, /* _bfd_free_cached_info */
3355 coff_new_section_hook
, /* _new_section_hook */
3356 _bfd_generic_get_section_contents
, /* _bfd_get_section_contents */
3357 /* _bfd_get_section_contents_in_window */
3358 _bfd_generic_get_section_contents_in_window
,
3361 _bfd_xcoff_copy_private_bfd_data
, /* _bfd_copy_private_bfd */
3362 /* _bfd_merge_private_bfd_data */
3363 ((boolean (*) (bfd
*, bfd
*)) bfd_true
),
3364 /* _bfd_copy_pivate_section_data */
3365 ((boolean (*) (bfd
*, asection
*, bfd
*, asection
*)) bfd_true
),
3366 /* _bfd_copy_private_symbol_data */
3367 ((boolean (*) (bfd
*, asymbol
*, bfd
*, asymbol
*)) bfd_true
),
3368 ((boolean (*) (bfd
*, flagword
)) bfd_true
), /* _bfd_set_private_flags */
3369 ((boolean (*) (bfd
*, void * )) bfd_true
), /* _bfd_print_private_bfd_data */
3372 coff_core_file_failing_command
, /* _core_file_failing_command */
3373 coff_core_file_failing_signal
, /* _core_file_failing_signal */
3374 /* _core_file_matches_executable_p */
3375 coff_core_file_matches_executable_p
,
3378 _bfd_xcoff_slurp_armap
, /* _slurp_armap */
3379 /* XCOFF archives do not have
3380 anything which corresponds to
3381 an extended name table. */
3382 bfd_false
, /* _slurp_extended_name_table */
3383 /* _construct_extended_name_table */
3384 ((boolean (*) (bfd
*, char **, bfd_size_type
*, const char **)) bfd_false
),
3385 bfd_dont_truncate_arname
, /* _truncate_arname */
3386 _bfd_xcoff_write_armap
, /* _write_armap */
3387 _bfd_xcoff_read_ar_hdr
, /* _read_ar_hdr */
3388 _bfd_xcoff_openr_next_archived_file
, /* _openr_next_archived_file */
3389 _bfd_generic_get_elt_at_index
, /* _get_elt_at_index */
3390 _bfd_xcoff_generic_stat_arch_elt
, /* _generic_dtat_arch_elt */
3391 /* XCOFF archives do not have
3393 bfd_true
, /* _update_armap_timestamp */
3396 coff_get_symtab_upper_bound
, /* _get_symtab_upper_bound */
3397 coff_get_symtab
, /* _get_symtab */
3398 coff_make_empty_symbol
, /* _make_empty_symbol */
3399 coff_print_symbol
, /* _print_symbol */
3400 coff_get_symbol_info
, /* _get_symbol_info */
3401 _bfd_xcoff_is_local_label_name
, /* _bfd_is_local_label_name */
3402 coff_get_lineno
, /* _get_lineno */
3403 coff_find_nearest_line
, /* _find_nearest_line */
3404 coff_bfd_make_debug_symbol
, /* _bfd_make_debug_symbol */
3405 _bfd_generic_read_minisymbols
, /* _read_minisymbols */
3406 _bfd_generic_minisymbol_to_symbol
, /* _minsymbol_to_symbol */
3409 coff_get_reloc_upper_bound
, /* _get_reloc_upper_bound */
3410 coff_canonicalize_reloc
, /* _cononicalize_reloc */
3411 _bfd_xcoff_reloc_type_lookup
, /* _bfd_reloc_type_lookup */
3414 coff_set_arch_mach
, /* _set_arch_mach */
3415 coff_set_section_contents
, /* _set_section_contents */
3418 _bfd_xcoff_sizeof_headers
, /* _sizeof_headers */
3419 /* _bfd_get_relocated_section_contents */
3420 bfd_generic_get_relocated_section_contents
,
3421 bfd_generic_relax_section
, /* _bfd_relax_section */
3422 _bfd_xcoff_bfd_link_hash_table_create
, /* _bfd_link_hash_table_create */
3423 _bfd_xcoff_bfd_link_add_symbols
, /* _bfd_link_add_symbols */
3424 _bfd_xcoff_bfd_final_link
, /* _bfd_filnal_link */
3425 _bfd_generic_link_split_section
, /* _bfd_link_split_section */
3426 bfd_generic_gc_sections
, /* _bfd_gc_sections */
3427 bfd_generic_merge_sections
, /* _bfd_merge_sections */
3430 /* _get_dynamic_symtab_upper_bound */
3431 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
3432 _bfd_xcoff_canonicalize_dynamic_symtab
, /* _cononicalize_dynamic_symtab */
3433 _bfd_xcoff_get_dynamic_reloc_upper_bound
,/* _get_dynamic_reloc_upper_bound */
3434 _bfd_xcoff_canonicalize_dynamic_reloc
, /* _cononicalize_dynamic_reloc */
3436 /* Opposite endian version, none exists */
3440 (void *) &bfd_pmac_xcoff_backend_data
,