1 /* BFD XCOFF object file private structure.
2 Copyright (C) 2001-2017 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. */
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
;
36 unsigned short _xcoff_magic_number
;
38 /* Architecture and machine for coff_set_arch_mach_hook. */
39 enum bfd_architecture _xcoff_architecture
;
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
;
64 unsigned long _xcoff_ldhdr_version
;
66 bfd_boolean (* _xcoff_put_symbol_name
)
67 (struct bfd_link_info
*, struct bfd_strtab_hash
*,
68 struct internal_syment
*, const char *);
70 bfd_boolean (* _xcoff_put_ldsymbol_name
)
71 (bfd
*, struct xcoff_loader_info
*, struct internal_ldsym
*,
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
;
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),\
110 /* Traverse an XCOFF link hash table. */
111 #define xcoff_link_hash_traverse(table, func, info) \
112 (bfd_link_hash_traverse \
114 (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func), \
117 /* Get the XCOFF link hash table from the info structure. This is
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, e) \
158 ((xcoff_backend (a)->_xcoff_put_symbol_name) ((b), (c), (d), (e)))
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
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. */
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 /* 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. */
241 struct xcoff_dwsect_name
{
242 /* A XCOFF dwarf section is identified by its name. */
245 /* Corresponding XCOFF section name. */
248 /* True if size must be prepended. */
249 bfd_boolean def_size
;
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
256 /* The dwarf sections array. */
257 extern const struct xcoff_dwsect_name
258 xcoff_dwsect_names
[XCOFF_DWSECT_NBR_NAMES
];
260 #endif /* LIBXCOFF_H */