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