15f210c2aSfgsch /* BFD back-end for IBM RS/6000 "XCOFF64" files.
2*cf2f2c56Smiod Copyright 2000, 2001, 2002, 2003
35f210c2aSfgsch Free Software Foundation, Inc.
45f210c2aSfgsch Written Clinton Popetz.
55f210c2aSfgsch Contributed by Cygnus Support.
65f210c2aSfgsch
75f210c2aSfgsch This file is part of BFD, the Binary File Descriptor library.
85f210c2aSfgsch
95f210c2aSfgsch This program is free software; you can redistribute it and/or modify
105f210c2aSfgsch it under the terms of the GNU General Public License as published by
115f210c2aSfgsch the Free Software Foundation; either version 2 of the License, or
125f210c2aSfgsch (at your option) any later version.
135f210c2aSfgsch
145f210c2aSfgsch This program is distributed in the hope that it will be useful,
155f210c2aSfgsch but WITHOUT ANY WARRANTY; without even the implied warranty of
165f210c2aSfgsch MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
175f210c2aSfgsch GNU General Public License for more details.
185f210c2aSfgsch
195f210c2aSfgsch You should have received a copy of the GNU General Public License
205f210c2aSfgsch along with this program; if not, write to the Free Software
215f210c2aSfgsch Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
225f210c2aSfgsch
235f210c2aSfgsch #include "bfd.h"
245f210c2aSfgsch #include "sysdep.h"
25d2201f2fSdrahn #include "bfdlink.h"
265f210c2aSfgsch #include "libbfd.h"
275f210c2aSfgsch #include "coff/internal.h"
28d2201f2fSdrahn #include "coff/xcoff.h"
295f210c2aSfgsch #include "coff/rs6k64.h"
305f210c2aSfgsch #include "libcoff.h"
31d2201f2fSdrahn #include "libxcoff.h"
325f210c2aSfgsch
33d2201f2fSdrahn #define GET_FILEHDR_SYMPTR H_GET_64
34d2201f2fSdrahn #define PUT_FILEHDR_SYMPTR H_PUT_64
35d2201f2fSdrahn #define GET_AOUTHDR_DATA_START H_GET_64
36d2201f2fSdrahn #define PUT_AOUTHDR_DATA_START H_PUT_64
37d2201f2fSdrahn #define GET_AOUTHDR_TEXT_START H_GET_64
38d2201f2fSdrahn #define PUT_AOUTHDR_TEXT_START H_PUT_64
39d2201f2fSdrahn #define GET_AOUTHDR_TSIZE H_GET_64
40d2201f2fSdrahn #define PUT_AOUTHDR_TSIZE H_PUT_64
41d2201f2fSdrahn #define GET_AOUTHDR_DSIZE H_GET_64
42d2201f2fSdrahn #define PUT_AOUTHDR_DSIZE H_PUT_64
43d2201f2fSdrahn #define GET_AOUTHDR_BSIZE H_GET_64
44d2201f2fSdrahn #define PUT_AOUTHDR_BSIZE H_PUT_64
45d2201f2fSdrahn #define GET_AOUTHDR_ENTRY H_GET_64
46d2201f2fSdrahn #define PUT_AOUTHDR_ENTRY H_PUT_64
47d2201f2fSdrahn #define GET_SCNHDR_PADDR H_GET_64
48d2201f2fSdrahn #define PUT_SCNHDR_PADDR H_PUT_64
49d2201f2fSdrahn #define GET_SCNHDR_VADDR H_GET_64
50d2201f2fSdrahn #define PUT_SCNHDR_VADDR H_PUT_64
51d2201f2fSdrahn #define GET_SCNHDR_SIZE H_GET_64
52d2201f2fSdrahn #define PUT_SCNHDR_SIZE H_PUT_64
53d2201f2fSdrahn #define GET_SCNHDR_SCNPTR H_GET_64
54d2201f2fSdrahn #define PUT_SCNHDR_SCNPTR H_PUT_64
55d2201f2fSdrahn #define GET_SCNHDR_RELPTR H_GET_64
56d2201f2fSdrahn #define PUT_SCNHDR_RELPTR H_PUT_64
57d2201f2fSdrahn #define GET_SCNHDR_LNNOPTR H_GET_64
58d2201f2fSdrahn #define PUT_SCNHDR_LNNOPTR H_PUT_64
59d2201f2fSdrahn #define GET_SCNHDR_NRELOC H_GET_32
605f210c2aSfgsch #define MAX_SCNHDR_NRELOC 0xffffffff
61d2201f2fSdrahn #define PUT_SCNHDR_NRELOC H_PUT_32
62d2201f2fSdrahn #define GET_SCNHDR_NLNNO H_GET_32
635f210c2aSfgsch #define MAX_SCNHDR_NLNNO 0xffffffff
64d2201f2fSdrahn #define PUT_SCNHDR_NLNNO H_PUT_32
65d2201f2fSdrahn #define GET_RELOC_VADDR H_GET_64
66d2201f2fSdrahn #define PUT_RELOC_VADDR H_PUT_64
675f210c2aSfgsch
685f210c2aSfgsch #define COFF_FORCE_SYMBOLS_IN_STRINGS
695f210c2aSfgsch #define COFF_DEBUG_STRING_WIDE_PREFIX
705f210c2aSfgsch
71d2201f2fSdrahn
725f210c2aSfgsch #define COFF_ADJUST_SCNHDR_OUT_POST(ABFD, INT, EXT) \
73d2201f2fSdrahn do \
74d2201f2fSdrahn { \
75d2201f2fSdrahn memset (((SCNHDR *) EXT)->s_pad, 0, \
76d2201f2fSdrahn sizeof (((SCNHDR *) EXT)->s_pad)); \
77d2201f2fSdrahn } \
78d2201f2fSdrahn while (0)
795f210c2aSfgsch
805f210c2aSfgsch #define NO_COFF_LINENOS
815f210c2aSfgsch
82d2201f2fSdrahn #define coff_SWAP_lineno_in _bfd_xcoff64_swap_lineno_in
83d2201f2fSdrahn #define coff_SWAP_lineno_out _bfd_xcoff64_swap_lineno_out
845f210c2aSfgsch
85d2201f2fSdrahn static void _bfd_xcoff64_swap_lineno_in
86d2201f2fSdrahn PARAMS ((bfd *, PTR, PTR));
87d2201f2fSdrahn static unsigned int _bfd_xcoff64_swap_lineno_out
88d2201f2fSdrahn PARAMS ((bfd *, PTR, PTR));
89d2201f2fSdrahn static bfd_boolean _bfd_xcoff64_put_symbol_name
90d2201f2fSdrahn PARAMS ((bfd *, struct bfd_strtab_hash *, struct internal_syment *,
91d2201f2fSdrahn const char *));
92d2201f2fSdrahn static bfd_boolean _bfd_xcoff64_put_ldsymbol_name
93d2201f2fSdrahn PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
94d2201f2fSdrahn const char *));
95d2201f2fSdrahn static void _bfd_xcoff64_swap_sym_in
96d2201f2fSdrahn PARAMS ((bfd *, PTR, PTR));
97d2201f2fSdrahn static unsigned int _bfd_xcoff64_swap_sym_out
98d2201f2fSdrahn PARAMS ((bfd *, PTR, PTR));
99d2201f2fSdrahn static void _bfd_xcoff64_swap_aux_in
100d2201f2fSdrahn PARAMS ((bfd *, PTR, int, int, int, int, PTR));
101d2201f2fSdrahn static unsigned int _bfd_xcoff64_swap_aux_out
102d2201f2fSdrahn PARAMS ((bfd *, PTR, int, int, int, int, PTR));
103d2201f2fSdrahn static void xcoff64_swap_reloc_in
104d2201f2fSdrahn PARAMS ((bfd *, PTR, PTR));
105d2201f2fSdrahn static unsigned int xcoff64_swap_reloc_out
106d2201f2fSdrahn PARAMS ((bfd *, PTR, PTR));
107d2201f2fSdrahn extern bfd_boolean _bfd_xcoff_mkobject
108d2201f2fSdrahn PARAMS ((bfd *));
109d2201f2fSdrahn extern bfd_boolean _bfd_xcoff_copy_private_bfd_data
110d2201f2fSdrahn PARAMS ((bfd *, bfd *));
111d2201f2fSdrahn extern bfd_boolean _bfd_xcoff_is_local_label_name
112d2201f2fSdrahn PARAMS ((bfd *, const char *));
113d2201f2fSdrahn extern void xcoff64_rtype2howto
114d2201f2fSdrahn PARAMS ((arelent *, struct internal_reloc *));
115d2201f2fSdrahn extern reloc_howto_type * xcoff64_reloc_type_lookup
116d2201f2fSdrahn PARAMS ((bfd *, bfd_reloc_code_real_type));
117d2201f2fSdrahn extern bfd_boolean _bfd_xcoff_slurp_armap
118d2201f2fSdrahn PARAMS ((bfd *));
119d2201f2fSdrahn extern PTR _bfd_xcoff_read_ar_hdr
120d2201f2fSdrahn PARAMS ((bfd *));
121d2201f2fSdrahn extern bfd *_bfd_xcoff_openr_next_archived_file
122d2201f2fSdrahn PARAMS ((bfd *, bfd *));
123d2201f2fSdrahn extern int _bfd_xcoff_stat_arch_elt
124d2201f2fSdrahn PARAMS ((bfd *, struct stat *));
125d2201f2fSdrahn extern bfd_boolean _bfd_xcoff_write_armap
126d2201f2fSdrahn PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
127d2201f2fSdrahn extern bfd_boolean _bfd_xcoff_write_archive_contents
128d2201f2fSdrahn PARAMS ((bfd *));
129d2201f2fSdrahn extern int _bfd_xcoff_sizeof_headers
130d2201f2fSdrahn PARAMS ((bfd *, bfd_boolean));
131d2201f2fSdrahn extern void _bfd_xcoff_swap_sym_in
132d2201f2fSdrahn PARAMS ((bfd *, PTR, PTR));
133d2201f2fSdrahn extern unsigned int _bfd_xcoff_swap_sym_out
134d2201f2fSdrahn PARAMS ((bfd *, PTR, PTR));
135d2201f2fSdrahn extern void _bfd_xcoff_swap_aux_in
136d2201f2fSdrahn PARAMS ((bfd *, PTR, int, int, int, int, PTR));
137d2201f2fSdrahn extern unsigned int _bfd_xcoff_swap_aux_out
138d2201f2fSdrahn PARAMS ((bfd *, PTR, int, int, int, int, PTR));
139d2201f2fSdrahn static void xcoff64_swap_ldhdr_in
140d2201f2fSdrahn PARAMS ((bfd *, const PTR, struct internal_ldhdr *));
141d2201f2fSdrahn static void xcoff64_swap_ldhdr_out
142d2201f2fSdrahn PARAMS ((bfd *, const struct internal_ldhdr *, PTR d));
143d2201f2fSdrahn static void xcoff64_swap_ldsym_in
144d2201f2fSdrahn PARAMS ((bfd *, const PTR, struct internal_ldsym *));
145d2201f2fSdrahn static void xcoff64_swap_ldsym_out
146d2201f2fSdrahn PARAMS ((bfd *, const struct internal_ldsym *, PTR d));
147d2201f2fSdrahn static void xcoff64_swap_ldrel_in
148d2201f2fSdrahn PARAMS ((bfd *, const PTR, struct internal_ldrel *));
149d2201f2fSdrahn static void xcoff64_swap_ldrel_out
150d2201f2fSdrahn PARAMS ((bfd *, const struct internal_ldrel *, PTR d));
151d2201f2fSdrahn static bfd_boolean xcoff64_write_object_contents
152d2201f2fSdrahn PARAMS ((bfd *));
153d2201f2fSdrahn static bfd_boolean xcoff64_ppc_relocate_section
154d2201f2fSdrahn PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
155d2201f2fSdrahn struct internal_reloc *, struct internal_syment *,
156d2201f2fSdrahn asection **));
157d2201f2fSdrahn static bfd_boolean xcoff64_slurp_armap
158d2201f2fSdrahn PARAMS ((bfd *));
159d2201f2fSdrahn static const bfd_target *xcoff64_archive_p
160d2201f2fSdrahn PARAMS ((bfd *));
161d2201f2fSdrahn static bfd *xcoff64_openr_next_archived_file
162d2201f2fSdrahn PARAMS ((bfd *, bfd *));
163d2201f2fSdrahn static int xcoff64_sizeof_headers
164d2201f2fSdrahn PARAMS ((bfd *, bfd_boolean));
165d2201f2fSdrahn static asection *xcoff64_create_csect_from_smclas
166d2201f2fSdrahn PARAMS ((bfd *, union internal_auxent *, const char *));
167d2201f2fSdrahn static bfd_boolean xcoff64_is_lineno_count_overflow
168d2201f2fSdrahn PARAMS ((bfd *, bfd_vma));
169d2201f2fSdrahn static bfd_boolean xcoff64_is_reloc_count_overflow
170d2201f2fSdrahn PARAMS ((bfd *, bfd_vma));
171d2201f2fSdrahn static bfd_vma xcoff64_loader_symbol_offset
172d2201f2fSdrahn PARAMS ((bfd *, struct internal_ldhdr *));
173d2201f2fSdrahn static bfd_vma xcoff64_loader_reloc_offset
174d2201f2fSdrahn PARAMS ((bfd *, struct internal_ldhdr *));
175d2201f2fSdrahn static bfd_boolean xcoff64_generate_rtinit
176d2201f2fSdrahn PARAMS ((bfd *, const char *, const char *, bfd_boolean));
177d2201f2fSdrahn static bfd_boolean xcoff64_bad_format_hook
178d2201f2fSdrahn PARAMS ((bfd *, PTR ));
179d2201f2fSdrahn
180d2201f2fSdrahn /* Relocation functions */
181d2201f2fSdrahn static bfd_boolean xcoff64_reloc_type_br
182d2201f2fSdrahn PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
183d2201f2fSdrahn
184d2201f2fSdrahn bfd_boolean (*xcoff64_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
185d2201f2fSdrahn PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)) =
186d2201f2fSdrahn {
187d2201f2fSdrahn xcoff_reloc_type_pos, /* R_POS (0x00) */
188d2201f2fSdrahn xcoff_reloc_type_neg, /* R_NEG (0x01) */
189d2201f2fSdrahn xcoff_reloc_type_rel, /* R_REL (0x02) */
190d2201f2fSdrahn xcoff_reloc_type_toc, /* R_TOC (0x03) */
191d2201f2fSdrahn xcoff_reloc_type_fail, /* R_RTB (0x04) */
192d2201f2fSdrahn xcoff_reloc_type_toc, /* R_GL (0x05) */
193d2201f2fSdrahn xcoff_reloc_type_toc, /* R_TCL (0x06) */
194d2201f2fSdrahn xcoff_reloc_type_fail, /* (0x07) */
195d2201f2fSdrahn xcoff_reloc_type_ba, /* R_BA (0x08) */
196d2201f2fSdrahn xcoff_reloc_type_fail, /* (0x09) */
197d2201f2fSdrahn xcoff64_reloc_type_br, /* R_BR (0x0a) */
198d2201f2fSdrahn xcoff_reloc_type_fail, /* (0x0b) */
199d2201f2fSdrahn xcoff_reloc_type_pos, /* R_RL (0x0c) */
200d2201f2fSdrahn xcoff_reloc_type_pos, /* R_RLA (0x0d) */
201d2201f2fSdrahn xcoff_reloc_type_fail, /* (0x0e) */
202d2201f2fSdrahn xcoff_reloc_type_noop, /* R_REF (0x0f) */
203d2201f2fSdrahn xcoff_reloc_type_fail, /* (0x10) */
204d2201f2fSdrahn xcoff_reloc_type_fail, /* (0x11) */
205d2201f2fSdrahn xcoff_reloc_type_toc, /* R_TRL (0x12) */
206d2201f2fSdrahn xcoff_reloc_type_toc, /* R_TRLA (0x13) */
207d2201f2fSdrahn xcoff_reloc_type_fail, /* R_RRTBI (0x14) */
208d2201f2fSdrahn xcoff_reloc_type_fail, /* R_RRTBA (0x15) */
209d2201f2fSdrahn xcoff_reloc_type_ba, /* R_CAI (0x16) */
210d2201f2fSdrahn xcoff_reloc_type_crel, /* R_CREL (0x17) */
211d2201f2fSdrahn xcoff_reloc_type_ba, /* R_RBA (0x18) */
212d2201f2fSdrahn xcoff_reloc_type_ba, /* R_RBAC (0x19) */
213d2201f2fSdrahn xcoff64_reloc_type_br, /* R_RBR (0x1a) */
214d2201f2fSdrahn xcoff_reloc_type_ba, /* R_RBRC (0x1b) */
215d2201f2fSdrahn };
216d2201f2fSdrahn
217d2201f2fSdrahn /* coffcode.h needs these to be defined. */
218d2201f2fSdrahn /* Internalcoff.h and coffcode.h modify themselves based on these flags. */
219d2201f2fSdrahn #define XCOFF64
220d2201f2fSdrahn #define RS6000COFF_C 1
221d2201f2fSdrahn
222d2201f2fSdrahn #define SELECT_RELOC(internal, howto) \
223d2201f2fSdrahn { \
224d2201f2fSdrahn internal.r_type = howto->type; \
225d2201f2fSdrahn internal.r_size = \
226d2201f2fSdrahn ((howto->complain_on_overflow == complain_overflow_signed \
227d2201f2fSdrahn ? 0x80 \
228d2201f2fSdrahn : 0) \
229d2201f2fSdrahn | (howto->bitsize - 1)); \
230d2201f2fSdrahn }
231d2201f2fSdrahn
232d2201f2fSdrahn #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
233d2201f2fSdrahn #define COFF_LONG_FILENAMES
234d2201f2fSdrahn #define NO_COFF_SYMBOLS
235d2201f2fSdrahn #define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst)
236d2201f2fSdrahn #define coff_mkobject _bfd_xcoff_mkobject
237d2201f2fSdrahn #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
238d2201f2fSdrahn #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
239d2201f2fSdrahn #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
240d2201f2fSdrahn #ifdef AIX_CORE
241d2201f2fSdrahn extern const bfd_target * rs6000coff_core_p
242d2201f2fSdrahn PARAMS ((bfd *abfd));
243d2201f2fSdrahn extern bfd_boolean rs6000coff_core_file_matches_executable_p
244d2201f2fSdrahn PARAMS ((bfd *cbfd, bfd *ebfd));
245d2201f2fSdrahn extern char *rs6000coff_core_file_failing_command
246d2201f2fSdrahn PARAMS ((bfd *abfd));
247d2201f2fSdrahn extern int rs6000coff_core_file_failing_signal
248d2201f2fSdrahn PARAMS ((bfd *abfd));
249d2201f2fSdrahn #define CORE_FILE_P rs6000coff_core_p
250d2201f2fSdrahn #define coff_core_file_failing_command \
251d2201f2fSdrahn rs6000coff_core_file_failing_command
252d2201f2fSdrahn #define coff_core_file_failing_signal \
253d2201f2fSdrahn rs6000coff_core_file_failing_signal
254d2201f2fSdrahn #define coff_core_file_matches_executable_p \
255d2201f2fSdrahn rs6000coff_core_file_matches_executable_p
256d2201f2fSdrahn #else
257d2201f2fSdrahn #define CORE_FILE_P _bfd_dummy_target
258d2201f2fSdrahn #define coff_core_file_failing_command \
259d2201f2fSdrahn _bfd_nocore_core_file_failing_command
260d2201f2fSdrahn #define coff_core_file_failing_signal \
261d2201f2fSdrahn _bfd_nocore_core_file_failing_signal
262d2201f2fSdrahn #define coff_core_file_matches_executable_p \
263d2201f2fSdrahn _bfd_nocore_core_file_matches_executable_p
264d2201f2fSdrahn #endif
265d2201f2fSdrahn #define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
266d2201f2fSdrahn #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
267d2201f2fSdrahn #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
268d2201f2fSdrahn #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
269d2201f2fSdrahn #define coff_swap_reloc_in xcoff64_swap_reloc_in
270d2201f2fSdrahn #define coff_swap_reloc_out xcoff64_swap_reloc_out
271d2201f2fSdrahn #define NO_COFF_RELOCS
272d2201f2fSdrahn
273d2201f2fSdrahn #include "coffcode.h"
2745f210c2aSfgsch
2755f210c2aSfgsch /* For XCOFF64, the effective width of symndx changes depending on
2765f210c2aSfgsch whether we are the first entry. Sigh. */
2775f210c2aSfgsch static void
_bfd_xcoff64_swap_lineno_in(abfd,ext1,in1)278d2201f2fSdrahn _bfd_xcoff64_swap_lineno_in (abfd, ext1, in1)
2795f210c2aSfgsch bfd *abfd;
2805f210c2aSfgsch PTR ext1;
2815f210c2aSfgsch PTR in1;
2825f210c2aSfgsch {
2835f210c2aSfgsch LINENO *ext = (LINENO *) ext1;
2845f210c2aSfgsch struct internal_lineno *in = (struct internal_lineno *) in1;
2855f210c2aSfgsch
286d2201f2fSdrahn in->l_lnno = H_GET_32 (abfd, (ext->l_lnno));
2875f210c2aSfgsch if (in->l_lnno == 0)
288d2201f2fSdrahn in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
2895f210c2aSfgsch else
290d2201f2fSdrahn in->l_addr.l_paddr = H_GET_64 (abfd, ext->l_addr.l_paddr);
2915f210c2aSfgsch }
2925f210c2aSfgsch
2935f210c2aSfgsch static unsigned int
_bfd_xcoff64_swap_lineno_out(abfd,inp,outp)294d2201f2fSdrahn _bfd_xcoff64_swap_lineno_out (abfd, inp, outp)
2955f210c2aSfgsch bfd *abfd;
2965f210c2aSfgsch PTR inp;
2975f210c2aSfgsch PTR outp;
2985f210c2aSfgsch {
2995f210c2aSfgsch struct internal_lineno *in = (struct internal_lineno *) inp;
3005f210c2aSfgsch struct external_lineno *ext = (struct external_lineno *) outp;
3015f210c2aSfgsch
302d2201f2fSdrahn H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
303d2201f2fSdrahn H_PUT_32 (abfd, in->l_lnno, (ext->l_lnno));
304d2201f2fSdrahn
3055f210c2aSfgsch if (in->l_lnno == 0)
306d2201f2fSdrahn H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
3075f210c2aSfgsch else
308d2201f2fSdrahn H_PUT_64 (abfd, in->l_addr.l_paddr, ext->l_addr.l_paddr);
3095f210c2aSfgsch
3105f210c2aSfgsch return bfd_coff_linesz (abfd);
3115f210c2aSfgsch }
3125f210c2aSfgsch
3135f210c2aSfgsch static void
_bfd_xcoff64_swap_sym_in(abfd,ext1,in1)314d2201f2fSdrahn _bfd_xcoff64_swap_sym_in (abfd, ext1, in1)
3155f210c2aSfgsch bfd *abfd;
3165f210c2aSfgsch PTR ext1;
3175f210c2aSfgsch PTR in1;
3185f210c2aSfgsch {
319d2201f2fSdrahn struct external_syment *ext = (struct external_syment *) ext1;
3205f210c2aSfgsch struct internal_syment *in = (struct internal_syment *) in1;
3215f210c2aSfgsch
3225f210c2aSfgsch in->_n._n_n._n_zeroes = 0;
323d2201f2fSdrahn in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e_offset);
324d2201f2fSdrahn in->n_value = H_GET_64 (abfd, ext->e_value);
325d2201f2fSdrahn in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
326d2201f2fSdrahn in->n_type = H_GET_16 (abfd, ext->e_type);
327d2201f2fSdrahn in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
328d2201f2fSdrahn in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
3295f210c2aSfgsch }
3305f210c2aSfgsch
3315f210c2aSfgsch static unsigned int
_bfd_xcoff64_swap_sym_out(abfd,inp,extp)332d2201f2fSdrahn _bfd_xcoff64_swap_sym_out (abfd, inp, extp)
3335f210c2aSfgsch bfd *abfd;
3345f210c2aSfgsch PTR inp;
3355f210c2aSfgsch PTR extp;
3365f210c2aSfgsch {
3375f210c2aSfgsch struct internal_syment *in = (struct internal_syment *) inp;
338d2201f2fSdrahn struct external_syment *ext = (struct external_syment *) extp;
3395f210c2aSfgsch
340d2201f2fSdrahn H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e_offset);
341d2201f2fSdrahn H_PUT_64 (abfd, in->n_value, ext->e_value);
342d2201f2fSdrahn H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
343d2201f2fSdrahn H_PUT_16 (abfd, in->n_type, ext->e_type);
344d2201f2fSdrahn H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
345d2201f2fSdrahn H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
3465f210c2aSfgsch return bfd_coff_symesz (abfd);
3475f210c2aSfgsch }
3485f210c2aSfgsch
3495f210c2aSfgsch static void
_bfd_xcoff64_swap_aux_in(abfd,ext1,type,class,indx,numaux,in1)350d2201f2fSdrahn _bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
3515f210c2aSfgsch bfd *abfd;
3525f210c2aSfgsch PTR ext1;
3535f210c2aSfgsch int type;
3545f210c2aSfgsch int class;
3555f210c2aSfgsch int indx;
3565f210c2aSfgsch int numaux;
3575f210c2aSfgsch PTR in1;
3585f210c2aSfgsch {
359d2201f2fSdrahn union external_auxent *ext = (union external_auxent *) ext1;
3605f210c2aSfgsch union internal_auxent *in = (union internal_auxent *) in1;
3615f210c2aSfgsch
362d2201f2fSdrahn switch (class)
3635f210c2aSfgsch {
364d2201f2fSdrahn case C_FILE:
365d2201f2fSdrahn if (ext->x_file.x_n.x_zeroes[0] == 0)
366d2201f2fSdrahn {
367d2201f2fSdrahn in->x_file.x_n.x_zeroes = 0;
368d2201f2fSdrahn in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
3695f210c2aSfgsch }
3705f210c2aSfgsch else
3715f210c2aSfgsch {
3725f210c2aSfgsch memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
3735f210c2aSfgsch }
3745f210c2aSfgsch goto end;
3755f210c2aSfgsch
3765f210c2aSfgsch /* RS/6000 "csect" auxents */
3775f210c2aSfgsch case C_EXT:
3785f210c2aSfgsch case C_HIDEXT:
3795f210c2aSfgsch if (indx + 1 == numaux)
3805f210c2aSfgsch {
381d2201f2fSdrahn bfd_signed_vma h = 0;
382d2201f2fSdrahn bfd_vma l = 0;
383d2201f2fSdrahn
384d2201f2fSdrahn h = H_GET_S32 (abfd, ext->x_csect.x_scnlen_hi);
385d2201f2fSdrahn l = H_GET_32 (abfd, ext->x_csect.x_scnlen_lo);
386d2201f2fSdrahn
387d2201f2fSdrahn in->x_csect.x_scnlen.l = h << 32 | (l & 0xffffffff);
388d2201f2fSdrahn
389d2201f2fSdrahn in->x_csect.x_parmhash = H_GET_32 (abfd, ext->x_csect.x_parmhash);
390d2201f2fSdrahn in->x_csect.x_snhash = H_GET_16 (abfd, ext->x_csect.x_snhash);
3915f210c2aSfgsch /* We don't have to hack bitfields in x_smtyp because it's
3925f210c2aSfgsch defined by shifts-and-ands, which are equivalent on all
3935f210c2aSfgsch byte orders. */
394d2201f2fSdrahn in->x_csect.x_smtyp = H_GET_8 (abfd, ext->x_csect.x_smtyp);
395d2201f2fSdrahn in->x_csect.x_smclas = H_GET_8 (abfd, ext->x_csect.x_smclas);
3965f210c2aSfgsch goto end;
3975f210c2aSfgsch }
3985f210c2aSfgsch break;
3995f210c2aSfgsch
4005f210c2aSfgsch case C_STAT:
4015f210c2aSfgsch case C_LEAFSTAT:
4025f210c2aSfgsch case C_HIDDEN:
403d2201f2fSdrahn if (type == T_NULL)
404d2201f2fSdrahn {
4055f210c2aSfgsch /* PE defines some extra fields; we zero them out for
4065f210c2aSfgsch safety. */
4075f210c2aSfgsch in->x_scn.x_checksum = 0;
4085f210c2aSfgsch in->x_scn.x_associated = 0;
4095f210c2aSfgsch in->x_scn.x_comdat = 0;
4105f210c2aSfgsch
4115f210c2aSfgsch goto end;
4125f210c2aSfgsch }
4135f210c2aSfgsch break;
4145f210c2aSfgsch }
4155f210c2aSfgsch
4165f210c2aSfgsch if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
4175f210c2aSfgsch {
418d2201f2fSdrahn in->x_sym.x_fcnary.x_fcn.x_lnnoptr
419d2201f2fSdrahn = H_GET_64 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
420d2201f2fSdrahn in->x_sym.x_fcnary.x_fcn.x_endndx.l
421d2201f2fSdrahn = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx);
4225f210c2aSfgsch }
423d2201f2fSdrahn if (ISFCN (type))
424d2201f2fSdrahn {
425d2201f2fSdrahn in->x_sym.x_misc.x_fsize
426d2201f2fSdrahn = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_fsize);
4275f210c2aSfgsch }
428d2201f2fSdrahn else
429d2201f2fSdrahn {
430d2201f2fSdrahn in->x_sym.x_misc.x_lnsz.x_lnno
431d2201f2fSdrahn = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_lnno);
432d2201f2fSdrahn in->x_sym.x_misc.x_lnsz.x_size
433d2201f2fSdrahn = H_GET_16 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_size);
4345f210c2aSfgsch }
4355f210c2aSfgsch
4365f210c2aSfgsch end: ;
4375f210c2aSfgsch }
4385f210c2aSfgsch
4395f210c2aSfgsch static unsigned int
_bfd_xcoff64_swap_aux_out(abfd,inp,type,class,indx,numaux,extp)440d2201f2fSdrahn _bfd_xcoff64_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
4415f210c2aSfgsch bfd *abfd;
4425f210c2aSfgsch PTR inp;
4435f210c2aSfgsch int type;
4445f210c2aSfgsch int class;
4455f210c2aSfgsch int indx ATTRIBUTE_UNUSED;
4465f210c2aSfgsch int numaux ATTRIBUTE_UNUSED;
4475f210c2aSfgsch PTR extp;
4485f210c2aSfgsch {
4495f210c2aSfgsch union internal_auxent *in = (union internal_auxent *) inp;
450d2201f2fSdrahn union external_auxent *ext = (union external_auxent *) extp;
4515f210c2aSfgsch
4525f210c2aSfgsch memset ((PTR) ext, 0, bfd_coff_auxesz (abfd));
4535f210c2aSfgsch switch (class)
4545f210c2aSfgsch {
4555f210c2aSfgsch case C_FILE:
456d2201f2fSdrahn if (in->x_file.x_n.x_zeroes == 0)
4575f210c2aSfgsch {
458d2201f2fSdrahn H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
459d2201f2fSdrahn H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
4605f210c2aSfgsch }
4615f210c2aSfgsch else
4625f210c2aSfgsch {
4635f210c2aSfgsch memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
4645f210c2aSfgsch }
465d2201f2fSdrahn H_PUT_8 (abfd, _AUX_FILE, ext->x_auxtype.x_auxtype);
4665f210c2aSfgsch goto end;
4675f210c2aSfgsch
4685f210c2aSfgsch /* RS/6000 "csect" auxents */
4695f210c2aSfgsch case C_EXT:
4705f210c2aSfgsch case C_HIDEXT:
4715f210c2aSfgsch if (indx + 1 == numaux)
4725f210c2aSfgsch {
473d2201f2fSdrahn bfd_vma temp;
474d2201f2fSdrahn
475d2201f2fSdrahn temp = in->x_csect.x_scnlen.l & 0xffffffff;
476d2201f2fSdrahn H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_lo);
477d2201f2fSdrahn temp = in->x_csect.x_scnlen.l >> 32;
478d2201f2fSdrahn H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_hi);
479d2201f2fSdrahn H_PUT_32 (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
480d2201f2fSdrahn H_PUT_16 (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
4815f210c2aSfgsch /* We don't have to hack bitfields in x_smtyp because it's
4825f210c2aSfgsch defined by shifts-and-ands, which are equivalent on all
4835f210c2aSfgsch byte orders. */
484d2201f2fSdrahn H_PUT_8 (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
485d2201f2fSdrahn H_PUT_8 (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
486d2201f2fSdrahn H_PUT_8 (abfd, _AUX_CSECT, ext->x_auxtype.x_auxtype);
4875f210c2aSfgsch goto end;
4885f210c2aSfgsch }
4895f210c2aSfgsch break;
4905f210c2aSfgsch
4915f210c2aSfgsch case C_STAT:
4925f210c2aSfgsch case C_LEAFSTAT:
4935f210c2aSfgsch case C_HIDDEN:
494d2201f2fSdrahn if (type == T_NULL)
495d2201f2fSdrahn {
4965f210c2aSfgsch goto end;
4975f210c2aSfgsch }
4985f210c2aSfgsch break;
4995f210c2aSfgsch }
5005f210c2aSfgsch
5015f210c2aSfgsch if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
5025f210c2aSfgsch {
503d2201f2fSdrahn H_PUT_64 (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
504d2201f2fSdrahn ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
505d2201f2fSdrahn H_PUT_8 (abfd, _AUX_FCN,
506d2201f2fSdrahn ext->x_auxtype.x_auxtype);
507d2201f2fSdrahn H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
508d2201f2fSdrahn ext->x_sym.x_fcnary.x_fcn.x_endndx);
5095f210c2aSfgsch }
5105f210c2aSfgsch if (ISFCN (type))
511d2201f2fSdrahn {
512d2201f2fSdrahn H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize,
513d2201f2fSdrahn ext->x_sym.x_fcnary.x_fcn.x_fsize);
514d2201f2fSdrahn }
5155f210c2aSfgsch else
5165f210c2aSfgsch {
517d2201f2fSdrahn H_PUT_32 (abfd, in->x_sym.x_misc.x_lnsz.x_lnno,
518d2201f2fSdrahn ext->x_sym.x_fcnary.x_lnsz.x_lnno);
519d2201f2fSdrahn H_PUT_16 (abfd, in->x_sym.x_misc.x_lnsz.x_size,
520d2201f2fSdrahn ext->x_sym.x_fcnary.x_lnsz.x_size);
5215f210c2aSfgsch }
5225f210c2aSfgsch
5235f210c2aSfgsch end:
524d2201f2fSdrahn
5255f210c2aSfgsch return bfd_coff_auxesz (abfd);
5265f210c2aSfgsch }
5275f210c2aSfgsch
528d2201f2fSdrahn static bfd_boolean
_bfd_xcoff64_put_symbol_name(abfd,strtab,sym,name)529d2201f2fSdrahn _bfd_xcoff64_put_symbol_name (abfd, strtab, sym, name)
530d2201f2fSdrahn bfd *abfd;
531d2201f2fSdrahn struct bfd_strtab_hash *strtab;
532d2201f2fSdrahn struct internal_syment *sym;
533d2201f2fSdrahn const char *name;
534d2201f2fSdrahn {
535d2201f2fSdrahn bfd_boolean hash;
536d2201f2fSdrahn bfd_size_type indx;
5375f210c2aSfgsch
538d2201f2fSdrahn hash = TRUE;
5395f210c2aSfgsch
540d2201f2fSdrahn if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
541d2201f2fSdrahn hash = FALSE;
542d2201f2fSdrahn
543d2201f2fSdrahn indx = _bfd_stringtab_add (strtab, name, hash, FALSE);
544d2201f2fSdrahn
545d2201f2fSdrahn if (indx == (bfd_size_type) -1)
546d2201f2fSdrahn return FALSE;
547d2201f2fSdrahn
548d2201f2fSdrahn sym->_n._n_n._n_zeroes = 0;
549d2201f2fSdrahn sym->_n._n_n._n_offset = STRING_SIZE_SIZE + indx;
550d2201f2fSdrahn
551d2201f2fSdrahn return TRUE;
552d2201f2fSdrahn }
553d2201f2fSdrahn
554d2201f2fSdrahn static bfd_boolean
_bfd_xcoff64_put_ldsymbol_name(abfd,ldinfo,ldsym,name)555d2201f2fSdrahn _bfd_xcoff64_put_ldsymbol_name (abfd, ldinfo, ldsym, name)
556d2201f2fSdrahn bfd *abfd ATTRIBUTE_UNUSED;
557d2201f2fSdrahn struct xcoff_loader_info *ldinfo;
558d2201f2fSdrahn struct internal_ldsym *ldsym;
559d2201f2fSdrahn const char *name;
560d2201f2fSdrahn {
561d2201f2fSdrahn size_t len;
562d2201f2fSdrahn len = strlen (name);
563d2201f2fSdrahn
564d2201f2fSdrahn if (ldinfo->string_size + len + 3 > ldinfo->string_alc)
565d2201f2fSdrahn {
566d2201f2fSdrahn bfd_size_type newalc;
567d2201f2fSdrahn bfd_byte *newstrings;
568d2201f2fSdrahn
569d2201f2fSdrahn newalc = ldinfo->string_alc * 2;
570d2201f2fSdrahn if (newalc == 0)
571d2201f2fSdrahn newalc = 32;
572d2201f2fSdrahn while (ldinfo->string_size + len + 3 > newalc)
573d2201f2fSdrahn newalc *= 2;
574d2201f2fSdrahn
575d2201f2fSdrahn newstrings = ((bfd_byte *)
576d2201f2fSdrahn bfd_realloc ((PTR) ldinfo->strings, newalc));
577d2201f2fSdrahn if (newstrings == NULL)
578d2201f2fSdrahn {
579d2201f2fSdrahn ldinfo->failed = TRUE;
580d2201f2fSdrahn return FALSE;
581d2201f2fSdrahn }
582d2201f2fSdrahn ldinfo->string_alc = newalc;
583d2201f2fSdrahn ldinfo->strings = newstrings;
584d2201f2fSdrahn }
585d2201f2fSdrahn
586d2201f2fSdrahn bfd_put_16 (ldinfo->output_bfd, (bfd_vma) (len + 1),
587d2201f2fSdrahn ldinfo->strings + ldinfo->string_size);
588d2201f2fSdrahn strcpy (ldinfo->strings + ldinfo->string_size + 2, name);
589d2201f2fSdrahn ldsym->_l._l_l._l_zeroes = 0;
590d2201f2fSdrahn ldsym->_l._l_l._l_offset = ldinfo->string_size + 2;
591d2201f2fSdrahn ldinfo->string_size += len + 3;
592d2201f2fSdrahn
593d2201f2fSdrahn return TRUE;
594d2201f2fSdrahn }
595d2201f2fSdrahn
596d2201f2fSdrahn /* Routines to swap information in the XCOFF .loader section. If we
597d2201f2fSdrahn ever need to write an XCOFF loader, this stuff will need to be
598d2201f2fSdrahn moved to another file shared by the linker (which XCOFF calls the
599d2201f2fSdrahn ``binder'') and the loader. */
600d2201f2fSdrahn
601d2201f2fSdrahn /* Swap in the ldhdr structure. */
602d2201f2fSdrahn
603d2201f2fSdrahn static void
xcoff64_swap_ldhdr_in(abfd,s,dst)604d2201f2fSdrahn xcoff64_swap_ldhdr_in (abfd, s, dst)
605d2201f2fSdrahn bfd *abfd;
606d2201f2fSdrahn const PTR s;
607d2201f2fSdrahn struct internal_ldhdr *dst;
608d2201f2fSdrahn {
609d2201f2fSdrahn const struct external_ldhdr *src = (const struct external_ldhdr *) s;
610d2201f2fSdrahn
611d2201f2fSdrahn dst->l_version = bfd_get_32 (abfd, src->l_version);
612d2201f2fSdrahn dst->l_nsyms = bfd_get_32 (abfd, src->l_nsyms);
613d2201f2fSdrahn dst->l_nreloc = bfd_get_32 (abfd, src->l_nreloc);
614d2201f2fSdrahn dst->l_istlen = bfd_get_32 (abfd, src->l_istlen);
615d2201f2fSdrahn dst->l_nimpid = bfd_get_32 (abfd, src->l_nimpid);
616d2201f2fSdrahn dst->l_stlen = bfd_get_32 (abfd, src->l_stlen);
617d2201f2fSdrahn dst->l_impoff = bfd_get_64 (abfd, src->l_impoff);
618d2201f2fSdrahn dst->l_stoff = bfd_get_64 (abfd, src->l_stoff);
619d2201f2fSdrahn dst->l_symoff = bfd_get_64 (abfd, src->l_symoff);
620d2201f2fSdrahn dst->l_rldoff = bfd_get_64 (abfd, src->l_rldoff);
621d2201f2fSdrahn }
622d2201f2fSdrahn
623d2201f2fSdrahn /* Swap out the ldhdr structure. */
624d2201f2fSdrahn
625d2201f2fSdrahn static void
xcoff64_swap_ldhdr_out(abfd,src,d)626d2201f2fSdrahn xcoff64_swap_ldhdr_out (abfd, src, d)
627d2201f2fSdrahn bfd *abfd;
628d2201f2fSdrahn const struct internal_ldhdr *src;
629d2201f2fSdrahn PTR d;
630d2201f2fSdrahn {
631d2201f2fSdrahn struct external_ldhdr *dst = (struct external_ldhdr *) d;
632d2201f2fSdrahn
633d2201f2fSdrahn bfd_put_32 (abfd, (bfd_vma) src->l_version, dst->l_version);
634d2201f2fSdrahn bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms);
635d2201f2fSdrahn bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc);
636d2201f2fSdrahn bfd_put_32 (abfd, src->l_istlen, dst->l_istlen);
637d2201f2fSdrahn bfd_put_32 (abfd, src->l_nimpid, dst->l_nimpid);
638d2201f2fSdrahn bfd_put_32 (abfd, src->l_stlen, dst->l_stlen);
639d2201f2fSdrahn bfd_put_64 (abfd, src->l_impoff, dst->l_impoff);
640d2201f2fSdrahn bfd_put_64 (abfd, src->l_stoff, dst->l_stoff);
641d2201f2fSdrahn bfd_put_64 (abfd, src->l_symoff, dst->l_symoff);
642d2201f2fSdrahn bfd_put_64 (abfd, src->l_rldoff, dst->l_rldoff);
643d2201f2fSdrahn }
644d2201f2fSdrahn
645d2201f2fSdrahn /* Swap in the ldsym structure. */
646d2201f2fSdrahn
647d2201f2fSdrahn static void
xcoff64_swap_ldsym_in(abfd,s,dst)648d2201f2fSdrahn xcoff64_swap_ldsym_in (abfd, s, dst)
649d2201f2fSdrahn bfd *abfd;
650d2201f2fSdrahn const PTR s;
651d2201f2fSdrahn struct internal_ldsym *dst;
652d2201f2fSdrahn {
653d2201f2fSdrahn const struct external_ldsym *src = (const struct external_ldsym *) s;
654d2201f2fSdrahn /* XCOFF64 does not use l_zeroes like XCOFF32
655d2201f2fSdrahn Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
656d2201f2fSdrahn as an offset into the loader symbol table. */
657d2201f2fSdrahn dst->_l._l_l._l_zeroes = 0;
658d2201f2fSdrahn dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->l_offset);
659d2201f2fSdrahn dst->l_value = bfd_get_64 (abfd, src->l_value);
660d2201f2fSdrahn dst->l_scnum = bfd_get_16 (abfd, src->l_scnum);
661d2201f2fSdrahn dst->l_smtype = bfd_get_8 (abfd, src->l_smtype);
662d2201f2fSdrahn dst->l_smclas = bfd_get_8 (abfd, src->l_smclas);
663d2201f2fSdrahn dst->l_ifile = bfd_get_32 (abfd, src->l_ifile);
664d2201f2fSdrahn dst->l_parm = bfd_get_32 (abfd, src->l_parm);
665d2201f2fSdrahn }
666d2201f2fSdrahn
667d2201f2fSdrahn /* Swap out the ldsym structure. */
668d2201f2fSdrahn
669d2201f2fSdrahn static void
xcoff64_swap_ldsym_out(abfd,src,d)670d2201f2fSdrahn xcoff64_swap_ldsym_out (abfd, src, d)
671d2201f2fSdrahn bfd *abfd;
672d2201f2fSdrahn const struct internal_ldsym *src;
673d2201f2fSdrahn PTR d;
674d2201f2fSdrahn {
675d2201f2fSdrahn struct external_ldsym *dst = (struct external_ldsym *) d;
676d2201f2fSdrahn
677d2201f2fSdrahn bfd_put_64 (abfd, src->l_value, dst->l_value);
678d2201f2fSdrahn bfd_put_32 (abfd, (bfd_vma) src->_l._l_l._l_offset, dst->l_offset);
679d2201f2fSdrahn bfd_put_16 (abfd, (bfd_vma) src->l_scnum, dst->l_scnum);
680d2201f2fSdrahn bfd_put_8 (abfd, src->l_smtype, dst->l_smtype);
681d2201f2fSdrahn bfd_put_8 (abfd, src->l_smclas, dst->l_smclas);
682d2201f2fSdrahn bfd_put_32 (abfd, src->l_ifile, dst->l_ifile);
683d2201f2fSdrahn bfd_put_32 (abfd, src->l_parm, dst->l_parm);
684d2201f2fSdrahn }
685d2201f2fSdrahn
686d2201f2fSdrahn static void
xcoff64_swap_reloc_in(abfd,s,d)687d2201f2fSdrahn xcoff64_swap_reloc_in (abfd, s, d)
688d2201f2fSdrahn bfd *abfd;
689d2201f2fSdrahn PTR s;
690d2201f2fSdrahn PTR d;
691d2201f2fSdrahn {
692d2201f2fSdrahn struct external_reloc *src = (struct external_reloc *) s;
693d2201f2fSdrahn struct internal_reloc *dst = (struct internal_reloc *) d;
694d2201f2fSdrahn
695d2201f2fSdrahn memset (dst, 0, sizeof (struct internal_reloc));
696d2201f2fSdrahn
697d2201f2fSdrahn dst->r_vaddr = bfd_get_64 (abfd, src->r_vaddr);
698d2201f2fSdrahn dst->r_symndx = bfd_get_32 (abfd, src->r_symndx);
699d2201f2fSdrahn dst->r_size = bfd_get_8 (abfd, src->r_size);
700d2201f2fSdrahn dst->r_type = bfd_get_8 (abfd, src->r_type);
701d2201f2fSdrahn }
702d2201f2fSdrahn
703d2201f2fSdrahn static unsigned int
xcoff64_swap_reloc_out(abfd,s,d)704d2201f2fSdrahn xcoff64_swap_reloc_out (abfd, s, d)
705d2201f2fSdrahn bfd *abfd;
706d2201f2fSdrahn PTR s;
707d2201f2fSdrahn PTR d;
708d2201f2fSdrahn {
709d2201f2fSdrahn struct internal_reloc *src = (struct internal_reloc *) s;
710d2201f2fSdrahn struct external_reloc *dst = (struct external_reloc *) d;
711d2201f2fSdrahn
712d2201f2fSdrahn bfd_put_64 (abfd, src->r_vaddr, dst->r_vaddr);
713d2201f2fSdrahn bfd_put_32 (abfd, src->r_symndx, dst->r_symndx);
714d2201f2fSdrahn bfd_put_8 (abfd, src->r_type, dst->r_type);
715d2201f2fSdrahn bfd_put_8 (abfd, src->r_size, dst->r_size);
716d2201f2fSdrahn
717d2201f2fSdrahn return bfd_coff_relsz (abfd);
718d2201f2fSdrahn }
719d2201f2fSdrahn
720d2201f2fSdrahn /* Swap in the ldrel structure. */
721d2201f2fSdrahn
722d2201f2fSdrahn static void
xcoff64_swap_ldrel_in(abfd,s,dst)723d2201f2fSdrahn xcoff64_swap_ldrel_in (abfd, s, dst)
724d2201f2fSdrahn bfd *abfd;
725d2201f2fSdrahn const PTR s;
726d2201f2fSdrahn struct internal_ldrel *dst;
727d2201f2fSdrahn {
728d2201f2fSdrahn const struct external_ldrel *src = (const struct external_ldrel *) s;
729d2201f2fSdrahn
730d2201f2fSdrahn dst->l_vaddr = bfd_get_64 (abfd, src->l_vaddr);
731d2201f2fSdrahn dst->l_symndx = bfd_get_32 (abfd, src->l_symndx);
732d2201f2fSdrahn dst->l_rtype = bfd_get_16 (abfd, src->l_rtype);
733d2201f2fSdrahn dst->l_rsecnm = bfd_get_16 (abfd, src->l_rsecnm);
734d2201f2fSdrahn }
735d2201f2fSdrahn
736d2201f2fSdrahn /* Swap out the ldrel structure. */
737d2201f2fSdrahn
738d2201f2fSdrahn static void
xcoff64_swap_ldrel_out(abfd,src,d)739d2201f2fSdrahn xcoff64_swap_ldrel_out (abfd, src, d)
740d2201f2fSdrahn bfd *abfd;
741d2201f2fSdrahn const struct internal_ldrel *src;
742d2201f2fSdrahn PTR d;
743d2201f2fSdrahn {
744d2201f2fSdrahn struct external_ldrel *dst = (struct external_ldrel *) d;
745d2201f2fSdrahn
746d2201f2fSdrahn bfd_put_64 (abfd, src->l_vaddr, dst->l_vaddr);
747d2201f2fSdrahn bfd_put_16 (abfd, (bfd_vma) src->l_rtype, dst->l_rtype);
748d2201f2fSdrahn bfd_put_16 (abfd, (bfd_vma) src->l_rsecnm, dst->l_rsecnm);
749d2201f2fSdrahn bfd_put_32 (abfd, src->l_symndx, dst->l_symndx);
750d2201f2fSdrahn }
751d2201f2fSdrahn
752d2201f2fSdrahn static bfd_boolean
xcoff64_write_object_contents(abfd)753d2201f2fSdrahn xcoff64_write_object_contents (abfd)
754d2201f2fSdrahn bfd *abfd;
755d2201f2fSdrahn {
756d2201f2fSdrahn asection *current;
757d2201f2fSdrahn bfd_boolean hasrelocs = FALSE;
758d2201f2fSdrahn bfd_boolean haslinno = FALSE;
759d2201f2fSdrahn file_ptr scn_base;
760d2201f2fSdrahn file_ptr reloc_base;
761d2201f2fSdrahn file_ptr lineno_base;
762d2201f2fSdrahn file_ptr sym_base;
763d2201f2fSdrahn unsigned long reloc_size = 0;
764d2201f2fSdrahn unsigned long lnno_size = 0;
765d2201f2fSdrahn bfd_boolean long_section_names;
766d2201f2fSdrahn asection *text_sec = ((void *) 0);
767d2201f2fSdrahn asection *data_sec = ((void *) 0);
768d2201f2fSdrahn asection *bss_sec = ((void *) 0);
769d2201f2fSdrahn struct internal_filehdr internal_f;
770d2201f2fSdrahn struct internal_aouthdr internal_a;
771d2201f2fSdrahn
772d2201f2fSdrahn bfd_set_error (bfd_error_system_call);
773d2201f2fSdrahn
774d2201f2fSdrahn if (! abfd->output_has_begun)
775d2201f2fSdrahn {
776d2201f2fSdrahn if (! bfd_coff_compute_section_file_positions (abfd))
777d2201f2fSdrahn return FALSE;
778d2201f2fSdrahn }
779d2201f2fSdrahn
780d2201f2fSdrahn /* Work out the size of the reloc and linno areas. */
781d2201f2fSdrahn reloc_base = obj_relocbase (abfd);
782d2201f2fSdrahn
783d2201f2fSdrahn for (current = abfd->sections; current != NULL; current = current->next)
784d2201f2fSdrahn reloc_size += current->reloc_count * bfd_coff_relsz (abfd);
785d2201f2fSdrahn
786d2201f2fSdrahn lineno_base = reloc_base + reloc_size;
787d2201f2fSdrahn
788d2201f2fSdrahn /* Make a pass through the symbol table to count line number entries and
789d2201f2fSdrahn put them into the correct asections. */
790d2201f2fSdrahn lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd);
791d2201f2fSdrahn
792d2201f2fSdrahn sym_base = lineno_base + lnno_size;
793d2201f2fSdrahn
794d2201f2fSdrahn /* Indicate in each section->line_filepos its actual file address. */
795d2201f2fSdrahn for (current = abfd->sections; current != NULL; current = current->next)
796d2201f2fSdrahn {
797d2201f2fSdrahn if (current->lineno_count)
798d2201f2fSdrahn {
799d2201f2fSdrahn current->line_filepos = lineno_base;
800d2201f2fSdrahn current->moving_line_filepos = lineno_base;
801d2201f2fSdrahn lineno_base += current->lineno_count * bfd_coff_linesz (abfd);
802d2201f2fSdrahn }
803d2201f2fSdrahn else
804d2201f2fSdrahn {
805d2201f2fSdrahn current->line_filepos = 0;
806d2201f2fSdrahn }
807d2201f2fSdrahn
808d2201f2fSdrahn if (current->reloc_count)
809d2201f2fSdrahn {
810d2201f2fSdrahn current->rel_filepos = reloc_base;
811d2201f2fSdrahn reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
812d2201f2fSdrahn }
813d2201f2fSdrahn else
814d2201f2fSdrahn {
815d2201f2fSdrahn current->rel_filepos = 0;
816d2201f2fSdrahn }
817d2201f2fSdrahn }
818d2201f2fSdrahn
819d2201f2fSdrahn if ((abfd->flags & EXEC_P) != 0)
820d2201f2fSdrahn {
821d2201f2fSdrahn scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
822d2201f2fSdrahn internal_f.f_opthdr = bfd_coff_aoutsz (abfd);
823d2201f2fSdrahn }
824d2201f2fSdrahn else
825d2201f2fSdrahn {
826d2201f2fSdrahn scn_base = bfd_coff_filhsz (abfd);
827d2201f2fSdrahn internal_f.f_opthdr = 0;
828d2201f2fSdrahn }
829d2201f2fSdrahn
830d2201f2fSdrahn internal_f.f_nscns = 0;
831d2201f2fSdrahn
832d2201f2fSdrahn if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
833d2201f2fSdrahn return FALSE;
834d2201f2fSdrahn
835d2201f2fSdrahn long_section_names = FALSE;
836d2201f2fSdrahn for (current = abfd->sections; current != NULL; current = current->next)
837d2201f2fSdrahn {
838d2201f2fSdrahn struct internal_scnhdr section;
839d2201f2fSdrahn struct external_scnhdr buff;
840d2201f2fSdrahn bfd_size_type amount;
841d2201f2fSdrahn
842d2201f2fSdrahn internal_f.f_nscns++;
843d2201f2fSdrahn
844d2201f2fSdrahn strncpy (section.s_name, current->name, SCNNMLEN);
845d2201f2fSdrahn
846d2201f2fSdrahn section.s_vaddr = current->vma;
847d2201f2fSdrahn section.s_paddr = current->lma;
848d2201f2fSdrahn section.s_size = current->_raw_size;
849d2201f2fSdrahn
850d2201f2fSdrahn /* If this section has no size or is unloadable then the scnptr
851d2201f2fSdrahn will be 0 too. */
852d2201f2fSdrahn if (current->_raw_size == 0
853d2201f2fSdrahn || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
854d2201f2fSdrahn {
855d2201f2fSdrahn section.s_scnptr = 0;
856d2201f2fSdrahn }
857d2201f2fSdrahn else
858d2201f2fSdrahn {
859d2201f2fSdrahn section.s_scnptr = current->filepos;
860d2201f2fSdrahn }
861d2201f2fSdrahn
862d2201f2fSdrahn section.s_relptr = current->rel_filepos;
863d2201f2fSdrahn section.s_lnnoptr = current->line_filepos;
864d2201f2fSdrahn section.s_nreloc = current->reloc_count;
865d2201f2fSdrahn
866d2201f2fSdrahn section.s_nlnno = current->lineno_count;
867d2201f2fSdrahn if (current->reloc_count != 0)
868d2201f2fSdrahn hasrelocs = TRUE;
869d2201f2fSdrahn if (current->lineno_count != 0)
870d2201f2fSdrahn haslinno = TRUE;
871d2201f2fSdrahn
872d2201f2fSdrahn section.s_flags = sec_to_styp_flags (current->name, current->flags);
873d2201f2fSdrahn
874d2201f2fSdrahn if (!strcmp (current->name, _TEXT))
875d2201f2fSdrahn {
876d2201f2fSdrahn text_sec = current;
877d2201f2fSdrahn }
878d2201f2fSdrahn else if (!strcmp (current->name, _DATA))
879d2201f2fSdrahn {
880d2201f2fSdrahn data_sec = current;
881d2201f2fSdrahn }
882d2201f2fSdrahn else if (!strcmp (current->name, _BSS))
883d2201f2fSdrahn {
884d2201f2fSdrahn bss_sec = current;
885d2201f2fSdrahn }
886d2201f2fSdrahn
887d2201f2fSdrahn amount = bfd_coff_scnhsz (abfd);
888d2201f2fSdrahn if (bfd_coff_swap_scnhdr_out (abfd, §ion, &buff) == 0
889d2201f2fSdrahn || bfd_bwrite ((PTR) (&buff), amount, abfd) != amount)
890d2201f2fSdrahn return FALSE;
891d2201f2fSdrahn }
892d2201f2fSdrahn
893d2201f2fSdrahn internal_f.f_timdat = 0;
894d2201f2fSdrahn
895d2201f2fSdrahn internal_f.f_flags = 0;
896d2201f2fSdrahn
897d2201f2fSdrahn if (!hasrelocs)
898d2201f2fSdrahn internal_f.f_flags |= F_RELFLG;
899d2201f2fSdrahn if (!haslinno)
900d2201f2fSdrahn internal_f.f_flags |= F_LNNO;
901d2201f2fSdrahn if (abfd->flags & EXEC_P)
902d2201f2fSdrahn internal_f.f_flags |= F_EXEC;
903d2201f2fSdrahn
904d2201f2fSdrahn /* FIXME: this is wrong for PPC_PE! */
905d2201f2fSdrahn if (bfd_little_endian (abfd))
906d2201f2fSdrahn internal_f.f_flags |= F_AR32WR;
907d2201f2fSdrahn else
908d2201f2fSdrahn internal_f.f_flags |= F_AR32W;
909d2201f2fSdrahn
910d2201f2fSdrahn if ((abfd->flags & DYNAMIC) != 0)
911d2201f2fSdrahn internal_f.f_flags |= F_SHROBJ;
912d2201f2fSdrahn if (bfd_get_section_by_name (abfd, _LOADER) != NULL)
913d2201f2fSdrahn internal_f.f_flags |= F_DYNLOAD;
914d2201f2fSdrahn
915d2201f2fSdrahn memset (&internal_a, 0, sizeof internal_a);
916d2201f2fSdrahn
917d2201f2fSdrahn internal_f.f_magic = bfd_xcoff_magic_number (abfd);
918d2201f2fSdrahn internal_a.magic = (abfd->flags & D_PAGED
919d2201f2fSdrahn ? RS6K_AOUTHDR_ZMAGIC
920d2201f2fSdrahn : (abfd->flags & WP_TEXT
921d2201f2fSdrahn ? RS6K_AOUTHDR_NMAGIC
922d2201f2fSdrahn : RS6K_AOUTHDR_OMAGIC));
923d2201f2fSdrahn
924d2201f2fSdrahn /* FIXME: Does anybody ever set this to another value? */
925d2201f2fSdrahn internal_a.vstamp = 0;
926d2201f2fSdrahn
927d2201f2fSdrahn /* Now should write relocs, strings, syms. */
928d2201f2fSdrahn obj_sym_filepos (abfd) = sym_base;
929d2201f2fSdrahn
930d2201f2fSdrahn internal_f.f_symptr = 0;
931d2201f2fSdrahn internal_f.f_nsyms = 0;
932d2201f2fSdrahn
933d2201f2fSdrahn /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
934d2201f2fSdrahn backend linker, and obj_raw_syment_count is not valid until after
935d2201f2fSdrahn coff_write_symbols is called. */
936d2201f2fSdrahn if (bfd_get_symcount (abfd) != 0)
937d2201f2fSdrahn {
938d2201f2fSdrahn int firstundef;
939d2201f2fSdrahn
940d2201f2fSdrahn if (!coff_renumber_symbols (abfd, &firstundef))
941d2201f2fSdrahn return FALSE;
942d2201f2fSdrahn coff_mangle_symbols (abfd);
943d2201f2fSdrahn if (! coff_write_symbols (abfd))
944d2201f2fSdrahn return FALSE;
945d2201f2fSdrahn if (! coff_write_linenumbers (abfd))
946d2201f2fSdrahn return FALSE;
947d2201f2fSdrahn if (! coff_write_relocs (abfd, firstundef))
948d2201f2fSdrahn return FALSE;
949d2201f2fSdrahn
950d2201f2fSdrahn internal_f.f_symptr = sym_base;
951d2201f2fSdrahn internal_f.f_nsyms = bfd_get_symcount (abfd);
952d2201f2fSdrahn }
953d2201f2fSdrahn else if (obj_raw_syment_count (abfd) != 0)
954d2201f2fSdrahn {
955d2201f2fSdrahn internal_f.f_symptr = sym_base;
956d2201f2fSdrahn
957d2201f2fSdrahn /* AIX appears to require that F_RELFLG not be set if there are
958d2201f2fSdrahn local symbols but no relocations. */
959d2201f2fSdrahn internal_f.f_flags &=~ F_RELFLG;
960d2201f2fSdrahn }
961d2201f2fSdrahn else
962d2201f2fSdrahn {
963d2201f2fSdrahn internal_f.f_flags |= F_LSYMS;
964d2201f2fSdrahn }
965d2201f2fSdrahn
966d2201f2fSdrahn if (text_sec)
967d2201f2fSdrahn {
968d2201f2fSdrahn internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
969d2201f2fSdrahn internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
970d2201f2fSdrahn }
971d2201f2fSdrahn
972d2201f2fSdrahn if (data_sec)
973d2201f2fSdrahn {
974d2201f2fSdrahn internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
975d2201f2fSdrahn internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
976d2201f2fSdrahn }
977d2201f2fSdrahn
978d2201f2fSdrahn if (bss_sec)
979d2201f2fSdrahn {
980d2201f2fSdrahn internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
981d2201f2fSdrahn if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
982d2201f2fSdrahn internal_a.data_start = bss_sec->vma;
983d2201f2fSdrahn }
984d2201f2fSdrahn
985d2201f2fSdrahn internal_a.entry = bfd_get_start_address (abfd);
986d2201f2fSdrahn internal_f.f_nsyms = obj_raw_syment_count (abfd);
987d2201f2fSdrahn
988d2201f2fSdrahn if (xcoff_data (abfd)->full_aouthdr)
989d2201f2fSdrahn {
990d2201f2fSdrahn bfd_vma toc;
991d2201f2fSdrahn asection *loader_sec;
992d2201f2fSdrahn
993d2201f2fSdrahn internal_a.vstamp = 1;
994d2201f2fSdrahn
995d2201f2fSdrahn internal_a.o_snentry = xcoff_data (abfd)->snentry;
996d2201f2fSdrahn if (internal_a.o_snentry == 0)
997d2201f2fSdrahn internal_a.entry = (bfd_vma) -1;
998d2201f2fSdrahn
999d2201f2fSdrahn if (text_sec != NULL)
1000d2201f2fSdrahn {
1001d2201f2fSdrahn internal_a.o_sntext = text_sec->target_index;
1002d2201f2fSdrahn internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec);
1003d2201f2fSdrahn }
1004d2201f2fSdrahn else
1005d2201f2fSdrahn {
1006d2201f2fSdrahn internal_a.o_sntext = 0;
1007d2201f2fSdrahn internal_a.o_algntext = 0;
1008d2201f2fSdrahn }
1009d2201f2fSdrahn
1010d2201f2fSdrahn if (data_sec != NULL)
1011d2201f2fSdrahn {
1012d2201f2fSdrahn internal_a.o_sndata = data_sec->target_index;
1013d2201f2fSdrahn internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
1014d2201f2fSdrahn }
1015d2201f2fSdrahn else
1016d2201f2fSdrahn {
1017d2201f2fSdrahn internal_a.o_sndata = 0;
1018d2201f2fSdrahn internal_a.o_algndata = 0;
1019d2201f2fSdrahn }
1020d2201f2fSdrahn
1021d2201f2fSdrahn loader_sec = bfd_get_section_by_name (abfd, ".loader");
1022d2201f2fSdrahn if (loader_sec != NULL)
1023d2201f2fSdrahn internal_a.o_snloader = loader_sec->target_index;
1024d2201f2fSdrahn else
1025d2201f2fSdrahn internal_a.o_snloader = 0;
1026d2201f2fSdrahn if (bss_sec != NULL)
1027d2201f2fSdrahn internal_a.o_snbss = bss_sec->target_index;
1028d2201f2fSdrahn else
1029d2201f2fSdrahn internal_a.o_snbss = 0;
1030d2201f2fSdrahn
1031d2201f2fSdrahn toc = xcoff_data (abfd)->toc;
1032d2201f2fSdrahn internal_a.o_toc = toc;
1033d2201f2fSdrahn internal_a.o_sntoc = xcoff_data (abfd)->sntoc;
1034d2201f2fSdrahn
1035d2201f2fSdrahn internal_a.o_modtype = xcoff_data (abfd)->modtype;
1036d2201f2fSdrahn if (xcoff_data (abfd)->cputype != -1)
1037d2201f2fSdrahn internal_a.o_cputype = xcoff_data (abfd)->cputype;
1038d2201f2fSdrahn else
1039d2201f2fSdrahn {
1040d2201f2fSdrahn switch (bfd_get_arch (abfd))
1041d2201f2fSdrahn {
1042d2201f2fSdrahn case bfd_arch_rs6000:
1043d2201f2fSdrahn internal_a.o_cputype = 4;
1044d2201f2fSdrahn break;
1045d2201f2fSdrahn case bfd_arch_powerpc:
1046d2201f2fSdrahn if (bfd_get_mach (abfd) == bfd_mach_ppc)
1047d2201f2fSdrahn internal_a.o_cputype = 3;
1048d2201f2fSdrahn else
1049d2201f2fSdrahn internal_a.o_cputype = 1;
1050d2201f2fSdrahn break;
1051d2201f2fSdrahn default:
1052d2201f2fSdrahn abort ();
1053d2201f2fSdrahn }
1054d2201f2fSdrahn }
1055d2201f2fSdrahn internal_a.o_maxstack = xcoff_data (abfd)->maxstack;
1056d2201f2fSdrahn internal_a.o_maxdata = xcoff_data (abfd)->maxdata;
1057d2201f2fSdrahn }
1058d2201f2fSdrahn
1059d2201f2fSdrahn if (bfd_seek (abfd, (file_ptr) 0, 0) != 0)
1060d2201f2fSdrahn return FALSE;
1061d2201f2fSdrahn
1062d2201f2fSdrahn {
1063d2201f2fSdrahn char * buff;
1064d2201f2fSdrahn bfd_size_type amount = bfd_coff_filhsz (abfd);
1065d2201f2fSdrahn
1066d2201f2fSdrahn buff = bfd_malloc (amount);
1067d2201f2fSdrahn if (buff == NULL)
1068d2201f2fSdrahn return FALSE;
1069d2201f2fSdrahn
1070d2201f2fSdrahn bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, (PTR) buff);
1071d2201f2fSdrahn amount = bfd_bwrite ((PTR) buff, amount, abfd);
1072d2201f2fSdrahn
1073d2201f2fSdrahn free (buff);
1074d2201f2fSdrahn
1075d2201f2fSdrahn if (amount != bfd_coff_filhsz (abfd))
1076d2201f2fSdrahn return FALSE;
1077d2201f2fSdrahn }
1078d2201f2fSdrahn
1079d2201f2fSdrahn if (abfd->flags & EXEC_P)
1080d2201f2fSdrahn {
1081d2201f2fSdrahn char * buff;
1082d2201f2fSdrahn bfd_size_type amount = bfd_coff_aoutsz (abfd);
1083d2201f2fSdrahn
1084d2201f2fSdrahn buff = bfd_malloc (amount);
1085d2201f2fSdrahn if (buff == NULL)
1086d2201f2fSdrahn return FALSE;
1087d2201f2fSdrahn
1088d2201f2fSdrahn bfd_coff_swap_aouthdr_out (abfd, (PTR) &internal_a, (PTR) buff);
1089d2201f2fSdrahn amount = bfd_bwrite ((PTR) buff, amount, abfd);
1090d2201f2fSdrahn
1091d2201f2fSdrahn free (buff);
1092d2201f2fSdrahn
1093d2201f2fSdrahn if (amount != bfd_coff_aoutsz (abfd))
1094d2201f2fSdrahn return FALSE;
1095d2201f2fSdrahn }
1096d2201f2fSdrahn
1097d2201f2fSdrahn return TRUE;
1098d2201f2fSdrahn }
1099d2201f2fSdrahn
1100d2201f2fSdrahn static bfd_boolean
xcoff64_reloc_type_br(input_bfd,input_section,output_bfd,rel,sym,howto,val,addend,relocation,contents)1101d2201f2fSdrahn xcoff64_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto,
1102d2201f2fSdrahn val, addend, relocation, contents)
1103d2201f2fSdrahn bfd *input_bfd;
1104d2201f2fSdrahn asection *input_section;
1105d2201f2fSdrahn bfd *output_bfd ATTRIBUTE_UNUSED;
1106d2201f2fSdrahn struct internal_reloc *rel;
1107d2201f2fSdrahn struct internal_syment *sym ATTRIBUTE_UNUSED;
1108d2201f2fSdrahn struct reloc_howto_struct *howto;
1109d2201f2fSdrahn bfd_vma val;
1110d2201f2fSdrahn bfd_vma addend;
1111d2201f2fSdrahn bfd_vma *relocation;
1112d2201f2fSdrahn bfd_byte *contents;
1113d2201f2fSdrahn {
1114d2201f2fSdrahn struct xcoff_link_hash_entry *h;
1115d2201f2fSdrahn
1116d2201f2fSdrahn if (0 > rel->r_symndx)
1117d2201f2fSdrahn return FALSE;
1118d2201f2fSdrahn
1119d2201f2fSdrahn h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];
1120d2201f2fSdrahn
1121d2201f2fSdrahn /* If we see an R_BR or R_RBR reloc which is jumping to global
1122d2201f2fSdrahn linkage code, and it is followed by an appropriate cror nop
1123d2201f2fSdrahn instruction, we replace the cror with ld r2,40(r1). This
1124d2201f2fSdrahn restores the TOC after the glink code. Contrariwise, if the
1125d2201f2fSdrahn call is followed by a ld r2,40(r1), but the call is not
1126d2201f2fSdrahn going to global linkage code, we can replace the load with a
1127d2201f2fSdrahn cror. */
1128d2201f2fSdrahn if (NULL != h
1129d2201f2fSdrahn && bfd_link_hash_defined == h->root.type
1130d2201f2fSdrahn && (rel->r_vaddr - input_section->vma + 8
1131d2201f2fSdrahn <= input_section->_cooked_size))
1132d2201f2fSdrahn {
1133d2201f2fSdrahn bfd_byte *pnext;
1134d2201f2fSdrahn unsigned long next;
1135d2201f2fSdrahn
1136d2201f2fSdrahn pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
1137d2201f2fSdrahn next = bfd_get_32 (input_bfd, pnext);
1138d2201f2fSdrahn
1139d2201f2fSdrahn /* The _ptrgl function is magic. It is used by the AIX compiler to call
1140d2201f2fSdrahn a function through a pointer. */
1141d2201f2fSdrahn if (h->smclas == XMC_GL || strcmp (h->root.root.string, "._ptrgl") == 0)
1142d2201f2fSdrahn {
1143d2201f2fSdrahn if (next == 0x4def7b82 /* cror 15,15,15 */
1144d2201f2fSdrahn || next == 0x4ffffb82 /* cror 31,31,31 */
1145d2201f2fSdrahn || next == 0x60000000) /* ori r0,r0,0 */
1146d2201f2fSdrahn bfd_put_32 (input_bfd, 0xe8410028, pnext); /* ld r2,40(r1) */
1147d2201f2fSdrahn }
1148d2201f2fSdrahn else
1149d2201f2fSdrahn {
1150d2201f2fSdrahn if (next == 0xe8410028) /* ld r2,40(r1) */
1151d2201f2fSdrahn bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */
1152d2201f2fSdrahn }
1153d2201f2fSdrahn }
1154d2201f2fSdrahn else if (NULL != h && bfd_link_hash_undefined == h->root.type)
1155d2201f2fSdrahn {
1156d2201f2fSdrahn /* Normally, this relocation is against a defined symbol. In the
1157d2201f2fSdrahn case where this is a partial link and the output section offset
1158d2201f2fSdrahn is greater than 2^25, the linker will return an invalid error
1159d2201f2fSdrahn message that the relocation has been truncated. Yes it has been
1160d2201f2fSdrahn truncated but no it not important. For this case, disable the
1161d2201f2fSdrahn overflow checking. */
1162d2201f2fSdrahn howto->complain_on_overflow = complain_overflow_dont;
1163d2201f2fSdrahn }
1164d2201f2fSdrahn
1165d2201f2fSdrahn howto->pc_relative = TRUE;
1166d2201f2fSdrahn howto->src_mask &= ~3;
1167d2201f2fSdrahn howto->dst_mask = howto->src_mask;
1168d2201f2fSdrahn
1169d2201f2fSdrahn /* A PC relative reloc includes the section address. */
1170d2201f2fSdrahn addend += input_section->vma;
1171d2201f2fSdrahn
1172d2201f2fSdrahn *relocation = val + addend;
1173d2201f2fSdrahn *relocation -= (input_section->output_section->vma
1174d2201f2fSdrahn + input_section->output_offset);
1175d2201f2fSdrahn return TRUE;
1176d2201f2fSdrahn }
1177d2201f2fSdrahn
1178d2201f2fSdrahn /* This is the relocation function for the PowerPC64.
1179d2201f2fSdrahn See xcoff_ppc_relocation_section for more information. */
1180d2201f2fSdrahn
1181d2201f2fSdrahn bfd_boolean
xcoff64_ppc_relocate_section(output_bfd,info,input_bfd,input_section,contents,relocs,syms,sections)1182d2201f2fSdrahn xcoff64_ppc_relocate_section (output_bfd, info, input_bfd,
1183d2201f2fSdrahn input_section, contents, relocs, syms,
1184d2201f2fSdrahn sections)
1185d2201f2fSdrahn bfd *output_bfd;
1186d2201f2fSdrahn struct bfd_link_info *info;
1187d2201f2fSdrahn bfd *input_bfd;
1188d2201f2fSdrahn asection *input_section;
1189d2201f2fSdrahn bfd_byte *contents;
1190d2201f2fSdrahn struct internal_reloc *relocs;
1191d2201f2fSdrahn struct internal_syment *syms;
1192d2201f2fSdrahn asection **sections;
1193d2201f2fSdrahn {
1194d2201f2fSdrahn struct internal_reloc *rel;
1195d2201f2fSdrahn struct internal_reloc *relend;
1196d2201f2fSdrahn
1197d2201f2fSdrahn rel = relocs;
1198d2201f2fSdrahn relend = rel + input_section->reloc_count;
1199d2201f2fSdrahn for (; rel < relend; rel++)
1200d2201f2fSdrahn {
1201d2201f2fSdrahn long symndx;
1202d2201f2fSdrahn struct xcoff_link_hash_entry *h;
1203d2201f2fSdrahn struct internal_syment *sym;
1204d2201f2fSdrahn bfd_vma addend;
1205d2201f2fSdrahn bfd_vma val;
1206d2201f2fSdrahn struct reloc_howto_struct howto;
1207d2201f2fSdrahn bfd_vma relocation;
1208d2201f2fSdrahn bfd_vma value_to_relocate;
1209d2201f2fSdrahn bfd_vma address;
1210d2201f2fSdrahn bfd_byte *location;
1211d2201f2fSdrahn
1212d2201f2fSdrahn /* Relocation type R_REF is a special relocation type which is
1213d2201f2fSdrahn merely used to prevent garbage collection from occurring for
1214d2201f2fSdrahn the csect including the symbol which it references. */
1215d2201f2fSdrahn if (rel->r_type == R_REF)
1216d2201f2fSdrahn continue;
1217d2201f2fSdrahn
1218d2201f2fSdrahn /* howto */
1219d2201f2fSdrahn howto.type = rel->r_type;
1220d2201f2fSdrahn howto.rightshift = 0;
1221d2201f2fSdrahn howto.bitsize = (rel->r_size & 0x3f) + 1;
1222d2201f2fSdrahn howto.size = howto.bitsize > 16 ? (howto.bitsize > 32 ? 4 : 2) : 1;
1223d2201f2fSdrahn howto.pc_relative = FALSE;
1224d2201f2fSdrahn howto.bitpos = 0;
1225d2201f2fSdrahn howto.complain_on_overflow = (rel->r_size & 0x80
1226d2201f2fSdrahn ? complain_overflow_signed
1227d2201f2fSdrahn : complain_overflow_bitfield);
1228d2201f2fSdrahn howto.special_function = NULL;
1229d2201f2fSdrahn howto.name = "internal";
1230d2201f2fSdrahn howto.partial_inplace = TRUE;
1231d2201f2fSdrahn howto.src_mask = howto.dst_mask = N_ONES (howto.bitsize);
1232d2201f2fSdrahn howto.pcrel_offset = FALSE;
1233d2201f2fSdrahn
1234d2201f2fSdrahn /* symbol */
1235d2201f2fSdrahn val = 0;
1236d2201f2fSdrahn addend = 0;
1237d2201f2fSdrahn h = NULL;
1238d2201f2fSdrahn sym = NULL;
1239d2201f2fSdrahn symndx = rel->r_symndx;
1240d2201f2fSdrahn
1241d2201f2fSdrahn if (-1 != symndx)
1242d2201f2fSdrahn {
1243d2201f2fSdrahn asection *sec;
1244d2201f2fSdrahn
1245d2201f2fSdrahn h = obj_xcoff_sym_hashes (input_bfd)[symndx];
1246d2201f2fSdrahn sym = syms + symndx;
1247d2201f2fSdrahn addend = - sym->n_value;
1248d2201f2fSdrahn
1249d2201f2fSdrahn if (NULL == h)
1250d2201f2fSdrahn {
1251d2201f2fSdrahn sec = sections[symndx];
1252d2201f2fSdrahn /* Hack to make sure we use the right TOC anchor value
1253d2201f2fSdrahn if this reloc is against the TOC anchor. */
1254d2201f2fSdrahn if (sec->name[3] == '0'
1255d2201f2fSdrahn && strcmp (sec->name, ".tc0") == 0)
1256d2201f2fSdrahn val = xcoff_data (output_bfd)->toc;
1257d2201f2fSdrahn else
1258d2201f2fSdrahn val = (sec->output_section->vma
1259d2201f2fSdrahn + sec->output_offset
1260d2201f2fSdrahn + sym->n_value
1261d2201f2fSdrahn - sec->vma);
1262d2201f2fSdrahn }
1263d2201f2fSdrahn else
1264d2201f2fSdrahn {
1265d2201f2fSdrahn if (h->root.type == bfd_link_hash_defined
1266d2201f2fSdrahn || h->root.type == bfd_link_hash_defweak)
1267d2201f2fSdrahn {
1268d2201f2fSdrahn sec = h->root.u.def.section;
1269d2201f2fSdrahn val = (h->root.u.def.value
1270d2201f2fSdrahn + sec->output_section->vma
1271d2201f2fSdrahn + sec->output_offset);
1272d2201f2fSdrahn }
1273d2201f2fSdrahn else if (h->root.type == bfd_link_hash_common)
1274d2201f2fSdrahn {
1275d2201f2fSdrahn sec = h->root.u.c.p->section;
1276d2201f2fSdrahn val = (sec->output_section->vma
1277d2201f2fSdrahn + sec->output_offset);
1278d2201f2fSdrahn }
1279d2201f2fSdrahn else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT)))
1280*cf2f2c56Smiod && ! info->relocatable)
1281d2201f2fSdrahn {
1282d2201f2fSdrahn if (! ((*info->callbacks->undefined_symbol)
1283d2201f2fSdrahn (info, h->root.root.string, input_bfd, input_section,
1284d2201f2fSdrahn rel->r_vaddr - input_section->vma, TRUE)))
1285d2201f2fSdrahn return FALSE;
1286d2201f2fSdrahn
1287d2201f2fSdrahn /* Don't try to process the reloc. It can't help, and
1288d2201f2fSdrahn it may generate another error. */
1289d2201f2fSdrahn continue;
1290d2201f2fSdrahn }
1291d2201f2fSdrahn }
1292d2201f2fSdrahn }
1293d2201f2fSdrahn
1294d2201f2fSdrahn if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION
1295d2201f2fSdrahn || !((*xcoff64_calculate_relocation[rel->r_type])
1296d2201f2fSdrahn (input_bfd, input_section, output_bfd, rel, sym, &howto, val,
1297d2201f2fSdrahn addend, &relocation, contents)))
1298d2201f2fSdrahn return FALSE;
1299d2201f2fSdrahn
1300d2201f2fSdrahn /* address */
1301d2201f2fSdrahn address = rel->r_vaddr - input_section->vma;
1302d2201f2fSdrahn location = contents + address;
1303d2201f2fSdrahn
1304d2201f2fSdrahn if (address > input_section->_raw_size)
1305d2201f2fSdrahn abort ();
1306d2201f2fSdrahn
1307d2201f2fSdrahn /* Get the value we are going to relocate. */
1308d2201f2fSdrahn if (1 == howto.size)
1309d2201f2fSdrahn value_to_relocate = bfd_get_16 (input_bfd, location);
1310d2201f2fSdrahn else if (2 == howto.size)
1311d2201f2fSdrahn value_to_relocate = bfd_get_32 (input_bfd, location);
1312d2201f2fSdrahn else
1313d2201f2fSdrahn value_to_relocate = bfd_get_64 (input_bfd, location);
1314d2201f2fSdrahn
1315d2201f2fSdrahn /* overflow.
1316d2201f2fSdrahn
1317d2201f2fSdrahn FIXME: We may drop bits during the addition
1318d2201f2fSdrahn which we don't check for. We must either check at every single
1319d2201f2fSdrahn operation, which would be tedious, or we must do the computations
1320d2201f2fSdrahn in a type larger than bfd_vma, which would be inefficient. */
1321d2201f2fSdrahn
1322d2201f2fSdrahn if ((unsigned int) howto.complain_on_overflow
1323d2201f2fSdrahn >= XCOFF_MAX_COMPLAIN_OVERFLOW)
1324d2201f2fSdrahn abort ();
1325d2201f2fSdrahn
1326d2201f2fSdrahn if (((*xcoff_complain_overflow[howto.complain_on_overflow])
1327d2201f2fSdrahn (input_bfd, value_to_relocate, relocation, &howto)))
1328d2201f2fSdrahn {
1329d2201f2fSdrahn const char *name;
1330d2201f2fSdrahn char buf[SYMNMLEN + 1];
1331d2201f2fSdrahn char reloc_type_name[10];
1332d2201f2fSdrahn
1333d2201f2fSdrahn if (symndx == -1)
1334d2201f2fSdrahn {
1335d2201f2fSdrahn name = "*ABS*";
1336d2201f2fSdrahn }
1337d2201f2fSdrahn else if (h != NULL)
1338d2201f2fSdrahn {
1339d2201f2fSdrahn name = h->root.root.string;
1340d2201f2fSdrahn }
1341d2201f2fSdrahn else
1342d2201f2fSdrahn {
1343d2201f2fSdrahn name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
1344d2201f2fSdrahn if (name == NULL)
1345d2201f2fSdrahn name = "UNKNOWN";
1346d2201f2fSdrahn }
1347d2201f2fSdrahn sprintf (reloc_type_name, "0x%02x", rel->r_type);
1348d2201f2fSdrahn
1349d2201f2fSdrahn if (! ((*info->callbacks->reloc_overflow)
1350d2201f2fSdrahn (info, name, reloc_type_name, (bfd_vma) 0, input_bfd,
1351d2201f2fSdrahn input_section, rel->r_vaddr - input_section->vma)))
1352d2201f2fSdrahn return FALSE;
1353d2201f2fSdrahn }
1354d2201f2fSdrahn
1355d2201f2fSdrahn /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE. */
1356d2201f2fSdrahn value_to_relocate = ((value_to_relocate & ~howto.dst_mask)
1357d2201f2fSdrahn | (((value_to_relocate & howto.src_mask)
1358d2201f2fSdrahn + relocation) & howto.dst_mask));
1359d2201f2fSdrahn
1360d2201f2fSdrahn /* Put the value back in the object file. */
1361d2201f2fSdrahn if (1 == howto.size)
1362d2201f2fSdrahn bfd_put_16 (input_bfd, value_to_relocate, location);
1363d2201f2fSdrahn else if (2 == howto.size)
1364d2201f2fSdrahn bfd_put_32 (input_bfd, value_to_relocate, location);
1365d2201f2fSdrahn else
1366d2201f2fSdrahn bfd_put_64 (input_bfd, value_to_relocate, location);
1367d2201f2fSdrahn
1368d2201f2fSdrahn }
1369d2201f2fSdrahn return TRUE;
1370d2201f2fSdrahn }
1371d2201f2fSdrahn
1372d2201f2fSdrahn
1373d2201f2fSdrahn /* The XCOFF reloc table. Actually, XCOFF relocations specify the
1374d2201f2fSdrahn bitsize and whether they are signed or not, along with a
1375d2201f2fSdrahn conventional type. This table is for the types, which are used for
1376d2201f2fSdrahn different algorithms for putting in the reloc. Many of these
1377d2201f2fSdrahn relocs need special_function entries, which I have not written. */
1378d2201f2fSdrahn
1379d2201f2fSdrahn reloc_howto_type xcoff64_howto_table[] =
1380d2201f2fSdrahn {
1381d2201f2fSdrahn /* Standard 64 bit relocation. */
1382d2201f2fSdrahn HOWTO (R_POS, /* type */
1383d2201f2fSdrahn 0, /* rightshift */
1384d2201f2fSdrahn 4, /* size (0 = byte, 1 = short, 2 = long) */
1385d2201f2fSdrahn 64, /* bitsize */
1386d2201f2fSdrahn FALSE, /* pc_relative */
1387d2201f2fSdrahn 0, /* bitpos */
1388d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1389d2201f2fSdrahn 0, /* special_function */
1390d2201f2fSdrahn "R_POS_64", /* name */
1391d2201f2fSdrahn TRUE, /* partial_inplace */
1392d2201f2fSdrahn MINUS_ONE, /* src_mask */
1393d2201f2fSdrahn MINUS_ONE, /* dst_mask */
1394d2201f2fSdrahn FALSE), /* pcrel_offset */
1395d2201f2fSdrahn
1396d2201f2fSdrahn /* 64 bit relocation, but store negative value. */
1397d2201f2fSdrahn HOWTO (R_NEG, /* type */
1398d2201f2fSdrahn 0, /* rightshift */
1399d2201f2fSdrahn -4, /* size (0 = byte, 1 = short, 2 = long) */
1400d2201f2fSdrahn 64, /* bitsize */
1401d2201f2fSdrahn FALSE, /* pc_relative */
1402d2201f2fSdrahn 0, /* bitpos */
1403d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1404d2201f2fSdrahn 0, /* special_function */
1405d2201f2fSdrahn "R_NEG", /* name */
1406d2201f2fSdrahn TRUE, /* partial_inplace */
1407d2201f2fSdrahn MINUS_ONE, /* src_mask */
1408d2201f2fSdrahn MINUS_ONE, /* dst_mask */
1409d2201f2fSdrahn FALSE), /* pcrel_offset */
1410d2201f2fSdrahn
1411d2201f2fSdrahn /* 32 bit PC relative relocation. */
1412d2201f2fSdrahn HOWTO (R_REL, /* type */
1413d2201f2fSdrahn 0, /* rightshift */
1414d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1415d2201f2fSdrahn 32, /* bitsize */
1416d2201f2fSdrahn TRUE, /* pc_relative */
1417d2201f2fSdrahn 0, /* bitpos */
1418d2201f2fSdrahn complain_overflow_signed, /* complain_on_overflow */
1419d2201f2fSdrahn 0, /* special_function */
1420d2201f2fSdrahn "R_REL", /* name */
1421d2201f2fSdrahn TRUE, /* partial_inplace */
1422d2201f2fSdrahn 0xffffffff, /* src_mask */
1423d2201f2fSdrahn 0xffffffff, /* dst_mask */
1424d2201f2fSdrahn FALSE), /* pcrel_offset */
1425d2201f2fSdrahn
1426d2201f2fSdrahn /* 16 bit TOC relative relocation. */
1427d2201f2fSdrahn HOWTO (R_TOC, /* type */
1428d2201f2fSdrahn 0, /* rightshift */
1429d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1430d2201f2fSdrahn 16, /* bitsize */
1431d2201f2fSdrahn FALSE, /* pc_relative */
1432d2201f2fSdrahn 0, /* bitpos */
1433d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1434d2201f2fSdrahn 0, /* special_function */
1435d2201f2fSdrahn "R_TOC", /* name */
1436d2201f2fSdrahn TRUE, /* partial_inplace */
1437d2201f2fSdrahn 0xffff, /* src_mask */
1438d2201f2fSdrahn 0xffff, /* dst_mask */
1439d2201f2fSdrahn FALSE), /* pcrel_offset */
1440d2201f2fSdrahn
1441d2201f2fSdrahn /* I don't really know what this is. */
1442d2201f2fSdrahn HOWTO (R_RTB, /* type */
1443d2201f2fSdrahn 1, /* rightshift */
1444d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1445d2201f2fSdrahn 32, /* bitsize */
1446d2201f2fSdrahn FALSE, /* pc_relative */
1447d2201f2fSdrahn 0, /* bitpos */
1448d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1449d2201f2fSdrahn 0, /* special_function */
1450d2201f2fSdrahn "R_RTB", /* name */
1451d2201f2fSdrahn TRUE, /* partial_inplace */
1452d2201f2fSdrahn 0xffffffff, /* src_mask */
1453d2201f2fSdrahn 0xffffffff, /* dst_mask */
1454d2201f2fSdrahn FALSE), /* pcrel_offset */
1455d2201f2fSdrahn
1456d2201f2fSdrahn /* External TOC relative symbol. */
1457d2201f2fSdrahn HOWTO (R_GL, /* type */
1458d2201f2fSdrahn 0, /* rightshift */
1459d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1460d2201f2fSdrahn 16, /* bitsize */
1461d2201f2fSdrahn FALSE, /* pc_relative */
1462d2201f2fSdrahn 0, /* bitpos */
1463d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1464d2201f2fSdrahn 0, /* special_function */
1465d2201f2fSdrahn "R_GL", /* name */
1466d2201f2fSdrahn TRUE, /* partial_inplace */
1467d2201f2fSdrahn 0xffff, /* src_mask */
1468d2201f2fSdrahn 0xffff, /* dst_mask */
1469d2201f2fSdrahn FALSE), /* pcrel_offset */
1470d2201f2fSdrahn
1471d2201f2fSdrahn /* Local TOC relative symbol. */
1472d2201f2fSdrahn HOWTO (R_TCL, /* type */
1473d2201f2fSdrahn 0, /* rightshift */
1474d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1475d2201f2fSdrahn 16, /* bitsize */
1476d2201f2fSdrahn FALSE, /* pc_relative */
1477d2201f2fSdrahn 0, /* bitpos */
1478d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1479d2201f2fSdrahn 0, /* special_function */
1480d2201f2fSdrahn "R_TCL", /* name */
1481d2201f2fSdrahn TRUE, /* partial_inplace */
1482d2201f2fSdrahn 0xffff, /* src_mask */
1483d2201f2fSdrahn 0xffff, /* dst_mask */
1484d2201f2fSdrahn FALSE), /* pcrel_offset */
1485d2201f2fSdrahn
1486d2201f2fSdrahn EMPTY_HOWTO (7),
1487d2201f2fSdrahn
1488d2201f2fSdrahn /* Non modifiable absolute branch. */
1489d2201f2fSdrahn HOWTO (R_BA, /* type */
1490d2201f2fSdrahn 0, /* rightshift */
1491d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1492d2201f2fSdrahn 26, /* bitsize */
1493d2201f2fSdrahn FALSE, /* pc_relative */
1494d2201f2fSdrahn 0, /* bitpos */
1495d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1496d2201f2fSdrahn 0, /* special_function */
1497d2201f2fSdrahn "R_BA_26", /* name */
1498d2201f2fSdrahn TRUE, /* partial_inplace */
1499d2201f2fSdrahn 0x03fffffc, /* src_mask */
1500d2201f2fSdrahn 0x03fffffc, /* dst_mask */
1501d2201f2fSdrahn FALSE), /* pcrel_offset */
1502d2201f2fSdrahn
1503d2201f2fSdrahn EMPTY_HOWTO (9),
1504d2201f2fSdrahn
1505d2201f2fSdrahn /* Non modifiable relative branch. */
1506d2201f2fSdrahn HOWTO (R_BR, /* type */
1507d2201f2fSdrahn 0, /* rightshift */
1508d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1509d2201f2fSdrahn 26, /* bitsize */
1510d2201f2fSdrahn TRUE, /* pc_relative */
1511d2201f2fSdrahn 0, /* bitpos */
1512d2201f2fSdrahn complain_overflow_signed, /* complain_on_overflow */
1513d2201f2fSdrahn 0, /* special_function */
1514d2201f2fSdrahn "R_BR", /* name */
1515d2201f2fSdrahn TRUE, /* partial_inplace */
1516d2201f2fSdrahn 0x03fffffc, /* src_mask */
1517d2201f2fSdrahn 0x03fffffc, /* dst_mask */
1518d2201f2fSdrahn FALSE), /* pcrel_offset */
1519d2201f2fSdrahn
1520d2201f2fSdrahn EMPTY_HOWTO (0xb),
1521d2201f2fSdrahn
1522d2201f2fSdrahn /* Indirect load. */
1523d2201f2fSdrahn HOWTO (R_RL, /* type */
1524d2201f2fSdrahn 0, /* rightshift */
1525d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1526d2201f2fSdrahn 16, /* bitsize */
1527d2201f2fSdrahn FALSE, /* pc_relative */
1528d2201f2fSdrahn 0, /* bitpos */
1529d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1530d2201f2fSdrahn 0, /* special_function */
1531d2201f2fSdrahn "R_RL", /* name */
1532d2201f2fSdrahn TRUE, /* partial_inplace */
1533d2201f2fSdrahn 0xffff, /* src_mask */
1534d2201f2fSdrahn 0xffff, /* dst_mask */
1535d2201f2fSdrahn FALSE), /* pcrel_offset */
1536d2201f2fSdrahn
1537d2201f2fSdrahn /* Load address. */
1538d2201f2fSdrahn HOWTO (R_RLA, /* type */
1539d2201f2fSdrahn 0, /* rightshift */
1540d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1541d2201f2fSdrahn 16, /* bitsize */
1542d2201f2fSdrahn FALSE, /* pc_relative */
1543d2201f2fSdrahn 0, /* bitpos */
1544d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1545d2201f2fSdrahn 0, /* special_function */
1546d2201f2fSdrahn "R_RLA", /* name */
1547d2201f2fSdrahn TRUE, /* partial_inplace */
1548d2201f2fSdrahn 0xffff, /* src_mask */
1549d2201f2fSdrahn 0xffff, /* dst_mask */
1550d2201f2fSdrahn FALSE), /* pcrel_offset */
1551d2201f2fSdrahn
1552d2201f2fSdrahn EMPTY_HOWTO (0xe),
1553d2201f2fSdrahn
1554d2201f2fSdrahn /* Non-relocating reference. */
1555d2201f2fSdrahn HOWTO (R_REF, /* type */
1556d2201f2fSdrahn 0, /* rightshift */
1557d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1558d2201f2fSdrahn 32, /* bitsize */
1559d2201f2fSdrahn FALSE, /* pc_relative */
1560d2201f2fSdrahn 0, /* bitpos */
1561d2201f2fSdrahn complain_overflow_dont, /* complain_on_overflow */
1562d2201f2fSdrahn 0, /* special_function */
1563d2201f2fSdrahn "R_REF", /* name */
1564d2201f2fSdrahn FALSE, /* partial_inplace */
1565d2201f2fSdrahn 0, /* src_mask */
1566d2201f2fSdrahn 0, /* dst_mask */
1567d2201f2fSdrahn FALSE), /* pcrel_offset */
1568d2201f2fSdrahn
1569d2201f2fSdrahn EMPTY_HOWTO (0x10),
1570d2201f2fSdrahn EMPTY_HOWTO (0x11),
1571d2201f2fSdrahn
1572d2201f2fSdrahn /* TOC relative indirect load. */
1573d2201f2fSdrahn HOWTO (R_TRL, /* type */
1574d2201f2fSdrahn 0, /* rightshift */
1575d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1576d2201f2fSdrahn 16, /* bitsize */
1577d2201f2fSdrahn FALSE, /* pc_relative */
1578d2201f2fSdrahn 0, /* bitpos */
1579d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1580d2201f2fSdrahn 0, /* special_function */
1581d2201f2fSdrahn "R_TRL", /* name */
1582d2201f2fSdrahn TRUE, /* partial_inplace */
1583d2201f2fSdrahn 0xffff, /* src_mask */
1584d2201f2fSdrahn 0xffff, /* dst_mask */
1585d2201f2fSdrahn FALSE), /* pcrel_offset */
1586d2201f2fSdrahn
1587d2201f2fSdrahn /* TOC relative load address. */
1588d2201f2fSdrahn HOWTO (R_TRLA, /* type */
1589d2201f2fSdrahn 0, /* rightshift */
1590d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1591d2201f2fSdrahn 16, /* bitsize */
1592d2201f2fSdrahn FALSE, /* pc_relative */
1593d2201f2fSdrahn 0, /* bitpos */
1594d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1595d2201f2fSdrahn 0, /* special_function */
1596d2201f2fSdrahn "R_TRLA", /* name */
1597d2201f2fSdrahn TRUE, /* partial_inplace */
1598d2201f2fSdrahn 0xffff, /* src_mask */
1599d2201f2fSdrahn 0xffff, /* dst_mask */
1600d2201f2fSdrahn FALSE), /* pcrel_offset */
1601d2201f2fSdrahn
1602d2201f2fSdrahn /* Modifiable relative branch. */
1603d2201f2fSdrahn HOWTO (R_RRTBI, /* type */
1604d2201f2fSdrahn 1, /* rightshift */
1605d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1606d2201f2fSdrahn 32, /* bitsize */
1607d2201f2fSdrahn FALSE, /* pc_relative */
1608d2201f2fSdrahn 0, /* bitpos */
1609d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1610d2201f2fSdrahn 0, /* special_function */
1611d2201f2fSdrahn "R_RRTBI", /* name */
1612d2201f2fSdrahn TRUE, /* partial_inplace */
1613d2201f2fSdrahn 0xffffffff, /* src_mask */
1614d2201f2fSdrahn 0xffffffff, /* dst_mask */
1615d2201f2fSdrahn FALSE), /* pcrel_offset */
1616d2201f2fSdrahn
1617d2201f2fSdrahn /* Modifiable absolute branch. */
1618d2201f2fSdrahn HOWTO (R_RRTBA, /* type */
1619d2201f2fSdrahn 1, /* rightshift */
1620d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1621d2201f2fSdrahn 32, /* bitsize */
1622d2201f2fSdrahn FALSE, /* pc_relative */
1623d2201f2fSdrahn 0, /* bitpos */
1624d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1625d2201f2fSdrahn 0, /* special_function */
1626d2201f2fSdrahn "R_RRTBA", /* name */
1627d2201f2fSdrahn TRUE, /* partial_inplace */
1628d2201f2fSdrahn 0xffffffff, /* src_mask */
1629d2201f2fSdrahn 0xffffffff, /* dst_mask */
1630d2201f2fSdrahn FALSE), /* pcrel_offset */
1631d2201f2fSdrahn
1632d2201f2fSdrahn /* Modifiable call absolute indirect. */
1633d2201f2fSdrahn HOWTO (R_CAI, /* type */
1634d2201f2fSdrahn 0, /* rightshift */
1635d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1636d2201f2fSdrahn 16, /* bitsize */
1637d2201f2fSdrahn FALSE, /* pc_relative */
1638d2201f2fSdrahn 0, /* bitpos */
1639d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1640d2201f2fSdrahn 0, /* special_function */
1641d2201f2fSdrahn "R_CAI", /* name */
1642d2201f2fSdrahn TRUE, /* partial_inplace */
1643d2201f2fSdrahn 0xffff, /* src_mask */
1644d2201f2fSdrahn 0xffff, /* dst_mask */
1645d2201f2fSdrahn FALSE), /* pcrel_offset */
1646d2201f2fSdrahn
1647d2201f2fSdrahn /* Modifiable call relative. */
1648d2201f2fSdrahn HOWTO (R_CREL, /* type */
1649d2201f2fSdrahn 0, /* rightshift */
1650d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1651d2201f2fSdrahn 16, /* bitsize */
1652d2201f2fSdrahn FALSE, /* pc_relative */
1653d2201f2fSdrahn 0, /* bitpos */
1654d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1655d2201f2fSdrahn 0, /* special_function */
1656d2201f2fSdrahn "R_CREL", /* name */
1657d2201f2fSdrahn TRUE, /* partial_inplace */
1658d2201f2fSdrahn 0xffff, /* src_mask */
1659d2201f2fSdrahn 0xffff, /* dst_mask */
1660d2201f2fSdrahn FALSE), /* pcrel_offset */
1661d2201f2fSdrahn
1662d2201f2fSdrahn /* Modifiable branch absolute. */
1663d2201f2fSdrahn HOWTO (R_RBA, /* type */
1664d2201f2fSdrahn 0, /* rightshift */
1665d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1666d2201f2fSdrahn 26, /* bitsize */
1667d2201f2fSdrahn FALSE, /* pc_relative */
1668d2201f2fSdrahn 0, /* bitpos */
1669d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1670d2201f2fSdrahn 0, /* special_function */
1671d2201f2fSdrahn "R_RBA", /* name */
1672d2201f2fSdrahn TRUE, /* partial_inplace */
1673d2201f2fSdrahn 0x03fffffc, /* src_mask */
1674d2201f2fSdrahn 0x03fffffc, /* dst_mask */
1675d2201f2fSdrahn FALSE), /* pcrel_offset */
1676d2201f2fSdrahn
1677d2201f2fSdrahn /* Modifiable branch absolute. */
1678d2201f2fSdrahn HOWTO (R_RBAC, /* type */
1679d2201f2fSdrahn 0, /* rightshift */
1680d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1681d2201f2fSdrahn 32, /* bitsize */
1682d2201f2fSdrahn FALSE, /* pc_relative */
1683d2201f2fSdrahn 0, /* bitpos */
1684d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1685d2201f2fSdrahn 0, /* special_function */
1686d2201f2fSdrahn "R_RBAC", /* name */
1687d2201f2fSdrahn TRUE, /* partial_inplace */
1688d2201f2fSdrahn 0xffffffff, /* src_mask */
1689d2201f2fSdrahn 0xffffffff, /* dst_mask */
1690d2201f2fSdrahn FALSE), /* pcrel_offset */
1691d2201f2fSdrahn
1692d2201f2fSdrahn /* Modifiable branch relative. */
1693d2201f2fSdrahn HOWTO (R_RBR, /* type */
1694d2201f2fSdrahn 0, /* rightshift */
1695d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1696d2201f2fSdrahn 26, /* bitsize */
1697d2201f2fSdrahn FALSE, /* pc_relative */
1698d2201f2fSdrahn 0, /* bitpos */
1699d2201f2fSdrahn complain_overflow_signed, /* complain_on_overflow */
1700d2201f2fSdrahn 0, /* special_function */
1701d2201f2fSdrahn "R_RBR_26", /* name */
1702d2201f2fSdrahn TRUE, /* partial_inplace */
1703d2201f2fSdrahn 0x03fffffc, /* src_mask */
1704d2201f2fSdrahn 0x03fffffc, /* dst_mask */
1705d2201f2fSdrahn FALSE), /* pcrel_offset */
1706d2201f2fSdrahn
1707d2201f2fSdrahn /* Modifiable branch absolute. */
1708d2201f2fSdrahn HOWTO (R_RBRC, /* type */
1709d2201f2fSdrahn 0, /* rightshift */
1710d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1711d2201f2fSdrahn 16, /* bitsize */
1712d2201f2fSdrahn FALSE, /* pc_relative */
1713d2201f2fSdrahn 0, /* bitpos */
1714d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1715d2201f2fSdrahn 0, /* special_function */
1716d2201f2fSdrahn "R_RBRC", /* name */
1717d2201f2fSdrahn TRUE, /* partial_inplace */
1718d2201f2fSdrahn 0xffff, /* src_mask */
1719d2201f2fSdrahn 0xffff, /* dst_mask */
1720d2201f2fSdrahn FALSE), /* pcrel_offset */
1721d2201f2fSdrahn
1722d2201f2fSdrahn HOWTO (R_POS, /* type */
1723d2201f2fSdrahn 0, /* rightshift */
1724d2201f2fSdrahn 2, /* size (0 = byte, 1 = short, 2 = long) */
1725d2201f2fSdrahn 32, /* bitsize */
1726d2201f2fSdrahn FALSE, /* pc_relative */
1727d2201f2fSdrahn 0, /* bitpos */
1728d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1729d2201f2fSdrahn 0, /* special_function */
1730d2201f2fSdrahn "R_POS_32", /* name */
1731d2201f2fSdrahn TRUE, /* partial_inplace */
1732d2201f2fSdrahn 0xffffffff, /* src_mask */
1733d2201f2fSdrahn 0xffffffff, /* dst_mask */
1734d2201f2fSdrahn FALSE), /* pcrel_offset */
1735d2201f2fSdrahn
1736d2201f2fSdrahn /* 16 bit Non modifiable absolute branch. */
1737d2201f2fSdrahn HOWTO (R_BA, /* type */
1738d2201f2fSdrahn 0, /* rightshift */
1739d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1740d2201f2fSdrahn 16, /* bitsize */
1741d2201f2fSdrahn FALSE, /* pc_relative */
1742d2201f2fSdrahn 0, /* bitpos */
1743d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1744d2201f2fSdrahn 0, /* special_function */
1745d2201f2fSdrahn "R_BA_16", /* name */
1746d2201f2fSdrahn TRUE, /* partial_inplace */
1747d2201f2fSdrahn 0xfffc, /* src_mask */
1748d2201f2fSdrahn 0xfffc, /* dst_mask */
1749d2201f2fSdrahn FALSE), /* pcrel_offset */
1750d2201f2fSdrahn
1751d2201f2fSdrahn /* Modifiable branch relative. */
1752d2201f2fSdrahn HOWTO (R_RBR, /* type */
1753d2201f2fSdrahn 0, /* rightshift */
1754d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1755d2201f2fSdrahn 16, /* bitsize */
1756d2201f2fSdrahn FALSE, /* pc_relative */
1757d2201f2fSdrahn 0, /* bitpos */
1758d2201f2fSdrahn complain_overflow_signed, /* complain_on_overflow */
1759d2201f2fSdrahn 0, /* special_function */
1760d2201f2fSdrahn "R_RBR_16", /* name */
1761d2201f2fSdrahn TRUE, /* partial_inplace */
1762d2201f2fSdrahn 0xffff, /* src_mask */
1763d2201f2fSdrahn 0xffff, /* dst_mask */
1764d2201f2fSdrahn FALSE), /* pcrel_offset */
1765d2201f2fSdrahn
1766d2201f2fSdrahn /* Modifiable branch absolute. */
1767d2201f2fSdrahn HOWTO (R_RBA, /* type */
1768d2201f2fSdrahn 0, /* rightshift */
1769d2201f2fSdrahn 1, /* size (0 = byte, 1 = short, 2 = long) */
1770d2201f2fSdrahn 16, /* bitsize */
1771d2201f2fSdrahn FALSE, /* pc_relative */
1772d2201f2fSdrahn 0, /* bitpos */
1773d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
1774d2201f2fSdrahn 0, /* special_function */
1775d2201f2fSdrahn "R_RBA_16", /* name */
1776d2201f2fSdrahn TRUE, /* partial_inplace */
1777d2201f2fSdrahn 0xffff, /* src_mask */
1778d2201f2fSdrahn 0xffff, /* dst_mask */
1779d2201f2fSdrahn FALSE), /* pcrel_offset */
1780d2201f2fSdrahn
1781d2201f2fSdrahn };
1782d2201f2fSdrahn
1783d2201f2fSdrahn void
xcoff64_rtype2howto(relent,internal)1784d2201f2fSdrahn xcoff64_rtype2howto (relent, internal)
1785d2201f2fSdrahn arelent *relent;
1786d2201f2fSdrahn struct internal_reloc *internal;
1787d2201f2fSdrahn {
1788d2201f2fSdrahn if (internal->r_type > R_RBRC)
1789d2201f2fSdrahn abort ();
1790d2201f2fSdrahn
1791d2201f2fSdrahn /* Default howto layout works most of the time */
1792d2201f2fSdrahn relent->howto = &xcoff64_howto_table[internal->r_type];
1793d2201f2fSdrahn
1794*cf2f2c56Smiod /* Special case some 16 bit reloc */
1795d2201f2fSdrahn if (15 == (internal->r_size & 0x3f))
1796d2201f2fSdrahn {
1797d2201f2fSdrahn if (R_BA == internal->r_type)
1798d2201f2fSdrahn relent->howto = &xcoff64_howto_table[0x1d];
1799d2201f2fSdrahn else if (R_RBR == internal->r_type)
1800d2201f2fSdrahn relent->howto = &xcoff64_howto_table[0x1e];
1801d2201f2fSdrahn else if (R_RBA == internal->r_type)
1802d2201f2fSdrahn relent->howto = &xcoff64_howto_table[0x1f];
1803d2201f2fSdrahn }
1804d2201f2fSdrahn /* Special case 32 bit */
1805d2201f2fSdrahn else if (31 == (internal->r_size & 0x3f))
1806d2201f2fSdrahn {
1807d2201f2fSdrahn if (R_POS == internal->r_type)
1808d2201f2fSdrahn relent->howto = &xcoff64_howto_table[0x1c];
1809d2201f2fSdrahn }
1810d2201f2fSdrahn
1811d2201f2fSdrahn /* The r_size field of an XCOFF reloc encodes the bitsize of the
1812d2201f2fSdrahn relocation, as well as indicating whether it is signed or not.
1813d2201f2fSdrahn Doublecheck that the relocation information gathered from the
1814d2201f2fSdrahn type matches this information. The bitsize is not significant
1815d2201f2fSdrahn for R_REF relocs. */
1816d2201f2fSdrahn if (relent->howto->dst_mask != 0
1817d2201f2fSdrahn && (relent->howto->bitsize
1818d2201f2fSdrahn != ((unsigned int) internal->r_size & 0x3f) + 1))
1819d2201f2fSdrahn abort ();
1820d2201f2fSdrahn }
1821d2201f2fSdrahn
1822d2201f2fSdrahn reloc_howto_type *
xcoff64_reloc_type_lookup(abfd,code)1823d2201f2fSdrahn xcoff64_reloc_type_lookup (abfd, code)
1824d2201f2fSdrahn bfd *abfd ATTRIBUTE_UNUSED;
1825d2201f2fSdrahn bfd_reloc_code_real_type code;
1826d2201f2fSdrahn {
1827d2201f2fSdrahn switch (code)
1828d2201f2fSdrahn {
1829d2201f2fSdrahn case BFD_RELOC_PPC_B26:
1830d2201f2fSdrahn return &xcoff64_howto_table[0xa];
1831d2201f2fSdrahn case BFD_RELOC_PPC_BA16:
1832d2201f2fSdrahn return &xcoff64_howto_table[0x1d];
1833d2201f2fSdrahn case BFD_RELOC_PPC_BA26:
1834d2201f2fSdrahn return &xcoff64_howto_table[8];
1835d2201f2fSdrahn case BFD_RELOC_PPC_TOC16:
1836d2201f2fSdrahn return &xcoff64_howto_table[3];
1837d2201f2fSdrahn case BFD_RELOC_32:
1838d2201f2fSdrahn case BFD_RELOC_CTOR:
1839d2201f2fSdrahn return &xcoff64_howto_table[0x1c];
1840d2201f2fSdrahn case BFD_RELOC_64:
1841d2201f2fSdrahn return &xcoff64_howto_table[0];
1842d2201f2fSdrahn default:
1843d2201f2fSdrahn return NULL;
1844d2201f2fSdrahn }
1845d2201f2fSdrahn }
1846d2201f2fSdrahn
1847d2201f2fSdrahn /* Read in the armap of an XCOFF archive. */
1848d2201f2fSdrahn
1849d2201f2fSdrahn static bfd_boolean
xcoff64_slurp_armap(abfd)1850d2201f2fSdrahn xcoff64_slurp_armap (abfd)
1851d2201f2fSdrahn bfd *abfd;
1852d2201f2fSdrahn {
1853d2201f2fSdrahn file_ptr off;
1854d2201f2fSdrahn size_t namlen;
1855d2201f2fSdrahn bfd_size_type sz, amt;
1856d2201f2fSdrahn bfd_byte *contents, *cend;
1857d2201f2fSdrahn bfd_vma c, i;
1858d2201f2fSdrahn carsym *arsym;
1859d2201f2fSdrahn bfd_byte *p;
1860d2201f2fSdrahn file_ptr pos;
1861d2201f2fSdrahn
1862d2201f2fSdrahn /* This is for the new format. */
1863d2201f2fSdrahn struct xcoff_ar_hdr_big hdr;
1864d2201f2fSdrahn
1865d2201f2fSdrahn if (xcoff_ardata (abfd) == NULL)
1866d2201f2fSdrahn {
1867d2201f2fSdrahn bfd_has_map (abfd) = FALSE;
1868d2201f2fSdrahn return TRUE;
1869d2201f2fSdrahn }
1870d2201f2fSdrahn
1871d2201f2fSdrahn off = bfd_scan_vma (xcoff_ardata_big (abfd)->symoff64,
1872d2201f2fSdrahn (const char **) NULL, 10);
1873d2201f2fSdrahn if (off == 0)
1874d2201f2fSdrahn {
1875d2201f2fSdrahn bfd_has_map (abfd) = FALSE;
1876d2201f2fSdrahn return TRUE;
1877d2201f2fSdrahn }
1878d2201f2fSdrahn
1879d2201f2fSdrahn if (bfd_seek (abfd, off, SEEK_SET) != 0)
1880d2201f2fSdrahn return FALSE;
1881d2201f2fSdrahn
1882d2201f2fSdrahn /* The symbol table starts with a normal archive header. */
1883d2201f2fSdrahn if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
1884d2201f2fSdrahn != SIZEOF_AR_HDR_BIG)
1885d2201f2fSdrahn return FALSE;
1886d2201f2fSdrahn
1887d2201f2fSdrahn /* Skip the name (normally empty). */
1888d2201f2fSdrahn namlen = strtol (hdr.namlen, (char **) NULL, 10);
1889d2201f2fSdrahn pos = ((namlen + 1) & ~(size_t) 1) + SXCOFFARFMAG;
1890d2201f2fSdrahn if (bfd_seek (abfd, pos, SEEK_CUR) != 0)
1891d2201f2fSdrahn return FALSE;
1892d2201f2fSdrahn
1893d2201f2fSdrahn sz = bfd_scan_vma (hdr.size, (const char **) NULL, 10);
1894d2201f2fSdrahn
1895d2201f2fSdrahn /* Read in the entire symbol table. */
1896d2201f2fSdrahn contents = (bfd_byte *) bfd_alloc (abfd, sz);
1897d2201f2fSdrahn if (contents == NULL)
1898d2201f2fSdrahn return FALSE;
1899d2201f2fSdrahn if (bfd_bread ((PTR) contents, sz, abfd) != sz)
1900d2201f2fSdrahn return FALSE;
1901d2201f2fSdrahn
1902d2201f2fSdrahn /* The symbol table starts with an eight byte count. */
1903d2201f2fSdrahn c = H_GET_64 (abfd, contents);
1904d2201f2fSdrahn
1905d2201f2fSdrahn if (c * 8 >= sz)
1906d2201f2fSdrahn {
1907d2201f2fSdrahn bfd_set_error (bfd_error_bad_value);
1908d2201f2fSdrahn return FALSE;
1909d2201f2fSdrahn }
1910d2201f2fSdrahn amt = c;
1911d2201f2fSdrahn amt *= sizeof (carsym);
1912d2201f2fSdrahn bfd_ardata (abfd)->symdefs = (carsym *) bfd_alloc (abfd, amt);
1913d2201f2fSdrahn if (bfd_ardata (abfd)->symdefs == NULL)
1914d2201f2fSdrahn return FALSE;
1915d2201f2fSdrahn
1916d2201f2fSdrahn /* After the count comes a list of eight byte file offsets. */
1917d2201f2fSdrahn for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8;
1918d2201f2fSdrahn i < c;
1919d2201f2fSdrahn ++i, ++arsym, p += 8)
1920d2201f2fSdrahn arsym->file_offset = H_GET_64 (abfd, p);
1921d2201f2fSdrahn
1922d2201f2fSdrahn /* After the file offsets come null terminated symbol names. */
1923d2201f2fSdrahn cend = contents + sz;
1924d2201f2fSdrahn for (i = 0, arsym = bfd_ardata (abfd)->symdefs;
1925d2201f2fSdrahn i < c;
1926d2201f2fSdrahn ++i, ++arsym, p += strlen ((char *) p) + 1)
1927d2201f2fSdrahn {
1928d2201f2fSdrahn if (p >= cend)
1929d2201f2fSdrahn {
1930d2201f2fSdrahn bfd_set_error (bfd_error_bad_value);
1931d2201f2fSdrahn return FALSE;
1932d2201f2fSdrahn }
1933d2201f2fSdrahn arsym->name = (char *) p;
1934d2201f2fSdrahn }
1935d2201f2fSdrahn
1936d2201f2fSdrahn bfd_ardata (abfd)->symdef_count = c;
1937d2201f2fSdrahn bfd_has_map (abfd) = TRUE;
1938d2201f2fSdrahn
1939d2201f2fSdrahn return TRUE;
1940d2201f2fSdrahn }
1941d2201f2fSdrahn
1942d2201f2fSdrahn
1943d2201f2fSdrahn /* See if this is an NEW XCOFF archive. */
1944d2201f2fSdrahn
1945d2201f2fSdrahn static const bfd_target *
xcoff64_archive_p(abfd)1946d2201f2fSdrahn xcoff64_archive_p (abfd)
1947d2201f2fSdrahn bfd *abfd;
1948d2201f2fSdrahn {
1949d2201f2fSdrahn struct artdata *tdata_hold;
1950d2201f2fSdrahn char magic[SXCOFFARMAG];
1951d2201f2fSdrahn /* This is the new format. */
1952d2201f2fSdrahn struct xcoff_ar_file_hdr_big hdr;
1953d2201f2fSdrahn bfd_size_type amt = SXCOFFARMAG;
1954d2201f2fSdrahn
1955d2201f2fSdrahn if (bfd_bread ((PTR) magic, amt, abfd) != amt)
1956d2201f2fSdrahn {
1957d2201f2fSdrahn if (bfd_get_error () != bfd_error_system_call)
1958d2201f2fSdrahn bfd_set_error (bfd_error_wrong_format);
1959d2201f2fSdrahn return NULL;
1960d2201f2fSdrahn }
1961d2201f2fSdrahn
1962d2201f2fSdrahn if (strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0)
1963d2201f2fSdrahn {
1964d2201f2fSdrahn bfd_set_error (bfd_error_wrong_format);
1965d2201f2fSdrahn return NULL;
1966d2201f2fSdrahn }
1967d2201f2fSdrahn
1968d2201f2fSdrahn /* Copy over the magic string. */
1969d2201f2fSdrahn memcpy (hdr.magic, magic, SXCOFFARMAG);
1970d2201f2fSdrahn
1971d2201f2fSdrahn /* Now read the rest of the file header. */
1972d2201f2fSdrahn amt = SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG;
1973d2201f2fSdrahn if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt)
1974d2201f2fSdrahn {
1975d2201f2fSdrahn if (bfd_get_error () != bfd_error_system_call)
1976d2201f2fSdrahn bfd_set_error (bfd_error_wrong_format);
1977d2201f2fSdrahn return NULL;
1978d2201f2fSdrahn }
1979d2201f2fSdrahn
1980d2201f2fSdrahn tdata_hold = bfd_ardata (abfd);
1981d2201f2fSdrahn
1982d2201f2fSdrahn amt = sizeof (struct artdata);
1983d2201f2fSdrahn bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt);
1984d2201f2fSdrahn if (bfd_ardata (abfd) == (struct artdata *) NULL)
1985d2201f2fSdrahn goto error_ret_restore;
1986d2201f2fSdrahn
1987d2201f2fSdrahn bfd_ardata (abfd)->cache = NULL;
1988d2201f2fSdrahn bfd_ardata (abfd)->archive_head = NULL;
1989d2201f2fSdrahn bfd_ardata (abfd)->symdefs = NULL;
1990d2201f2fSdrahn bfd_ardata (abfd)->extended_names = NULL;
1991d2201f2fSdrahn bfd_ardata (abfd)->first_file_filepos = bfd_scan_vma (hdr.firstmemoff,
1992d2201f2fSdrahn (const char **) NULL,
1993d2201f2fSdrahn 10);
1994d2201f2fSdrahn
1995d2201f2fSdrahn amt = SIZEOF_AR_FILE_HDR_BIG;
1996d2201f2fSdrahn bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
1997d2201f2fSdrahn if (bfd_ardata (abfd)->tdata == NULL)
1998d2201f2fSdrahn goto error_ret;
1999d2201f2fSdrahn
2000d2201f2fSdrahn memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG);
2001d2201f2fSdrahn
2002d2201f2fSdrahn if (! xcoff64_slurp_armap (abfd))
2003d2201f2fSdrahn {
2004d2201f2fSdrahn error_ret:
2005d2201f2fSdrahn bfd_release (abfd, bfd_ardata (abfd));
2006d2201f2fSdrahn error_ret_restore:
2007d2201f2fSdrahn bfd_ardata (abfd) = tdata_hold;
2008d2201f2fSdrahn return NULL;
2009d2201f2fSdrahn }
2010d2201f2fSdrahn
2011d2201f2fSdrahn return abfd->xvec;
2012d2201f2fSdrahn }
2013d2201f2fSdrahn
2014d2201f2fSdrahn
2015d2201f2fSdrahn /* Open the next element in an XCOFF archive. */
2016d2201f2fSdrahn
2017d2201f2fSdrahn static bfd *
xcoff64_openr_next_archived_file(archive,last_file)2018d2201f2fSdrahn xcoff64_openr_next_archived_file (archive, last_file)
2019d2201f2fSdrahn bfd *archive;
2020d2201f2fSdrahn bfd *last_file;
2021d2201f2fSdrahn {
2022d2201f2fSdrahn bfd_vma filestart;
2023d2201f2fSdrahn
2024d2201f2fSdrahn if ((xcoff_ardata (archive) == NULL)
2025d2201f2fSdrahn || ! xcoff_big_format_p (archive))
2026d2201f2fSdrahn {
2027d2201f2fSdrahn bfd_set_error (bfd_error_invalid_operation);
2028d2201f2fSdrahn return NULL;
2029d2201f2fSdrahn }
2030d2201f2fSdrahn
2031d2201f2fSdrahn if (last_file == NULL)
2032d2201f2fSdrahn {
2033d2201f2fSdrahn filestart = bfd_ardata (archive)->first_file_filepos;
2034d2201f2fSdrahn }
2035d2201f2fSdrahn else
2036d2201f2fSdrahn {
2037d2201f2fSdrahn filestart = bfd_scan_vma (arch_xhdr_big (last_file)->nextoff,
2038d2201f2fSdrahn (const char **) NULL, 10);
2039d2201f2fSdrahn }
2040d2201f2fSdrahn
2041d2201f2fSdrahn if (filestart == 0
2042d2201f2fSdrahn || filestart == bfd_scan_vma (xcoff_ardata_big (archive)->memoff,
2043d2201f2fSdrahn (const char **) NULL, 10)
2044d2201f2fSdrahn || filestart == bfd_scan_vma (xcoff_ardata_big (archive)->symoff,
2045d2201f2fSdrahn (const char **) NULL, 10))
2046d2201f2fSdrahn {
2047d2201f2fSdrahn bfd_set_error (bfd_error_no_more_archived_files);
2048d2201f2fSdrahn return NULL;
2049d2201f2fSdrahn }
2050d2201f2fSdrahn
2051d2201f2fSdrahn return _bfd_get_elt_at_filepos (archive, (file_ptr) filestart);
2052d2201f2fSdrahn }
2053d2201f2fSdrahn
2054d2201f2fSdrahn /* We can't use the usual coff_sizeof_headers routine, because AIX
2055d2201f2fSdrahn always uses an a.out header. */
2056d2201f2fSdrahn
2057d2201f2fSdrahn static int
xcoff64_sizeof_headers(abfd,reloc)2058d2201f2fSdrahn xcoff64_sizeof_headers (abfd, reloc)
2059d2201f2fSdrahn bfd *abfd;
2060d2201f2fSdrahn bfd_boolean reloc ATTRIBUTE_UNUSED;
2061d2201f2fSdrahn {
2062d2201f2fSdrahn int size;
2063d2201f2fSdrahn
2064d2201f2fSdrahn size = bfd_coff_filhsz (abfd);
2065d2201f2fSdrahn
2066d2201f2fSdrahn /* Don't think the small aout header can be used since some of the
2067d2201f2fSdrahn old elements have been reordered past the end of the old coff
2068d2201f2fSdrahn small aout size. */
2069d2201f2fSdrahn
2070d2201f2fSdrahn if (xcoff_data (abfd)->full_aouthdr)
2071d2201f2fSdrahn size += bfd_coff_aoutsz (abfd);
2072d2201f2fSdrahn
2073d2201f2fSdrahn size += abfd->section_count * bfd_coff_scnhsz (abfd);
2074d2201f2fSdrahn return size;
2075d2201f2fSdrahn }
2076d2201f2fSdrahn
2077d2201f2fSdrahn
2078d2201f2fSdrahn
2079d2201f2fSdrahn static asection *
xcoff64_create_csect_from_smclas(abfd,aux,symbol_name)2080d2201f2fSdrahn xcoff64_create_csect_from_smclas (abfd, aux, symbol_name)
2081d2201f2fSdrahn bfd *abfd;
2082d2201f2fSdrahn union internal_auxent *aux;
2083d2201f2fSdrahn const char *symbol_name;
2084d2201f2fSdrahn {
2085d2201f2fSdrahn asection *return_value = NULL;
2086d2201f2fSdrahn
2087d2201f2fSdrahn /* Changes from 32 :
2088d2201f2fSdrahn .sv == 8, is only for 32 bit programs
2089d2201f2fSdrahn .ti == 12 and .tb == 13 are now reserved. */
2090d2201f2fSdrahn static const char *names[19] =
2091d2201f2fSdrahn {
2092d2201f2fSdrahn ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
2093d2201f2fSdrahn NULL, ".bs", ".ds", ".uc", NULL, NULL, NULL, ".tc0",
2094d2201f2fSdrahn ".td", ".sv64", ".sv3264"
2095d2201f2fSdrahn };
2096d2201f2fSdrahn
2097d2201f2fSdrahn if ((19 >= aux->x_csect.x_smclas)
2098d2201f2fSdrahn && (NULL != names[aux->x_csect.x_smclas]))
2099d2201f2fSdrahn {
2100d2201f2fSdrahn
2101d2201f2fSdrahn return_value = bfd_make_section_anyway
2102d2201f2fSdrahn (abfd, names[aux->x_csect.x_smclas]);
2103d2201f2fSdrahn
2104d2201f2fSdrahn }
2105d2201f2fSdrahn else
2106d2201f2fSdrahn {
2107d2201f2fSdrahn (*_bfd_error_handler)
2108d2201f2fSdrahn (_("%s: symbol `%s' has unrecognized smclas %d"),
2109d2201f2fSdrahn bfd_archive_filename (abfd), symbol_name, aux->x_csect.x_smclas);
2110d2201f2fSdrahn bfd_set_error (bfd_error_bad_value);
2111d2201f2fSdrahn }
2112d2201f2fSdrahn
2113d2201f2fSdrahn return return_value;
2114d2201f2fSdrahn }
2115d2201f2fSdrahn
2116d2201f2fSdrahn static bfd_boolean
xcoff64_is_lineno_count_overflow(abfd,value)2117d2201f2fSdrahn xcoff64_is_lineno_count_overflow (abfd, value)
2118d2201f2fSdrahn bfd *abfd ATTRIBUTE_UNUSED;
2119d2201f2fSdrahn bfd_vma value ATTRIBUTE_UNUSED;
2120d2201f2fSdrahn {
2121d2201f2fSdrahn return FALSE;
2122d2201f2fSdrahn }
2123d2201f2fSdrahn
2124d2201f2fSdrahn static bfd_boolean
xcoff64_is_reloc_count_overflow(abfd,value)2125d2201f2fSdrahn xcoff64_is_reloc_count_overflow (abfd, value)
2126d2201f2fSdrahn bfd *abfd ATTRIBUTE_UNUSED;
2127d2201f2fSdrahn bfd_vma value ATTRIBUTE_UNUSED;
2128d2201f2fSdrahn {
2129d2201f2fSdrahn return FALSE;
2130d2201f2fSdrahn }
2131d2201f2fSdrahn
2132d2201f2fSdrahn static bfd_vma
xcoff64_loader_symbol_offset(abfd,ldhdr)2133d2201f2fSdrahn xcoff64_loader_symbol_offset (abfd, ldhdr)
2134d2201f2fSdrahn bfd *abfd ATTRIBUTE_UNUSED;
2135d2201f2fSdrahn struct internal_ldhdr *ldhdr;
2136d2201f2fSdrahn {
2137d2201f2fSdrahn return (ldhdr->l_symoff);
2138d2201f2fSdrahn }
2139d2201f2fSdrahn
2140d2201f2fSdrahn static bfd_vma
xcoff64_loader_reloc_offset(abfd,ldhdr)2141d2201f2fSdrahn xcoff64_loader_reloc_offset (abfd, ldhdr)
2142d2201f2fSdrahn bfd *abfd ATTRIBUTE_UNUSED;
2143d2201f2fSdrahn struct internal_ldhdr *ldhdr;
2144d2201f2fSdrahn {
2145d2201f2fSdrahn return (ldhdr->l_rldoff);
2146d2201f2fSdrahn }
2147d2201f2fSdrahn
2148d2201f2fSdrahn static bfd_boolean
xcoff64_bad_format_hook(abfd,filehdr)2149d2201f2fSdrahn xcoff64_bad_format_hook (abfd, filehdr)
2150d2201f2fSdrahn bfd * abfd;
2151d2201f2fSdrahn PTR filehdr;
2152d2201f2fSdrahn {
2153d2201f2fSdrahn struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2154d2201f2fSdrahn
2155d2201f2fSdrahn /* Check flavor first. */
2156d2201f2fSdrahn if (bfd_get_flavour (abfd) != bfd_target_xcoff_flavour)
2157d2201f2fSdrahn return FALSE;
2158d2201f2fSdrahn
2159d2201f2fSdrahn if (bfd_xcoff_magic_number (abfd) != internal_f->f_magic)
2160d2201f2fSdrahn return FALSE;
2161d2201f2fSdrahn
2162d2201f2fSdrahn return TRUE;
2163d2201f2fSdrahn }
2164d2201f2fSdrahn
2165d2201f2fSdrahn static bfd_boolean
xcoff64_generate_rtinit(abfd,init,fini,rtld)2166d2201f2fSdrahn xcoff64_generate_rtinit (abfd, init, fini, rtld)
2167d2201f2fSdrahn bfd *abfd;
2168d2201f2fSdrahn const char *init;
2169d2201f2fSdrahn const char *fini;
2170d2201f2fSdrahn bfd_boolean rtld;
2171d2201f2fSdrahn {
2172d2201f2fSdrahn bfd_byte filehdr_ext[FILHSZ];
2173d2201f2fSdrahn bfd_byte scnhdr_ext[SCNHSZ * 3];
2174d2201f2fSdrahn bfd_byte syment_ext[SYMESZ * 10];
2175d2201f2fSdrahn bfd_byte reloc_ext[RELSZ * 3];
2176d2201f2fSdrahn bfd_byte *data_buffer;
2177d2201f2fSdrahn bfd_size_type data_buffer_size;
2178d2201f2fSdrahn bfd_byte *string_table, *st_tmp;
2179d2201f2fSdrahn bfd_size_type string_table_size;
2180d2201f2fSdrahn bfd_vma val;
2181d2201f2fSdrahn size_t initsz, finisz;
2182d2201f2fSdrahn struct internal_filehdr filehdr;
2183d2201f2fSdrahn struct internal_scnhdr text_scnhdr;
2184d2201f2fSdrahn struct internal_scnhdr data_scnhdr;
2185d2201f2fSdrahn struct internal_scnhdr bss_scnhdr;
2186d2201f2fSdrahn struct internal_syment syment;
2187d2201f2fSdrahn union internal_auxent auxent;
2188d2201f2fSdrahn struct internal_reloc reloc;
2189d2201f2fSdrahn
2190d2201f2fSdrahn char *text_name = ".text";
2191d2201f2fSdrahn char *data_name = ".data";
2192d2201f2fSdrahn char *bss_name = ".bss";
2193d2201f2fSdrahn char *rtinit_name = "__rtinit";
2194d2201f2fSdrahn char *rtld_name = "__rtld";
2195d2201f2fSdrahn
2196d2201f2fSdrahn if (! bfd_xcoff_rtinit_size (abfd))
2197d2201f2fSdrahn return FALSE;
2198d2201f2fSdrahn
2199d2201f2fSdrahn initsz = (init == NULL ? 0 : 1 + strlen (init));
2200d2201f2fSdrahn finisz = (fini == NULL ? 0 : 1 + strlen (fini));
2201d2201f2fSdrahn
2202d2201f2fSdrahn /* File header. */
2203d2201f2fSdrahn memset (filehdr_ext, 0, FILHSZ);
2204d2201f2fSdrahn memset (&filehdr, 0, sizeof (struct internal_filehdr));
2205d2201f2fSdrahn filehdr.f_magic = bfd_xcoff_magic_number (abfd);
2206d2201f2fSdrahn filehdr.f_nscns = 3;
2207d2201f2fSdrahn filehdr.f_timdat = 0;
2208d2201f2fSdrahn filehdr.f_nsyms = 0; /* at least 6, no more than 8 */
2209d2201f2fSdrahn filehdr.f_symptr = 0; /* set below */
2210d2201f2fSdrahn filehdr.f_opthdr = 0;
2211d2201f2fSdrahn filehdr.f_flags = 0;
2212d2201f2fSdrahn
2213d2201f2fSdrahn /* Section headers. */
2214d2201f2fSdrahn memset (scnhdr_ext, 0, 3 * SCNHSZ);
2215d2201f2fSdrahn
2216d2201f2fSdrahn /* Text. */
2217d2201f2fSdrahn memset (&text_scnhdr, 0, sizeof (struct internal_scnhdr));
2218d2201f2fSdrahn memcpy (text_scnhdr.s_name, text_name, strlen (text_name));
2219d2201f2fSdrahn text_scnhdr.s_paddr = 0;
2220d2201f2fSdrahn text_scnhdr.s_vaddr = 0;
2221d2201f2fSdrahn text_scnhdr.s_size = 0;
2222d2201f2fSdrahn text_scnhdr.s_scnptr = 0;
2223d2201f2fSdrahn text_scnhdr.s_relptr = 0;
2224d2201f2fSdrahn text_scnhdr.s_lnnoptr = 0;
2225d2201f2fSdrahn text_scnhdr.s_nreloc = 0;
2226d2201f2fSdrahn text_scnhdr.s_nlnno = 0;
2227d2201f2fSdrahn text_scnhdr.s_flags = STYP_TEXT;
2228d2201f2fSdrahn
2229d2201f2fSdrahn /* Data. */
2230d2201f2fSdrahn memset (&data_scnhdr, 0, sizeof (struct internal_scnhdr));
2231d2201f2fSdrahn memcpy (data_scnhdr.s_name, data_name, strlen (data_name));
2232d2201f2fSdrahn data_scnhdr.s_paddr = 0;
2233d2201f2fSdrahn data_scnhdr.s_vaddr = 0;
2234d2201f2fSdrahn data_scnhdr.s_size = 0; /* set below */
2235d2201f2fSdrahn data_scnhdr.s_scnptr = FILHSZ + 3 * SCNHSZ;
2236d2201f2fSdrahn data_scnhdr.s_relptr = 0; /* set below */
2237d2201f2fSdrahn data_scnhdr.s_lnnoptr = 0;
2238d2201f2fSdrahn data_scnhdr.s_nreloc = 0; /* either 1 or 2 */
2239d2201f2fSdrahn data_scnhdr.s_nlnno = 0;
2240d2201f2fSdrahn data_scnhdr.s_flags = STYP_DATA;
2241d2201f2fSdrahn
2242d2201f2fSdrahn /* Bss. */
2243d2201f2fSdrahn memset (&bss_scnhdr, 0, sizeof (struct internal_scnhdr));
2244d2201f2fSdrahn memcpy (bss_scnhdr.s_name, bss_name, strlen (bss_name));
2245d2201f2fSdrahn bss_scnhdr.s_paddr = 0; /* set below */
2246d2201f2fSdrahn bss_scnhdr.s_vaddr = 0; /* set below */
2247d2201f2fSdrahn bss_scnhdr.s_size = 0; /* set below */
2248d2201f2fSdrahn bss_scnhdr.s_scnptr = 0;
2249d2201f2fSdrahn bss_scnhdr.s_relptr = 0;
2250d2201f2fSdrahn bss_scnhdr.s_lnnoptr = 0;
2251d2201f2fSdrahn bss_scnhdr.s_nreloc = 0;
2252d2201f2fSdrahn bss_scnhdr.s_nlnno = 0;
2253d2201f2fSdrahn bss_scnhdr.s_flags = STYP_BSS;
2254d2201f2fSdrahn
2255d2201f2fSdrahn /* .data
2256d2201f2fSdrahn 0x0000 0x00000000 : rtl
2257d2201f2fSdrahn 0x0004 0x00000000 :
2258d2201f2fSdrahn 0x0008 0x00000018 : offset to init, or 0
2259d2201f2fSdrahn 0x000C 0x00000038 : offset to fini, or 0
2260d2201f2fSdrahn 0x0010 0x00000010 : size of descriptor
2261d2201f2fSdrahn 0x0014 0x00000000 : pad
2262d2201f2fSdrahn 0x0018 0x00000000 : init, needs a reloc
2263d2201f2fSdrahn 0x001C 0x00000000 :
2264d2201f2fSdrahn 0x0020 0x00000058 : offset to init name
2265d2201f2fSdrahn 0x0024 0x00000000 : flags, padded to a word
2266d2201f2fSdrahn 0x0028 0x00000000 : empty init
2267d2201f2fSdrahn 0x002C 0x00000000 :
2268d2201f2fSdrahn 0x0030 0x00000000 :
2269d2201f2fSdrahn 0x0034 0x00000000 :
2270d2201f2fSdrahn 0x0038 0x00000000 : fini, needs a reloc
2271d2201f2fSdrahn 0x003C 0x00000000 :
2272d2201f2fSdrahn 0x0040 0x00000??? : offset to fini name
2273d2201f2fSdrahn 0x0044 0x00000000 : flags, padded to a word
2274d2201f2fSdrahn 0x0048 0x00000000 : empty fini
2275d2201f2fSdrahn 0x004C 0x00000000 :
2276d2201f2fSdrahn 0x0050 0x00000000 :
2277d2201f2fSdrahn 0x0054 0x00000000 :
2278d2201f2fSdrahn 0x0058 init name
2279d2201f2fSdrahn 0x0058 + initsz fini name */
2280d2201f2fSdrahn
2281d2201f2fSdrahn data_buffer_size = 0x0058 + initsz + finisz;
2282d2201f2fSdrahn data_buffer_size = (data_buffer_size + 7) &~ (bfd_size_type) 7;
2283d2201f2fSdrahn data_buffer = NULL;
2284d2201f2fSdrahn data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size);
2285d2201f2fSdrahn if (data_buffer == NULL)
2286d2201f2fSdrahn return FALSE;
2287d2201f2fSdrahn
2288d2201f2fSdrahn if (initsz)
2289d2201f2fSdrahn {
2290d2201f2fSdrahn val = 0x18;
2291d2201f2fSdrahn bfd_put_32 (abfd, val, &data_buffer[0x08]);
2292d2201f2fSdrahn val = 0x58;
2293d2201f2fSdrahn bfd_put_32 (abfd, val, &data_buffer[0x20]);
2294d2201f2fSdrahn memcpy (&data_buffer[val], init, initsz);
2295d2201f2fSdrahn }
2296d2201f2fSdrahn
2297d2201f2fSdrahn if (finisz)
2298d2201f2fSdrahn {
2299d2201f2fSdrahn val = 0x38;
2300d2201f2fSdrahn bfd_put_32 (abfd, val, &data_buffer[0x0C]);
2301d2201f2fSdrahn val = 0x58 + initsz;
2302d2201f2fSdrahn bfd_put_32 (abfd, val, &data_buffer[0x40]);
2303d2201f2fSdrahn memcpy (&data_buffer[val], fini, finisz);
2304d2201f2fSdrahn }
2305d2201f2fSdrahn
2306d2201f2fSdrahn val = 0x10;
2307d2201f2fSdrahn bfd_put_32 (abfd, val, &data_buffer[0x10]);
2308d2201f2fSdrahn data_scnhdr.s_size = data_buffer_size;
2309d2201f2fSdrahn bss_scnhdr.s_paddr = bss_scnhdr.s_vaddr = data_scnhdr.s_size;
2310d2201f2fSdrahn
2311d2201f2fSdrahn /* String table. */
2312d2201f2fSdrahn string_table_size = 4;
2313d2201f2fSdrahn string_table_size += strlen (data_name) + 1;
2314d2201f2fSdrahn string_table_size += strlen (rtinit_name) + 1;
2315d2201f2fSdrahn string_table_size += initsz;
2316d2201f2fSdrahn string_table_size += finisz;
2317d2201f2fSdrahn if (rtld)
2318d2201f2fSdrahn string_table_size += strlen (rtld_name) + 1;
2319d2201f2fSdrahn
2320d2201f2fSdrahn string_table = (bfd_byte *) bfd_zmalloc (string_table_size);
2321d2201f2fSdrahn if (string_table == NULL)
2322d2201f2fSdrahn return FALSE;
2323d2201f2fSdrahn
2324d2201f2fSdrahn val = string_table_size;
2325d2201f2fSdrahn bfd_put_32 (abfd, val, &string_table[0]);
2326d2201f2fSdrahn st_tmp = string_table + 4;
2327d2201f2fSdrahn
2328d2201f2fSdrahn /* symbols
2329d2201f2fSdrahn 0. .data csect
2330d2201f2fSdrahn 2. __rtinit
2331d2201f2fSdrahn 4. init function
2332d2201f2fSdrahn 6. fini function
2333d2201f2fSdrahn 8. __rtld */
2334d2201f2fSdrahn memset (syment_ext, 0, 10 * SYMESZ);
2335d2201f2fSdrahn memset (reloc_ext, 0, 3 * RELSZ);
2336d2201f2fSdrahn
2337d2201f2fSdrahn /* .data csect */
2338d2201f2fSdrahn memset (&syment, 0, sizeof (struct internal_syment));
2339d2201f2fSdrahn memset (&auxent, 0, sizeof (union internal_auxent));
2340d2201f2fSdrahn
2341d2201f2fSdrahn syment._n._n_n._n_offset = st_tmp - string_table;
2342d2201f2fSdrahn memcpy (st_tmp, data_name, strlen (data_name));
2343d2201f2fSdrahn st_tmp += strlen (data_name) + 1;
2344d2201f2fSdrahn
2345d2201f2fSdrahn syment.n_scnum = 2;
2346d2201f2fSdrahn syment.n_sclass = C_HIDEXT;
2347d2201f2fSdrahn syment.n_numaux = 1;
2348d2201f2fSdrahn auxent.x_csect.x_scnlen.l = data_buffer_size;
2349d2201f2fSdrahn auxent.x_csect.x_smtyp = 3 << 3 | XTY_SD;
2350d2201f2fSdrahn auxent.x_csect.x_smclas = XMC_RW;
2351d2201f2fSdrahn bfd_coff_swap_sym_out (abfd, &syment,
2352d2201f2fSdrahn &syment_ext[filehdr.f_nsyms * SYMESZ]);
2353d2201f2fSdrahn bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2354d2201f2fSdrahn syment.n_numaux,
2355d2201f2fSdrahn &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2356d2201f2fSdrahn filehdr.f_nsyms += 2;
2357d2201f2fSdrahn
2358d2201f2fSdrahn /* __rtinit */
2359d2201f2fSdrahn memset (&syment, 0, sizeof (struct internal_syment));
2360d2201f2fSdrahn memset (&auxent, 0, sizeof (union internal_auxent));
2361d2201f2fSdrahn syment._n._n_n._n_offset = st_tmp - string_table;
2362d2201f2fSdrahn memcpy (st_tmp, rtinit_name, strlen (rtinit_name));
2363d2201f2fSdrahn st_tmp += strlen (rtinit_name) + 1;
2364d2201f2fSdrahn
2365d2201f2fSdrahn syment.n_scnum = 2;
2366d2201f2fSdrahn syment.n_sclass = C_EXT;
2367d2201f2fSdrahn syment.n_numaux = 1;
2368d2201f2fSdrahn auxent.x_csect.x_smtyp = XTY_LD;
2369d2201f2fSdrahn auxent.x_csect.x_smclas = XMC_RW;
2370d2201f2fSdrahn bfd_coff_swap_sym_out (abfd, &syment,
2371d2201f2fSdrahn &syment_ext[filehdr.f_nsyms * SYMESZ]);
2372d2201f2fSdrahn bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2373d2201f2fSdrahn syment.n_numaux,
2374d2201f2fSdrahn &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2375d2201f2fSdrahn filehdr.f_nsyms += 2;
2376d2201f2fSdrahn
2377d2201f2fSdrahn /* Init. */
2378d2201f2fSdrahn if (initsz)
2379d2201f2fSdrahn {
2380d2201f2fSdrahn memset (&syment, 0, sizeof (struct internal_syment));
2381d2201f2fSdrahn memset (&auxent, 0, sizeof (union internal_auxent));
2382d2201f2fSdrahn
2383d2201f2fSdrahn syment._n._n_n._n_offset = st_tmp - string_table;
2384d2201f2fSdrahn memcpy (st_tmp, init, initsz);
2385d2201f2fSdrahn st_tmp += initsz;
2386d2201f2fSdrahn
2387d2201f2fSdrahn syment.n_sclass = C_EXT;
2388d2201f2fSdrahn syment.n_numaux = 1;
2389d2201f2fSdrahn bfd_coff_swap_sym_out (abfd, &syment,
2390d2201f2fSdrahn &syment_ext[filehdr.f_nsyms * SYMESZ]);
2391d2201f2fSdrahn bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2392d2201f2fSdrahn syment.n_numaux,
2393d2201f2fSdrahn &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2394d2201f2fSdrahn /* Reloc. */
2395d2201f2fSdrahn memset (&reloc, 0, sizeof (struct internal_reloc));
2396d2201f2fSdrahn reloc.r_vaddr = 0x0018;
2397d2201f2fSdrahn reloc.r_symndx = filehdr.f_nsyms;
2398d2201f2fSdrahn reloc.r_type = R_POS;
2399d2201f2fSdrahn reloc.r_size = 63;
2400d2201f2fSdrahn bfd_coff_swap_reloc_out (abfd, &reloc, &reloc_ext[0]);
2401d2201f2fSdrahn
2402d2201f2fSdrahn filehdr.f_nsyms += 2;
2403d2201f2fSdrahn data_scnhdr.s_nreloc += 1;
2404d2201f2fSdrahn }
2405d2201f2fSdrahn
2406d2201f2fSdrahn /* Finit. */
2407d2201f2fSdrahn if (finisz)
2408d2201f2fSdrahn {
2409d2201f2fSdrahn memset (&syment, 0, sizeof (struct internal_syment));
2410d2201f2fSdrahn memset (&auxent, 0, sizeof (union internal_auxent));
2411d2201f2fSdrahn
2412d2201f2fSdrahn syment._n._n_n._n_offset = st_tmp - string_table;
2413d2201f2fSdrahn memcpy (st_tmp, fini, finisz);
2414d2201f2fSdrahn st_tmp += finisz;
2415d2201f2fSdrahn
2416d2201f2fSdrahn syment.n_sclass = C_EXT;
2417d2201f2fSdrahn syment.n_numaux = 1;
2418d2201f2fSdrahn bfd_coff_swap_sym_out (abfd, &syment,
2419d2201f2fSdrahn &syment_ext[filehdr.f_nsyms * SYMESZ]);
2420d2201f2fSdrahn bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2421d2201f2fSdrahn syment.n_numaux,
2422d2201f2fSdrahn &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2423d2201f2fSdrahn
2424d2201f2fSdrahn /* Reloc. */
2425d2201f2fSdrahn memset (&reloc, 0, sizeof (struct internal_reloc));
2426d2201f2fSdrahn reloc.r_vaddr = 0x0038;
2427d2201f2fSdrahn reloc.r_symndx = filehdr.f_nsyms;
2428d2201f2fSdrahn reloc.r_type = R_POS;
2429d2201f2fSdrahn reloc.r_size = 63;
2430d2201f2fSdrahn bfd_coff_swap_reloc_out (abfd, &reloc,
2431d2201f2fSdrahn &reloc_ext[data_scnhdr.s_nreloc * RELSZ]);
2432d2201f2fSdrahn
2433d2201f2fSdrahn filehdr.f_nsyms += 2;
2434d2201f2fSdrahn data_scnhdr.s_nreloc += 1;
2435d2201f2fSdrahn }
2436d2201f2fSdrahn
2437d2201f2fSdrahn if (rtld)
2438d2201f2fSdrahn {
2439d2201f2fSdrahn memset (&syment, 0, sizeof (struct internal_syment));
2440d2201f2fSdrahn memset (&auxent, 0, sizeof (union internal_auxent));
2441d2201f2fSdrahn
2442d2201f2fSdrahn syment._n._n_n._n_offset = st_tmp - string_table;
2443d2201f2fSdrahn memcpy (st_tmp, rtld_name, strlen (rtld_name));
2444d2201f2fSdrahn st_tmp += strlen (rtld_name) + 1;
2445d2201f2fSdrahn
2446d2201f2fSdrahn syment.n_sclass = C_EXT;
2447d2201f2fSdrahn syment.n_numaux = 1;
2448d2201f2fSdrahn bfd_coff_swap_sym_out (abfd, &syment,
2449d2201f2fSdrahn &syment_ext[filehdr.f_nsyms * SYMESZ]);
2450d2201f2fSdrahn bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
2451d2201f2fSdrahn syment.n_numaux,
2452d2201f2fSdrahn &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
2453d2201f2fSdrahn
2454d2201f2fSdrahn /* Reloc. */
2455d2201f2fSdrahn memset (&reloc, 0, sizeof (struct internal_reloc));
2456d2201f2fSdrahn reloc.r_vaddr = 0x0000;
2457d2201f2fSdrahn reloc.r_symndx = filehdr.f_nsyms;
2458d2201f2fSdrahn reloc.r_type = R_POS;
2459d2201f2fSdrahn reloc.r_size = 63;
2460d2201f2fSdrahn bfd_coff_swap_reloc_out (abfd, &reloc,
2461d2201f2fSdrahn &reloc_ext[data_scnhdr.s_nreloc * RELSZ]);
2462d2201f2fSdrahn
2463d2201f2fSdrahn filehdr.f_nsyms += 2;
2464d2201f2fSdrahn data_scnhdr.s_nreloc += 1;
2465d2201f2fSdrahn
2466d2201f2fSdrahn bss_scnhdr.s_size = 0;
2467d2201f2fSdrahn }
2468d2201f2fSdrahn
2469d2201f2fSdrahn data_scnhdr.s_relptr = data_scnhdr.s_scnptr + data_buffer_size;
2470d2201f2fSdrahn filehdr.f_symptr = data_scnhdr.s_relptr + data_scnhdr.s_nreloc * RELSZ;
2471d2201f2fSdrahn
2472d2201f2fSdrahn bfd_coff_swap_filehdr_out (abfd, &filehdr, filehdr_ext);
2473d2201f2fSdrahn bfd_bwrite (filehdr_ext, FILHSZ, abfd);
2474d2201f2fSdrahn bfd_coff_swap_scnhdr_out (abfd, &text_scnhdr, &scnhdr_ext[SCNHSZ * 0]);
2475d2201f2fSdrahn bfd_coff_swap_scnhdr_out (abfd, &data_scnhdr, &scnhdr_ext[SCNHSZ * 1]);
2476d2201f2fSdrahn bfd_coff_swap_scnhdr_out (abfd, &bss_scnhdr, &scnhdr_ext[SCNHSZ * 2]);
2477d2201f2fSdrahn bfd_bwrite (scnhdr_ext, 3 * SCNHSZ, abfd);
2478d2201f2fSdrahn bfd_bwrite (data_buffer, data_buffer_size, abfd);
2479d2201f2fSdrahn bfd_bwrite (reloc_ext, data_scnhdr.s_nreloc * RELSZ, abfd);
2480d2201f2fSdrahn bfd_bwrite (syment_ext, filehdr.f_nsyms * SYMESZ, abfd);
2481d2201f2fSdrahn bfd_bwrite (string_table, string_table_size, abfd);
2482d2201f2fSdrahn
2483d2201f2fSdrahn free (data_buffer);
2484d2201f2fSdrahn data_buffer = NULL;
2485d2201f2fSdrahn
2486d2201f2fSdrahn return TRUE;
2487d2201f2fSdrahn }
2488d2201f2fSdrahn
2489d2201f2fSdrahn /* The typical dynamic reloc. */
2490d2201f2fSdrahn
2491d2201f2fSdrahn static reloc_howto_type xcoff64_dynamic_reloc =
2492d2201f2fSdrahn HOWTO (0, /* type */
2493d2201f2fSdrahn 0, /* rightshift */
2494d2201f2fSdrahn 4, /* size (0 = byte, 1 = short, 2 = long) */
2495d2201f2fSdrahn 64, /* bitsize */
2496d2201f2fSdrahn FALSE, /* pc_relative */
2497d2201f2fSdrahn 0, /* bitpos */
2498d2201f2fSdrahn complain_overflow_bitfield, /* complain_on_overflow */
2499d2201f2fSdrahn 0, /* special_function */
2500d2201f2fSdrahn "R_POS", /* name */
2501d2201f2fSdrahn TRUE, /* partial_inplace */
2502d2201f2fSdrahn MINUS_ONE, /* src_mask */
2503d2201f2fSdrahn MINUS_ONE, /* dst_mask */
2504d2201f2fSdrahn FALSE); /* pcrel_offset */
2505d2201f2fSdrahn
2506d2201f2fSdrahn static unsigned long xcoff64_glink_code[10] =
2507d2201f2fSdrahn {
2508d2201f2fSdrahn 0xe9820000, /* ld r12,0(r2) */
2509d2201f2fSdrahn 0xf8410028, /* std r2,40(r1) */
2510d2201f2fSdrahn 0xe80c0000, /* ld r0,0(r12) */
2511d2201f2fSdrahn 0xe84c0008, /* ld r0,8(r12) */
2512d2201f2fSdrahn 0x7c0903a6, /* mtctr r0 */
2513d2201f2fSdrahn 0x4e800420, /* bctr */
2514d2201f2fSdrahn 0x00000000, /* start of traceback table */
2515d2201f2fSdrahn 0x000ca000, /* traceback table */
2516d2201f2fSdrahn 0x00000000, /* traceback table */
2517d2201f2fSdrahn 0x00000018, /* ??? */
2518d2201f2fSdrahn };
2519d2201f2fSdrahn
2520d2201f2fSdrahn static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
2521d2201f2fSdrahn {
2522d2201f2fSdrahn { /* COFF backend, defined in libcoff.h. */
2523d2201f2fSdrahn _bfd_xcoff64_swap_aux_in,
2524d2201f2fSdrahn _bfd_xcoff64_swap_sym_in,
2525d2201f2fSdrahn _bfd_xcoff64_swap_lineno_in,
2526d2201f2fSdrahn _bfd_xcoff64_swap_aux_out,
2527d2201f2fSdrahn _bfd_xcoff64_swap_sym_out,
2528d2201f2fSdrahn _bfd_xcoff64_swap_lineno_out,
2529d2201f2fSdrahn xcoff64_swap_reloc_out,
2530d2201f2fSdrahn coff_swap_filehdr_out,
2531d2201f2fSdrahn coff_swap_aouthdr_out,
2532d2201f2fSdrahn coff_swap_scnhdr_out,
2533d2201f2fSdrahn FILHSZ,
2534d2201f2fSdrahn AOUTSZ,
2535d2201f2fSdrahn SCNHSZ,
2536d2201f2fSdrahn SYMESZ,
2537d2201f2fSdrahn AUXESZ,
2538d2201f2fSdrahn RELSZ,
2539d2201f2fSdrahn LINESZ,
2540d2201f2fSdrahn FILNMLEN,
2541d2201f2fSdrahn TRUE, /* _bfd_coff_long_filenames */
2542d2201f2fSdrahn FALSE, /* _bfd_coff_long_section_names */
2543d2201f2fSdrahn 3, /* _bfd_coff_default_section_alignment_power */
2544d2201f2fSdrahn TRUE, /* _bfd_coff_force_symnames_in_strings */
2545d2201f2fSdrahn 4, /* _bfd_coff_debug_string_prefix_length */
2546d2201f2fSdrahn coff_swap_filehdr_in,
2547d2201f2fSdrahn coff_swap_aouthdr_in,
2548d2201f2fSdrahn coff_swap_scnhdr_in,
2549d2201f2fSdrahn xcoff64_swap_reloc_in,
2550d2201f2fSdrahn xcoff64_bad_format_hook,
2551d2201f2fSdrahn coff_set_arch_mach_hook,
2552d2201f2fSdrahn coff_mkobject_hook,
2553d2201f2fSdrahn styp_to_sec_flags,
2554d2201f2fSdrahn coff_set_alignment_hook,
2555d2201f2fSdrahn coff_slurp_symbol_table,
2556d2201f2fSdrahn symname_in_debug_hook,
2557d2201f2fSdrahn coff_pointerize_aux_hook,
2558d2201f2fSdrahn coff_print_aux,
2559d2201f2fSdrahn dummy_reloc16_extra_cases,
2560d2201f2fSdrahn dummy_reloc16_estimate,
2561d2201f2fSdrahn NULL, /* bfd_coff_sym_is_global */
2562d2201f2fSdrahn coff_compute_section_file_positions,
2563d2201f2fSdrahn NULL, /* _bfd_coff_start_final_link */
2564d2201f2fSdrahn xcoff64_ppc_relocate_section,
2565d2201f2fSdrahn coff_rtype_to_howto,
2566d2201f2fSdrahn NULL, /* _bfd_coff_adjust_symndx */
2567d2201f2fSdrahn _bfd_generic_link_add_one_symbol,
2568d2201f2fSdrahn coff_link_output_has_begun,
2569d2201f2fSdrahn coff_final_link_postscript
2570d2201f2fSdrahn },
2571d2201f2fSdrahn
2572d2201f2fSdrahn 0x01EF, /* magic number */
2573d2201f2fSdrahn bfd_arch_powerpc,
2574d2201f2fSdrahn bfd_mach_ppc_620,
2575d2201f2fSdrahn
2576d2201f2fSdrahn /* Function pointers to xcoff specific swap routines. */
2577d2201f2fSdrahn xcoff64_swap_ldhdr_in,
2578d2201f2fSdrahn xcoff64_swap_ldhdr_out,
2579d2201f2fSdrahn xcoff64_swap_ldsym_in,
2580d2201f2fSdrahn xcoff64_swap_ldsym_out,
2581d2201f2fSdrahn xcoff64_swap_ldrel_in,
2582d2201f2fSdrahn xcoff64_swap_ldrel_out,
2583d2201f2fSdrahn
2584d2201f2fSdrahn /* Sizes. */
2585d2201f2fSdrahn LDHDRSZ,
2586d2201f2fSdrahn LDSYMSZ,
2587d2201f2fSdrahn LDRELSZ,
2588d2201f2fSdrahn 24, /* _xcoff_function_descriptor_size */
2589d2201f2fSdrahn 0, /* _xcoff_small_aout_header_size */
2590d2201f2fSdrahn
2591d2201f2fSdrahn /* Versions. */
2592d2201f2fSdrahn 2, /* _xcoff_ldhdr_version */
2593d2201f2fSdrahn
2594d2201f2fSdrahn _bfd_xcoff64_put_symbol_name,
2595d2201f2fSdrahn _bfd_xcoff64_put_ldsymbol_name,
2596d2201f2fSdrahn &xcoff64_dynamic_reloc,
2597d2201f2fSdrahn xcoff64_create_csect_from_smclas,
2598d2201f2fSdrahn
2599d2201f2fSdrahn /* Lineno and reloc count overflow. */
2600d2201f2fSdrahn xcoff64_is_lineno_count_overflow,
2601d2201f2fSdrahn xcoff64_is_reloc_count_overflow,
2602d2201f2fSdrahn
2603d2201f2fSdrahn xcoff64_loader_symbol_offset,
2604d2201f2fSdrahn xcoff64_loader_reloc_offset,
2605d2201f2fSdrahn
2606d2201f2fSdrahn /* glink. */
2607d2201f2fSdrahn &xcoff64_glink_code[0],
2608d2201f2fSdrahn 40, /* _xcoff_glink_size */
2609d2201f2fSdrahn
2610d2201f2fSdrahn /* rtinit. */
2611d2201f2fSdrahn 88, /* _xcoff_rtinit_size */
2612d2201f2fSdrahn xcoff64_generate_rtinit,
2613d2201f2fSdrahn };
2614d2201f2fSdrahn
2615d2201f2fSdrahn /* The transfer vector that leads the outside world to all of the above. */
2616d2201f2fSdrahn const bfd_target rs6000coff64_vec =
2617d2201f2fSdrahn {
2618d2201f2fSdrahn "aixcoff64-rs6000",
2619d2201f2fSdrahn bfd_target_xcoff_flavour,
2620d2201f2fSdrahn BFD_ENDIAN_BIG, /* data byte order is big */
2621d2201f2fSdrahn BFD_ENDIAN_BIG, /* header byte order is big */
2622d2201f2fSdrahn
2623d2201f2fSdrahn (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC
2624d2201f2fSdrahn | HAS_SYMS | HAS_LOCALS | WP_TEXT),
2625d2201f2fSdrahn
2626d2201f2fSdrahn SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA,
2627d2201f2fSdrahn 0, /* leading char */
2628d2201f2fSdrahn '/', /* ar_pad_char */
2629d2201f2fSdrahn 15, /* ar_max_namelen */
2630d2201f2fSdrahn
2631d2201f2fSdrahn /* data */
2632d2201f2fSdrahn bfd_getb64,
2633d2201f2fSdrahn bfd_getb_signed_64,
2634d2201f2fSdrahn bfd_putb64,
2635d2201f2fSdrahn bfd_getb32,
2636d2201f2fSdrahn bfd_getb_signed_32,
2637d2201f2fSdrahn bfd_putb32,
2638d2201f2fSdrahn bfd_getb16,
2639d2201f2fSdrahn bfd_getb_signed_16,
2640d2201f2fSdrahn bfd_putb16,
2641d2201f2fSdrahn
2642d2201f2fSdrahn /* hdrs */
2643d2201f2fSdrahn bfd_getb64,
2644d2201f2fSdrahn bfd_getb_signed_64,
2645d2201f2fSdrahn bfd_putb64,
2646d2201f2fSdrahn bfd_getb32,
2647d2201f2fSdrahn bfd_getb_signed_32,
2648d2201f2fSdrahn bfd_putb32,
2649d2201f2fSdrahn bfd_getb16,
2650d2201f2fSdrahn bfd_getb_signed_16,
2651d2201f2fSdrahn bfd_putb16,
2652d2201f2fSdrahn
2653d2201f2fSdrahn { /* bfd_check_format */
2654d2201f2fSdrahn _bfd_dummy_target,
2655d2201f2fSdrahn coff_object_p,
2656d2201f2fSdrahn xcoff64_archive_p,
2657d2201f2fSdrahn CORE_FILE_P
2658d2201f2fSdrahn },
2659d2201f2fSdrahn
2660d2201f2fSdrahn { /* bfd_set_format */
2661d2201f2fSdrahn bfd_false,
2662d2201f2fSdrahn coff_mkobject,
2663d2201f2fSdrahn _bfd_generic_mkarchive,
2664d2201f2fSdrahn bfd_false
2665d2201f2fSdrahn },
2666d2201f2fSdrahn
2667d2201f2fSdrahn {/* bfd_write_contents */
2668d2201f2fSdrahn bfd_false,
2669d2201f2fSdrahn xcoff64_write_object_contents,
2670d2201f2fSdrahn _bfd_xcoff_write_archive_contents,
2671d2201f2fSdrahn bfd_false
2672d2201f2fSdrahn },
2673d2201f2fSdrahn
2674d2201f2fSdrahn /* Generic */
2675d2201f2fSdrahn bfd_true,
2676d2201f2fSdrahn bfd_true,
2677d2201f2fSdrahn coff_new_section_hook,
2678d2201f2fSdrahn _bfd_generic_get_section_contents,
2679d2201f2fSdrahn _bfd_generic_get_section_contents_in_window,
2680d2201f2fSdrahn
2681d2201f2fSdrahn /* Copy */
2682d2201f2fSdrahn _bfd_xcoff_copy_private_bfd_data,
2683d2201f2fSdrahn ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
2684d2201f2fSdrahn ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
2685d2201f2fSdrahn ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
2686d2201f2fSdrahn ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
2687d2201f2fSdrahn ((bfd_boolean (*) (bfd *, void * )) bfd_true),
2688d2201f2fSdrahn
2689d2201f2fSdrahn /* Core */
2690d2201f2fSdrahn coff_core_file_failing_command,
2691d2201f2fSdrahn coff_core_file_failing_signal,
2692d2201f2fSdrahn coff_core_file_matches_executable_p,
2693d2201f2fSdrahn
2694d2201f2fSdrahn /* Archive */
2695d2201f2fSdrahn xcoff64_slurp_armap,
2696d2201f2fSdrahn bfd_false,
2697d2201f2fSdrahn ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
2698d2201f2fSdrahn bfd_dont_truncate_arname,
2699d2201f2fSdrahn _bfd_xcoff_write_armap,
2700d2201f2fSdrahn _bfd_xcoff_read_ar_hdr,
2701d2201f2fSdrahn xcoff64_openr_next_archived_file,
2702d2201f2fSdrahn _bfd_generic_get_elt_at_index,
2703d2201f2fSdrahn _bfd_xcoff_stat_arch_elt,
2704d2201f2fSdrahn bfd_true,
2705d2201f2fSdrahn
2706d2201f2fSdrahn /* Symbols */
2707d2201f2fSdrahn coff_get_symtab_upper_bound,
2708*cf2f2c56Smiod coff_canonicalize_symtab,
2709d2201f2fSdrahn coff_make_empty_symbol,
2710d2201f2fSdrahn coff_print_symbol,
2711d2201f2fSdrahn coff_get_symbol_info,
2712d2201f2fSdrahn _bfd_xcoff_is_local_label_name,
2713d2201f2fSdrahn coff_get_lineno,
2714d2201f2fSdrahn coff_find_nearest_line,
2715d2201f2fSdrahn coff_bfd_make_debug_symbol,
2716d2201f2fSdrahn _bfd_generic_read_minisymbols,
2717d2201f2fSdrahn _bfd_generic_minisymbol_to_symbol,
2718d2201f2fSdrahn
2719d2201f2fSdrahn /* Reloc */
2720d2201f2fSdrahn coff_get_reloc_upper_bound,
2721d2201f2fSdrahn coff_canonicalize_reloc,
2722d2201f2fSdrahn xcoff64_reloc_type_lookup,
2723d2201f2fSdrahn
2724d2201f2fSdrahn /* Write */
2725d2201f2fSdrahn coff_set_arch_mach,
2726d2201f2fSdrahn coff_set_section_contents,
2727d2201f2fSdrahn
2728d2201f2fSdrahn /* Link */
2729d2201f2fSdrahn xcoff64_sizeof_headers,
2730d2201f2fSdrahn bfd_generic_get_relocated_section_contents,
2731d2201f2fSdrahn bfd_generic_relax_section,
2732d2201f2fSdrahn _bfd_xcoff_bfd_link_hash_table_create,
2733d2201f2fSdrahn _bfd_generic_link_hash_table_free,
2734d2201f2fSdrahn _bfd_xcoff_bfd_link_add_symbols,
2735d2201f2fSdrahn _bfd_generic_link_just_syms,
2736d2201f2fSdrahn _bfd_xcoff_bfd_final_link,
2737d2201f2fSdrahn _bfd_generic_link_split_section,
2738d2201f2fSdrahn bfd_generic_gc_sections,
2739d2201f2fSdrahn bfd_generic_merge_sections,
2740d2201f2fSdrahn bfd_generic_discard_group,
2741d2201f2fSdrahn
2742d2201f2fSdrahn /* Dynamic */
2743d2201f2fSdrahn _bfd_xcoff_get_dynamic_symtab_upper_bound,
2744d2201f2fSdrahn _bfd_xcoff_canonicalize_dynamic_symtab,
2745d2201f2fSdrahn _bfd_xcoff_get_dynamic_reloc_upper_bound,
2746d2201f2fSdrahn _bfd_xcoff_canonicalize_dynamic_reloc,
2747d2201f2fSdrahn
2748d2201f2fSdrahn /* Opposite endian version, none exists */
2749d2201f2fSdrahn NULL,
2750d2201f2fSdrahn
2751d2201f2fSdrahn (void *) &bfd_xcoff_backend_data,
2752d2201f2fSdrahn };
2753d2201f2fSdrahn
2754d2201f2fSdrahn extern const bfd_target *xcoff64_core_p
2755d2201f2fSdrahn PARAMS ((bfd *));
2756d2201f2fSdrahn extern bfd_boolean xcoff64_core_file_matches_executable_p
2757d2201f2fSdrahn PARAMS ((bfd *, bfd *));
2758d2201f2fSdrahn extern char *xcoff64_core_file_failing_command
2759d2201f2fSdrahn PARAMS ((bfd *));
2760d2201f2fSdrahn extern int xcoff64_core_file_failing_signal
2761d2201f2fSdrahn PARAMS ((bfd *));
2762d2201f2fSdrahn
2763d2201f2fSdrahn /* AIX 5 */
2764d2201f2fSdrahn static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data =
2765d2201f2fSdrahn {
2766d2201f2fSdrahn { /* COFF backend, defined in libcoff.h. */
2767d2201f2fSdrahn _bfd_xcoff64_swap_aux_in,
2768d2201f2fSdrahn _bfd_xcoff64_swap_sym_in,
2769d2201f2fSdrahn _bfd_xcoff64_swap_lineno_in,
2770d2201f2fSdrahn _bfd_xcoff64_swap_aux_out,
2771d2201f2fSdrahn _bfd_xcoff64_swap_sym_out,
2772d2201f2fSdrahn _bfd_xcoff64_swap_lineno_out,
2773d2201f2fSdrahn xcoff64_swap_reloc_out,
2774d2201f2fSdrahn coff_swap_filehdr_out,
2775d2201f2fSdrahn coff_swap_aouthdr_out,
2776d2201f2fSdrahn coff_swap_scnhdr_out,
2777d2201f2fSdrahn FILHSZ,
2778d2201f2fSdrahn AOUTSZ,
2779d2201f2fSdrahn SCNHSZ,
2780d2201f2fSdrahn SYMESZ,
2781d2201f2fSdrahn AUXESZ,
2782d2201f2fSdrahn RELSZ,
2783d2201f2fSdrahn LINESZ,
2784d2201f2fSdrahn FILNMLEN,
2785d2201f2fSdrahn TRUE, /* _bfd_coff_long_filenames */
2786d2201f2fSdrahn FALSE, /* _bfd_coff_long_section_names */
2787d2201f2fSdrahn 3, /* _bfd_coff_default_section_alignment_power */
2788d2201f2fSdrahn TRUE, /* _bfd_coff_force_symnames_in_strings */
2789d2201f2fSdrahn 4, /* _bfd_coff_debug_string_prefix_length */
2790d2201f2fSdrahn coff_swap_filehdr_in,
2791d2201f2fSdrahn coff_swap_aouthdr_in,
2792d2201f2fSdrahn coff_swap_scnhdr_in,
2793d2201f2fSdrahn xcoff64_swap_reloc_in,
2794d2201f2fSdrahn xcoff64_bad_format_hook,
2795d2201f2fSdrahn coff_set_arch_mach_hook,
2796d2201f2fSdrahn coff_mkobject_hook,
2797d2201f2fSdrahn styp_to_sec_flags,
2798d2201f2fSdrahn coff_set_alignment_hook,
2799d2201f2fSdrahn coff_slurp_symbol_table,
2800d2201f2fSdrahn symname_in_debug_hook,
2801d2201f2fSdrahn coff_pointerize_aux_hook,
2802d2201f2fSdrahn coff_print_aux,
2803d2201f2fSdrahn dummy_reloc16_extra_cases,
2804d2201f2fSdrahn dummy_reloc16_estimate,
2805d2201f2fSdrahn NULL, /* bfd_coff_sym_is_global */
2806d2201f2fSdrahn coff_compute_section_file_positions,
2807d2201f2fSdrahn NULL, /* _bfd_coff_start_final_link */
2808d2201f2fSdrahn xcoff64_ppc_relocate_section,
2809d2201f2fSdrahn coff_rtype_to_howto,
2810d2201f2fSdrahn NULL, /* _bfd_coff_adjust_symndx */
2811d2201f2fSdrahn _bfd_generic_link_add_one_symbol,
2812d2201f2fSdrahn coff_link_output_has_begun,
2813d2201f2fSdrahn coff_final_link_postscript
2814d2201f2fSdrahn },
2815d2201f2fSdrahn
2816d2201f2fSdrahn U64_TOCMAGIC, /* magic number */
2817d2201f2fSdrahn bfd_arch_powerpc,
2818d2201f2fSdrahn bfd_mach_ppc_620,
2819d2201f2fSdrahn
2820d2201f2fSdrahn /* Function pointers to xcoff specific swap routines. */
2821d2201f2fSdrahn xcoff64_swap_ldhdr_in,
2822d2201f2fSdrahn xcoff64_swap_ldhdr_out,
2823d2201f2fSdrahn xcoff64_swap_ldsym_in,
2824d2201f2fSdrahn xcoff64_swap_ldsym_out,
2825d2201f2fSdrahn xcoff64_swap_ldrel_in,
2826d2201f2fSdrahn xcoff64_swap_ldrel_out,
2827d2201f2fSdrahn
2828d2201f2fSdrahn /* Sizes. */
2829d2201f2fSdrahn LDHDRSZ,
2830d2201f2fSdrahn LDSYMSZ,
2831d2201f2fSdrahn LDRELSZ,
2832d2201f2fSdrahn 24, /* _xcoff_function_descriptor_size */
2833d2201f2fSdrahn 0, /* _xcoff_small_aout_header_size */
2834d2201f2fSdrahn /* Versions. */
2835d2201f2fSdrahn 2, /* _xcoff_ldhdr_version */
2836d2201f2fSdrahn
2837d2201f2fSdrahn _bfd_xcoff64_put_symbol_name,
2838d2201f2fSdrahn _bfd_xcoff64_put_ldsymbol_name,
2839d2201f2fSdrahn &xcoff64_dynamic_reloc,
2840d2201f2fSdrahn xcoff64_create_csect_from_smclas,
2841d2201f2fSdrahn
2842d2201f2fSdrahn /* Lineno and reloc count overflow. */
2843d2201f2fSdrahn xcoff64_is_lineno_count_overflow,
2844d2201f2fSdrahn xcoff64_is_reloc_count_overflow,
2845d2201f2fSdrahn
2846d2201f2fSdrahn xcoff64_loader_symbol_offset,
2847d2201f2fSdrahn xcoff64_loader_reloc_offset,
2848d2201f2fSdrahn
2849d2201f2fSdrahn /* glink. */
2850d2201f2fSdrahn &xcoff64_glink_code[0],
2851d2201f2fSdrahn 40, /* _xcoff_glink_size */
2852d2201f2fSdrahn
2853d2201f2fSdrahn /* rtinit. */
2854d2201f2fSdrahn 88, /* _xcoff_rtinit_size */
2855d2201f2fSdrahn xcoff64_generate_rtinit,
2856d2201f2fSdrahn };
2857d2201f2fSdrahn
2858d2201f2fSdrahn /* The transfer vector that leads the outside world to all of the above. */
2859d2201f2fSdrahn const bfd_target aix5coff64_vec =
2860d2201f2fSdrahn {
2861d2201f2fSdrahn "aix5coff64-rs6000",
2862d2201f2fSdrahn bfd_target_xcoff_flavour,
2863d2201f2fSdrahn BFD_ENDIAN_BIG, /* data byte order is big */
2864d2201f2fSdrahn BFD_ENDIAN_BIG, /* header byte order is big */
2865d2201f2fSdrahn
2866d2201f2fSdrahn (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC
2867d2201f2fSdrahn | HAS_SYMS | HAS_LOCALS | WP_TEXT),
2868d2201f2fSdrahn
2869d2201f2fSdrahn SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA,
2870d2201f2fSdrahn 0, /* leading char */
2871d2201f2fSdrahn '/', /* ar_pad_char */
2872d2201f2fSdrahn 15, /* ar_max_namelen */
2873d2201f2fSdrahn
2874d2201f2fSdrahn /* data */
2875d2201f2fSdrahn bfd_getb64,
2876d2201f2fSdrahn bfd_getb_signed_64,
2877d2201f2fSdrahn bfd_putb64,
2878d2201f2fSdrahn bfd_getb32,
2879d2201f2fSdrahn bfd_getb_signed_32,
2880d2201f2fSdrahn bfd_putb32,
2881d2201f2fSdrahn bfd_getb16,
2882d2201f2fSdrahn bfd_getb_signed_16,
2883d2201f2fSdrahn bfd_putb16,
2884d2201f2fSdrahn
2885d2201f2fSdrahn /* hdrs */
2886d2201f2fSdrahn bfd_getb64,
2887d2201f2fSdrahn bfd_getb_signed_64,
2888d2201f2fSdrahn bfd_putb64,
2889d2201f2fSdrahn bfd_getb32,
2890d2201f2fSdrahn bfd_getb_signed_32,
2891d2201f2fSdrahn bfd_putb32,
2892d2201f2fSdrahn bfd_getb16,
2893d2201f2fSdrahn bfd_getb_signed_16,
2894d2201f2fSdrahn bfd_putb16,
2895d2201f2fSdrahn
2896d2201f2fSdrahn { /* bfd_check_format */
2897d2201f2fSdrahn _bfd_dummy_target,
2898d2201f2fSdrahn coff_object_p,
2899d2201f2fSdrahn xcoff64_archive_p,
2900d2201f2fSdrahn xcoff64_core_p
2901d2201f2fSdrahn },
2902d2201f2fSdrahn
2903d2201f2fSdrahn { /* bfd_set_format */
2904d2201f2fSdrahn bfd_false,
2905d2201f2fSdrahn coff_mkobject,
2906d2201f2fSdrahn _bfd_generic_mkarchive,
2907d2201f2fSdrahn bfd_false
2908d2201f2fSdrahn },
2909d2201f2fSdrahn
2910d2201f2fSdrahn {/* bfd_write_contents */
2911d2201f2fSdrahn bfd_false,
2912d2201f2fSdrahn xcoff64_write_object_contents,
2913d2201f2fSdrahn _bfd_xcoff_write_archive_contents,
2914d2201f2fSdrahn bfd_false
2915d2201f2fSdrahn },
2916d2201f2fSdrahn
2917d2201f2fSdrahn /* Generic */
2918d2201f2fSdrahn bfd_true,
2919d2201f2fSdrahn bfd_true,
2920d2201f2fSdrahn coff_new_section_hook,
2921d2201f2fSdrahn _bfd_generic_get_section_contents,
2922d2201f2fSdrahn _bfd_generic_get_section_contents_in_window,
2923d2201f2fSdrahn
2924d2201f2fSdrahn /* Copy */
2925d2201f2fSdrahn _bfd_xcoff_copy_private_bfd_data,
2926d2201f2fSdrahn ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
2927d2201f2fSdrahn ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
2928d2201f2fSdrahn ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
2929d2201f2fSdrahn ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
2930d2201f2fSdrahn ((bfd_boolean (*) (bfd *, void * )) bfd_true),
2931d2201f2fSdrahn
2932d2201f2fSdrahn /* Core */
2933d2201f2fSdrahn xcoff64_core_file_failing_command,
2934d2201f2fSdrahn xcoff64_core_file_failing_signal,
2935d2201f2fSdrahn xcoff64_core_file_matches_executable_p,
2936d2201f2fSdrahn
2937d2201f2fSdrahn /* Archive */
2938d2201f2fSdrahn xcoff64_slurp_armap,
2939d2201f2fSdrahn bfd_false,
2940d2201f2fSdrahn ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
2941d2201f2fSdrahn bfd_dont_truncate_arname,
2942d2201f2fSdrahn _bfd_xcoff_write_armap,
2943d2201f2fSdrahn _bfd_xcoff_read_ar_hdr,
2944d2201f2fSdrahn xcoff64_openr_next_archived_file,
2945d2201f2fSdrahn _bfd_generic_get_elt_at_index,
2946d2201f2fSdrahn _bfd_xcoff_stat_arch_elt,
2947d2201f2fSdrahn bfd_true,
2948d2201f2fSdrahn
2949d2201f2fSdrahn /* Symbols */
2950d2201f2fSdrahn coff_get_symtab_upper_bound,
2951*cf2f2c56Smiod coff_canonicalize_symtab,
2952d2201f2fSdrahn coff_make_empty_symbol,
2953d2201f2fSdrahn coff_print_symbol,
2954d2201f2fSdrahn coff_get_symbol_info,
2955d2201f2fSdrahn _bfd_xcoff_is_local_label_name,
2956d2201f2fSdrahn coff_get_lineno,
2957d2201f2fSdrahn coff_find_nearest_line,
2958d2201f2fSdrahn coff_bfd_make_debug_symbol,
2959d2201f2fSdrahn _bfd_generic_read_minisymbols,
2960d2201f2fSdrahn _bfd_generic_minisymbol_to_symbol,
2961d2201f2fSdrahn
2962d2201f2fSdrahn /* Reloc */
2963d2201f2fSdrahn coff_get_reloc_upper_bound,
2964d2201f2fSdrahn coff_canonicalize_reloc,
2965d2201f2fSdrahn xcoff64_reloc_type_lookup,
2966d2201f2fSdrahn
2967d2201f2fSdrahn /* Write */
2968d2201f2fSdrahn coff_set_arch_mach,
2969d2201f2fSdrahn coff_set_section_contents,
2970d2201f2fSdrahn
2971d2201f2fSdrahn /* Link */
2972d2201f2fSdrahn xcoff64_sizeof_headers,
2973d2201f2fSdrahn bfd_generic_get_relocated_section_contents,
2974d2201f2fSdrahn bfd_generic_relax_section,
2975d2201f2fSdrahn _bfd_xcoff_bfd_link_hash_table_create,
2976d2201f2fSdrahn _bfd_generic_link_hash_table_free,
2977d2201f2fSdrahn _bfd_xcoff_bfd_link_add_symbols,
2978d2201f2fSdrahn _bfd_generic_link_just_syms,
2979d2201f2fSdrahn _bfd_xcoff_bfd_final_link,
2980d2201f2fSdrahn _bfd_generic_link_split_section,
2981d2201f2fSdrahn bfd_generic_gc_sections,
2982d2201f2fSdrahn bfd_generic_merge_sections,
2983d2201f2fSdrahn bfd_generic_discard_group,
2984d2201f2fSdrahn
2985d2201f2fSdrahn /* Dynamic */
2986d2201f2fSdrahn _bfd_xcoff_get_dynamic_symtab_upper_bound,
2987d2201f2fSdrahn _bfd_xcoff_canonicalize_dynamic_symtab,
2988d2201f2fSdrahn _bfd_xcoff_get_dynamic_reloc_upper_bound,
2989d2201f2fSdrahn _bfd_xcoff_canonicalize_dynamic_reloc,
2990d2201f2fSdrahn
2991d2201f2fSdrahn /* Opposite endian version, none exists. */
2992d2201f2fSdrahn NULL,
2993d2201f2fSdrahn
2994d2201f2fSdrahn (void *) & bfd_xcoff_aix5_backend_data,
2995d2201f2fSdrahn };
2996