]>
Commit | Line | Data |
---|---|---|
beb1bf64 | 1 | /* BFD XCOFF object file private structure. |
eb1e0e80 | 2 | Copyright (C) 2001, 2002 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 | ||
29 | struct 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. */ |
2a52da53 AM |
42 | void (* _xcoff_swap_ldhdr_in) |
43 | PARAMS ((bfd *, const PTR, struct internal_ldhdr *)); | |
44 | void (* _xcoff_swap_ldhdr_out) | |
45 | PARAMS ((bfd *, const struct internal_ldhdr *, PTR)); | |
46 | void (* _xcoff_swap_ldsym_in) | |
47 | PARAMS ((bfd *, const PTR, struct internal_ldsym *)); | |
48 | void (* _xcoff_swap_ldsym_out) | |
49 | PARAMS ((bfd *, const struct internal_ldsym *, PTR)); | |
50 | void (* _xcoff_swap_ldrel_in) | |
51 | PARAMS ((bfd *, const PTR, struct internal_ldrel *)); | |
52 | void (* _xcoff_swap_ldrel_out) | |
53 | PARAMS ((bfd *, const struct internal_ldrel *, PTR)); | |
beb1bf64 | 54 | |
eb1e0e80 | 55 | /* Size of the external struct. */ |
dc810e39 | 56 | unsigned int _xcoff_ldhdrsz; |
beb1bf64 TR |
57 | unsigned int _xcoff_ldsymsz; |
58 | unsigned int _xcoff_ldrelsz; | |
59 | ||
eb1e0e80 | 60 | /* Size an entry in a descriptor section. */ |
beb1bf64 TR |
61 | unsigned int _xcoff_function_descriptor_size; |
62 | ||
eb1e0e80 | 63 | /* Size of the small aout file header. */ |
beb1bf64 TR |
64 | unsigned int _xcoff_small_aout_header_size; |
65 | ||
330693f5 TR |
66 | /* Loader version |
67 | 1 : XCOFF32 | |
eb1e0e80 | 68 | 2 : XCOFF64. */ |
beb1bf64 TR |
69 | unsigned long _xcoff_ldhdr_version; |
70 | ||
eb1e0e80 | 71 | boolean (* _xcoff_put_symbol_name) |
2a52da53 AM |
72 | PARAMS ((bfd *, struct bfd_strtab_hash *, struct internal_syment *, |
73 | const char *)); | |
beb1bf64 | 74 | |
eb1e0e80 | 75 | boolean (* _xcoff_put_ldsymbol_name) |
2a52da53 AM |
76 | PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *, |
77 | const char *)); | |
beb1bf64 TR |
78 | |
79 | reloc_howto_type *_xcoff_dynamic_reloc; | |
80 | ||
eb1e0e80 | 81 | asection * (* _xcoff_create_csect_from_smclas) |
2a52da53 | 82 | PARAMS ((bfd *, union internal_auxent *, const char *)); |
beb1bf64 | 83 | |
330693f5 TR |
84 | /* Line number and relocation overflow. |
85 | XCOFF32 overflows to another section when the line number or the | |
86 | relocation count exceeds 0xffff. XCOFF64 does not overflow. */ | |
2a52da53 AM |
87 | boolean (*_xcoff_is_lineno_count_overflow) |
88 | PARAMS ((bfd *, bfd_vma)); | |
89 | boolean (*_xcoff_is_reloc_count_overflow) | |
90 | PARAMS ((bfd *, bfd_vma)); | |
beb1bf64 | 91 | |
330693f5 TR |
92 | /* Loader section symbol and relocation table offset |
93 | XCOFF32 is after the .loader header | |
eb1e0e80 | 94 | XCOFF64 is offset in .loader header. */ |
2a52da53 AM |
95 | bfd_vma (*_xcoff_loader_symbol_offset) |
96 | PARAMS ((bfd *, struct internal_ldhdr *)); | |
97 | bfd_vma (*_xcoff_loader_reloc_offset) | |
98 | PARAMS ((bfd *, struct internal_ldhdr *)); | |
330693f5 TR |
99 | |
100 | /* Global linkage. The first word of global linkage code must be be | |
101 | modified by filling in the correct TOC offset. */ | |
beb1bf64 | 102 | unsigned long *_xcoff_glink_code; |
330693f5 TR |
103 | |
104 | /* Size of the global link code in bytes of the xcoff_glink_code table. */ | |
beb1bf64 TR |
105 | unsigned long _xcoff_glink_size; |
106 | ||
eb1e0e80 | 107 | /* rtinit. */ |
9a4c7f16 | 108 | unsigned int _xcoff_rtinit_size; |
2a52da53 AM |
109 | boolean (*_xcoff_generate_rtinit) |
110 | PARAMS ((bfd *, const char *, const char *, boolean)); | |
beb1bf64 TR |
111 | }; |
112 | ||
113 | /* Look up an entry in an XCOFF link hash table. */ | |
beb1bf64 TR |
114 | #define xcoff_link_hash_lookup(table, string, create, copy, follow) \ |
115 | ((struct xcoff_link_hash_entry *) \ | |
116 | bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\ | |
117 | (follow))) | |
118 | ||
119 | /* Traverse an XCOFF link hash table. */ | |
beb1bf64 TR |
120 | #define xcoff_link_hash_traverse(table, func, info) \ |
121 | (bfd_link_hash_traverse \ | |
122 | (&(table)->root, \ | |
123 | (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ | |
124 | (info))) | |
125 | ||
126 | /* Get the XCOFF link hash table from the info structure. This is | |
127 | just a cast. */ | |
beb1bf64 TR |
128 | #define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash)) |
129 | ||
130 | ||
131 | #define xcoff_backend(abfd) \ | |
132 | ((struct xcoff_backend_data_rec *) (abfd)->xvec->backend_data) | |
133 | ||
134 | #define bfd_xcoff_magic_number(a) ((xcoff_backend(a)->_xcoff_magic_number)) | |
135 | #define bfd_xcoff_architecture(a) ((xcoff_backend(a)->_xcoff_architecture)) | |
136 | #define bfd_xcoff_machine(a) ((xcoff_backend(a)->_xcoff_machine)) | |
137 | ||
138 | #define bfd_xcoff_swap_ldhdr_in(a, b, c) \ | |
139 | ((xcoff_backend(a)->_xcoff_swap_ldhdr_in) ((a), (b), (c))) | |
140 | ||
141 | #define bfd_xcoff_swap_ldhdr_out(a, b, c) \ | |
142 | ((xcoff_backend(a)->_xcoff_swap_ldhdr_out) ((a), (b), (c))) | |
143 | ||
144 | #define bfd_xcoff_swap_ldsym_in(a, b, c) \ | |
145 | ((xcoff_backend(a)->_xcoff_swap_ldsym_in) ((a), (b), (c))) | |
146 | ||
147 | #define bfd_xcoff_swap_ldsym_out(a, b, c) \ | |
148 | ((xcoff_backend(a)->_xcoff_swap_ldsym_out) ((a), (b), (c))) | |
149 | ||
150 | #define bfd_xcoff_swap_ldrel_in(a, b, c) \ | |
151 | ((xcoff_backend(a)->_xcoff_swap_ldrel_in) ((a), (b), (c))) | |
152 | ||
153 | #define bfd_xcoff_swap_ldrel_out(a, b, c) \ | |
154 | ((xcoff_backend(a)->_xcoff_swap_ldrel_out) ((a), (b), (c))) | |
155 | ||
156 | #define bfd_xcoff_ldhdrsz(a) ((xcoff_backend(a)->_xcoff_ldhdrsz)) | |
157 | #define bfd_xcoff_ldsymsz(a) ((xcoff_backend(a)->_xcoff_ldsymsz)) | |
158 | #define bfd_xcoff_ldrelsz(a) ((xcoff_backend(a)->_xcoff_ldrelsz)) | |
159 | #define bfd_xcoff_function_descriptor_size(a) \ | |
160 | ((xcoff_backend(a)->_xcoff_function_descriptor_size)) | |
161 | #define bfd_xcoff_small_aout_header_size(a) \ | |
162 | ((xcoff_backend(a)->_xcoff_small_aout_header_size)) | |
163 | ||
164 | #define bfd_xcoff_ldhdr_version(a) ((xcoff_backend(a)->_xcoff_ldhdr_version)) | |
165 | ||
166 | #define bfd_xcoff_put_symbol_name(a, b, c, d) \ | |
167 | ((xcoff_backend(a)->_xcoff_put_symbol_name) ((a), (b), (c), (d))) | |
168 | ||
169 | #define bfd_xcoff_put_ldsymbol_name(a, b, c, d) \ | |
170 | ((xcoff_backend(a)->_xcoff_put_ldsymbol_name) ((a), (b), (c), (d))) | |
171 | ||
172 | /* Get the XCOFF hash table entries for a BFD. */ | |
173 | #define obj_xcoff_sym_hashes(bfd) \ | |
174 | ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd)) | |
175 | ||
176 | #define bfd_xcoff_dynamic_reloc_howto(a) \ | |
177 | ((xcoff_backend(a)->_xcoff_dynamic_reloc)) | |
178 | ||
179 | #define bfd_xcoff_create_csect_from_smclas(a, b, c) \ | |
180 | ((xcoff_backend(a)->_xcoff_create_csect_from_smclas((a), (b), (c)))) | |
181 | ||
182 | #define bfd_xcoff_is_lineno_count_overflow(a, b) \ | |
183 | ((xcoff_backend(a)->_xcoff_is_lineno_count_overflow((a), (b)))) | |
184 | ||
185 | #define bfd_xcoff_is_reloc_count_overflow(a, b) \ | |
186 | ((xcoff_backend(a)->_xcoff_is_reloc_count_overflow((a), (b)))) | |
187 | ||
188 | #define bfd_xcoff_loader_symbol_offset(a, b) \ | |
189 | ((xcoff_backend(a)->_xcoff_loader_symbol_offset((a), (b)))) | |
190 | ||
191 | #define bfd_xcoff_loader_reloc_offset(a, b) \ | |
192 | ((xcoff_backend(a)->_xcoff_loader_reloc_offset((a), (b)))) | |
193 | ||
194 | #define bfd_xcoff_glink_code(a, b) ((xcoff_backend(a)->_xcoff_glink_code[(b)])) | |
195 | #define bfd_xcoff_glink_code_size(a) ((xcoff_backend(a)->_xcoff_glink_size)) | |
196 | ||
eb1e0e80 NC |
197 | /* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit |
198 | targets. */ | |
199 | #define bfd_xcoff_is_xcoff64(a) \ | |
200 | ( (0x01EF == (bfd_xcoff_magic_number(a))) \ | |
201 | || (0x01F7 == (bfd_xcoff_magic_number(a)))) | |
9a4c7f16 TR |
202 | |
203 | /* Check for the magic number U802TOMAGIC for 32 bit targets. */ | |
beb1bf64 TR |
204 | #define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number(a))) |
205 | ||
9a4c7f16 | 206 | #define bfd_xcoff_rtinit_size(a) ((xcoff_backend(a)->_xcoff_rtinit_size)) |
69f284c7 | 207 | #define bfd_xcoff_generate_rtinit(a, b, c, d) ((xcoff_backend(a)->_xcoff_generate_rtinit ((a), (b), (c), (d)))) |
9a4c7f16 | 208 | |
eb1e0e80 NC |
209 | /* Accessor macros for tdata. */ |
210 | #define bfd_xcoff_text_align_power(a) ((xcoff_data (a)->text_align_power)) | |
211 | #define bfd_xcoff_data_align_power(a) ((xcoff_data (a)->data_align_power)) | |
212 | ||
dbe341c6 TR |
213 | /* xcoff*_ppc_relocate_section macros */ |
214 | #define XCOFF_MAX_CALCULATE_RELOCATION (0x1c) | |
215 | #define XCOFF_MAX_COMPLAIN_OVERFLOW (4) | |
216 | /* N_ONES produces N one bits, without overflowing machine arithmetic. */ | |
217 | #ifdef N_ONES | |
218 | #undef N_ONES | |
219 | #endif | |
220 | #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1) | |
221 | ||
222 | #define XCOFF_RELOC_FUNCTION_ARGS \ | |
223 | bfd *, asection *, bfd *, struct internal_reloc *, \ | |
224 | struct internal_syment *, struct reloc_howto_struct *, bfd_vma, bfd_vma, \ | |
225 | bfd_vma *relocation, bfd_byte *contents | |
226 | ||
227 | #define XCOFF_COMPLAIN_FUNCTION_ARGS \ | |
228 | bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *howto | |
229 | ||
230 | extern boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION]) | |
2a52da53 | 231 | PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); |
dbe341c6 | 232 | extern boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW]) |
2a52da53 | 233 | PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS)); |
dbe341c6 | 234 | |
f1f0d9ab TR |
235 | /* Relocation functions */ |
236 | boolean xcoff_reloc_type_noop PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); | |
237 | boolean xcoff_reloc_type_fail PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); | |
238 | boolean xcoff_reloc_type_pos PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); | |
239 | boolean xcoff_reloc_type_neg PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); | |
240 | boolean xcoff_reloc_type_rel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); | |
241 | boolean xcoff_reloc_type_toc PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); | |
242 | boolean xcoff_reloc_type_ba PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); | |
243 | boolean xcoff_reloc_type_crel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)); | |
244 | ||
beb1bf64 | 245 | #endif /* LIBXCOFF_H */ |