]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/libxcoff.h
[PATCH] fix windmc typedef bug
[thirdparty/binutils-gdb.git] / bfd / libxcoff.h
CommitLineData
beb1bf64 1/* BFD XCOFF object file private structure.
b3adc24a 2 Copyright (C) 2001-2020 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
cd123cb7 9 the Free Software Foundation; either version 3 of the License, or
eb1e0e80 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
cd123cb7
NC
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
beb1bf64
TR
21
22#ifndef LIBXCOFF_H
23#define LIBXCOFF_H
24
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. */
29
30struct xcoff_backend_data_rec
31{
330693f5 32 /* COFF backend information. */
beb1bf64
TR
33 bfd_coff_backend_data coff;
34
eb1e0e80 35 /* Magic number. */
dc810e39 36 unsigned short _xcoff_magic_number;
beb1bf64 37
eb1e0e80 38 /* Architecture and machine for coff_set_arch_mach_hook. */
beb1bf64
TR
39 enum bfd_architecture _xcoff_architecture;
40 long _xcoff_machine;
41
eb1e0e80 42 /* Function pointers to xcoff specific swap routines. */
7920ce38
NC
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 *);
beb1bf64 49
eb1e0e80 50 /* Size of the external struct. */
dc810e39 51 unsigned int _xcoff_ldhdrsz;
beb1bf64
TR
52 unsigned int _xcoff_ldsymsz;
53 unsigned int _xcoff_ldrelsz;
54
eb1e0e80 55 /* Size an entry in a descriptor section. */
beb1bf64
TR
56 unsigned int _xcoff_function_descriptor_size;
57
eb1e0e80 58 /* Size of the small aout file header. */
beb1bf64
TR
59 unsigned int _xcoff_small_aout_header_size;
60
330693f5
TR
61 /* Loader version
62 1 : XCOFF32
eb1e0e80 63 2 : XCOFF64. */
beb1bf64
TR
64 unsigned long _xcoff_ldhdr_version;
65
b34976b6 66 bfd_boolean (* _xcoff_put_symbol_name)
b560e2ac
AM
67 (struct bfd_link_info *, struct bfd_strtab_hash *,
68 struct internal_syment *, const char *);
beb1bf64 69
b34976b6 70 bfd_boolean (* _xcoff_put_ldsymbol_name)
7920ce38
NC
71 (bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
72 const char *);
beb1bf64
TR
73
74 reloc_howto_type *_xcoff_dynamic_reloc;
75
eb1e0e80 76 asection * (* _xcoff_create_csect_from_smclas)
7920ce38 77 (bfd *, union internal_auxent *, const char *);
beb1bf64 78
330693f5 79 /* Line number and relocation overflow.
68ffbac6 80 XCOFF32 overflows to another section when the line number or the
330693f5 81 relocation count exceeds 0xffff. XCOFF64 does not overflow. */
7920ce38
NC
82 bfd_boolean (*_xcoff_is_lineno_count_overflow) (bfd *, bfd_vma);
83 bfd_boolean (*_xcoff_is_reloc_count_overflow) (bfd *, bfd_vma);
beb1bf64 84
330693f5
TR
85 /* Loader section symbol and relocation table offset
86 XCOFF32 is after the .loader header
eb1e0e80 87 XCOFF64 is offset in .loader header. */
7920ce38
NC
88 bfd_vma (*_xcoff_loader_symbol_offset) (bfd *, struct internal_ldhdr *);
89 bfd_vma (*_xcoff_loader_reloc_offset) (bfd *, struct internal_ldhdr *);
68ffbac6
L
90
91 /* Global linkage. The first word of global linkage code must be be
330693f5 92 modified by filling in the correct TOC offset. */
beb1bf64 93 unsigned long *_xcoff_glink_code;
68ffbac6 94
330693f5 95 /* Size of the global link code in bytes of the xcoff_glink_code table. */
beb1bf64
TR
96 unsigned long _xcoff_glink_size;
97
eb1e0e80 98 /* rtinit. */
9a4c7f16 99 unsigned int _xcoff_rtinit_size;
b34976b6 100 bfd_boolean (*_xcoff_generate_rtinit)
7920ce38 101 (bfd *, const char *, const char *, bfd_boolean);
beb1bf64
TR
102};
103
104/* Look up an entry in an XCOFF link hash table. */
beb1bf64
TR
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)))
109
110/* Traverse an XCOFF link hash table. */
beb1bf64
TR
111#define xcoff_link_hash_traverse(table, func, info) \
112 (bfd_link_hash_traverse \
113 (&(table)->root, \
7920ce38 114 (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func), \
beb1bf64
TR
115 (info)))
116
117/* Get the XCOFF link hash table from the info structure. This is
118 just a cast. */
beb1bf64
TR
119#define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash))
120
121
122#define xcoff_backend(abfd) \
123 ((struct xcoff_backend_data_rec *) (abfd)->xvec->backend_data)
124
7920ce38
NC
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))
beb1bf64
TR
128
129#define bfd_xcoff_swap_ldhdr_in(a, b, c) \
7920ce38 130 ((xcoff_backend (a)->_xcoff_swap_ldhdr_in) ((a), (b), (c)))
beb1bf64
TR
131
132#define bfd_xcoff_swap_ldhdr_out(a, b, c) \
7920ce38 133 ((xcoff_backend (a)->_xcoff_swap_ldhdr_out) ((a), (b), (c)))
beb1bf64
TR
134
135#define bfd_xcoff_swap_ldsym_in(a, b, c) \
7920ce38 136 ((xcoff_backend (a)->_xcoff_swap_ldsym_in) ((a), (b), (c)))
beb1bf64
TR
137
138#define bfd_xcoff_swap_ldsym_out(a, b, c) \
7920ce38 139 ((xcoff_backend (a)->_xcoff_swap_ldsym_out) ((a), (b), (c)))
beb1bf64
TR
140
141#define bfd_xcoff_swap_ldrel_in(a, b, c) \
7920ce38 142 ((xcoff_backend (a)->_xcoff_swap_ldrel_in) ((a), (b), (c)))
beb1bf64
TR
143
144#define bfd_xcoff_swap_ldrel_out(a, b, c) \
7920ce38 145 ((xcoff_backend (a)->_xcoff_swap_ldrel_out) ((a), (b), (c)))
beb1bf64 146
7920ce38
NC
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))
beb1bf64 150#define bfd_xcoff_function_descriptor_size(a) \
7920ce38 151 ((xcoff_backend (a)->_xcoff_function_descriptor_size))
beb1bf64 152#define bfd_xcoff_small_aout_header_size(a) \
7920ce38 153 ((xcoff_backend (a)->_xcoff_small_aout_header_size))
beb1bf64 154
7920ce38 155#define bfd_xcoff_ldhdr_version(a) ((xcoff_backend (a)->_xcoff_ldhdr_version))
beb1bf64 156
b560e2ac
AM
157#define bfd_xcoff_put_symbol_name(a, b, c, d, e) \
158 ((xcoff_backend (a)->_xcoff_put_symbol_name) ((b), (c), (d), (e)))
beb1bf64
TR
159
160#define bfd_xcoff_put_ldsymbol_name(a, b, c, d) \
7920ce38 161 ((xcoff_backend (a)->_xcoff_put_ldsymbol_name) ((a), (b), (c), (d)))
beb1bf64
TR
162
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))
166
167#define bfd_xcoff_dynamic_reloc_howto(a) \
7920ce38 168 ((xcoff_backend (a)->_xcoff_dynamic_reloc))
beb1bf64
TR
169
170#define bfd_xcoff_create_csect_from_smclas(a, b, c) \
7920ce38 171 ((xcoff_backend (a)->_xcoff_create_csect_from_smclas((a), (b), (c))))
beb1bf64
TR
172
173#define bfd_xcoff_is_lineno_count_overflow(a, b) \
7920ce38 174 ((xcoff_backend (a)->_xcoff_is_lineno_count_overflow((a), (b))))
beb1bf64
TR
175
176#define bfd_xcoff_is_reloc_count_overflow(a, b) \
7920ce38 177 ((xcoff_backend (a)->_xcoff_is_reloc_count_overflow((a), (b))))
beb1bf64
TR
178
179#define bfd_xcoff_loader_symbol_offset(a, b) \
7920ce38 180 ((xcoff_backend (a)->_xcoff_loader_symbol_offset((a), (b))))
beb1bf64
TR
181
182#define bfd_xcoff_loader_reloc_offset(a, b) \
7920ce38 183 ((xcoff_backend (a)->_xcoff_loader_reloc_offset((a), (b))))
beb1bf64 184
7920ce38
NC
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))
beb1bf64 187
68ffbac6 188/* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit
eb1e0e80
NC
189 targets. */
190#define bfd_xcoff_is_xcoff64(a) \
7920ce38
NC
191 ( (0x01EF == (bfd_xcoff_magic_number (a))) \
192 || (0x01F7 == (bfd_xcoff_magic_number (a))))
9a4c7f16
TR
193
194/* Check for the magic number U802TOMAGIC for 32 bit targets. */
7920ce38 195#define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number (a)))
beb1bf64 196
07d6d2b8 197#define bfd_xcoff_rtinit_size(a) ((xcoff_backend (a)->_xcoff_rtinit_size))
7920ce38 198#define bfd_xcoff_generate_rtinit(a, b, c, d) ((xcoff_backend (a)->_xcoff_generate_rtinit ((a), (b), (c), (d))))
9a4c7f16 199
eb1e0e80
NC
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))
203
dbe341c6
TR
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)
212
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
217
218#define XCOFF_COMPLAIN_FUNCTION_ARGS \
219 bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *howto
220
b34976b6 221extern bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
7920ce38 222 (XCOFF_RELOC_FUNCTION_ARGS);
b34976b6 223extern bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
7920ce38 224 (XCOFF_COMPLAIN_FUNCTION_ARGS);
dbe341c6 225
88183869
DK
226#define XCOFF_NO_LONG_SECTION_NAMES (FALSE), bfd_coff_set_long_section_names_disallowed
227
f1f0d9ab 228/* Relocation functions */
7920ce38
NC
229bfd_boolean xcoff_reloc_type_noop (XCOFF_RELOC_FUNCTION_ARGS);
230bfd_boolean xcoff_reloc_type_fail (XCOFF_RELOC_FUNCTION_ARGS);
231bfd_boolean xcoff_reloc_type_pos (XCOFF_RELOC_FUNCTION_ARGS);
232bfd_boolean xcoff_reloc_type_neg (XCOFF_RELOC_FUNCTION_ARGS);
233bfd_boolean xcoff_reloc_type_rel (XCOFF_RELOC_FUNCTION_ARGS);
234bfd_boolean xcoff_reloc_type_toc (XCOFF_RELOC_FUNCTION_ARGS);
235bfd_boolean xcoff_reloc_type_ba (XCOFF_RELOC_FUNCTION_ARGS);
236bfd_boolean xcoff_reloc_type_crel (XCOFF_RELOC_FUNCTION_ARGS);
f1f0d9ab 237
85645aed
TG
238/* Structure to describe dwarf sections.
239 Useful to convert from XCOFF section name to flag and vice-versa.
240 Also mark if section has a length field at the beginning. */
241struct xcoff_dwsect_name {
242 /* A XCOFF dwarf section is identified by its name. */
243 unsigned int flag;
244
245 /* Corresponding XCOFF section name. */
246 const char *name;
247
248 /* True if size must be prepended. */
249 bfd_boolean def_size;
250};
251
252/* Number of entries in the array. The number is known and public so that user
253 can 'extend' this array by index. */
254#define XCOFF_DWSECT_NBR_NAMES 8
255
256/* The dwarf sections array. */
257extern const struct xcoff_dwsect_name
258 xcoff_dwsect_names[XCOFF_DWSECT_NBR_NAMES];
259
beb1bf64 260#endif /* LIBXCOFF_H */