1 /* BFD back-end for IBM RS/6000 "XCOFF64" files.
3 Free Software Foundation, Inc.
4 Written Clinton Popetz.
5 Contributed by Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27 #include "coff/internal.h"
28 #include "coff/xcoff.h"
29 #include "coff/rs6k64.h"
33 #define GET_FILEHDR_SYMPTR bfd_h_get_64
34 #define PUT_FILEHDR_SYMPTR bfd_h_put_64
35 #define GET_AOUTHDR_DATA_START bfd_h_get_64
36 #define PUT_AOUTHDR_DATA_START bfd_h_put_64
37 #define GET_AOUTHDR_TEXT_START bfd_h_get_64
38 #define PUT_AOUTHDR_TEXT_START bfd_h_put_64
39 #define GET_AOUTHDR_TSIZE bfd_h_get_64
40 #define PUT_AOUTHDR_TSIZE bfd_h_put_64
41 #define GET_AOUTHDR_DSIZE bfd_h_get_64
42 #define PUT_AOUTHDR_DSIZE bfd_h_put_64
43 #define GET_AOUTHDR_BSIZE bfd_h_get_64
44 #define PUT_AOUTHDR_BSIZE bfd_h_put_64
45 #define GET_AOUTHDR_ENTRY bfd_h_get_64
46 #define PUT_AOUTHDR_ENTRY bfd_h_put_64
47 #define GET_SCNHDR_PADDR bfd_h_get_64
48 #define PUT_SCNHDR_PADDR bfd_h_put_64
49 #define GET_SCNHDR_VADDR bfd_h_get_64
50 #define PUT_SCNHDR_VADDR bfd_h_put_64
51 #define GET_SCNHDR_SIZE bfd_h_get_64
52 #define PUT_SCNHDR_SIZE bfd_h_put_64
53 #define GET_SCNHDR_SCNPTR bfd_h_get_64
54 #define PUT_SCNHDR_SCNPTR bfd_h_put_64
55 #define GET_SCNHDR_RELPTR bfd_h_get_64
56 #define PUT_SCNHDR_RELPTR bfd_h_put_64
57 #define GET_SCNHDR_LNNOPTR bfd_h_get_64
58 #define PUT_SCNHDR_LNNOPTR bfd_h_put_64
59 #define GET_SCNHDR_NRELOC bfd_h_get_32
60 #define MAX_SCNHDR_NRELOC 0xffffffff
61 #define PUT_SCNHDR_NRELOC bfd_h_put_32
62 #define GET_SCNHDR_NLNNO bfd_h_get_32
63 #define MAX_SCNHDR_NLNNO 0xffffffff
64 #define PUT_SCNHDR_NLNNO bfd_h_put_32
65 #define GET_RELOC_VADDR bfd_h_get_64
66 #define PUT_RELOC_VADDR bfd_h_put_64
68 #define COFF_FORCE_SYMBOLS_IN_STRINGS
69 #define COFF_DEBUG_STRING_WIDE_PREFIX
72 #define COFF_ADJUST_SCNHDR_OUT_POST(ABFD,INT,EXT) \
74 memset (((SCNHDR *)EXT)->s_pad, 0, sizeof (((SCNHDR *)EXT)->s_pad));\
77 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
78 from smaller values. Start with zero, widen, *then* decrement. */
79 #define MINUS_ONE (((bfd_vma)0) - 1)
82 #define NO_COFF_LINENOS
84 #define coff_SWAP_lineno_in _bfd_xcoff64_swap_lineno_in
85 #define coff_SWAP_lineno_out _bfd_xcoff64_swap_lineno_out
87 #define PUTWORD bfd_h_put_32
88 #define PUTHALF bfd_h_put_16
89 #define PUTBYTE bfd_h_put_8
90 #define GETWORD bfd_h_get_32
91 #define GETHALF bfd_h_get_16
92 #define GETBYTE bfd_h_get_8
95 static void _bfd_xcoff64_swap_lineno_in
PARAMS ((bfd
*, PTR
, PTR
));
96 static unsigned int _bfd_xcoff64_swap_lineno_out
PARAMS ((bfd
*, PTR
, PTR
));
97 static boolean _bfd_xcoff64_put_ldsymbol_name
98 PARAMS ((bfd
*, struct xcoff_loader_info
*, struct internal_ldsym
*,
101 /* For XCOFF64, the effective width of symndx changes depending on
102 whether we are the first entry. Sigh. */
104 _bfd_xcoff64_swap_lineno_in (abfd
, ext1
, in1
)
109 LINENO
*ext
= (LINENO
*)ext1
;
110 struct internal_lineno
*in
= (struct internal_lineno
*)in1
;
112 in
->l_lnno
= bfd_h_get_32(abfd
, (bfd_byte
*) (ext
->l_lnno
));
114 in
->l_addr
.l_symndx
=
115 bfd_h_get_32(abfd
, (bfd_byte
*) ext
->l_addr
.l_symndx
);
118 bfd_h_get_64(abfd
, (bfd_byte
*) ext
->l_addr
.l_paddr
);
122 _bfd_xcoff64_swap_lineno_out (abfd
, inp
, outp
)
127 struct internal_lineno
*in
= (struct internal_lineno
*)inp
;
128 struct external_lineno
*ext
= (struct external_lineno
*)outp
;
129 PUTWORD(abfd
, in
->l_addr
.l_symndx
, (bfd_byte
*)
130 ext
->l_addr
.l_symndx
);
132 bfd_h_put_32 (abfd
, in
->l_lnno
, (bfd_byte
*) (ext
->l_lnno
));
134 bfd_h_put_32 (abfd
, in
->l_addr
.l_symndx
, (bfd_byte
*)ext
->l_addr
.l_symndx
);
136 bfd_h_put_64 (abfd
, in
->l_addr
.l_paddr
, (bfd_byte
*)ext
->l_addr
.l_paddr
);
138 return bfd_coff_linesz (abfd
);
142 static void _bfd_xcoff64_swap_sym_in
PARAMS ((bfd
*, PTR
, PTR
));
143 static unsigned int _bfd_xcoff64_swap_sym_out
PARAMS ((bfd
*, PTR
, PTR
));
144 static void _bfd_xcoff64_swap_aux_in
PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
145 static unsigned int _bfd_xcoff64_swap_aux_out
PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
148 _bfd_xcoff64_swap_sym_in (abfd
, ext1
, in1
)
153 struct external_syment
*ext
= (struct external_syment
*)ext1
;
154 struct internal_syment
*in
= (struct internal_syment
*)in1
;
156 in
->_n
._n_n
._n_zeroes
= 0;
157 in
->_n
._n_n
._n_offset
= bfd_h_get_32(abfd
, (bfd_byte
*) ext
->e_offset
);
158 in
->n_value
= bfd_h_get_64(abfd
, (bfd_byte
*) ext
->e_value
);
159 in
->n_scnum
= bfd_h_get_16(abfd
, (bfd_byte
*) ext
->e_scnum
);
160 in
->n_type
= bfd_h_get_16(abfd
, (bfd_byte
*) ext
->e_type
);
161 in
->n_sclass
= bfd_h_get_8(abfd
, ext
->e_sclass
);
162 in
->n_numaux
= bfd_h_get_8(abfd
, ext
->e_numaux
);
166 _bfd_xcoff64_swap_sym_out (abfd
, inp
, extp
)
171 struct internal_syment
*in
= (struct internal_syment
*)inp
;
172 struct external_syment
*ext
=(struct external_syment
*)extp
;
174 bfd_h_put_32(abfd
, in
->_n
._n_n
._n_offset
, (bfd_byte
*) ext
->e_offset
);
175 bfd_h_put_64(abfd
, in
->n_value
, (bfd_byte
*) ext
->e_value
);
176 bfd_h_put_16(abfd
, in
->n_scnum
, (bfd_byte
*) ext
->e_scnum
);
177 bfd_h_put_16(abfd
, in
->n_type
, (bfd_byte
*) ext
->e_type
);
178 bfd_h_put_8(abfd
, in
->n_sclass
, ext
->e_sclass
);
179 bfd_h_put_8(abfd
, in
->n_numaux
, ext
->e_numaux
);
180 return bfd_coff_symesz (abfd
);
184 _bfd_xcoff64_swap_aux_in (abfd
, ext1
, type
, class, indx
, numaux
, in1
)
193 union external_auxent
*ext
= (union external_auxent
*)ext1
;
194 union internal_auxent
*in
= (union internal_auxent
*)in1
;
198 if (ext
->x_file
.x_n
.x_zeroes
== 0) {
199 in
->x_file
.x_n
.x_zeroes
= 0;
200 in
->x_file
.x_n
.x_offset
=
201 bfd_h_get_32(abfd
, (bfd_byte
*) ext
->x_file
.x_n
.x_offset
);
203 memcpy (in
->x_file
.x_fname
, ext
->x_file
.x_fname
, FILNMLEN
);
207 /* RS/6000 "csect" auxents */
210 if (indx
+ 1 == numaux
)
212 bfd_signed_vma h
= 0;
215 h
= bfd_h_get_signed_32(abfd
, ext
->x_csect
.x_scnlen_hi
);
216 l
= bfd_h_get_32 (abfd
, ext
->x_csect
.x_scnlen_lo
);
218 in
->x_csect
.x_scnlen
.l
= h
<< 32 | (l
& 0xffffffff);
220 in
->x_csect
.x_parmhash
= bfd_h_get_32 (abfd
,
221 ext
->x_csect
.x_parmhash
);
222 in
->x_csect
.x_snhash
= bfd_h_get_16 (abfd
, ext
->x_csect
.x_snhash
);
223 /* We don't have to hack bitfields in x_smtyp because it's
224 defined by shifts-and-ands, which are equivalent on all
226 in
->x_csect
.x_smtyp
= bfd_h_get_8 (abfd
, ext
->x_csect
.x_smtyp
);
227 in
->x_csect
.x_smclas
= bfd_h_get_8 (abfd
, ext
->x_csect
.x_smclas
);
235 if (type
== T_NULL
) {
236 /* PE defines some extra fields; we zero them out for
238 in
->x_scn
.x_checksum
= 0;
239 in
->x_scn
.x_associated
= 0;
240 in
->x_scn
.x_comdat
= 0;
247 if (class == C_BLOCK
|| class == C_FCN
|| ISFCN (type
) || ISTAG (class))
249 in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
= bfd_h_get_64(abfd
, (bfd_byte
*)
250 ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
251 in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
= bfd_h_get_32(abfd
, (bfd_byte
*)
252 ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
255 in
->x_sym
.x_misc
.x_fsize
= bfd_h_get_32(abfd
, (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_fcn
.x_fsize
);
258 in
->x_sym
.x_misc
.x_lnsz
.x_lnno
= bfd_h_get_32(abfd
, (bfd_byte
*)
259 ext
->x_sym
.x_fcnary
.x_lnsz
.x_lnno
);
260 in
->x_sym
.x_misc
.x_lnsz
.x_size
= bfd_h_get_16(abfd
, (bfd_byte
*)
261 ext
->x_sym
.x_fcnary
.x_lnsz
.x_size
);
265 /* the semicolon is because MSVC doesn't like labels at
273 _bfd_xcoff64_swap_aux_out (abfd
, inp
, type
, class, indx
, numaux
, extp
)
278 int indx ATTRIBUTE_UNUSED
;
279 int numaux ATTRIBUTE_UNUSED
;
282 union internal_auxent
*in
= (union internal_auxent
*)inp
;
283 union external_auxent
*ext
= (union external_auxent
*)extp
;
285 memset((PTR
)ext
, 0, bfd_coff_auxesz (abfd
));
289 if (ext
->x_file
.x_n
.x_zeroes
== 0) {
290 bfd_h_put_32 (abfd
, 0, (bfd_byte
*) ext
->x_file
.x_n
.x_zeroes
);
291 bfd_h_put_32 (abfd
, in
->x_file
.x_n
.x_offset
,
292 (bfd_byte
*) ext
->x_file
.x_n
.x_offset
);
294 memcpy (ext
->x_file
.x_fname
, in
->x_file
.x_fname
, FILNMLEN
);
296 bfd_h_put_8 (abfd
, _AUX_FILE
, (bfd_byte
*) ext
->x_auxtype
.x_auxtype
);
299 /* RS/6000 "csect" auxents */
302 if (indx
+ 1 == numaux
)
306 temp
= in
->x_csect
.x_scnlen
.l
& 0xffffffff;
307 bfd_h_put_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_lo
);
308 temp
= in
->x_csect
.x_scnlen
.l
>> 32;
309 bfd_h_put_32 (abfd
, temp
, ext
->x_csect
.x_scnlen_hi
);
310 bfd_h_put_32 (abfd
, in
->x_csect
.x_parmhash
, ext
->x_csect
.x_parmhash
);
311 bfd_h_put_16 (abfd
, in
->x_csect
.x_snhash
, ext
->x_csect
.x_snhash
);
312 /* We don't have to hack bitfields in x_smtyp because it's
313 defined by shifts-and-ands, which are equivalent on all
315 bfd_h_put_8 (abfd
, in
->x_csect
.x_smtyp
, ext
->x_csect
.x_smtyp
);
316 bfd_h_put_8 (abfd
, in
->x_csect
.x_smclas
, ext
->x_csect
.x_smclas
);
317 bfd_h_put_8 (abfd
, _AUX_CSECT
, (bfd_byte
*) ext
->x_auxtype
.x_auxtype
);
325 if (type
== T_NULL
) {
331 if (class == C_BLOCK
|| class == C_FCN
|| ISFCN (type
) || ISTAG (class))
333 bfd_h_put_64(abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
,
334 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_fcn
.x_lnnoptr
);
335 bfd_h_put_8 (abfd
, _AUX_FCN
, (bfd_byte
*) ext
->x_auxtype
.x_auxtype
);
336 bfd_h_put_32(abfd
, in
->x_sym
.x_fcnary
.x_fcn
.x_endndx
.l
,
337 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_fcn
.x_endndx
);
340 bfd_h_put_32 (abfd
, in
->x_sym
.x_misc
.x_fsize
,
341 (bfd_byte
*) ext
->x_sym
.x_fcnary
.x_fcn
.x_fsize
);
344 bfd_h_put_32(abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_lnno
,
345 (bfd_byte
*)ext
->x_sym
.x_fcnary
.x_lnsz
.x_lnno
);
346 bfd_h_put_16(abfd
, in
->x_sym
.x_misc
.x_lnsz
.x_size
,
347 (bfd_byte
*)ext
->x_sym
.x_fcnary
.x_lnsz
.x_size
);
352 return bfd_coff_auxesz (abfd
);
356 _bfd_xcoff64_put_symbol_name (bfd
*abfd
, struct bfd_strtab_hash
*strtab
,
357 struct internal_syment
*sym
,
364 if ((abfd
->flags
& BFD_TRADITIONAL_FORMAT
) != 0)
367 indx
= _bfd_stringtab_add (strtab
, name
, hash
, false);
369 if (indx
== (bfd_size_type
) -1)
372 sym
->_n
._n_n
._n_zeroes
= 0;
373 sym
->_n
._n_n
._n_offset
= STRING_SIZE_SIZE
+ indx
;
379 _bfd_xcoff64_put_ldsymbol_name (abfd
, ldinfo
, ldsym
, name
)
380 bfd
*abfd ATTRIBUTE_UNUSED
;
381 struct xcoff_loader_info
*ldinfo
;
382 struct internal_ldsym
*ldsym
;
389 if (ldinfo
->string_size
+ len
+ 3 > ldinfo
->string_alc
){
391 bfd_byte
*newstrings
;
393 newalc
= ldinfo
->string_alc
* 2;
396 while (ldinfo
->string_size
+ len
+ 3 > newalc
)
399 newstrings
= ((bfd_byte
*)
400 bfd_realloc ((PTR
) ldinfo
->strings
, newalc
));
401 if (newstrings
== NULL
) {
402 ldinfo
->failed
= true;
405 ldinfo
->string_alc
= newalc
;
406 ldinfo
->strings
= newstrings
;
409 bfd_put_16 (ldinfo
->output_bfd
, len
+ 1,
410 ldinfo
->strings
+ ldinfo
->string_size
);
411 strcpy (ldinfo
->strings
+ ldinfo
->string_size
+ 2, name
);
412 ldsym
->_l
._l_l
._l_zeroes
= 0;
413 ldsym
->_l
._l_l
._l_offset
= ldinfo
->string_size
+ 2;
414 ldinfo
->string_size
+= len
+ 3;
419 extern boolean _bfd_xcoff_mkobject
PARAMS ((bfd
*));
420 extern boolean _bfd_xcoff_copy_private_bfd_data
PARAMS ((bfd
*, bfd
*));
421 extern boolean _bfd_xcoff_is_local_label_name
PARAMS ((bfd
*, const char *));
422 extern void xcoff64_rtype2howto
423 PARAMS ((arelent
*, struct internal_reloc
*));
424 extern reloc_howto_type
* xcoff64_reloc_type_lookup
425 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
426 extern boolean _bfd_xcoff_slurp_armap
PARAMS ((bfd
*));
427 extern PTR _bfd_xcoff_read_ar_hdr
PARAMS ((bfd
*));
428 extern bfd
*_bfd_xcoff_openr_next_archived_file
PARAMS ((bfd
*, bfd
*));
429 extern int _bfd_xcoff_generic_stat_arch_elt
PARAMS ((bfd
*, struct stat
*));
430 extern boolean _bfd_xcoff_write_armap
431 PARAMS ((bfd
*, unsigned int, struct orl
*, unsigned int, int));
432 extern boolean _bfd_xcoff_write_archive_contents
PARAMS ((bfd
*));
433 extern int _bfd_xcoff_sizeof_headers
PARAMS ((bfd
*, boolean
));
434 extern void _bfd_xcoff_swap_sym_in
PARAMS ((bfd
*, PTR
, PTR
));
435 extern unsigned int _bfd_xcoff_swap_sym_out
PARAMS ((bfd
*, PTR
, PTR
));
436 extern void _bfd_xcoff_swap_aux_in
PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
437 extern unsigned int _bfd_xcoff_swap_aux_out
PARAMS ((bfd
*, PTR
, int, int, int, int, PTR
));
439 /* coffcode.h needs these to be defined */
440 /* Internalcoff.h and coffcode.h modify themselves based on these flags. */
442 #define RS6000COFF_C 1
444 #define SELECT_RELOC(internal, howto) \
446 internal.r_type = howto->type; \
448 ((howto->complain_on_overflow == complain_overflow_signed \
451 | (howto->bitsize - 1)); \
454 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
455 #define COFF_LONG_FILENAMES
456 #define NO_COFF_SYMBOLS
457 #define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst)
458 #define coff_mkobject _bfd_xcoff_mkobject
459 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
460 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
461 #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
463 extern const bfd_target
* rs6000coff_core_p ();
464 extern boolean
rs6000coff_core_file_matches_executable_p ();
465 extern char *rs6000coff_core_file_failing_command
PARAMS ((bfd
*abfd
));
466 extern int rs6000coff_core_file_failing_signal
PARAMS ((bfd
*abfd
));
467 #define CORE_FILE_P rs6000coff_core_p
468 #define coff_core_file_failing_command \
469 rs6000coff_core_file_failing_command
470 #define coff_core_file_failing_signal \
471 rs6000coff_core_file_failing_signal
472 #define coff_core_file_matches_executable_p \
473 rs6000coff_core_file_matches_executable_p
475 #define CORE_FILE_P _bfd_dummy_target
476 #define coff_core_file_failing_command \
477 _bfd_nocore_core_file_failing_command
478 #define coff_core_file_failing_signal \
479 _bfd_nocore_core_file_failing_signal
480 #define coff_core_file_matches_executable_p \
481 _bfd_nocore_core_file_matches_executable_p
483 #define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
484 #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
485 #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
486 #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
490 #include "coffcode.h"
492 /* Routines to swap information in the XCOFF .loader section. If we
493 ever need to write an XCOFF loader, this stuff will need to be
494 moved to another file shared by the linker (which XCOFF calls the
495 ``binder'') and the loader. */
497 static void xcoff64_swap_ldhdr_in
498 PARAMS ((bfd
*, const PTR
, struct internal_ldhdr
*));
499 static void xcoff64_swap_ldhdr_out
500 PARAMS ((bfd
*, const struct internal_ldhdr
*, PTR d
));
501 static void xcoff64_swap_ldsym_in
502 PARAMS ((bfd
*, const PTR
, struct internal_ldsym
*));
503 static void xcoff64_swap_ldsym_out
504 PARAMS ((bfd
*, const struct internal_ldsym
*, PTR d
));
505 static void xcoff64_swap_ldrel_in
506 PARAMS ((bfd
*, const PTR
, struct internal_ldrel
*));
507 static void xcoff64_swap_ldrel_out
508 PARAMS ((bfd
*, const struct internal_ldrel
*, PTR d
));
509 static boolean xcoff64_write_object_contents
PARAMS ((bfd
*));
510 static boolean xcoff64_ppc_relocate_section
511 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
512 struct internal_reloc
*, struct internal_syment
*,
513 asection
**sections
));
514 static boolean xcoff64_slurp_armap
PARAMS ((bfd
*));
515 static const bfd_target
*xcoff64_archive_p
PARAMS ((bfd
*));
516 static bfd
*xcoff64_openr_next_archived_file
PARAMS ((bfd
*, bfd
*));
517 static int xcoff64_sizeof_headers
PARAMS ((bfd
*, boolean
));
518 static asection
*xcoff64_create_csect_from_smclas
519 PARAMS ((bfd
*, union internal_auxent
*, const char *));
520 static boolean xcoff64_is_lineno_count_overflow
PARAMS ((bfd
*, bfd_vma
));
521 static boolean xcoff64_is_reloc_count_overflow
PARAMS ((bfd
*, bfd_vma
));
522 static bfd_vma xcoff64_loader_symbol_offset
523 PARAMS ((bfd
*, struct internal_ldhdr
*));
524 static bfd_vma xcoff64_loader_reloc_offset
525 PARAMS ((bfd
*, struct internal_ldhdr
*));
527 /* Swap in the ldhdr structure. */
530 xcoff64_swap_ldhdr_in (abfd
, s
, dst
)
533 struct internal_ldhdr
*dst
;
535 const struct external_ldhdr
*src
= (const struct external_ldhdr
*) s
;
537 dst
->l_version
= bfd_get_32 (abfd
, src
->l_version
);
538 dst
->l_nsyms
= bfd_get_32 (abfd
, src
->l_nsyms
);
539 dst
->l_nreloc
= bfd_get_32 (abfd
, src
->l_nreloc
);
540 dst
->l_istlen
= bfd_get_32 (abfd
, src
->l_istlen
);
541 dst
->l_nimpid
= bfd_get_32 (abfd
, src
->l_nimpid
);
542 dst
->l_stlen
= bfd_get_32 (abfd
, src
->l_stlen
);
543 dst
->l_impoff
= bfd_get_64 (abfd
, src
->l_impoff
);
544 dst
->l_stoff
= bfd_get_64 (abfd
, src
->l_stoff
);
545 dst
->l_symoff
= bfd_get_64 (abfd
, src
->l_symoff
);
546 dst
->l_rldoff
= bfd_get_64 (abfd
, src
->l_rldoff
);
549 /* Swap out the ldhdr structure. */
552 xcoff64_swap_ldhdr_out (abfd
, src
, d
)
554 const struct internal_ldhdr
*src
;
557 struct external_ldhdr
*dst
= (struct external_ldhdr
*) d
;
559 bfd_put_32 (abfd
, src
->l_version
, dst
->l_version
);
560 bfd_put_32 (abfd
, src
->l_nsyms
, dst
->l_nsyms
);
561 bfd_put_32 (abfd
, src
->l_nreloc
, dst
->l_nreloc
);
562 bfd_put_32 (abfd
, src
->l_istlen
, dst
->l_istlen
);
563 bfd_put_32 (abfd
, src
->l_nimpid
, dst
->l_nimpid
);
564 bfd_put_32 (abfd
, src
->l_stlen
, dst
->l_stlen
);
565 bfd_put_64 (abfd
, src
->l_impoff
, dst
->l_impoff
);
566 bfd_put_64 (abfd
, src
->l_stoff
, dst
->l_stoff
);
567 bfd_put_64 (abfd
, src
->l_symoff
, dst
->l_symoff
);
568 bfd_put_64 (abfd
, src
->l_rldoff
, dst
->l_rldoff
);
571 /* Swap in the ldsym structure. */
574 xcoff64_swap_ldsym_in (abfd
, s
, dst
)
577 struct internal_ldsym
*dst
;
579 const struct external_ldsym
*src
= (const struct external_ldsym
*) s
;
581 * XCOFF64 does not use l_zeroes like XCOFF32
582 * Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
583 * as an offset into the loader symbol table
585 dst
->_l
._l_l
._l_zeroes
= 0;
586 dst
->_l
._l_l
._l_offset
= bfd_get_32 (abfd
, src
->l_offset
);
587 dst
->l_value
= bfd_get_64 (abfd
, src
->l_value
);
588 dst
->l_scnum
= bfd_get_16 (abfd
, src
->l_scnum
);
589 dst
->l_smtype
= bfd_get_8 (abfd
, src
->l_smtype
);
590 dst
->l_smclas
= bfd_get_8 (abfd
, src
->l_smclas
);
591 dst
->l_ifile
= bfd_get_32 (abfd
, src
->l_ifile
);
592 dst
->l_parm
= bfd_get_32 (abfd
, src
->l_parm
);
595 /* Swap out the ldsym structure. */
598 xcoff64_swap_ldsym_out (abfd
, src
, d
)
600 const struct internal_ldsym
*src
;
603 struct external_ldsym
*dst
= (struct external_ldsym
*) d
;
605 bfd_put_64 (abfd
, src
->l_value
, dst
->l_value
);
606 bfd_put_32 (abfd
, src
->_l
._l_l
._l_offset
, dst
->l_offset
);
607 bfd_put_16 (abfd
, src
->l_scnum
, dst
->l_scnum
);
608 bfd_put_8 (abfd
, src
->l_smtype
, dst
->l_smtype
);
609 bfd_put_8 (abfd
, src
->l_smclas
, dst
->l_smclas
);
610 bfd_put_32 (abfd
, src
->l_ifile
, dst
->l_ifile
);
611 bfd_put_32 (abfd
, src
->l_parm
, dst
->l_parm
);
614 /* Swap in the ldrel structure. */
617 xcoff64_swap_ldrel_in (abfd
, s
, dst
)
620 struct internal_ldrel
*dst
;
622 const struct external_ldrel
*src
= (const struct external_ldrel
*) s
;
624 dst
->l_vaddr
= bfd_get_64 (abfd
, src
->l_vaddr
);
625 dst
->l_symndx
= bfd_get_32 (abfd
, src
->l_symndx
);
626 dst
->l_rtype
= bfd_get_16 (abfd
, src
->l_rtype
);
627 dst
->l_rsecnm
= bfd_get_16 (abfd
, src
->l_rsecnm
);
630 /* Swap out the ldrel structure. */
633 xcoff64_swap_ldrel_out (abfd
, src
, d
)
635 const struct internal_ldrel
*src
;
638 struct external_ldrel
*dst
= (struct external_ldrel
*) d
;
640 bfd_put_64 (abfd
, src
->l_vaddr
, dst
->l_vaddr
);
641 bfd_put_16 (abfd
, src
->l_rtype
, dst
->l_rtype
);
642 bfd_put_16 (abfd
, src
->l_rsecnm
, dst
->l_rsecnm
);
643 bfd_put_32 (abfd
, src
->l_symndx
, dst
->l_symndx
);
647 xcoff64_write_object_contents (abfd
)
651 boolean hasrelocs
= false;
652 boolean haslinno
= false;
655 file_ptr lineno_base
;
657 unsigned long reloc_size
= 0;
658 unsigned long lnno_size
= 0;
659 boolean long_section_names
;
660 asection
*text_sec
= ((void *)0) ;
661 asection
*data_sec
= ((void *)0) ;
662 asection
*bss_sec
= ((void *)0) ;
663 struct internal_filehdr internal_f
;
664 struct internal_aouthdr internal_a
;
666 bfd_set_error (bfd_error_system_call
);
668 if (abfd
->output_has_begun
== false) {
669 if (! bfd_coff_compute_section_file_positions (abfd
))
673 /* Work out the size of the reloc and linno areas */
674 reloc_base
= obj_relocbase (abfd
);
676 for (current
= abfd
->sections
; current
!= NULL
; current
= current
->next
) {
677 reloc_size
+= current
->reloc_count
* bfd_coff_relsz (abfd
);
680 lineno_base
= reloc_base
+ reloc_size
;
682 /* Make a pass through the symbol table to count line number entries and
683 put them into the correct asections */
684 lnno_size
= coff_count_linenumbers (abfd
) * bfd_coff_linesz (abfd
);
686 sym_base
= lineno_base
+ lnno_size
;
688 /* Indicate in each section->line_filepos its actual file address */
689 for (current
= abfd
->sections
; current
!= NULL
; current
= current
->next
) {
690 if (current
->lineno_count
) {
691 current
->line_filepos
= lineno_base
;
692 current
->moving_line_filepos
= lineno_base
;
693 lineno_base
+= current
->lineno_count
* bfd_coff_linesz (abfd
);
695 current
->line_filepos
= 0;
698 if (current
->reloc_count
) {
699 current
->rel_filepos
= reloc_base
;
700 reloc_base
+= current
->reloc_count
* bfd_coff_relsz (abfd
);
702 current
->rel_filepos
= 0;
706 if ((abfd
->flags
& EXEC_P
) != 0) {
707 scn_base
= bfd_coff_filhsz (abfd
) + bfd_coff_aoutsz (abfd
);
708 internal_f
.f_opthdr
= bfd_coff_aoutsz (abfd
);
710 scn_base
= bfd_coff_filhsz (abfd
);
711 internal_f
.f_opthdr
= 0;
714 internal_f
.f_nscns
= 0;
716 if (bfd_seek (abfd
, scn_base
, SEEK_SET
) != 0)
719 long_section_names
= false;
720 for (current
= abfd
->sections
; current
!= NULL
; current
= current
->next
) {
722 struct internal_scnhdr section
;
723 struct external_scnhdr buff
;
725 internal_f
.f_nscns
++;
727 strncpy (section
.s_name
, current
->name
, SCNNMLEN
);
729 section
.s_vaddr
= current
->vma
;
730 section
.s_paddr
= current
->lma
;
731 section
.s_size
= current
->_raw_size
;
734 If this section has no size or is unloadable then the scnptr
737 if (current
->_raw_size
== 0 ||
738 (current
->flags
& (SEC_LOAD
| SEC_HAS_CONTENTS
)) == 0) {
739 section
.s_scnptr
= 0;
741 section
.s_scnptr
= current
->filepos
;
744 section
.s_relptr
= current
->rel_filepos
;
745 section
.s_lnnoptr
= current
->line_filepos
;
746 section
.s_nreloc
= current
->reloc_count
;
748 section
.s_nlnno
= current
->lineno_count
;
749 if (current
->reloc_count
!= 0)
751 if (current
->lineno_count
!= 0)
754 section
.s_flags
= sec_to_styp_flags (current
->name
, current
->flags
);
756 if (!strcmp (current
->name
, _TEXT
)) {
758 } else if (!strcmp (current
->name
, _DATA
)) {
760 } else if (!strcmp (current
->name
, _BSS
)) {
764 if (bfd_coff_swap_scnhdr_out (abfd
, §ion
, &buff
) == 0
765 || bfd_write ((PTR
) (&buff
), 1, bfd_coff_scnhsz (abfd
), abfd
)
766 != bfd_coff_scnhsz (abfd
))
770 internal_f
.f_timdat
= 0;
772 internal_f
.f_flags
= 0;
775 internal_f
.f_flags
|= F_RELFLG
;
777 internal_f
.f_flags
|= F_LNNO
;
778 if (abfd
->flags
& EXEC_P
)
779 internal_f
.f_flags
|= F_EXEC
;
781 /* FIXME: this is wrong for PPC_PE! */
782 if (bfd_little_endian (abfd
))
783 internal_f
.f_flags
|= F_AR32WR
;
785 internal_f
.f_flags
|= F_AR32W
;
787 if ((abfd
->flags
& DYNAMIC
) != 0)
788 internal_f
.f_flags
|= F_SHROBJ
;
789 if (bfd_get_section_by_name (abfd
, _LOADER
) != NULL
)
790 internal_f
.f_flags
|= F_DYNLOAD
;
792 memset (&internal_a
, 0, sizeof internal_a
);
796 * This can only be called from the xcoff64 backend so the magic # must
799 internal_f
.f_magic
= 0757;
801 internal_a
.magic
= (abfd
->flags
& D_PAGED
) ? RS6K_AOUTHDR_ZMAGIC
:
802 (abfd
->flags
& WP_TEXT
) ? RS6K_AOUTHDR_NMAGIC
:
805 /* FIXME: Does anybody ever set this to another value? */
806 internal_a
.vstamp
= 0;
808 /* Now should write relocs, strings, syms */
809 obj_sym_filepos (abfd
) = sym_base
;
811 internal_f
.f_symptr
= 0;
812 internal_f
.f_nsyms
= 0;
815 * If bfd_get_symcount (abfd) != 0, then we are not using the COFF
816 * backend linker, and obj_raw_syment_count is not valid until after
817 * coff_write_symbols is called.
819 if (bfd_get_symcount (abfd
) != 0) {
822 if (!coff_renumber_symbols (abfd
, &firstundef
))
824 coff_mangle_symbols (abfd
);
825 if (! coff_write_symbols (abfd
))
827 if (! coff_write_linenumbers (abfd
))
829 if (! coff_write_relocs (abfd
, firstundef
))
832 internal_f
.f_symptr
= sym_base
;
833 internal_f
.f_nsyms
= bfd_get_symcount (abfd
);
834 } else if (obj_raw_syment_count (abfd
) != 0) {
835 internal_f
.f_symptr
= sym_base
;
838 * AIX appears to require that F_RELFLG not be set if there are
839 * local symbols but no relocations.
841 internal_f
.f_flags
&=~ F_RELFLG
;
843 internal_f
.f_flags
|= F_LSYMS
;
847 internal_a
.tsize
= bfd_get_section_size_before_reloc (text_sec
);
848 internal_a
.text_start
= internal_a
.tsize
? text_sec
->vma
: 0;
852 internal_a
.dsize
= bfd_get_section_size_before_reloc (data_sec
);
853 internal_a
.data_start
= internal_a
.dsize
? data_sec
->vma
: 0;
857 internal_a
.bsize
= bfd_get_section_size_before_reloc (bss_sec
);
858 if (internal_a
.bsize
&& bss_sec
->vma
< internal_a
.data_start
)
859 internal_a
.data_start
= bss_sec
->vma
;
862 internal_a
.entry
= bfd_get_start_address (abfd
);
863 internal_f
.f_nsyms
= obj_raw_syment_count (abfd
);
865 if (xcoff_data (abfd
)->full_aouthdr
) {
868 asection
*loader_sec
;
870 internal_a
.vstamp
= 1;
872 internal_a
.o_snentry
= xcoff_data (abfd
)->snentry
;
873 if (internal_a
.o_snentry
== 0)
874 internal_a
.entry
= (bfd_vma
) -1;
876 if (text_sec
!= NULL
) {
877 internal_a
.o_sntext
= text_sec
->target_index
;
878 internal_a
.o_algntext
= bfd_get_section_alignment (abfd
, text_sec
);
880 internal_a
.o_sntext
= 0;
881 internal_a
.o_algntext
= 0;
884 if (data_sec
!= NULL
) {
885 internal_a
.o_sndata
= data_sec
->target_index
;
886 internal_a
.o_algndata
= bfd_get_section_alignment (abfd
, data_sec
);
888 internal_a
.o_sndata
= 0;
889 internal_a
.o_algndata
= 0;
892 loader_sec
= bfd_get_section_by_name (abfd
, ".loader");
893 if (loader_sec
!= NULL
)
894 internal_a
.o_snloader
= loader_sec
->target_index
;
896 internal_a
.o_snloader
= 0;
898 internal_a
.o_snbss
= bss_sec
->target_index
;
900 internal_a
.o_snbss
= 0;
902 toc
= xcoff_data (abfd
)->toc
;
903 internal_a
.o_toc
= toc
;
904 internal_a
.o_sntoc
= xcoff_data (abfd
)->sntoc
;
906 internal_a
.o_modtype
= xcoff_data (abfd
)->modtype
;
907 if (xcoff_data (abfd
)->cputype
!= -1)
908 internal_a
.o_cputype
= xcoff_data (abfd
)->cputype
;
911 switch (bfd_get_arch (abfd
))
913 case bfd_arch_rs6000
:
914 internal_a
.o_cputype
= 4;
916 case bfd_arch_powerpc
:
917 if (bfd_get_mach (abfd
) == 0)
918 internal_a
.o_cputype
= 3;
920 internal_a
.o_cputype
= 1;
926 internal_a
.o_maxstack
= xcoff_data (abfd
)->maxstack
;
927 internal_a
.o_maxdata
= xcoff_data (abfd
)->maxdata
;
930 if (bfd_seek (abfd
, (file_ptr
) 0, 0 ) != 0)
935 bfd_size_type amount
;
937 buff
= bfd_malloc (bfd_coff_filhsz (abfd
));
938 if (buff
== ((void *)0) )
941 bfd_coff_swap_filehdr_out (abfd
, (PTR
) & internal_f
, (PTR
) buff
);
942 amount
= bfd_write ((PTR
) buff
, 1, bfd_coff_filhsz (abfd
), abfd
);
946 if (amount
!= bfd_coff_filhsz (abfd
))
950 if (abfd
->flags
& EXEC_P
) {
953 bfd_size_type amount
;
955 buff
= bfd_malloc (bfd_coff_aoutsz (abfd
));
959 bfd_coff_swap_aouthdr_out (abfd
, (PTR
) & internal_a
, (PTR
) buff
);
960 amount
= bfd_write ((PTR
) buff
, 1, bfd_coff_aoutsz (abfd
), abfd
);
964 if (amount
!= bfd_coff_aoutsz (abfd
))
972 /* This is the relocation function for the RS/6000/POWER/PowerPC.
973 This is currently the only processor which uses XCOFF; I hope that
974 will never change. */
977 xcoff64_ppc_relocate_section (output_bfd
, info
, input_bfd
,
978 input_section
, contents
, relocs
, syms
,
981 struct bfd_link_info
*info
;
983 asection
*input_section
;
985 struct internal_reloc
*relocs
;
986 struct internal_syment
*syms
;
989 struct internal_reloc
*rel
;
990 struct internal_reloc
*relend
;
993 relend
= rel
+ input_section
->reloc_count
;
994 for (; rel
< relend
; rel
++)
997 struct xcoff_link_hash_entry
*h
;
998 struct internal_syment
*sym
;
1001 struct reloc_howto_struct howto
;
1002 bfd_reloc_status_type rstat
;
1004 /* Relocation type R_REF is a special relocation type which is
1005 merely used to prevent garbage collection from occurring for
1006 the csect including the symbol which it references. */
1007 if (rel
->r_type
== R_REF
)
1010 symndx
= rel
->r_symndx
;
1017 h
= obj_xcoff_sym_hashes (input_bfd
)[symndx
];
1018 sym
= syms
+ symndx
;
1019 addend
= - sym
->n_value
;
1022 /* We build the howto information on the fly. */
1024 howto
.type
= rel
->r_type
;
1025 howto
.rightshift
= 0;
1027 howto
.bitsize
= (rel
->r_size
& 0x3f) + 1;
1028 howto
.pc_relative
= false;
1030 if ((rel
->r_size
& 0x80) != 0)
1031 howto
.complain_on_overflow
= complain_overflow_signed
;
1033 howto
.complain_on_overflow
= complain_overflow_bitfield
;
1034 howto
.special_function
= NULL
;
1035 howto
.name
= "internal";
1036 howto
.partial_inplace
= true;
1038 if (howto
.bitsize
== 64) {
1039 howto
.src_mask
= howto
.dst_mask
= MINUS_ONE
;
1040 } else if (howto
.bitsize
== 32) {
1041 howto
.src_mask
= howto
.dst_mask
= 0xffffffff;
1043 howto
.src_mask
= howto
.dst_mask
= (1 << howto
.bitsize
) - 1;
1044 if (howto
.bitsize
== 16)
1047 howto
.pcrel_offset
= false;
1055 sec
= bfd_abs_section_ptr
;
1058 sec
= sections
[symndx
];
1059 /* Hack to make sure we use the right TOC anchor value
1060 if this reloc is against the TOC anchor. */
1061 if (sec
->name
[3] == '0'
1062 && strcmp (sec
->name
, ".tc0") == 0)
1063 val
= xcoff_data (output_bfd
)->toc
;
1065 val
= (sec
->output_section
->vma
1066 + sec
->output_offset
1073 if (h
->root
.type
== bfd_link_hash_defined
1074 || h
->root
.type
== bfd_link_hash_defweak
) {
1077 sec
= h
->root
.u
.def
.section
;
1078 val
= (h
->root
.u
.def
.value
1079 + sec
->output_section
->vma
1080 + sec
->output_offset
);
1082 } else if (h
->root
.type
== bfd_link_hash_common
) {
1085 sec
= h
->root
.u
.c
.p
->section
;
1086 val
= (sec
->output_section
->vma
1087 + sec
->output_offset
);
1088 } else if ((h
->flags
& XCOFF_DEF_DYNAMIC
) != 0
1089 || (h
->flags
& XCOFF_IMPORT
) != 0) {
1090 /* Every symbol in a shared object is defined somewhere. */
1092 } else if (! info
->relocateable
) {
1093 if (! ((*info
->callbacks
->undefined_symbol
)
1094 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
1095 rel
->r_vaddr
- input_section
->vma
, true)))
1098 /* Don't try to process the reloc. It can't help, and
1099 it may generate another error. */
1104 /* I took the relocation type definitions from two documents:
1105 the PowerPC AIX Version 4 Application Binary Interface, First
1106 Edition (April 1992), and the PowerOpen ABI, Big-Endian
1107 32-Bit Hardware Implementation (June 30, 1994). Differences
1108 between the documents are noted below. */
1110 switch (rel
->r_type
) {
1114 /* These relocs are defined by the PowerPC ABI to be
1115 relative branches which use half of the difference
1116 between the symbol and the program counter. I can't
1117 quite figure out when this is useful. These relocs are
1118 not defined by the PowerOpen ABI. */
1120 (*_bfd_error_handler
)
1121 (_("%s: unsupported relocation type 0x%02x"),
1122 bfd_get_filename (input_bfd
), (unsigned int) rel
->r_type
);
1123 bfd_set_error (bfd_error_bad_value
);
1126 /* Simple positive relocation. */
1129 /* Simple negative relocation. */
1133 /* Simple PC relative relocation. */
1134 howto
.pc_relative
= true;
1137 /* TOC relative relocation. The value in the instruction in
1138 the input file is the offset from the input file TOC to
1139 the desired location. We want the offset from the final
1140 TOC to the desired location. We have:
1145 so we must change insn by on - in.
1148 /* Global linkage relocation. The value of this relocation
1149 is the address of the entry in the TOC section. */
1151 /* Local object TOC address. I can't figure out the
1152 difference between this and case R_GL. */
1154 /* TOC relative relocation. A TOC relative load instruction
1155 which may be changed to a load address instruction.
1156 FIXME: We don't currently implement this optimization. */
1158 /* TOC relative relocation. This is a TOC relative load
1159 address instruction which may be changed to a load
1160 instruction. FIXME: I don't know if this is the correct
1162 if (h
!= NULL
&& h
->smclas
!= XMC_TD
)
1164 if (h
->toc_section
== NULL
)
1166 (*_bfd_error_handler
)
1167 (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
1168 bfd_get_filename (input_bfd
), rel
->r_vaddr
,
1169 h
->root
.root
.string
);
1170 bfd_set_error (bfd_error_bad_value
);
1174 BFD_ASSERT ((h
->flags
& XCOFF_SET_TOC
) == 0);
1175 val
= (h
->toc_section
->output_section
->vma
1176 + h
->toc_section
->output_offset
);
1181 val
= ((val
- xcoff_data (output_bfd
)->toc
)
1182 - (sym
->n_value
- xcoff_data (input_bfd
)->toc
));
1187 /* Absolute branch. We don't want to mess with the lower
1188 two bits of the instruction. */
1190 /* The PowerPC ABI defines this as an absolute call which
1191 may be modified to become a relative call. The PowerOpen
1192 ABI does not define this relocation type. */
1194 /* Absolute branch which may be modified to become a
1197 /* The PowerPC ABI defines this as an absolute branch to a
1198 fixed address which may be modified to an absolute branch
1199 to a symbol. The PowerOpen ABI does not define this
1202 /* The PowerPC ABI defines this as an absolute branch to a
1203 fixed address which may be modified to a relative branch.
1204 The PowerOpen ABI does not define this relocation type. */
1205 howto
.src_mask
&= ~3;
1206 howto
.dst_mask
= howto
.src_mask
;
1209 /* Relative branch. We don't want to mess with the lower
1210 two bits of the instruction. */
1212 /* The PowerPC ABI defines this as a relative call which may
1213 be modified to become an absolute call. The PowerOpen
1214 ABI does not define this relocation type. */
1216 /* A relative branch which may be modified to become an
1217 absolute branch. FIXME: We don't implement this,
1218 although we should for symbols of storage mapping class
1220 howto
.pc_relative
= true;
1221 howto
.src_mask
&= ~3;
1222 howto
.dst_mask
= howto
.src_mask
;
1224 howto
.complain_on_overflow
= complain_overflow_bitfield
;
1227 /* The PowerPC AIX ABI describes this as a load which may be
1228 changed to a load address. The PowerOpen ABI says this
1229 is the same as case R_POS. */
1232 /* The PowerPC AIX ABI describes this as a load address
1233 which may be changed to a load. The PowerOpen ABI says
1234 this is the same as R_POS. */
1238 /* If we see an R_BR or R_RBR reloc which is jumping to global
1239 linkage code, and it is followed by an appropriate cror nop
1240 instruction, we replace the cror with ld r2,40(r1). This
1241 restores the TOC after the glink code. Contrariwise, if the
1242 call is followed by a ld r2,40(r1), but the call is not
1243 going to global linkage code, we can replace the load with a
1245 if ((rel
->r_type
== R_BR
|| rel
->r_type
== R_RBR
) &&
1247 h
->root
.type
== bfd_link_hash_defined
&&
1248 (rel
->r_vaddr
- input_section
->vma
+ 8
1249 <= input_section
->_cooked_size
)) {
1254 pnext
= contents
+ (rel
->r_vaddr
- input_section
->vma
) + 4;
1255 next
= bfd_get_32 (input_bfd
, pnext
);
1258 /* The _ptrgl function is magic. It is used by the AIX
1259 * compiler to call a function through a pointer.
1261 * special case XMC_GL, global linkage
1263 if (h
->smclas
== XMC_GL
1264 || strcmp (h
->root
.root
.string
, "._ptrgl") == 0)
1266 if (next
== 0x4def7b82 /* cror 15,15,15 */
1267 || next
== 0x4ffffb82 /* cror 31,31,31 */
1268 || next
== 0x60000000) /* ori r0,r0,0 */
1269 bfd_put_32 (input_bfd
, 0xe8410028, pnext
); /* ld r2,40(r1) */
1273 if (next
== 0xe8410028) /* ld r2,40(r1) */
1274 bfd_put_32 (input_bfd
, 0x60000000, pnext
); /* ori r0,r0,0 */
1278 /* A PC relative reloc includes the section address. */
1279 if (howto
.pc_relative
)
1280 addend
+= input_section
->vma
;
1282 rstat
= _bfd_final_link_relocate (&howto
, input_bfd
, input_section
,
1284 rel
->r_vaddr
- input_section
->vma
,
1293 case bfd_reloc_overflow
:
1296 char buf
[SYMNMLEN
+ 1];
1297 char howto_name
[10];
1302 name
= h
->root
.root
.string
;
1305 name
= _bfd_coff_internal_syment_name (input_bfd
, sym
, buf
);
1309 sprintf (howto_name
, "0x%02x", rel
->r_type
);
1311 if (! ((*info
->callbacks
->reloc_overflow
)
1312 (info
, name
, howto_name
, (bfd_vma
) 0, input_bfd
,
1313 input_section
, rel
->r_vaddr
- input_section
->vma
)))
1324 /* The XCOFF reloc table. Actually, XCOFF relocations specify the
1325 bitsize and whether they are signed or not, along with a
1326 conventional type. This table is for the types, which are used for
1327 different algorithms for putting in the reloc. Many of these
1328 relocs need special_function entries, which I have not written. */
1331 reloc_howto_type xcoff64_howto_table
[] =
1333 /* Standard 64 bit relocation. */
1334 HOWTO (0, /* type */
1336 4, /* size (0 = byte, 1 = short, 2 = long) */
1338 false, /* pc_relative */
1340 complain_overflow_bitfield
, /* complain_on_overflow */
1341 0, /* special_function */
1343 true, /* partial_inplace */
1344 MINUS_ONE
, /* src_mask */
1345 MINUS_ONE
, /* dst_mask */
1346 false), /* pcrel_offset */
1348 /* 64 bit relocation, but store negative value. */
1349 HOWTO (1, /* type */
1351 -4, /* size (0 = byte, 1 = short, 2 = long) */
1353 false, /* pc_relative */
1355 complain_overflow_bitfield
, /* complain_on_overflow */
1356 0, /* special_function */
1358 true, /* partial_inplace */
1359 MINUS_ONE
, /* src_mask */
1360 MINUS_ONE
, /* dst_mask */
1361 false), /* pcrel_offset */
1363 /* 32 bit PC relative relocation. */
1364 HOWTO (2, /* type */
1366 2, /* size (0 = byte, 1 = short, 2 = long) */
1368 true, /* pc_relative */
1370 complain_overflow_signed
, /* complain_on_overflow */
1371 0, /* special_function */
1373 true, /* partial_inplace */
1374 0xffffffff, /* src_mask */
1375 0xffffffff, /* dst_mask */
1376 false), /* pcrel_offset */
1378 /* 16 bit TOC relative relocation. */
1379 HOWTO (3, /* type */
1381 1, /* size (0 = byte, 1 = short, 2 = long) */
1383 false, /* pc_relative */
1385 complain_overflow_bitfield
, /* complain_on_overflow */
1386 0, /* special_function */
1388 true, /* partial_inplace */
1389 0xffff, /* src_mask */
1390 0xffff, /* dst_mask */
1391 false), /* pcrel_offset */
1393 /* I don't really know what this is. */
1394 HOWTO (4, /* type */
1396 2, /* size (0 = byte, 1 = short, 2 = long) */
1398 false, /* pc_relative */
1400 complain_overflow_bitfield
, /* complain_on_overflow */
1401 0, /* special_function */
1403 true, /* partial_inplace */
1404 0xffffffff, /* src_mask */
1405 0xffffffff, /* dst_mask */
1406 false), /* pcrel_offset */
1408 /* External TOC relative symbol. */
1409 HOWTO (5, /* type */
1411 2, /* size (0 = byte, 1 = short, 2 = long) */
1413 false, /* pc_relative */
1415 complain_overflow_bitfield
, /* complain_on_overflow */
1416 0, /* special_function */
1418 true, /* partial_inplace */
1419 0xffff, /* src_mask */
1420 0xffff, /* dst_mask */
1421 false), /* pcrel_offset */
1423 /* Local TOC relative symbol. */
1424 HOWTO (6, /* type */
1426 2, /* size (0 = byte, 1 = short, 2 = long) */
1428 false, /* pc_relative */
1430 complain_overflow_bitfield
, /* complain_on_overflow */
1431 0, /* special_function */
1433 true, /* partial_inplace */
1434 0xffff, /* src_mask */
1435 0xffff, /* dst_mask */
1436 false), /* pcrel_offset */
1440 /* Non modifiable absolute branch. */
1441 HOWTO (8, /* type */
1443 2, /* size (0 = byte, 1 = short, 2 = long) */
1445 false, /* pc_relative */
1447 complain_overflow_bitfield
, /* complain_on_overflow */
1448 0, /* special_function */
1450 true, /* partial_inplace */
1451 0x3fffffc, /* src_mask */
1452 0x3fffffc, /* dst_mask */
1453 false), /* pcrel_offset */
1457 /* Non modifiable relative branch. */
1458 HOWTO (0xa, /* type */
1460 2, /* size (0 = byte, 1 = short, 2 = long) */
1462 true, /* pc_relative */
1464 complain_overflow_signed
, /* complain_on_overflow */
1465 0, /* special_function */
1467 true, /* partial_inplace */
1468 0x3fffffc, /* src_mask */
1469 0x3fffffc, /* dst_mask */
1470 false), /* pcrel_offset */
1474 /* Indirect load. */
1475 HOWTO (0xc, /* type */
1477 2, /* size (0 = byte, 1 = short, 2 = long) */
1479 false, /* pc_relative */
1481 complain_overflow_bitfield
, /* complain_on_overflow */
1482 0, /* special_function */
1484 true, /* partial_inplace */
1485 0xffff, /* src_mask */
1486 0xffff, /* dst_mask */
1487 false), /* pcrel_offset */
1490 HOWTO (0xd, /* type */
1492 2, /* size (0 = byte, 1 = short, 2 = long) */
1494 false, /* pc_relative */
1496 complain_overflow_bitfield
, /* complain_on_overflow */
1497 0, /* special_function */
1499 true, /* partial_inplace */
1500 0xffff, /* src_mask */
1501 0xffff, /* dst_mask */
1502 false), /* pcrel_offset */
1506 /* Non-relocating reference. */
1507 HOWTO (0xf, /* type */
1509 2, /* size (0 = byte, 1 = short, 2 = long) */
1511 false, /* pc_relative */
1513 complain_overflow_bitfield
, /* complain_on_overflow */
1514 0, /* special_function */
1516 false, /* partial_inplace */
1519 false), /* pcrel_offset */
1524 /* TOC relative indirect load. */
1525 HOWTO (0x12, /* type */
1527 2, /* size (0 = byte, 1 = short, 2 = long) */
1529 false, /* pc_relative */
1531 complain_overflow_bitfield
, /* complain_on_overflow */
1532 0, /* special_function */
1534 true, /* partial_inplace */
1535 0xffff, /* src_mask */
1536 0xffff, /* dst_mask */
1537 false), /* pcrel_offset */
1539 /* TOC relative load address. */
1540 HOWTO (0x13, /* type */
1542 2, /* size (0 = byte, 1 = short, 2 = long) */
1544 false, /* pc_relative */
1546 complain_overflow_bitfield
, /* complain_on_overflow */
1547 0, /* special_function */
1548 "R_TRLA", /* name */
1549 true, /* partial_inplace */
1550 0xffff, /* src_mask */
1551 0xffff, /* dst_mask */
1552 false), /* pcrel_offset */
1554 /* Modifiable relative branch. */
1555 HOWTO (0x14, /* type */
1557 2, /* size (0 = byte, 1 = short, 2 = long) */
1559 false, /* pc_relative */
1561 complain_overflow_bitfield
, /* complain_on_overflow */
1562 0, /* special_function */
1563 "R_RRTBI", /* name */
1564 true, /* partial_inplace */
1565 0xffffffff, /* src_mask */
1566 0xffffffff, /* dst_mask */
1567 false), /* pcrel_offset */
1569 /* Modifiable absolute branch. */
1570 HOWTO (0x15, /* type */
1572 2, /* size (0 = byte, 1 = short, 2 = long) */
1574 false, /* pc_relative */
1576 complain_overflow_bitfield
, /* complain_on_overflow */
1577 0, /* special_function */
1578 "R_RRTBA", /* name */
1579 true, /* partial_inplace */
1580 0xffffffff, /* src_mask */
1581 0xffffffff, /* dst_mask */
1582 false), /* pcrel_offset */
1584 /* Modifiable call absolute indirect. */
1585 HOWTO (0x16, /* type */
1587 2, /* size (0 = byte, 1 = short, 2 = long) */
1589 false, /* pc_relative */
1591 complain_overflow_bitfield
, /* complain_on_overflow */
1592 0, /* special_function */
1594 true, /* partial_inplace */
1595 0xffff, /* src_mask */
1596 0xffff, /* dst_mask */
1597 false), /* pcrel_offset */
1599 /* Modifiable call relative. */
1600 HOWTO (0x17, /* type */
1602 2, /* size (0 = byte, 1 = short, 2 = long) */
1604 false, /* pc_relative */
1606 complain_overflow_bitfield
, /* complain_on_overflow */
1607 0, /* special_function */
1608 "R_CREL", /* name */
1609 true, /* partial_inplace */
1610 0xffff, /* src_mask */
1611 0xffff, /* dst_mask */
1612 false), /* pcrel_offset */
1614 /* Modifiable branch absolute. */
1615 HOWTO (0x18, /* type */
1617 2, /* size (0 = byte, 1 = short, 2 = long) */
1619 false, /* pc_relative */
1621 complain_overflow_bitfield
, /* complain_on_overflow */
1622 0, /* special_function */
1624 true, /* partial_inplace */
1625 0xffff, /* src_mask */
1626 0xffff, /* dst_mask */
1627 false), /* pcrel_offset */
1629 /* Modifiable branch absolute. */
1630 HOWTO (0x19, /* type */
1632 2, /* size (0 = byte, 1 = short, 2 = long) */
1634 false, /* pc_relative */
1636 complain_overflow_bitfield
, /* complain_on_overflow */
1637 0, /* special_function */
1638 "R_RBAC", /* name */
1639 true, /* partial_inplace */
1640 0xffff, /* src_mask */
1641 0xffff, /* dst_mask */
1642 false), /* pcrel_offset */
1644 /* Modifiable branch relative. */
1645 HOWTO (0x1a, /* type */
1647 2, /* size (0 = byte, 1 = short, 2 = long) */
1649 false, /* pc_relative */
1651 complain_overflow_signed
, /* complain_on_overflow */
1652 0, /* special_function */
1654 true, /* partial_inplace */
1655 0xffff, /* src_mask */
1656 0xffff, /* dst_mask */
1657 false), /* pcrel_offset */
1659 /* Modifiable branch absolute. */
1660 HOWTO (0x1b, /* type */
1662 2, /* size (0 = byte, 1 = short, 2 = long) */
1664 false, /* pc_relative */
1666 complain_overflow_bitfield
, /* complain_on_overflow */
1667 0, /* special_function */
1668 "R_RBRC", /* name */
1669 true, /* partial_inplace */
1670 0xffff, /* src_mask */
1671 0xffff, /* dst_mask */
1672 false), /* pcrel_offset */
1674 HOWTO (0, /* type */
1676 4, /* size (0 = byte, 1 = short, 2 = long) */
1678 false, /* pc_relative */
1680 complain_overflow_bitfield
, /* complain_on_overflow */
1681 0, /* special_function */
1683 true, /* partial_inplace */
1684 MINUS_ONE
, /* src_mask */
1685 MINUS_ONE
, /* dst_mask */
1686 false) /* pcrel_offset */
1691 xcoff64_rtype2howto (relent
, internal
)
1693 struct internal_reloc
*internal
;
1695 relent
->howto
= xcoff64_howto_table
+ internal
->r_type
;
1697 /* Check for relocs we don't know of. */
1698 if (internal
->r_type
1699 >= sizeof (xcoff64_howto_table
) / sizeof (xcoff64_howto_table
[0]))
1701 if (internal
->r_type
!= relent
->howto
->type
)
1704 /* The r_size field of an XCOFF reloc encodes the bitsize of the
1705 relocation, as well as indicating whether it is signed or not.
1706 Doublecheck that the relocation information gathered from the
1707 type matches this information. The bitsize is not significant
1708 for R_REF relocs. */
1709 if (relent
->howto
->dst_mask
!= 0
1710 && (relent
->howto
->bitsize
1711 != ((unsigned int) internal
->r_size
& 0x3f) + 1))
1714 if ((internal
->r_size
& 0x80) != 0
1715 ? (relent
->howto
->complain_on_overflow
!= complain_overflow_signed
)
1716 : (relent
->howto
->complain_on_overflow
!= complain_overflow_bitfield
))
1722 xcoff64_reloc_type_lookup (abfd
, code
)
1723 bfd
*abfd ATTRIBUTE_UNUSED
;
1724 bfd_reloc_code_real_type code
;
1728 case BFD_RELOC_PPC_B26
:
1729 return &xcoff64_howto_table
[0xa];
1730 case BFD_RELOC_PPC_BA26
:
1731 return &xcoff64_howto_table
[8];
1732 case BFD_RELOC_PPC_TOC16
:
1733 return &xcoff64_howto_table
[3];
1735 case BFD_RELOC_CTOR
:
1736 return &xcoff64_howto_table
[0];
1738 return &xcoff64_howto_table
[0x1c];
1746 /* Read in the armap of an XCOFF archive. */
1749 xcoff64_slurp_armap (abfd
)
1755 bfd_byte
*contents
, *cend
;
1760 /* This is for the new format. */
1761 struct xcoff_ar_hdr_big hdr
;
1763 if (xcoff_ardata (abfd
) == NULL
) {
1764 bfd_has_map (abfd
) = false;
1768 off
= strtol (xcoff_ardata_big (abfd
)->symoff64
, (char **) NULL
, 10);
1770 bfd_has_map (abfd
) = false;
1774 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
1777 /* The symbol table starts with a normal archive header. */
1778 if (bfd_read ((PTR
) &hdr
, SIZEOF_AR_HDR_BIG
, 1, abfd
) != SIZEOF_AR_HDR_BIG
)
1781 /* Skip the name (normally empty). */
1782 namlen
= strtol (hdr
.namlen
, (char **) NULL
, 10);
1783 if (bfd_seek (abfd
, ((namlen
+ 1) & ~1) + SXCOFFARFMAG
, SEEK_CUR
) != 0)
1786 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1787 machines) since the field width is 20 and there numbers with more
1788 than 32 bits can be represented. */
1789 sz
= strtol (hdr
.size
, (char **) NULL
, 10);
1791 /* Read in the entire symbol table. */
1792 contents
= (bfd_byte
*) bfd_alloc (abfd
, sz
);
1793 if (contents
== NULL
)
1795 if (bfd_read ((PTR
) contents
, 1, sz
, abfd
) != sz
)
1798 /* The symbol table starts with an eight byte count. */
1799 c
= bfd_h_get_64 (abfd
, contents
);
1802 bfd_set_error (bfd_error_bad_value
);
1806 bfd_ardata (abfd
)->symdefs
= ((carsym
*)
1807 bfd_alloc (abfd
, c
* sizeof (carsym
)));
1808 if (bfd_ardata (abfd
)->symdefs
== NULL
)
1811 /* After the count comes a list of eight byte file offsets. */
1812 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
, p
= contents
+ 8;
1814 ++i
, ++arsym
, p
+= 8)
1815 arsym
->file_offset
= bfd_h_get_64 (abfd
, p
);
1817 /* After the file offsets come null terminated symbol names. */
1818 cend
= contents
+ sz
;
1819 for (i
= 0, arsym
= bfd_ardata (abfd
)->symdefs
;
1821 ++i
, ++arsym
, p
+= strlen ((char *) p
) + 1)
1825 bfd_set_error (bfd_error_bad_value
);
1828 arsym
->name
= (char *) p
;
1831 bfd_ardata (abfd
)->symdef_count
= c
;
1832 bfd_has_map (abfd
) = true;
1839 /* See if this is an NEW XCOFF archive. */
1841 static const bfd_target
*
1842 xcoff64_archive_p (abfd
)
1845 char magic
[SXCOFFARMAG
];
1846 /* This is the new format. */
1847 struct xcoff_ar_file_hdr_big hdr
;
1849 if (bfd_read ((PTR
) magic
, SXCOFFARMAG
, 1, abfd
) != SXCOFFARMAG
) {
1850 if (bfd_get_error () != bfd_error_system_call
)
1851 bfd_set_error (bfd_error_wrong_format
);
1855 if (strncmp (magic
, XCOFFARMAGBIG
, SXCOFFARMAG
) != 0) {
1856 bfd_set_error (bfd_error_wrong_format
);
1860 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
1861 involves a cast, we can't do it as the left operand of
1863 abfd
->tdata
.aout_ar_data
=
1864 (struct artdata
*) bfd_zalloc (abfd
, sizeof (struct artdata
));
1866 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
1869 bfd_ardata (abfd
)->cache
= NULL
;
1870 bfd_ardata (abfd
)->archive_head
= NULL
;
1871 bfd_ardata (abfd
)->symdefs
= NULL
;
1872 bfd_ardata (abfd
)->extended_names
= NULL
;
1874 /* Copy over the magic string. */
1875 memcpy (hdr
.magic
, magic
, SXCOFFARMAG
);
1877 /* Now read the rest of the file header. */
1878 if (bfd_read ((PTR
) &hdr
.memoff
, SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
, 1,
1879 abfd
) != SIZEOF_AR_FILE_HDR_BIG
- SXCOFFARMAG
) {
1880 if (bfd_get_error () != bfd_error_system_call
)
1881 bfd_set_error (bfd_error_wrong_format
);
1885 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1886 machines) since the field width is 20 and there numbers with more
1887 than 32 bits can be represented. */
1888 bfd_ardata (abfd
)->first_file_filepos
= strtol (hdr
.firstmemoff
,
1889 (char **) NULL
, 10);
1891 bfd_ardata (abfd
)->tdata
= bfd_zalloc (abfd
, SIZEOF_AR_FILE_HDR_BIG
);
1892 if (bfd_ardata (abfd
)->tdata
== NULL
)
1895 memcpy (bfd_ardata (abfd
)->tdata
, &hdr
, SIZEOF_AR_FILE_HDR_BIG
);
1897 if (! xcoff64_slurp_armap (abfd
)) {
1899 bfd_release (abfd
, bfd_ardata (abfd
));
1900 abfd
->tdata
.aout_ar_data
= (struct artdata
*) NULL
;
1908 /* Open the next element in an XCOFF archive. */
1911 xcoff64_openr_next_archived_file (archive
, last_file
)
1917 if ((xcoff_ardata (archive
) == NULL
) ||
1918 (! xcoff_big_format_p (archive
))) {
1919 bfd_set_error (bfd_error_invalid_operation
);
1923 if (last_file
== NULL
) {
1924 filestart
= bfd_ardata (archive
)->first_file_filepos
;
1926 /* XXX These actually have to be a calls to strtoll (at least
1927 on 32-bit machines) since the fields's width is 20 and
1928 there numbers with more than 32 bits can be represented. */
1929 filestart
= strtol (arch_xhdr_big (last_file
)->nextoff
, (char **) NULL
,
1932 /* XXX These actually have to be calls to strtoll (at least on 32-bit
1933 machines) since the fields's width is 20 and there numbers with more
1934 than 32 bits can be represented. */
1936 || filestart
== strtol (xcoff_ardata_big (archive
)->memoff
,
1938 || filestart
== strtol (xcoff_ardata_big (archive
)->symoff
,
1939 (char **) NULL
, 10)) {
1940 bfd_set_error (bfd_error_no_more_archived_files
);
1944 return _bfd_get_elt_at_filepos (archive
, filestart
);
1947 /* We can't use the usual coff_sizeof_headers routine, because AIX
1948 always uses an a.out header. */
1952 xcoff64_sizeof_headers (abfd
, reloc
)
1954 boolean reloc ATTRIBUTE_UNUSED
;
1958 size
= bfd_coff_filhsz(abfd
);
1961 * Don't think the small aout header can be used since some of the the
1962 * old elements have been reordered past the end of the old coff
1966 if (xcoff_data (abfd
)->full_aouthdr
)
1967 size
+= bfd_coff_aoutsz(abfd
);
1969 size
+= abfd
->section_count
* bfd_coff_scnhsz(abfd
);
1976 xcoff64_create_csect_from_smclas (abfd
, aux
, symbol_name
)
1978 union internal_auxent
*aux
;
1979 const char *symbol_name
;
1981 asection
*return_value
= NULL
;
1985 * .sv == 8, is only for 32 bit programs
1986 * .ti == 12 and .tb == 13 are now reserved
1988 static const char *names
[19] = {
1989 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
1990 NULL
, ".bs", ".ds", ".uc", NULL
, NULL
, NULL
, ".tc0",
1991 ".td", ".sv64", ".sv3264"
1994 if ((19 >= aux
->x_csect
.x_smclas
) &&
1995 (NULL
!= names
[aux
->x_csect
.x_smclas
])) {
1997 return_value
= bfd_make_section_anyway
1998 (abfd
, names
[aux
->x_csect
.x_smclas
]);
2001 (*_bfd_error_handler
)
2002 (_("%s: symbol `%s' has unrecognized smclas %d"),
2003 bfd_get_filename (abfd
), symbol_name
, aux
->x_csect
.x_smclas
);
2004 bfd_set_error (bfd_error_bad_value
);
2007 return return_value
;
2011 xcoff64_is_lineno_count_overflow (abfd
, value
)
2012 bfd
*abfd ATTRIBUTE_UNUSED
;
2013 bfd_vma value ATTRIBUTE_UNUSED
;
2019 xcoff64_is_reloc_count_overflow (abfd
, value
)
2020 bfd
*abfd ATTRIBUTE_UNUSED
;
2021 bfd_vma value ATTRIBUTE_UNUSED
;
2027 xcoff64_loader_symbol_offset (abfd
, ldhdr
)
2028 bfd
*abfd ATTRIBUTE_UNUSED
;
2029 struct internal_ldhdr
*ldhdr
;
2031 return (ldhdr
->l_symoff
);
2035 xcoff64_loader_reloc_offset (abfd
, ldhdr
)
2036 bfd
*abfd ATTRIBUTE_UNUSED
;
2037 struct internal_ldhdr
*ldhdr
;
2039 return (ldhdr
->l_rldoff
);
2042 /* The typical dynamic reloc. */
2044 static reloc_howto_type xcoff64_dynamic_reloc
=
2045 HOWTO (0, /* type */
2047 4, /* size (0 = byte, 1 = short, 2 = long) */
2049 false, /* pc_relative */
2051 complain_overflow_bitfield
, /* complain_on_overflow */
2052 0, /* special_function */
2054 true, /* partial_inplace */
2055 MINUS_ONE
, /* src_mask */
2056 MINUS_ONE
, /* dst_mask */
2057 false); /* pcrel_offset */
2059 static unsigned long xcoff64_glink_code
[10] =
2061 0xe9820000, /* ld r12,0(r2) */
2062 0xf8410028, /* std r2,40(r1) */
2063 0xe80c0000, /* ld r0,0(r12) */
2064 0xe84c0008, /* ld r0,8(r12) */
2065 0x7c0903a6, /* mtctr r0 */
2066 0x4e800420, /* bctr */
2067 0x00000000, /* start of traceback table */
2068 0x000ca000, /* traceback table */
2069 0x00000000, /* traceback table */
2070 0x00000018, /* ??? */
2073 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data
=
2075 { /* COFF backend, defined in libcoff.h */
2076 _bfd_xcoff64_swap_aux_in
, /* _bfd_coff_swap_aux_in */
2077 _bfd_xcoff64_swap_sym_in
, /* _bfd_coff_swap_sym_in */
2078 _bfd_xcoff64_swap_lineno_in
, /* _bfd_coff_swap_lineno_in */
2079 _bfd_xcoff64_swap_aux_out
, /* _bfd_swap_aux_out */
2080 _bfd_xcoff64_swap_sym_out
, /* _bfd_swap_sym_out */
2081 _bfd_xcoff64_swap_lineno_out
, /* _bfd_swap_lineno_out */
2082 coff_swap_reloc_out
, /* _bfd_swap_reloc_out */
2083 coff_swap_filehdr_out
, /* _bfd_swap_filehdr_out */
2084 coff_swap_aouthdr_out
, /* _bfd_swap_aouthdr_out */
2085 coff_swap_scnhdr_out
, /* _bfd_swap_scnhdr_out */
2086 FILHSZ
, /* _bfd_filhsz */
2087 AOUTSZ
, /* _bfd_aoutsz */
2088 SCNHSZ
, /* _bfd_scnhsz */
2089 SYMESZ
, /* _bfd_symesz */
2090 AUXESZ
, /* _bfd_auxesz */
2091 RELSZ
, /* _bfd_relsz */
2092 LINESZ
, /* _bfd_linesz */
2093 FILNMLEN
, /* _bfd_filnmlen */
2094 true, /* _bfd_coff_long_filenames */
2095 false, /* _bfd_coff_long_section_names */
2096 (3), /* _bfd_coff_default_section_alignment_power */
2097 true, /* _bfd_coff_force_symnames_in_strings */
2098 4, /* _bfd_coff_debug_string_prefix_length */
2099 coff_swap_filehdr_in
, /* _bfd_coff_swap_filehdr_in */
2100 coff_swap_aouthdr_in
, /* _bfd_swap_aouthdr_in */
2101 coff_swap_scnhdr_in
, /* _bfd_swap_scnhdr_in */
2102 coff_swap_reloc_in
, /* _bfd_reloc_in */
2103 coff_bad_format_hook
, /* _bfd_bad_format_hook */
2104 coff_set_arch_mach_hook
, /* _bfd_set_arch_mach_hook */
2105 coff_mkobject_hook
, /* _bfd_mkobject_hook */
2106 styp_to_sec_flags
, /* _bfd_syp_to_sec_flags */
2107 coff_set_alignment_hook
, /* _bfd_set_alignment_hook */
2108 coff_slurp_symbol_table
, /* _bfd_coff_slurp_symbol_table */
2109 symname_in_debug_hook
, /* _coff_symname_in_debug_hook */
2110 coff_pointerize_aux_hook
, /* _bfd_coff_pointerize_aux_hook */
2111 coff_print_aux
, /* bfd_coff_print_aux */
2112 dummy_reloc16_extra_cases
, /* _bfd_coff_reloc16_extra_cases */
2113 dummy_reloc16_estimate
, /* _bfd_coff_reloc16_estimate */
2114 NULL
, /* bfd_coff_sym_is_global */
2115 /* _bfd_coff_compute_section_file_positions */
2116 coff_compute_section_file_positions
,
2117 NULL
, /* _bfd_coff_start_final_link */
2118 xcoff64_ppc_relocate_section
, /* _bfd_coff_relocate_section */
2119 coff_rtype_to_howto
, /* _bfd_coff_rtype_to_howto */
2120 NULL
, /* _bfd_coff_addust_symndx */
2121 _bfd_generic_link_add_one_symbol
, /* _bfd_coff_add_one_symbol */
2122 coff_link_output_has_begun
, /* _bfd_coff_link_output_has_begun */
2123 coff_final_link_postscript
/* _bfd_coff_final_link_postscript */
2126 0x01EF, /* magic number */
2127 bfd_arch_powerpc
, /* architecture */
2128 bfd_mach_ppc_620
, /* machine */
2130 /* function pointers to xcoff specific swap routines */
2131 xcoff64_swap_ldhdr_in
, /* _xcoff_swap_ldhdr_in */
2132 xcoff64_swap_ldhdr_out
, /* _xcoff_swap_ldhdr_out */
2133 xcoff64_swap_ldsym_in
, /* _xcoff_swap_ldsym_in */
2134 xcoff64_swap_ldsym_out
, /* _xcoff_swap_ldsym_out */
2135 xcoff64_swap_ldrel_in
, /* _xcoff_swap_ldrel_in */
2136 xcoff64_swap_ldrel_out
, /* _xcoff_swap_ldrel_out */
2139 LDHDRSZ
, /* _xcoff_ldhdrsz */
2140 LDSYMSZ
, /* _xcoff_ldsymsz */
2141 LDRELSZ
, /* _xcoff_ldrelsz */
2142 24, /* _xcoff_function_descriptor_size */
2143 0, /* _xcoff_small_aout_header_size */
2145 2, /* _xcoff_ldhdr_version */
2147 /* xcoff vs xcoff64 putting symbol names */
2148 _bfd_xcoff64_put_symbol_name
, /* _xcoff_put_symbol_name */
2149 _bfd_xcoff64_put_ldsymbol_name
, /* _xcoff_put_ldsymbol_name */
2151 /* dynamic reloc howto */
2152 &xcoff64_dynamic_reloc
,
2154 xcoff64_create_csect_from_smclas
,
2156 /* lineno and reloc count overflow */
2157 xcoff64_is_lineno_count_overflow
,
2158 xcoff64_is_reloc_count_overflow
,
2160 xcoff64_loader_symbol_offset
,
2161 xcoff64_loader_reloc_offset
,
2164 &xcoff64_glink_code
[0],
2165 40, /* _xcoff_glink_size */
2169 /* The transfer vector that leads the outside world to all of the above. */
2170 const bfd_target rs6000coff64_vec
=
2173 bfd_target_xcoff_flavour
,
2174 BFD_ENDIAN_BIG
, /* data byte order is big */
2175 BFD_ENDIAN_BIG
, /* header byte order is big */
2177 (HAS_RELOC
| EXEC_P
| /* object flags */
2178 HAS_LINENO
| HAS_DEBUG
| DYNAMIC
|
2179 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
),
2181 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
2182 0, /* leading char */
2183 '/', /* ar_pad_char */
2184 15, /* ar_max_namelen??? FIXMEmgo */
2187 bfd_getb64
, /* bfd_getx64 */
2188 bfd_getb_signed_64
, /* bfd_getx_signed_64 */
2189 bfd_putb64
, /* bfd_putx64 */
2190 bfd_getb32
, /* bfd_getx32 */
2191 bfd_getb_signed_32
, /* bfd_getx_signed_32 */
2192 bfd_putb32
, /* bfd_putx32 */
2193 bfd_getb16
, /* bfd_getx16 */
2194 bfd_getb_signed_16
, /* bfd_getx_signed_16 */
2195 bfd_putb16
, /* bfd_putx16 */
2198 bfd_getb64
, /* bfd_h_getx64 */
2199 bfd_getb_signed_64
, /* bfd_h_getx_signed_64 */
2200 bfd_putb64
, /* bfd_h_putx64 */
2201 bfd_getb32
, /* bfd_h_getx32 */
2202 bfd_getb_signed_32
, /* bfd_h_getx_signed_32 */
2203 bfd_putb32
, /* bfd_h_putx32 */
2204 bfd_getb16
, /* bfd_h_getx16 */
2205 bfd_getb_signed_16
, /* bfd_h_getx_signed_16 */
2206 bfd_putb16
, /* bfd_h_putx16 */
2208 { /* bfd_check_format */
2215 { /* bfd_set_format */
2218 _bfd_generic_mkarchive
,
2222 {/* bfd_write_contents */
2224 xcoff64_write_object_contents
,
2225 _bfd_xcoff_write_archive_contents
,
2230 bfd_true
, /* _close_and_cleanup */
2231 bfd_true
, /* _bfd_free_cached_info */
2232 coff_new_section_hook
, /* _new_section_hook */
2233 _bfd_generic_get_section_contents
, /* _bfd_get_section_contents */
2234 /* _bfd_get_section_contents_in_window */
2235 _bfd_generic_get_section_contents_in_window
,
2238 _bfd_xcoff_copy_private_bfd_data
, /* _bfd_copy_private_bfd */
2239 /* _bfd_merge_private_bfd_data */
2240 ((boolean (*) (bfd
*, bfd
*)) bfd_true
),
2241 /* _bfd_copy_pivate_section_data */
2242 ((boolean (*) (bfd
*, asection
*, bfd
*, asection
*)) bfd_true
),
2243 /* _bfd_copy_private_symbol_data */
2244 ((boolean (*) (bfd
*, asymbol
*, bfd
*, asymbol
*)) bfd_true
),
2245 ((boolean (*) (bfd
*, flagword
)) bfd_true
), /* _bfd_set_private_flags */
2246 ((boolean (*) (bfd
*, void * )) bfd_true
), /* _bfd_print_private_bfd_data */
2249 coff_core_file_failing_command
, /* _core_file_failing_command */
2250 coff_core_file_failing_signal
, /* _core_file_failing_signal */
2251 /* _core_file_matches_executable_p */
2252 coff_core_file_matches_executable_p
,
2255 xcoff64_slurp_armap
, /* _slurp_armap */
2256 /* XCOFF archives do not have
2257 anything which corresponds to
2258 an extended name table. */
2259 bfd_false
, /* _slurp_extended_name_table */
2260 /* _construct_extended_name_table */
2261 ((boolean (*) (bfd
*, char **, bfd_size_type
*, const char **)) bfd_false
),
2262 bfd_dont_truncate_arname
, /* _truncate_arname */
2263 _bfd_xcoff_write_armap
, /* _write_armap */
2264 _bfd_xcoff_read_ar_hdr
, /* _read_ar_hdr */
2265 xcoff64_openr_next_archived_file
, /* _openr_next_archived_file */
2266 _bfd_generic_get_elt_at_index
, /* _get_elt_at_index */
2267 _bfd_xcoff_generic_stat_arch_elt
, /* _generic_dtat_arch_elt */
2268 /* XCOFF archives do not have
2270 bfd_true
, /* _update_armap_timestamp */
2273 coff_get_symtab_upper_bound
, /* _get_symtab_upper_bound */
2274 coff_get_symtab
, /* _get_symtab */
2275 coff_make_empty_symbol
, /* _make_empty_symbol */
2276 coff_print_symbol
, /* _print_symbol */
2277 coff_get_symbol_info
, /* _get_symbol_info */
2278 _bfd_xcoff_is_local_label_name
, /* _bfd_is_local_label_name */
2279 coff_get_lineno
, /* _get_lineno */
2280 coff_find_nearest_line
, /* _find_nearest_line */
2281 coff_bfd_make_debug_symbol
, /* _bfd_make_debug_symbol */
2282 _bfd_generic_read_minisymbols
, /* _read_minisymbols */
2283 _bfd_generic_minisymbol_to_symbol
, /* _minsymbol_to_symbol */
2286 coff_get_reloc_upper_bound
, /* _get_reloc_upper_bound */
2287 coff_canonicalize_reloc
, /* _cononicalize_reloc */
2288 xcoff64_reloc_type_lookup
, /* _bfd_reloc_type_lookup */
2291 coff_set_arch_mach
, /* _set_arch_mach */
2292 coff_set_section_contents
, /* _set_section_contents */
2295 xcoff64_sizeof_headers
, /* _sizeof_headers */
2296 /* _bfd_get_relocated_section_contents */
2297 bfd_generic_get_relocated_section_contents
,
2298 bfd_generic_relax_section
, /* _bfd_relax_section */
2299 _bfd_xcoff_bfd_link_hash_table_create
, /* _bfd_link_hash_table_create */
2300 _bfd_xcoff_bfd_link_add_symbols
, /* _bfd_link_add_symbols */
2301 _bfd_xcoff_bfd_final_link
, /* _bfd_filnal_link */
2302 _bfd_generic_link_split_section
, /* _bfd_link_split_section */
2303 bfd_generic_gc_sections
, /* _bfd_gc_sections */
2304 bfd_generic_merge_sections
, /* _bfd_merge_sections */
2307 /* _get_dynamic_symtab_upper_bound */
2308 _bfd_xcoff_get_dynamic_symtab_upper_bound
,
2309 _bfd_xcoff_canonicalize_dynamic_symtab
, /* _cononicalize_dynamic_symtab */
2310 _bfd_xcoff_get_dynamic_reloc_upper_bound
,/* _get_dynamic_reloc_upper_bound */
2311 _bfd_xcoff_canonicalize_dynamic_reloc
, /* _cononicalize_dynamic_reloc */
2313 /* Opposite endian version, none exists */
2317 (void *) &bfd_xcoff_backend_data
,