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