Commit | Line | Data |
---|---|---|
beb1bf64 TR |
1 | /* BFD XCOFF object file private structure. |
2 | Copyright (C) 2001 Free Software Foundation, Inc. | |
3 | Written by Tom Rix, Redhat. | |
4 | ||
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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. */ | |
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 | { | |
dc810e39 AM |
31 | /* |
32 | * COFF backend information. Must be the first field. | |
beb1bf64 TR |
33 | * This is where the std coff swap table goes |
34 | */ | |
35 | bfd_coff_backend_data coff; | |
36 | ||
37 | /* Magic number */ | |
dc810e39 | 38 | unsigned short _xcoff_magic_number; |
beb1bf64 TR |
39 | |
40 | /* Architecture and machine for coff_set_arch_mach_hook */ | |
41 | enum bfd_architecture _xcoff_architecture; | |
42 | long _xcoff_machine; | |
43 | ||
44 | /* function pointers to xcoff specific swap routines */ | |
814fa6ab AM |
45 | void (* _xcoff_swap_ldhdr_in)(bfd *, const PTR, struct internal_ldhdr *); |
46 | void (* _xcoff_swap_ldhdr_out)(bfd *, const struct internal_ldhdr *, PTR); | |
47 | void (* _xcoff_swap_ldsym_in)(bfd *, const PTR, struct internal_ldsym *); | |
48 | void (* _xcoff_swap_ldsym_out)(bfd *, const struct internal_ldsym *, PTR); | |
49 | void (* _xcoff_swap_ldrel_in)(bfd *, const PTR, struct internal_ldrel *); | |
50 | void (* _xcoff_swap_ldrel_out)(bfd *, const struct internal_ldrel *, PTR); | |
beb1bf64 | 51 | |
08da05b0 | 52 | /* size of the external struct */ |
dc810e39 | 53 | unsigned int _xcoff_ldhdrsz; |
beb1bf64 TR |
54 | unsigned int _xcoff_ldsymsz; |
55 | unsigned int _xcoff_ldrelsz; | |
56 | ||
57 | /* size an entry in a descriptor section */ | |
58 | unsigned int _xcoff_function_descriptor_size; | |
59 | ||
60 | /* size of the small aout file header */ | |
61 | unsigned int _xcoff_small_aout_header_size; | |
62 | ||
dc810e39 AM |
63 | /* |
64 | * version | |
65 | * loader version | |
beb1bf64 TR |
66 | * 1 : xcoff32 |
67 | * 2 : xcoff64 | |
68 | */ | |
69 | unsigned long _xcoff_ldhdr_version; | |
70 | ||
71 | boolean (* _xcoff_put_symbol_name)(bfd *, struct bfd_strtab_hash *, | |
72 | struct internal_syment *, | |
73 | const char *); | |
74 | ||
dc810e39 | 75 | boolean (* _xcoff_put_ldsymbol_name)(bfd *, struct xcoff_loader_info *, |
beb1bf64 TR |
76 | struct internal_ldsym *, |
77 | const char *); | |
78 | ||
79 | reloc_howto_type *_xcoff_dynamic_reloc; | |
80 | ||
81 | asection * (* _xcoff_create_csect_from_smclas) (bfd *, union internal_auxent *, const char *); | |
82 | ||
dc810e39 AM |
83 | /* |
84 | * line_no and reloc overflow | |
beb1bf64 | 85 | * 32 overflows to another section when the line_no or reloc count go |
dc810e39 | 86 | * over 0xffff. 64 does not overflow. |
beb1bf64 TR |
87 | */ |
88 | boolean (*_xcoff_is_lineno_count_overflow)(bfd *, bfd_vma); | |
89 | boolean (*_xcoff_is_reloc_count_overflow)(bfd *, bfd_vma); | |
90 | ||
dc810e39 | 91 | /* |
beb1bf64 TR |
92 | * .loader symbol table offset |
93 | * 32 is after the .loader header | |
94 | * 64 is offset in .loader header | |
dc810e39 | 95 | * |
beb1bf64 TR |
96 | * Similar for the reloc table |
97 | */ | |
98 | bfd_vma (*_xcoff_loader_symbol_offset)(bfd *, struct internal_ldhdr *); | |
99 | bfd_vma (*_xcoff_loader_reloc_offset)(bfd *, struct internal_ldhdr *); | |
100 | ||
101 | ||
dc810e39 AM |
102 | /* |
103 | * Global linkage | |
104 | * | |
beb1bf64 | 105 | * The first word of global linkage code must be be modified by |
dc810e39 | 106 | * filling in the correct TOC offset. |
beb1bf64 TR |
107 | */ |
108 | unsigned long *_xcoff_glink_code; | |
109 | ||
dc810e39 | 110 | /* |
beb1bf64 TR |
111 | * Size of the global link code in bytes of the xcoff_glink_code table |
112 | */ | |
113 | unsigned long _xcoff_glink_size; | |
114 | ||
9a4c7f16 TR |
115 | /* rtinit */ |
116 | unsigned int _xcoff_rtinit_size; | |
117 | boolean (*_xcoff_generate_rtinit)(bfd *, const char *, const char *); | |
beb1bf64 TR |
118 | }; |
119 | ||
120 | /* Look up an entry in an XCOFF link hash table. */ | |
121 | ||
122 | #define xcoff_link_hash_lookup(table, string, create, copy, follow) \ | |
123 | ((struct xcoff_link_hash_entry *) \ | |
124 | bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\ | |
125 | (follow))) | |
126 | ||
127 | /* Traverse an XCOFF link hash table. */ | |
128 | ||
129 | #define xcoff_link_hash_traverse(table, func, info) \ | |
130 | (bfd_link_hash_traverse \ | |
131 | (&(table)->root, \ | |
132 | (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ | |
133 | (info))) | |
134 | ||
135 | /* Get the XCOFF link hash table from the info structure. This is | |
136 | just a cast. */ | |
137 | ||
138 | #define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash)) | |
139 | ||
140 | ||
141 | #define xcoff_backend(abfd) \ | |
142 | ((struct xcoff_backend_data_rec *) (abfd)->xvec->backend_data) | |
143 | ||
144 | #define bfd_xcoff_magic_number(a) ((xcoff_backend(a)->_xcoff_magic_number)) | |
145 | #define bfd_xcoff_architecture(a) ((xcoff_backend(a)->_xcoff_architecture)) | |
146 | #define bfd_xcoff_machine(a) ((xcoff_backend(a)->_xcoff_machine)) | |
147 | ||
148 | #define bfd_xcoff_swap_ldhdr_in(a, b, c) \ | |
149 | ((xcoff_backend(a)->_xcoff_swap_ldhdr_in) ((a), (b), (c))) | |
150 | ||
151 | #define bfd_xcoff_swap_ldhdr_out(a, b, c) \ | |
152 | ((xcoff_backend(a)->_xcoff_swap_ldhdr_out) ((a), (b), (c))) | |
153 | ||
154 | #define bfd_xcoff_swap_ldsym_in(a, b, c) \ | |
155 | ((xcoff_backend(a)->_xcoff_swap_ldsym_in) ((a), (b), (c))) | |
156 | ||
157 | #define bfd_xcoff_swap_ldsym_out(a, b, c) \ | |
158 | ((xcoff_backend(a)->_xcoff_swap_ldsym_out) ((a), (b), (c))) | |
159 | ||
160 | #define bfd_xcoff_swap_ldrel_in(a, b, c) \ | |
161 | ((xcoff_backend(a)->_xcoff_swap_ldrel_in) ((a), (b), (c))) | |
162 | ||
163 | #define bfd_xcoff_swap_ldrel_out(a, b, c) \ | |
164 | ((xcoff_backend(a)->_xcoff_swap_ldrel_out) ((a), (b), (c))) | |
165 | ||
166 | #define bfd_xcoff_ldhdrsz(a) ((xcoff_backend(a)->_xcoff_ldhdrsz)) | |
167 | #define bfd_xcoff_ldsymsz(a) ((xcoff_backend(a)->_xcoff_ldsymsz)) | |
168 | #define bfd_xcoff_ldrelsz(a) ((xcoff_backend(a)->_xcoff_ldrelsz)) | |
169 | #define bfd_xcoff_function_descriptor_size(a) \ | |
170 | ((xcoff_backend(a)->_xcoff_function_descriptor_size)) | |
171 | #define bfd_xcoff_small_aout_header_size(a) \ | |
172 | ((xcoff_backend(a)->_xcoff_small_aout_header_size)) | |
173 | ||
174 | #define bfd_xcoff_ldhdr_version(a) ((xcoff_backend(a)->_xcoff_ldhdr_version)) | |
175 | ||
176 | #define bfd_xcoff_put_symbol_name(a, b, c, d) \ | |
177 | ((xcoff_backend(a)->_xcoff_put_symbol_name) ((a), (b), (c), (d))) | |
178 | ||
179 | #define bfd_xcoff_put_ldsymbol_name(a, b, c, d) \ | |
180 | ((xcoff_backend(a)->_xcoff_put_ldsymbol_name) ((a), (b), (c), (d))) | |
181 | ||
182 | /* Get the XCOFF hash table entries for a BFD. */ | |
183 | #define obj_xcoff_sym_hashes(bfd) \ | |
184 | ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd)) | |
185 | ||
186 | #define bfd_xcoff_dynamic_reloc_howto(a) \ | |
187 | ((xcoff_backend(a)->_xcoff_dynamic_reloc)) | |
188 | ||
189 | #define bfd_xcoff_create_csect_from_smclas(a, b, c) \ | |
190 | ((xcoff_backend(a)->_xcoff_create_csect_from_smclas((a), (b), (c)))) | |
191 | ||
192 | #define bfd_xcoff_is_lineno_count_overflow(a, b) \ | |
193 | ((xcoff_backend(a)->_xcoff_is_lineno_count_overflow((a), (b)))) | |
194 | ||
195 | #define bfd_xcoff_is_reloc_count_overflow(a, b) \ | |
196 | ((xcoff_backend(a)->_xcoff_is_reloc_count_overflow((a), (b)))) | |
197 | ||
198 | #define bfd_xcoff_loader_symbol_offset(a, b) \ | |
199 | ((xcoff_backend(a)->_xcoff_loader_symbol_offset((a), (b)))) | |
200 | ||
201 | #define bfd_xcoff_loader_reloc_offset(a, b) \ | |
202 | ((xcoff_backend(a)->_xcoff_loader_reloc_offset((a), (b)))) | |
203 | ||
204 | #define bfd_xcoff_glink_code(a, b) ((xcoff_backend(a)->_xcoff_glink_code[(b)])) | |
205 | #define bfd_xcoff_glink_code_size(a) ((xcoff_backend(a)->_xcoff_glink_size)) | |
206 | ||
9a4c7f16 | 207 | /* Check for the magic number U803XTOCMAGIC for 64 bit targets. */ |
beb1bf64 | 208 | #define bfd_xcoff_is_xcoff64(a) (0x01EF == (bfd_xcoff_magic_number(a))) |
9a4c7f16 TR |
209 | |
210 | /* Check for the magic number U802TOMAGIC for 32 bit targets. */ | |
beb1bf64 TR |
211 | #define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number(a))) |
212 | ||
9a4c7f16 TR |
213 | #define bfd_xcoff_rtinit_size(a) ((xcoff_backend(a)->_xcoff_rtinit_size)) |
214 | #define bfd_xcoff_generate_rtinit(a, b, c) ((xcoff_backend(a)->_xcoff_generate_rtinit ((a), (b), (c)))) | |
215 | ||
beb1bf64 TR |
216 | /* Functions in xcofflink.c. */ |
217 | ||
218 | extern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *)); | |
219 | extern long _bfd_xcoff_canonicalize_dynamic_symtab | |
220 | PARAMS ((bfd *, asymbol **)); | |
221 | extern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *)); | |
222 | extern long _bfd_xcoff_canonicalize_dynamic_reloc | |
223 | PARAMS ((bfd *, arelent **, asymbol **)); | |
224 | extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create | |
225 | PARAMS ((bfd *)); | |
226 | extern boolean _bfd_xcoff_bfd_link_add_symbols | |
227 | PARAMS ((bfd *, struct bfd_link_info *)); | |
228 | extern boolean _bfd_xcoff_bfd_final_link | |
229 | PARAMS ((bfd *, struct bfd_link_info *)); | |
dc810e39 | 230 | extern boolean _bfd_xcoff_slurp_symbol_table |
beb1bf64 | 231 | PARAMS ((bfd *)); |
dc810e39 | 232 | extern long _bfd_xcoff_get_symbol_table |
beb1bf64 | 233 | PARAMS ((bfd *, asymbol **)); |
dc810e39 | 234 | extern asymbol *_bfd_xcoff_make_empty_symbol |
beb1bf64 | 235 | PARAMS ((bfd *)); |
dc810e39 | 236 | extern long _bfd_xcoff_get_symbol_table_upper_bound |
beb1bf64 | 237 | PARAMS ((bfd *)); |
dc810e39 | 238 | extern void _bfd_xcoff_print_symbol |
beb1bf64 | 239 | PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); |
dc810e39 | 240 | extern void _bfd_xcoff_get_symbol_info |
beb1bf64 | 241 | PARAMS ((bfd *, asymbol *, symbol_info *)); |
dc810e39 | 242 | extern long _bfd_xcoff_canonicalize_reloc |
beb1bf64 TR |
243 | PARAMS((bfd *, sec_ptr, arelent **, asymbol **)); |
244 | extern reloc_howto_type *_bfd_xcoff_rtype_to_howto | |
245 | PARAMS ((bfd *, asection *, struct internal_reloc *, | |
246 | struct coff_link_hash_entry *, struct internal_syment *, | |
247 | bfd_vma *)); | |
248 | extern boolean _bfd_xcoff_set_section_contents | |
249 | PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type)); | |
250 | boolean _bfd_xcoff_write_object_contents PARAMS ((bfd *)); | |
251 | ||
252 | ||
253 | /* XCOFF support routines for the linker. */ | |
254 | ||
255 | extern boolean bfd_xcoff_link_record_set | |
256 | PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, | |
257 | bfd_size_type)); | |
258 | extern boolean bfd_xcoff_import_symbol | |
259 | PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, | |
1fdf0249 | 260 | bfd_vma, const char *, const char *, const char *, unsigned int)); |
beb1bf64 | 261 | extern boolean bfd_xcoff_export_symbol |
1fdf0249 | 262 | PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)); |
beb1bf64 TR |
263 | extern boolean bfd_xcoff_link_count_reloc |
264 | PARAMS ((bfd *, struct bfd_link_info *, const char *)); | |
265 | extern boolean bfd_xcoff_record_link_assignment | |
266 | PARAMS ((bfd *, struct bfd_link_info *, const char *)); | |
267 | extern boolean bfd_xcoff_size_dynamic_sections | |
268 | PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *, | |
269 | unsigned long, unsigned long, unsigned long, boolean, | |
270 | int, boolean, boolean, struct sec **)); | |
dc810e39 | 271 | extern boolean xcoff_slurp_reloc_table |
beb1bf64 TR |
272 | PARAMS ((bfd *, asection *, asymbol **)); |
273 | ||
274 | #endif /* LIBXCOFF_H */ |