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