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