Update to ISO-C90 and fix formatting
[deliverable/binutils-gdb.git] / bfd / libxcoff.h
CommitLineData
beb1bf64 1/* BFD XCOFF object file private structure.
7920ce38 2 Copyright 2001, 2002, 2005 Free Software Foundation, Inc.
beb1bf64
TR
3 Written by Tom Rix, Redhat.
4
eb1e0e80 5 This file is part of BFD, the Binary File Descriptor library.
beb1bf64 6
eb1e0e80
NC
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
beb1bf64 11
eb1e0e80
NC
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
beb1bf64 16
eb1e0e80
NC
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
beb1bf64
TR
20
21#ifndef LIBXCOFF_H
22#define LIBXCOFF_H
23
24/* This is the backend information kept for XCOFF files. This
25 structure is constant for a particular backend. The first element
26 is the COFF backend data structure, so that XCOFF targets can use
27 the generic COFF code. */
28
29struct xcoff_backend_data_rec
30{
330693f5 31 /* COFF backend information. */
beb1bf64
TR
32 bfd_coff_backend_data coff;
33
eb1e0e80 34 /* Magic number. */
dc810e39 35 unsigned short _xcoff_magic_number;
beb1bf64 36
eb1e0e80 37 /* Architecture and machine for coff_set_arch_mach_hook. */
beb1bf64
TR
38 enum bfd_architecture _xcoff_architecture;
39 long _xcoff_machine;
40
eb1e0e80 41 /* Function pointers to xcoff specific swap routines. */
7920ce38
NC
42 void (* _xcoff_swap_ldhdr_in) (bfd *, const void *, struct internal_ldhdr *);
43 void (* _xcoff_swap_ldhdr_out)(bfd *, const struct internal_ldhdr *, void *);
44 void (* _xcoff_swap_ldsym_in) (bfd *, const void *, struct internal_ldsym *);
45 void (* _xcoff_swap_ldsym_out)(bfd *, const struct internal_ldsym *, void *);
46 void (* _xcoff_swap_ldrel_in) (bfd *, const void *, struct internal_ldrel *);
47 void (* _xcoff_swap_ldrel_out)(bfd *, const struct internal_ldrel *, void *);
beb1bf64 48
eb1e0e80 49 /* Size of the external struct. */
dc810e39 50 unsigned int _xcoff_ldhdrsz;
beb1bf64
TR
51 unsigned int _xcoff_ldsymsz;
52 unsigned int _xcoff_ldrelsz;
53
eb1e0e80 54 /* Size an entry in a descriptor section. */
beb1bf64
TR
55 unsigned int _xcoff_function_descriptor_size;
56
eb1e0e80 57 /* Size of the small aout file header. */
beb1bf64
TR
58 unsigned int _xcoff_small_aout_header_size;
59
330693f5
TR
60 /* Loader version
61 1 : XCOFF32
eb1e0e80 62 2 : XCOFF64. */
beb1bf64
TR
63 unsigned long _xcoff_ldhdr_version;
64
b34976b6 65 bfd_boolean (* _xcoff_put_symbol_name)
7920ce38
NC
66 (bfd *, struct bfd_strtab_hash *, struct internal_syment *,
67 const char *);
beb1bf64 68
b34976b6 69 bfd_boolean (* _xcoff_put_ldsymbol_name)
7920ce38
NC
70 (bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
71 const char *);
beb1bf64
TR
72
73 reloc_howto_type *_xcoff_dynamic_reloc;
74
eb1e0e80 75 asection * (* _xcoff_create_csect_from_smclas)
7920ce38 76 (bfd *, union internal_auxent *, const char *);
beb1bf64 77
330693f5
TR
78 /* Line number and relocation overflow.
79 XCOFF32 overflows to another section when the line number or the
80 relocation count exceeds 0xffff. XCOFF64 does not overflow. */
7920ce38
NC
81 bfd_boolean (*_xcoff_is_lineno_count_overflow) (bfd *, bfd_vma);
82 bfd_boolean (*_xcoff_is_reloc_count_overflow) (bfd *, bfd_vma);
beb1bf64 83
330693f5
TR
84 /* Loader section symbol and relocation table offset
85 XCOFF32 is after the .loader header
eb1e0e80 86 XCOFF64 is offset in .loader header. */
7920ce38
NC
87 bfd_vma (*_xcoff_loader_symbol_offset) (bfd *, struct internal_ldhdr *);
88 bfd_vma (*_xcoff_loader_reloc_offset) (bfd *, struct internal_ldhdr *);
330693f5
TR
89
90 /* Global linkage. The first word of global linkage code must be be
91 modified by filling in the correct TOC offset. */
beb1bf64 92 unsigned long *_xcoff_glink_code;
330693f5
TR
93
94 /* Size of the global link code in bytes of the xcoff_glink_code table. */
beb1bf64
TR
95 unsigned long _xcoff_glink_size;
96
eb1e0e80 97 /* rtinit. */
9a4c7f16 98 unsigned int _xcoff_rtinit_size;
b34976b6 99 bfd_boolean (*_xcoff_generate_rtinit)
7920ce38 100 (bfd *, const char *, const char *, bfd_boolean);
beb1bf64
TR
101};
102
103/* Look up an entry in an XCOFF link hash table. */
beb1bf64
TR
104#define xcoff_link_hash_lookup(table, string, create, copy, follow) \
105 ((struct xcoff_link_hash_entry *) \
106 bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\
107 (follow)))
108
109/* Traverse an XCOFF link hash table. */
beb1bf64
TR
110#define xcoff_link_hash_traverse(table, func, info) \
111 (bfd_link_hash_traverse \
112 (&(table)->root, \
7920ce38 113 (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func), \
beb1bf64
TR
114 (info)))
115
116/* Get the XCOFF link hash table from the info structure. This is
117 just a cast. */
beb1bf64
TR
118#define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash))
119
120
121#define xcoff_backend(abfd) \
122 ((struct xcoff_backend_data_rec *) (abfd)->xvec->backend_data)
123
7920ce38
NC
124#define bfd_xcoff_magic_number(a) ((xcoff_backend (a)->_xcoff_magic_number))
125#define bfd_xcoff_architecture(a) ((xcoff_backend (a)->_xcoff_architecture))
126#define bfd_xcoff_machine(a) ((xcoff_backend (a)->_xcoff_machine))
beb1bf64
TR
127
128#define bfd_xcoff_swap_ldhdr_in(a, b, c) \
7920ce38 129 ((xcoff_backend (a)->_xcoff_swap_ldhdr_in) ((a), (b), (c)))
beb1bf64
TR
130
131#define bfd_xcoff_swap_ldhdr_out(a, b, c) \
7920ce38 132 ((xcoff_backend (a)->_xcoff_swap_ldhdr_out) ((a), (b), (c)))
beb1bf64
TR
133
134#define bfd_xcoff_swap_ldsym_in(a, b, c) \
7920ce38 135 ((xcoff_backend (a)->_xcoff_swap_ldsym_in) ((a), (b), (c)))
beb1bf64
TR
136
137#define bfd_xcoff_swap_ldsym_out(a, b, c) \
7920ce38 138 ((xcoff_backend (a)->_xcoff_swap_ldsym_out) ((a), (b), (c)))
beb1bf64
TR
139
140#define bfd_xcoff_swap_ldrel_in(a, b, c) \
7920ce38 141 ((xcoff_backend (a)->_xcoff_swap_ldrel_in) ((a), (b), (c)))
beb1bf64
TR
142
143#define bfd_xcoff_swap_ldrel_out(a, b, c) \
7920ce38 144 ((xcoff_backend (a)->_xcoff_swap_ldrel_out) ((a), (b), (c)))
beb1bf64 145
7920ce38
NC
146#define bfd_xcoff_ldhdrsz(a) ((xcoff_backend (a)->_xcoff_ldhdrsz))
147#define bfd_xcoff_ldsymsz(a) ((xcoff_backend (a)->_xcoff_ldsymsz))
148#define bfd_xcoff_ldrelsz(a) ((xcoff_backend (a)->_xcoff_ldrelsz))
beb1bf64 149#define bfd_xcoff_function_descriptor_size(a) \
7920ce38 150 ((xcoff_backend (a)->_xcoff_function_descriptor_size))
beb1bf64 151#define bfd_xcoff_small_aout_header_size(a) \
7920ce38 152 ((xcoff_backend (a)->_xcoff_small_aout_header_size))
beb1bf64 153
7920ce38 154#define bfd_xcoff_ldhdr_version(a) ((xcoff_backend (a)->_xcoff_ldhdr_version))
beb1bf64
TR
155
156#define bfd_xcoff_put_symbol_name(a, b, c, d) \
7920ce38 157 ((xcoff_backend (a)->_xcoff_put_symbol_name) ((a), (b), (c), (d)))
beb1bf64
TR
158
159#define bfd_xcoff_put_ldsymbol_name(a, b, c, d) \
7920ce38 160 ((xcoff_backend (a)->_xcoff_put_ldsymbol_name) ((a), (b), (c), (d)))
beb1bf64
TR
161
162/* Get the XCOFF hash table entries for a BFD. */
163#define obj_xcoff_sym_hashes(bfd) \
164 ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd))
165
166#define bfd_xcoff_dynamic_reloc_howto(a) \
7920ce38 167 ((xcoff_backend (a)->_xcoff_dynamic_reloc))
beb1bf64
TR
168
169#define bfd_xcoff_create_csect_from_smclas(a, b, c) \
7920ce38 170 ((xcoff_backend (a)->_xcoff_create_csect_from_smclas((a), (b), (c))))
beb1bf64
TR
171
172#define bfd_xcoff_is_lineno_count_overflow(a, b) \
7920ce38 173 ((xcoff_backend (a)->_xcoff_is_lineno_count_overflow((a), (b))))
beb1bf64
TR
174
175#define bfd_xcoff_is_reloc_count_overflow(a, b) \
7920ce38 176 ((xcoff_backend (a)->_xcoff_is_reloc_count_overflow((a), (b))))
beb1bf64
TR
177
178#define bfd_xcoff_loader_symbol_offset(a, b) \
7920ce38 179 ((xcoff_backend (a)->_xcoff_loader_symbol_offset((a), (b))))
beb1bf64
TR
180
181#define bfd_xcoff_loader_reloc_offset(a, b) \
7920ce38 182 ((xcoff_backend (a)->_xcoff_loader_reloc_offset((a), (b))))
beb1bf64 183
7920ce38
NC
184#define bfd_xcoff_glink_code(a, b) ((xcoff_backend (a)->_xcoff_glink_code[(b)]))
185#define bfd_xcoff_glink_code_size(a) ((xcoff_backend (a)->_xcoff_glink_size))
beb1bf64 186
eb1e0e80
NC
187/* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit
188 targets. */
189#define bfd_xcoff_is_xcoff64(a) \
7920ce38
NC
190 ( (0x01EF == (bfd_xcoff_magic_number (a))) \
191 || (0x01F7 == (bfd_xcoff_magic_number (a))))
9a4c7f16
TR
192
193/* Check for the magic number U802TOMAGIC for 32 bit targets. */
7920ce38 194#define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number (a)))
beb1bf64 195
7920ce38
NC
196#define bfd_xcoff_rtinit_size(a) ((xcoff_backend (a)->_xcoff_rtinit_size))
197#define bfd_xcoff_generate_rtinit(a, b, c, d) ((xcoff_backend (a)->_xcoff_generate_rtinit ((a), (b), (c), (d))))
9a4c7f16 198
eb1e0e80
NC
199/* Accessor macros for tdata. */
200#define bfd_xcoff_text_align_power(a) ((xcoff_data (a)->text_align_power))
201#define bfd_xcoff_data_align_power(a) ((xcoff_data (a)->data_align_power))
202
dbe341c6
TR
203/* xcoff*_ppc_relocate_section macros */
204#define XCOFF_MAX_CALCULATE_RELOCATION (0x1c)
205#define XCOFF_MAX_COMPLAIN_OVERFLOW (4)
206/* N_ONES produces N one bits, without overflowing machine arithmetic. */
207#ifdef N_ONES
208#undef N_ONES
209#endif
210#define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
211
212#define XCOFF_RELOC_FUNCTION_ARGS \
213 bfd *, asection *, bfd *, struct internal_reloc *, \
214 struct internal_syment *, struct reloc_howto_struct *, bfd_vma, bfd_vma, \
215 bfd_vma *relocation, bfd_byte *contents
216
217#define XCOFF_COMPLAIN_FUNCTION_ARGS \
218 bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *howto
219
b34976b6 220extern bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
7920ce38 221 (XCOFF_RELOC_FUNCTION_ARGS);
b34976b6 222extern bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
7920ce38 223 (XCOFF_COMPLAIN_FUNCTION_ARGS);
dbe341c6 224
f1f0d9ab 225/* Relocation functions */
7920ce38
NC
226bfd_boolean xcoff_reloc_type_noop (XCOFF_RELOC_FUNCTION_ARGS);
227bfd_boolean xcoff_reloc_type_fail (XCOFF_RELOC_FUNCTION_ARGS);
228bfd_boolean xcoff_reloc_type_pos (XCOFF_RELOC_FUNCTION_ARGS);
229bfd_boolean xcoff_reloc_type_neg (XCOFF_RELOC_FUNCTION_ARGS);
230bfd_boolean xcoff_reloc_type_rel (XCOFF_RELOC_FUNCTION_ARGS);
231bfd_boolean xcoff_reloc_type_toc (XCOFF_RELOC_FUNCTION_ARGS);
232bfd_boolean xcoff_reloc_type_ba (XCOFF_RELOC_FUNCTION_ARGS);
233bfd_boolean xcoff_reloc_type_crel (XCOFF_RELOC_FUNCTION_ARGS);
f1f0d9ab 234
beb1bf64 235#endif /* LIBXCOFF_H */
This page took 0.26429 seconds and 4 git commands to generate.