Add comment
[binutils.git] / bfd / libxcoff.h
blobb0ac0501f582fcfb86bbd85289bcf851d0ac7d66
1 /* BFD XCOFF object file private structure.
2 Copyright (C) 2001 Free Software Foundation, Inc.
3 Written by Tom Rix, Redhat.
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
21 #ifndef LIBXCOFF_H
22 #define LIBXCOFF_H
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. */
29 struct xcoff_backend_data_rec
32 * COFF backend information. Must be the first field.
33 * This is where the std coff swap table goes
35 bfd_coff_backend_data coff;
37 /* Magic number */
38 unsigned short _xcoff_magic_number;
40 /* Architecture and machine for coff_set_arch_mach_hook */
41 enum bfd_architecture _xcoff_architecture;
42 long _xcoff_machine;
44 /* function pointers to xcoff specific swap routines */
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);
52 /* size of the external struct */
53 unsigned int _xcoff_ldhdrsz;
54 unsigned int _xcoff_ldsymsz;
55 unsigned int _xcoff_ldrelsz;
57 /* size an entry in a descriptor section */
58 unsigned int _xcoff_function_descriptor_size;
60 /* size of the small aout file header */
61 unsigned int _xcoff_small_aout_header_size;
64 * version
65 * loader version
66 * 1 : xcoff32
67 * 2 : xcoff64
69 unsigned long _xcoff_ldhdr_version;
71 boolean (* _xcoff_put_symbol_name)(bfd *, struct bfd_strtab_hash *,
72 struct internal_syment *,
73 const char *);
75 boolean (* _xcoff_put_ldsymbol_name)(bfd *, struct xcoff_loader_info *,
76 struct internal_ldsym *,
77 const char *);
79 reloc_howto_type *_xcoff_dynamic_reloc;
81 asection * (* _xcoff_create_csect_from_smclas) (bfd *, union internal_auxent *, const char *);
84 * line_no and reloc overflow
85 * 32 overflows to another section when the line_no or reloc count go
86 * over 0xffff. 64 does not overflow.
88 boolean (*_xcoff_is_lineno_count_overflow)(bfd *, bfd_vma);
89 boolean (*_xcoff_is_reloc_count_overflow)(bfd *, bfd_vma);
92 * .loader symbol table offset
93 * 32 is after the .loader header
94 * 64 is offset in .loader header
96 * Similar for the reloc table
98 bfd_vma (*_xcoff_loader_symbol_offset)(bfd *, struct internal_ldhdr *);
99 bfd_vma (*_xcoff_loader_reloc_offset)(bfd *, struct internal_ldhdr *);
103 * Global linkage
105 * The first word of global linkage code must be be modified by
106 * filling in the correct TOC offset.
108 unsigned long *_xcoff_glink_code;
111 * Size of the global link code in bytes of the xcoff_glink_code table
113 unsigned long _xcoff_glink_size;
117 /* Look up an entry in an XCOFF link hash table. */
119 #define xcoff_link_hash_lookup(table, string, create, copy, follow) \
120 ((struct xcoff_link_hash_entry *) \
121 bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\
122 (follow)))
124 /* Traverse an XCOFF link hash table. */
126 #define xcoff_link_hash_traverse(table, func, info) \
127 (bfd_link_hash_traverse \
128 (&(table)->root, \
129 (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
130 (info)))
132 /* Get the XCOFF link hash table from the info structure. This is
133 just a cast. */
135 #define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash))
138 #define xcoff_backend(abfd) \
139 ((struct xcoff_backend_data_rec *) (abfd)->xvec->backend_data)
141 #define bfd_xcoff_magic_number(a) ((xcoff_backend(a)->_xcoff_magic_number))
142 #define bfd_xcoff_architecture(a) ((xcoff_backend(a)->_xcoff_architecture))
143 #define bfd_xcoff_machine(a) ((xcoff_backend(a)->_xcoff_machine))
145 #define bfd_xcoff_swap_ldhdr_in(a, b, c) \
146 ((xcoff_backend(a)->_xcoff_swap_ldhdr_in) ((a), (b), (c)))
148 #define bfd_xcoff_swap_ldhdr_out(a, b, c) \
149 ((xcoff_backend(a)->_xcoff_swap_ldhdr_out) ((a), (b), (c)))
151 #define bfd_xcoff_swap_ldsym_in(a, b, c) \
152 ((xcoff_backend(a)->_xcoff_swap_ldsym_in) ((a), (b), (c)))
154 #define bfd_xcoff_swap_ldsym_out(a, b, c) \
155 ((xcoff_backend(a)->_xcoff_swap_ldsym_out) ((a), (b), (c)))
157 #define bfd_xcoff_swap_ldrel_in(a, b, c) \
158 ((xcoff_backend(a)->_xcoff_swap_ldrel_in) ((a), (b), (c)))
160 #define bfd_xcoff_swap_ldrel_out(a, b, c) \
161 ((xcoff_backend(a)->_xcoff_swap_ldrel_out) ((a), (b), (c)))
163 #define bfd_xcoff_ldhdrsz(a) ((xcoff_backend(a)->_xcoff_ldhdrsz))
164 #define bfd_xcoff_ldsymsz(a) ((xcoff_backend(a)->_xcoff_ldsymsz))
165 #define bfd_xcoff_ldrelsz(a) ((xcoff_backend(a)->_xcoff_ldrelsz))
166 #define bfd_xcoff_function_descriptor_size(a) \
167 ((xcoff_backend(a)->_xcoff_function_descriptor_size))
168 #define bfd_xcoff_small_aout_header_size(a) \
169 ((xcoff_backend(a)->_xcoff_small_aout_header_size))
171 #define bfd_xcoff_ldhdr_version(a) ((xcoff_backend(a)->_xcoff_ldhdr_version))
173 #define bfd_xcoff_put_symbol_name(a, b, c, d) \
174 ((xcoff_backend(a)->_xcoff_put_symbol_name) ((a), (b), (c), (d)))
176 #define bfd_xcoff_put_ldsymbol_name(a, b, c, d) \
177 ((xcoff_backend(a)->_xcoff_put_ldsymbol_name) ((a), (b), (c), (d)))
179 /* Get the XCOFF hash table entries for a BFD. */
180 #define obj_xcoff_sym_hashes(bfd) \
181 ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd))
183 #define bfd_xcoff_dynamic_reloc_howto(a) \
184 ((xcoff_backend(a)->_xcoff_dynamic_reloc))
186 #define bfd_xcoff_create_csect_from_smclas(a, b, c) \
187 ((xcoff_backend(a)->_xcoff_create_csect_from_smclas((a), (b), (c))))
189 #define bfd_xcoff_is_lineno_count_overflow(a, b) \
190 ((xcoff_backend(a)->_xcoff_is_lineno_count_overflow((a), (b))))
192 #define bfd_xcoff_is_reloc_count_overflow(a, b) \
193 ((xcoff_backend(a)->_xcoff_is_reloc_count_overflow((a), (b))))
195 #define bfd_xcoff_loader_symbol_offset(a, b) \
196 ((xcoff_backend(a)->_xcoff_loader_symbol_offset((a), (b))))
198 #define bfd_xcoff_loader_reloc_offset(a, b) \
199 ((xcoff_backend(a)->_xcoff_loader_reloc_offset((a), (b))))
201 #define bfd_xcoff_glink_code(a, b) ((xcoff_backend(a)->_xcoff_glink_code[(b)]))
202 #define bfd_xcoff_glink_code_size(a) ((xcoff_backend(a)->_xcoff_glink_size))
204 #define bfd_xcoff_is_xcoff64(a) (0x01EF == (bfd_xcoff_magic_number(a)))
205 #define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number(a)))
207 /* Functions in xcofflink.c. */
209 extern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
210 extern long _bfd_xcoff_canonicalize_dynamic_symtab
211 PARAMS ((bfd *, asymbol **));
212 extern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
213 extern long _bfd_xcoff_canonicalize_dynamic_reloc
214 PARAMS ((bfd *, arelent **, asymbol **));
215 extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
216 PARAMS ((bfd *));
217 extern boolean _bfd_xcoff_bfd_link_add_symbols
218 PARAMS ((bfd *, struct bfd_link_info *));
219 extern boolean _bfd_xcoff_bfd_final_link
220 PARAMS ((bfd *, struct bfd_link_info *));
221 extern boolean _bfd_xcoff_slurp_symbol_table
222 PARAMS ((bfd *));
223 extern long _bfd_xcoff_get_symbol_table
224 PARAMS ((bfd *, asymbol **));
225 extern asymbol *_bfd_xcoff_make_empty_symbol
226 PARAMS ((bfd *));
227 extern long _bfd_xcoff_get_symbol_table_upper_bound
228 PARAMS ((bfd *));
229 extern void _bfd_xcoff_print_symbol
230 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
231 extern void _bfd_xcoff_get_symbol_info
232 PARAMS ((bfd *, asymbol *, symbol_info *));
233 extern long _bfd_xcoff_canonicalize_reloc
234 PARAMS((bfd *, sec_ptr, arelent **, asymbol **));
235 extern reloc_howto_type *_bfd_xcoff_rtype_to_howto
236 PARAMS ((bfd *, asection *, struct internal_reloc *,
237 struct coff_link_hash_entry *, struct internal_syment *,
238 bfd_vma *));
239 extern boolean _bfd_xcoff_set_section_contents
240 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
241 boolean _bfd_xcoff_write_object_contents PARAMS ((bfd *));
244 /* XCOFF support routines for the linker. */
246 extern boolean bfd_xcoff_link_record_set
247 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
248 bfd_size_type));
249 extern boolean bfd_xcoff_import_symbol
250 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
251 bfd_vma, const char *, const char *, const char *, unsigned int));
252 extern boolean bfd_xcoff_export_symbol
253 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *));
254 extern boolean bfd_xcoff_link_count_reloc
255 PARAMS ((bfd *, struct bfd_link_info *, const char *));
256 extern boolean bfd_xcoff_record_link_assignment
257 PARAMS ((bfd *, struct bfd_link_info *, const char *));
258 extern boolean bfd_xcoff_size_dynamic_sections
259 PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
260 unsigned long, unsigned long, unsigned long, boolean,
261 int, boolean, boolean, struct sec **));
262 extern boolean xcoff_slurp_reloc_table
263 PARAMS ((bfd *, asection *, asymbol **));
265 #endif /* LIBXCOFF_H */