]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - bfd/elfxx-target.h
* libelf.h: Rename to elf-bfd.h to avoid conflict with
[thirdparty/binutils-gdb.git] / bfd / elfxx-target.h
1 /* Target definitions for NN-bit ELF
2 Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20 /* This structure contains everything that BFD knows about a target.
21 It includes things like its byte order, name, what routines to call
22 to do various operations, etc. Every BFD points to a target structure
23 with its "xvec" member.
24
25 There are two such structures here: one for big-endian machines and
26 one for little-endian machines. */
27
28 #define bfd_elfNN_close_and_cleanup _bfd_generic_close_and_cleanup
29 #define bfd_elfNN_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
30 #ifndef bfd_elfNN_get_section_contents
31 #define bfd_elfNN_get_section_contents _bfd_generic_get_section_contents
32 #endif
33
34 #define bfd_elfNN_canonicalize_dynamic_symtab _bfd_elf_canonicalize_dynamic_symtab
35 #define bfd_elfNN_canonicalize_reloc _bfd_elf_canonicalize_reloc
36 #ifndef bfd_elfNN_find_nearest_line
37 #define bfd_elfNN_find_nearest_line _bfd_elf_find_nearest_line
38 #endif
39 #define bfd_elfNN_read_minisymbols _bfd_elf_read_minisymbols
40 #define bfd_elfNN_minisymbol_to_symbol _bfd_elf_minisymbol_to_symbol
41 #define bfd_elfNN_get_dynamic_symtab_upper_bound _bfd_elf_get_dynamic_symtab_upper_bound
42 #define bfd_elfNN_get_lineno _bfd_elf_get_lineno
43 #define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound
44 #define bfd_elfNN_get_symbol_info _bfd_elf_get_symbol_info
45 #define bfd_elfNN_get_symtab _bfd_elf_get_symtab
46 #define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
47 #if 0 /* done in elf-bfd.h */
48 #define bfd_elfNN_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
49 #endif
50 #define bfd_elfNN_make_empty_symbol _bfd_elf_make_empty_symbol
51 #define bfd_elfNN_new_section_hook _bfd_elf_new_section_hook
52 #define bfd_elfNN_set_arch_mach _bfd_elf_set_arch_mach
53 #ifndef bfd_elfNN_set_section_contents
54 #define bfd_elfNN_set_section_contents _bfd_elf_set_section_contents
55 #endif
56 #define bfd_elfNN_sizeof_headers _bfd_elf_sizeof_headers
57 #define bfd_elfNN_write_object_contents _bfd_elf_write_object_contents
58
59 #ifndef elf_backend_want_got_plt
60 #define elf_backend_want_got_plt 0
61 #endif
62 #ifndef elf_backend_plt_readonly
63 #define elf_backend_plt_readonly 0
64 #endif
65 #ifndef elf_backend_want_plt_sym
66 #define elf_backend_want_plt_sym 0
67 #endif
68
69 #ifndef elf_backend_want_hdr_in_seg
70 #define elf_backend_want_hdr_in_seg 0
71 #endif
72
73 #define bfd_elfNN_bfd_debug_info_start bfd_void
74 #define bfd_elfNN_bfd_debug_info_end bfd_void
75 #define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
76
77 #ifndef bfd_elfNN_bfd_get_relocated_section_contents
78 #define bfd_elfNN_bfd_get_relocated_section_contents \
79 bfd_generic_get_relocated_section_contents
80 #endif
81
82 #define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
83 #define bfd_elfNN_bfd_make_debug_symbol \
84 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
85
86 #ifndef bfd_elfNN_bfd_copy_private_symbol_data
87 #define bfd_elfNN_bfd_copy_private_symbol_data \
88 ((boolean (*) PARAMS ((bfd *, asymbol *, bfd *, asymbol *))) bfd_true)
89 #endif
90 #ifndef bfd_elfNN_bfd_copy_private_section_data
91 #define bfd_elfNN_bfd_copy_private_section_data \
92 ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
93 #endif
94 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
95 #define bfd_elfNN_bfd_copy_private_bfd_data \
96 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
97 #endif
98 #ifndef bfd_elfNN_bfd_print_private_bfd_data
99 #define bfd_elfNN_bfd_print_private_bfd_data \
100 ((boolean (*) PARAMS ((bfd *, void *))) bfd_true)
101 #endif
102 #ifndef bfd_elfNN_bfd_merge_private_bfd_data
103 #define bfd_elfNN_bfd_merge_private_bfd_data \
104 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
105 #endif
106 #ifndef bfd_elfNN_bfd_set_private_flags
107 #define bfd_elfNN_bfd_set_private_flags \
108 ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
109 #endif
110 #ifndef bfd_elfNN_bfd_is_local_label
111 #define bfd_elfNN_bfd_is_local_label bfd_generic_is_local_label
112 #endif
113
114 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
115 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
116 _bfd_nodynamic_get_dynamic_reloc_upper_bound
117 #endif
118 #ifndef bfd_elfNN_canonicalize_dynamic_reloc
119 #define bfd_elfNN_canonicalize_dynamic_reloc \
120 _bfd_nodynamic_canonicalize_dynamic_reloc
121 #endif
122
123 #ifdef elf_backend_relocate_section
124 #ifndef bfd_elfNN_bfd_link_hash_table_create
125 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
126 #endif
127 #else /* ! defined (elf_backend_relocate_section) */
128 /* If no backend relocate_section routine, use the generic linker. */
129 #ifndef bfd_elfNN_bfd_link_hash_table_create
130 #define bfd_elfNN_bfd_link_hash_table_create \
131 _bfd_generic_link_hash_table_create
132 #endif
133 #ifndef bfd_elfNN_bfd_link_add_symbols
134 #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
135 #endif
136 #ifndef bfd_elfNN_bfd_final_link
137 #define bfd_elfNN_bfd_final_link _bfd_generic_final_link
138 #endif
139 #endif /* ! defined (elf_backend_relocate_section) */
140 #ifndef bfd_elfNN_bfd_link_split_section
141 #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
142 #endif
143
144 #ifndef elf_info_to_howto_rel
145 #define elf_info_to_howto_rel 0
146 #endif
147
148 #ifndef ELF_MAXPAGESIZE
149 #define ELF_MAXPAGESIZE 1
150 #endif
151
152 #ifndef elf_backend_collect
153 #define elf_backend_collect false
154 #endif
155
156 #ifndef elf_backend_sym_is_global
157 #define elf_backend_sym_is_global 0
158 #endif
159 #ifndef elf_backend_object_p
160 #define elf_backend_object_p 0
161 #endif
162 #ifndef elf_backend_symbol_processing
163 #define elf_backend_symbol_processing 0
164 #endif
165 #ifndef elf_backend_symbol_table_processing
166 #define elf_backend_symbol_table_processing 0
167 #endif
168 #ifndef elf_backend_section_processing
169 #define elf_backend_section_processing 0
170 #endif
171 #ifndef elf_backend_section_from_shdr
172 #define elf_backend_section_from_shdr 0
173 #endif
174 #ifndef elf_backend_fake_sections
175 #define elf_backend_fake_sections 0
176 #endif
177 #ifndef elf_backend_section_from_bfd_section
178 #define elf_backend_section_from_bfd_section 0
179 #endif
180 #ifndef elf_backend_add_symbol_hook
181 #define elf_backend_add_symbol_hook 0
182 #endif
183 #ifndef elf_backend_link_output_symbol_hook
184 #define elf_backend_link_output_symbol_hook 0
185 #endif
186 #ifndef elf_backend_create_dynamic_sections
187 #define elf_backend_create_dynamic_sections 0
188 #endif
189 #ifndef elf_backend_check_relocs
190 #define elf_backend_check_relocs 0
191 #endif
192 #ifndef elf_backend_adjust_dynamic_symbol
193 #define elf_backend_adjust_dynamic_symbol 0
194 #endif
195 #ifndef elf_backend_size_dynamic_sections
196 #define elf_backend_size_dynamic_sections 0
197 #endif
198 #ifndef elf_backend_relocate_section
199 #define elf_backend_relocate_section 0
200 #endif
201 #ifndef elf_backend_finish_dynamic_symbol
202 #define elf_backend_finish_dynamic_symbol 0
203 #endif
204 #ifndef elf_backend_finish_dynamic_sections
205 #define elf_backend_finish_dynamic_sections 0
206 #endif
207 #ifndef elf_backend_begin_write_processing
208 #define elf_backend_begin_write_processing 0
209 #endif
210 #ifndef elf_backend_final_write_processing
211 #define elf_backend_final_write_processing 0
212 #endif
213 #ifndef elf_backend_create_program_headers
214 #define elf_backend_create_program_headers 0
215 #endif
216 #ifndef elf_backend_ecoff_debug_swap
217 #define elf_backend_ecoff_debug_swap 0
218 #endif
219
220 #ifndef ELF_MACHINE_ALT1
221 #define ELF_MACHINE_ALT1 0
222 #endif
223
224 #ifndef ELF_MACHINE_ALT2
225 #define ELF_MACHINE_ALT2 0
226 #endif
227
228 extern const struct elf_size_info _bfd_elfNN_size_info;
229
230 static CONST struct elf_backend_data elfNN_bed =
231 {
232 #ifdef USE_REL
233 0, /* use_rela_p */
234 #else
235 1, /* use_rela_p */
236 #endif
237 ELF_ARCH, /* arch */
238 ELF_MACHINE_CODE, /* elf_machine_code */
239 ELF_MAXPAGESIZE, /* maxpagesize */
240 elf_backend_collect,
241 elf_info_to_howto,
242 elf_info_to_howto_rel,
243 elf_backend_sym_is_global,
244 elf_backend_object_p,
245 elf_backend_symbol_processing,
246 elf_backend_symbol_table_processing,
247 elf_backend_section_processing,
248 elf_backend_section_from_shdr,
249 elf_backend_fake_sections,
250 elf_backend_section_from_bfd_section,
251 elf_backend_add_symbol_hook,
252 elf_backend_link_output_symbol_hook,
253 elf_backend_create_dynamic_sections,
254 elf_backend_check_relocs,
255 elf_backend_adjust_dynamic_symbol,
256 elf_backend_size_dynamic_sections,
257 elf_backend_relocate_section,
258 elf_backend_finish_dynamic_symbol,
259 elf_backend_finish_dynamic_sections,
260 elf_backend_begin_write_processing,
261 elf_backend_final_write_processing,
262 elf_backend_create_program_headers,
263 elf_backend_ecoff_debug_swap,
264 ELF_MACHINE_ALT1,
265 ELF_MACHINE_ALT2,
266 &_bfd_elfNN_size_info,
267 elf_backend_want_got_plt,
268 elf_backend_plt_readonly,
269 elf_backend_want_plt_sym,
270 elf_backend_want_hdr_in_seg,
271 };
272
273 #ifdef TARGET_BIG_SYM
274 const bfd_target TARGET_BIG_SYM =
275 {
276 /* name: identify kind of target */
277 TARGET_BIG_NAME,
278
279 /* flavour: general indication about file */
280 bfd_target_elf_flavour,
281
282 /* byteorder_big_p: data is big endian */
283 true,
284
285 /* header_byteorder_big_p: header is also big endian */
286 true,
287
288 /* object_flags: mask of all file flags */
289 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
290 DYNAMIC | WP_TEXT | D_PAGED),
291
292 /* section_flags: mask of all section flags */
293 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
294 SEC_CODE | SEC_DATA | SEC_DEBUGGING),
295
296 /* leading_symbol_char: is the first char of a user symbol
297 predictable, and if so what is it */
298 0,
299
300 /* ar_pad_char: pad character for filenames within an archive header
301 FIXME: this really has nothing to do with ELF, this is a characteristic
302 of the archiver and/or os and should be independently tunable */
303 '/',
304
305 /* ar_max_namelen: maximum number of characters in an archive header
306 FIXME: this really has nothing to do with ELF, this is a characteristic
307 of the archiver and should be independently tunable. This value is
308 a WAG (wild a** guess) */
309 14,
310
311 /* Routines to byte-swap various sized integers from the data sections */
312 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
313 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
314 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
315
316 /* Routines to byte-swap various sized integers from the file headers */
317 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
318 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
319 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
320
321 /* bfd_check_format: check the format of a file being read */
322 { _bfd_dummy_target, /* unknown format */
323 bfd_elfNN_object_p, /* assembler/linker output (object file) */
324 bfd_generic_archive_p, /* an archive */
325 bfd_elfNN_core_file_p /* a core file */
326 },
327
328 /* bfd_set_format: set the format of a file being written */
329 { bfd_false,
330 bfd_elf_mkobject,
331 _bfd_generic_mkarchive,
332 bfd_false
333 },
334
335 /* bfd_write_contents: write cached information into a file being written */
336 { bfd_false,
337 bfd_elfNN_write_object_contents,
338 _bfd_write_archive_contents,
339 bfd_false
340 },
341
342 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
343 BFD_JUMP_TABLE_COPY (bfd_elfNN),
344 BFD_JUMP_TABLE_CORE (bfd_elfNN),
345 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
346 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
347 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
348 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
349 BFD_JUMP_TABLE_LINK (bfd_elfNN),
350 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
351
352 /* backend_data: */
353 (PTR) &elfNN_bed,
354 };
355 #endif
356
357 #ifdef TARGET_LITTLE_SYM
358 const bfd_target TARGET_LITTLE_SYM =
359 {
360 /* name: identify kind of target */
361 TARGET_LITTLE_NAME,
362
363 /* flavour: general indication about file */
364 bfd_target_elf_flavour,
365
366 /* byteorder_big_p: data is big endian */
367 false, /* Nope -- this one's little endian */
368
369 /* header_byteorder_big_p: header is also big endian */
370 false, /* Nope -- this one's little endian */
371
372 /* object_flags: mask of all file flags */
373 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
374 DYNAMIC | WP_TEXT | D_PAGED),
375
376 /* section_flags: mask of all section flags */
377 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
378 SEC_CODE | SEC_DATA | SEC_DEBUGGING),
379
380 /* leading_symbol_char: is the first char of a user symbol
381 predictable, and if so what is it */
382 0,
383
384 /* ar_pad_char: pad character for filenames within an archive header
385 FIXME: this really has nothing to do with ELF, this is a characteristic
386 of the archiver and/or os and should be independently tunable */
387 '/',
388
389 /* ar_max_namelen: maximum number of characters in an archive header
390 FIXME: this really has nothing to do with ELF, this is a characteristic
391 of the archiver and should be independently tunable. This value is
392 a WAG (wild a** guess) */
393 14,
394
395 /* Routines to byte-swap various sized integers from the data sections */
396 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
397 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
398 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
399
400 /* Routines to byte-swap various sized integers from the file headers */
401 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
402 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
403 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
404
405 /* bfd_check_format: check the format of a file being read */
406 { _bfd_dummy_target, /* unknown format */
407 bfd_elfNN_object_p, /* assembler/linker output (object file) */
408 bfd_generic_archive_p, /* an archive */
409 bfd_elfNN_core_file_p /* a core file */
410 },
411
412 /* bfd_set_format: set the format of a file being written */
413 { bfd_false,
414 bfd_elf_mkobject,
415 _bfd_generic_mkarchive,
416 bfd_false
417 },
418
419 /* bfd_write_contents: write cached information into a file being written */
420 { bfd_false,
421 bfd_elfNN_write_object_contents,
422 _bfd_write_archive_contents,
423 bfd_false
424 },
425
426 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
427 BFD_JUMP_TABLE_COPY (bfd_elfNN),
428 BFD_JUMP_TABLE_CORE (bfd_elfNN),
429 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
430 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
431 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
432 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
433 BFD_JUMP_TABLE_LINK (bfd_elfNN),
434 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
435
436 /* backend_data: */
437 (PTR) &elfNN_bed,
438 };
439 #endif