Fix PE-COFF archiving long name tables
[binutils/dougsmingw.git] / bfd / libxcoff.h
blob3900dd3c7ea0be397af0f6b5be3c04777a60f820
1 /* BFD XCOFF object file private structure.
2 Copyright 2001, 2002, 2005, 2007, 2009 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
22 #ifndef LIBXCOFF_H
23 #define LIBXCOFF_H
25 /* This is the backend information kept for XCOFF files. This
26 structure is constant for a particular backend. The first element
27 is the COFF backend data structure, so that XCOFF targets can use
28 the generic COFF code. */
30 struct xcoff_backend_data_rec
32 /* COFF backend information. */
33 bfd_coff_backend_data coff;
35 /* Magic number. */
36 unsigned short _xcoff_magic_number;
38 /* Architecture and machine for coff_set_arch_mach_hook. */
39 enum bfd_architecture _xcoff_architecture;
40 long _xcoff_machine;
42 /* Function pointers to xcoff specific swap routines. */
43 void (* _xcoff_swap_ldhdr_in) (bfd *, const void *, struct internal_ldhdr *);
44 void (* _xcoff_swap_ldhdr_out)(bfd *, const struct internal_ldhdr *, void *);
45 void (* _xcoff_swap_ldsym_in) (bfd *, const void *, struct internal_ldsym *);
46 void (* _xcoff_swap_ldsym_out)(bfd *, const struct internal_ldsym *, void *);
47 void (* _xcoff_swap_ldrel_in) (bfd *, const void *, struct internal_ldrel *);
48 void (* _xcoff_swap_ldrel_out)(bfd *, const struct internal_ldrel *, void *);
50 /* Size of the external struct. */
51 unsigned int _xcoff_ldhdrsz;
52 unsigned int _xcoff_ldsymsz;
53 unsigned int _xcoff_ldrelsz;
55 /* Size an entry in a descriptor section. */
56 unsigned int _xcoff_function_descriptor_size;
58 /* Size of the small aout file header. */
59 unsigned int _xcoff_small_aout_header_size;
61 /* Loader version
62 1 : XCOFF32
63 2 : XCOFF64. */
64 unsigned long _xcoff_ldhdr_version;
66 bfd_boolean (* _xcoff_put_symbol_name)
67 (bfd *, struct bfd_strtab_hash *, struct internal_syment *,
68 const char *);
70 bfd_boolean (* _xcoff_put_ldsymbol_name)
71 (bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
72 const char *);
74 reloc_howto_type *_xcoff_dynamic_reloc;
76 asection * (* _xcoff_create_csect_from_smclas)
77 (bfd *, union internal_auxent *, const char *);
79 /* Line number and relocation overflow.
80 XCOFF32 overflows to another section when the line number or the
81 relocation count exceeds 0xffff. XCOFF64 does not overflow. */
82 bfd_boolean (*_xcoff_is_lineno_count_overflow) (bfd *, bfd_vma);
83 bfd_boolean (*_xcoff_is_reloc_count_overflow) (bfd *, bfd_vma);
85 /* Loader section symbol and relocation table offset
86 XCOFF32 is after the .loader header
87 XCOFF64 is offset in .loader header. */
88 bfd_vma (*_xcoff_loader_symbol_offset) (bfd *, struct internal_ldhdr *);
89 bfd_vma (*_xcoff_loader_reloc_offset) (bfd *, struct internal_ldhdr *);
91 /* Global linkage. The first word of global linkage code must be be
92 modified by filling in the correct TOC offset. */
93 unsigned long *_xcoff_glink_code;
95 /* Size of the global link code in bytes of the xcoff_glink_code table. */
96 unsigned long _xcoff_glink_size;
98 /* rtinit. */
99 unsigned int _xcoff_rtinit_size;
100 bfd_boolean (*_xcoff_generate_rtinit)
101 (bfd *, const char *, const char *, bfd_boolean);
104 /* Look up an entry in an XCOFF link hash table. */
105 #define xcoff_link_hash_lookup(table, string, create, copy, follow) \
106 ((struct xcoff_link_hash_entry *) \
107 bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\
108 (follow)))
110 /* Traverse an XCOFF link hash table. */
111 #define xcoff_link_hash_traverse(table, func, info) \
112 (bfd_link_hash_traverse \
113 (&(table)->root, \
114 (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func), \
115 (info)))
117 /* Get the XCOFF link hash table from the info structure. This is
118 just a cast. */
119 #define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash))
122 #define xcoff_backend(abfd) \
123 ((struct xcoff_backend_data_rec *) (abfd)->xvec->backend_data)
125 #define bfd_xcoff_magic_number(a) ((xcoff_backend (a)->_xcoff_magic_number))
126 #define bfd_xcoff_architecture(a) ((xcoff_backend (a)->_xcoff_architecture))
127 #define bfd_xcoff_machine(a) ((xcoff_backend (a)->_xcoff_machine))
129 #define bfd_xcoff_swap_ldhdr_in(a, b, c) \
130 ((xcoff_backend (a)->_xcoff_swap_ldhdr_in) ((a), (b), (c)))
132 #define bfd_xcoff_swap_ldhdr_out(a, b, c) \
133 ((xcoff_backend (a)->_xcoff_swap_ldhdr_out) ((a), (b), (c)))
135 #define bfd_xcoff_swap_ldsym_in(a, b, c) \
136 ((xcoff_backend (a)->_xcoff_swap_ldsym_in) ((a), (b), (c)))
138 #define bfd_xcoff_swap_ldsym_out(a, b, c) \
139 ((xcoff_backend (a)->_xcoff_swap_ldsym_out) ((a), (b), (c)))
141 #define bfd_xcoff_swap_ldrel_in(a, b, c) \
142 ((xcoff_backend (a)->_xcoff_swap_ldrel_in) ((a), (b), (c)))
144 #define bfd_xcoff_swap_ldrel_out(a, b, c) \
145 ((xcoff_backend (a)->_xcoff_swap_ldrel_out) ((a), (b), (c)))
147 #define bfd_xcoff_ldhdrsz(a) ((xcoff_backend (a)->_xcoff_ldhdrsz))
148 #define bfd_xcoff_ldsymsz(a) ((xcoff_backend (a)->_xcoff_ldsymsz))
149 #define bfd_xcoff_ldrelsz(a) ((xcoff_backend (a)->_xcoff_ldrelsz))
150 #define bfd_xcoff_function_descriptor_size(a) \
151 ((xcoff_backend (a)->_xcoff_function_descriptor_size))
152 #define bfd_xcoff_small_aout_header_size(a) \
153 ((xcoff_backend (a)->_xcoff_small_aout_header_size))
155 #define bfd_xcoff_ldhdr_version(a) ((xcoff_backend (a)->_xcoff_ldhdr_version))
157 #define bfd_xcoff_put_symbol_name(a, b, c, d) \
158 ((xcoff_backend (a)->_xcoff_put_symbol_name) ((a), (b), (c), (d)))
160 #define bfd_xcoff_put_ldsymbol_name(a, b, c, d) \
161 ((xcoff_backend (a)->_xcoff_put_ldsymbol_name) ((a), (b), (c), (d)))
163 /* Get the XCOFF hash table entries for a BFD. */
164 #define obj_xcoff_sym_hashes(bfd) \
165 ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd))
167 #define bfd_xcoff_dynamic_reloc_howto(a) \
168 ((xcoff_backend (a)->_xcoff_dynamic_reloc))
170 #define bfd_xcoff_create_csect_from_smclas(a, b, c) \
171 ((xcoff_backend (a)->_xcoff_create_csect_from_smclas((a), (b), (c))))
173 #define bfd_xcoff_is_lineno_count_overflow(a, b) \
174 ((xcoff_backend (a)->_xcoff_is_lineno_count_overflow((a), (b))))
176 #define bfd_xcoff_is_reloc_count_overflow(a, b) \
177 ((xcoff_backend (a)->_xcoff_is_reloc_count_overflow((a), (b))))
179 #define bfd_xcoff_loader_symbol_offset(a, b) \
180 ((xcoff_backend (a)->_xcoff_loader_symbol_offset((a), (b))))
182 #define bfd_xcoff_loader_reloc_offset(a, b) \
183 ((xcoff_backend (a)->_xcoff_loader_reloc_offset((a), (b))))
185 #define bfd_xcoff_glink_code(a, b) ((xcoff_backend (a)->_xcoff_glink_code[(b)]))
186 #define bfd_xcoff_glink_code_size(a) ((xcoff_backend (a)->_xcoff_glink_size))
188 /* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit
189 targets. */
190 #define bfd_xcoff_is_xcoff64(a) \
191 ( (0x01EF == (bfd_xcoff_magic_number (a))) \
192 || (0x01F7 == (bfd_xcoff_magic_number (a))))
194 /* Check for the magic number U802TOMAGIC for 32 bit targets. */
195 #define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number (a)))
197 #define bfd_xcoff_rtinit_size(a) ((xcoff_backend (a)->_xcoff_rtinit_size))
198 #define bfd_xcoff_generate_rtinit(a, b, c, d) ((xcoff_backend (a)->_xcoff_generate_rtinit ((a), (b), (c), (d))))
200 /* Accessor macros for tdata. */
201 #define bfd_xcoff_text_align_power(a) ((xcoff_data (a)->text_align_power))
202 #define bfd_xcoff_data_align_power(a) ((xcoff_data (a)->data_align_power))
204 /* xcoff*_ppc_relocate_section macros */
205 #define XCOFF_MAX_CALCULATE_RELOCATION (0x1c)
206 #define XCOFF_MAX_COMPLAIN_OVERFLOW (4)
207 /* N_ONES produces N one bits, without overflowing machine arithmetic. */
208 #ifdef N_ONES
209 #undef N_ONES
210 #endif
211 #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
213 #define XCOFF_RELOC_FUNCTION_ARGS \
214 bfd *, asection *, bfd *, struct internal_reloc *, \
215 struct internal_syment *, struct reloc_howto_struct *, bfd_vma, bfd_vma, \
216 bfd_vma *relocation, bfd_byte *contents
218 #define XCOFF_COMPLAIN_FUNCTION_ARGS \
219 bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *howto
221 extern bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
222 (XCOFF_RELOC_FUNCTION_ARGS);
223 extern bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
224 (XCOFF_COMPLAIN_FUNCTION_ARGS);
226 #define XCOFF_NO_LONG_SECTION_NAMES (FALSE), bfd_coff_set_long_section_names_disallowed
228 /* Relocation functions */
229 bfd_boolean xcoff_reloc_type_noop (XCOFF_RELOC_FUNCTION_ARGS);
230 bfd_boolean xcoff_reloc_type_fail (XCOFF_RELOC_FUNCTION_ARGS);
231 bfd_boolean xcoff_reloc_type_pos (XCOFF_RELOC_FUNCTION_ARGS);
232 bfd_boolean xcoff_reloc_type_neg (XCOFF_RELOC_FUNCTION_ARGS);
233 bfd_boolean xcoff_reloc_type_rel (XCOFF_RELOC_FUNCTION_ARGS);
234 bfd_boolean xcoff_reloc_type_toc (XCOFF_RELOC_FUNCTION_ARGS);
235 bfd_boolean xcoff_reloc_type_ba (XCOFF_RELOC_FUNCTION_ARGS);
236 bfd_boolean xcoff_reloc_type_crel (XCOFF_RELOC_FUNCTION_ARGS);
238 #endif /* LIBXCOFF_H */