°
[binutils.git] / bfd / elfxx-target.h
blob735d95e4644c08f896f774ec5afd97c617e799f8
1 /* Target definitions for NN-bit ELF
2 Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
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.
25 There are two such structures here: one for big-endian machines and
26 one for little-endian machines. */
28 #define bfd_elfNN_close_and_cleanup _bfd_elf_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
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 #ifndef bfd_elfNN_get_reloc_upper_bound
44 #define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound
45 #endif
46 #define bfd_elfNN_get_symbol_info _bfd_elf_get_symbol_info
47 #define bfd_elfNN_get_symtab _bfd_elf_get_symtab
48 #define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
49 #if 0 /* done in elf-bfd.h */
50 #define bfd_elfNN_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
51 #endif
52 #define bfd_elfNN_make_empty_symbol _bfd_elf_make_empty_symbol
53 #define bfd_elfNN_new_section_hook _bfd_elf_new_section_hook
54 #define bfd_elfNN_set_arch_mach _bfd_elf_set_arch_mach
55 #ifndef bfd_elfNN_set_section_contents
56 #define bfd_elfNN_set_section_contents _bfd_elf_set_section_contents
57 #endif
58 #define bfd_elfNN_sizeof_headers _bfd_elf_sizeof_headers
59 #define bfd_elfNN_write_object_contents _bfd_elf_write_object_contents
60 #define bfd_elfNN_write_corefile_contents _bfd_elf_write_corefile_contents
62 #define bfd_elfNN_get_section_contents_in_window \
63 _bfd_generic_get_section_contents_in_window
65 #ifndef elf_backend_got_symbol_offset
66 #define elf_backend_got_symbol_offset (bfd_vma) 0
67 #endif
68 #ifndef elf_backend_want_got_plt
69 #define elf_backend_want_got_plt 0
70 #endif
71 #ifndef elf_backend_plt_readonly
72 #define elf_backend_plt_readonly 0
73 #endif
74 #ifndef elf_backend_want_plt_sym
75 #define elf_backend_want_plt_sym 0
76 #endif
77 #ifndef elf_backend_plt_not_loaded
78 #define elf_backend_plt_not_loaded 0
79 #endif
80 #ifndef elf_backend_plt_alignment
81 #define elf_backend_plt_alignment 2
82 #endif
84 #define bfd_elfNN_bfd_debug_info_start bfd_void
85 #define bfd_elfNN_bfd_debug_info_end bfd_void
86 #define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
88 #ifndef bfd_elfNN_bfd_get_relocated_section_contents
89 #define bfd_elfNN_bfd_get_relocated_section_contents \
90 bfd_generic_get_relocated_section_contents
91 #endif
93 #ifndef bfd_elfNN_bfd_relax_section
94 #define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
95 #endif
97 #ifndef elf_backend_can_gc_sections
98 #define elf_backend_can_gc_sections 0
99 #endif
100 #ifndef elf_backend_gc_mark_hook
101 #define elf_backend_gc_mark_hook NULL
102 #endif
103 #ifndef elf_backend_gc_sweep_hook
104 #define elf_backend_gc_sweep_hook NULL
105 #endif
106 #ifndef bfd_elfNN_bfd_gc_sections
107 #define bfd_elfNN_bfd_gc_sections _bfd_elfNN_gc_sections
108 #endif
110 #define bfd_elfNN_bfd_make_debug_symbol \
111 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
113 #ifndef bfd_elfNN_bfd_copy_private_symbol_data
114 #define bfd_elfNN_bfd_copy_private_symbol_data \
115 _bfd_elf_copy_private_symbol_data
116 #endif
118 #ifndef bfd_elfNN_bfd_copy_private_section_data
119 #define bfd_elfNN_bfd_copy_private_section_data \
120 _bfd_elf_copy_private_section_data
121 #endif
122 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
123 #define bfd_elfNN_bfd_copy_private_bfd_data \
124 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
125 #endif
126 #ifndef bfd_elfNN_bfd_print_private_bfd_data
127 #define bfd_elfNN_bfd_print_private_bfd_data \
128 _bfd_elf_print_private_bfd_data
129 #endif
130 #ifndef bfd_elfNN_bfd_merge_private_bfd_data
131 #define bfd_elfNN_bfd_merge_private_bfd_data \
132 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
133 #endif
134 #ifndef bfd_elfNN_bfd_set_private_flags
135 #define bfd_elfNN_bfd_set_private_flags \
136 ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
137 #endif
138 #ifndef bfd_elfNN_bfd_is_local_label_name
139 #define bfd_elfNN_bfd_is_local_label_name _bfd_elf_is_local_label_name
140 #endif
142 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
143 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
144 _bfd_elf_get_dynamic_reloc_upper_bound
145 #endif
146 #ifndef bfd_elfNN_canonicalize_dynamic_reloc
147 #define bfd_elfNN_canonicalize_dynamic_reloc \
148 _bfd_elf_canonicalize_dynamic_reloc
149 #endif
151 #ifdef elf_backend_relocate_section
152 #ifndef bfd_elfNN_bfd_link_hash_table_create
153 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
154 #endif
155 #else /* ! defined (elf_backend_relocate_section) */
156 /* If no backend relocate_section routine, use the generic linker. */
157 #ifndef bfd_elfNN_bfd_link_hash_table_create
158 #define bfd_elfNN_bfd_link_hash_table_create \
159 _bfd_generic_link_hash_table_create
160 #endif
161 #ifndef bfd_elfNN_bfd_link_add_symbols
162 #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
163 #endif
164 #ifndef bfd_elfNN_bfd_final_link
165 #define bfd_elfNN_bfd_final_link _bfd_generic_final_link
166 #endif
167 #endif /* ! defined (elf_backend_relocate_section) */
168 #ifndef bfd_elfNN_bfd_link_split_section
169 #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
170 #endif
172 #ifndef bfd_elfNN_archive_p
173 #define bfd_elfNN_archive_p bfd_generic_archive_p
174 #endif
176 #ifndef bfd_elfNN_write_archive_contents
177 #define bfd_elfNN_write_archive_contents _bfd_write_archive_contents
178 #endif
180 #ifndef bfd_elfNN_mkobject
181 #define bfd_elfNN_mkobject bfd_elf_mkobject
182 #endif
184 #ifndef bfd_elfNN_mkcorefile
185 #define bfd_elfNN_mkcorefile bfd_elf_mkcorefile
186 #endif
188 #ifndef bfd_elfNN_mkarchive
189 #define bfd_elfNN_mkarchive _bfd_generic_mkarchive
190 #endif
192 #ifndef elf_symbol_leading_char
193 #define elf_symbol_leading_char 0
194 #endif
196 #ifndef elf_info_to_howto
197 #define elf_info_to_howto 0
198 #endif
200 #ifndef elf_info_to_howto_rel
201 #define elf_info_to_howto_rel 0
202 #endif
204 #ifndef ELF_MAXPAGESIZE
205 #error ELF_MAXPAGESIZE is not defined
206 #define ELF_MAXPAGESIZE 1
207 #endif
209 #ifndef elf_backend_collect
210 #define elf_backend_collect false
211 #endif
212 #ifndef elf_backend_type_change_ok
213 #define elf_backend_type_change_ok false
214 #endif
216 #ifndef elf_backend_sym_is_global
217 #define elf_backend_sym_is_global 0
218 #endif
219 #ifndef elf_backend_object_p
220 #define elf_backend_object_p 0
221 #endif
222 #ifndef elf_backend_symbol_processing
223 #define elf_backend_symbol_processing 0
224 #endif
225 #ifndef elf_backend_symbol_table_processing
226 #define elf_backend_symbol_table_processing 0
227 #endif
228 #ifndef elf_backend_get_symbol_type
229 #define elf_backend_get_symbol_type 0
230 #endif
231 #ifndef elf_backend_section_processing
232 #define elf_backend_section_processing 0
233 #endif
234 #ifndef elf_backend_section_from_shdr
235 #define elf_backend_section_from_shdr 0
236 #endif
237 #ifndef elf_backend_fake_sections
238 #define elf_backend_fake_sections 0
239 #endif
240 #ifndef elf_backend_section_from_bfd_section
241 #define elf_backend_section_from_bfd_section 0
242 #endif
243 #ifndef elf_backend_add_symbol_hook
244 #define elf_backend_add_symbol_hook 0
245 #endif
246 #ifndef elf_backend_link_output_symbol_hook
247 #define elf_backend_link_output_symbol_hook 0
248 #endif
249 #ifndef elf_backend_create_dynamic_sections
250 #define elf_backend_create_dynamic_sections 0
251 #endif
252 #ifndef elf_backend_check_relocs
253 #define elf_backend_check_relocs 0
254 #endif
255 #ifndef elf_backend_adjust_dynamic_symbol
256 #define elf_backend_adjust_dynamic_symbol 0
257 #endif
258 #ifndef elf_backend_always_size_sections
259 #define elf_backend_always_size_sections 0
260 #endif
261 #ifndef elf_backend_size_dynamic_sections
262 #define elf_backend_size_dynamic_sections 0
263 #endif
264 #ifndef elf_backend_relocate_section
265 #define elf_backend_relocate_section 0
266 #endif
267 #ifndef elf_backend_finish_dynamic_symbol
268 #define elf_backend_finish_dynamic_symbol 0
269 #endif
270 #ifndef elf_backend_finish_dynamic_sections
271 #define elf_backend_finish_dynamic_sections 0
272 #endif
273 #ifndef elf_backend_begin_write_processing
274 #define elf_backend_begin_write_processing 0
275 #endif
276 #ifndef elf_backend_final_write_processing
277 #define elf_backend_final_write_processing 0
278 #endif
279 #ifndef elf_backend_additional_program_headers
280 #define elf_backend_additional_program_headers 0
281 #endif
282 #ifndef elf_backend_modify_segment_map
283 #define elf_backend_modify_segment_map 0
284 #endif
285 #ifndef elf_backend_ecoff_debug_swap
286 #define elf_backend_ecoff_debug_swap 0
287 #endif
288 #ifndef elf_backend_got_header_size
289 #define elf_backend_got_header_size 0
290 #endif
291 #ifndef elf_backend_plt_header_size
292 #define elf_backend_plt_header_size 0
293 #endif
294 #ifndef elf_backend_post_process_headers
295 #define elf_backend_post_process_headers NULL
296 #endif
298 /* Previously, backends could only use SHT_REL or SHT_RELA relocation
299 sections, but not both. They defined USE_REL to indicate SHT_REL
300 sections, and left it undefined to indicated SHT_RELA sections.
301 For backwards compatibility, we still support this usage. */
302 #ifndef USE_REL
303 #define USE_REL 0
304 #else
305 #undef USE_REL
306 #define USE_REL 1
307 #endif
309 /* Use these in new code. */
310 #ifndef elf_backend_may_use_rel_p
311 #define elf_backend_may_use_rel_p USE_REL
312 #endif
313 #ifndef elf_backend_may_use_rela_p
314 #define elf_backend_may_use_rela_p !USE_REL
315 #endif
316 #ifndef elf_backend_default_use_rela_p
317 #define elf_backend_default_use_rela_p !USE_REL
318 #endif
320 #ifndef ELF_MACHINE_ALT1
321 #define ELF_MACHINE_ALT1 0
322 #endif
324 #ifndef ELF_MACHINE_ALT2
325 #define ELF_MACHINE_ALT2 0
326 #endif
328 #ifndef elf_backend_size_info
329 #define elf_backend_size_info _bfd_elfNN_size_info
330 #endif
332 extern const struct elf_size_info _bfd_elfNN_size_info;
334 static CONST struct elf_backend_data elfNN_bed =
336 ELF_ARCH, /* arch */
337 ELF_MACHINE_CODE, /* elf_machine_code */
338 ELF_MAXPAGESIZE, /* maxpagesize */
339 elf_backend_collect,
340 elf_backend_type_change_ok,
341 elf_info_to_howto,
342 elf_info_to_howto_rel,
343 elf_backend_sym_is_global,
344 elf_backend_object_p,
345 elf_backend_symbol_processing,
346 elf_backend_symbol_table_processing,
347 elf_backend_get_symbol_type,
348 elf_backend_section_processing,
349 elf_backend_section_from_shdr,
350 elf_backend_fake_sections,
351 elf_backend_section_from_bfd_section,
352 elf_backend_add_symbol_hook,
353 elf_backend_link_output_symbol_hook,
354 elf_backend_create_dynamic_sections,
355 elf_backend_check_relocs,
356 elf_backend_adjust_dynamic_symbol,
357 elf_backend_always_size_sections,
358 elf_backend_size_dynamic_sections,
359 elf_backend_relocate_section,
360 elf_backend_finish_dynamic_symbol,
361 elf_backend_finish_dynamic_sections,
362 elf_backend_begin_write_processing,
363 elf_backend_final_write_processing,
364 elf_backend_additional_program_headers,
365 elf_backend_modify_segment_map,
366 elf_backend_gc_mark_hook,
367 elf_backend_gc_sweep_hook,
368 elf_backend_post_process_headers,
369 elf_backend_ecoff_debug_swap,
370 ELF_MACHINE_ALT1,
371 ELF_MACHINE_ALT2,
372 &elf_backend_size_info,
373 elf_backend_got_symbol_offset,
374 elf_backend_got_header_size,
375 elf_backend_plt_header_size,
376 elf_backend_may_use_rel_p,
377 elf_backend_may_use_rela_p,
378 elf_backend_default_use_rela_p,
379 elf_backend_want_got_plt,
380 elf_backend_plt_readonly,
381 elf_backend_want_plt_sym,
382 elf_backend_plt_not_loaded,
383 elf_backend_plt_alignment,
384 elf_backend_can_gc_sections
387 #ifdef TARGET_BIG_SYM
388 const bfd_target TARGET_BIG_SYM =
390 /* name: identify kind of target */
391 TARGET_BIG_NAME,
393 /* flavour: general indication about file */
394 bfd_target_elf_flavour,
396 /* byteorder: data is big endian */
397 BFD_ENDIAN_BIG,
399 /* header_byteorder: header is also big endian */
400 BFD_ENDIAN_BIG,
402 /* object_flags: mask of all file flags */
403 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
404 DYNAMIC | WP_TEXT | D_PAGED),
406 /* section_flags: mask of all section flags */
407 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
408 SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
410 /* leading_symbol_char: is the first char of a user symbol
411 predictable, and if so what is it */
412 elf_symbol_leading_char,
414 /* ar_pad_char: pad character for filenames within an archive header
415 FIXME: this really has nothing to do with ELF, this is a characteristic
416 of the archiver and/or os and should be independently tunable */
417 '/',
419 /* ar_max_namelen: maximum number of characters in an archive header
420 FIXME: this really has nothing to do with ELF, this is a characteristic
421 of the archiver and should be independently tunable. This value is
422 a WAG (wild a** guess) */
425 /* Routines to byte-swap various sized integers from the data sections */
426 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
427 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
428 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
430 /* Routines to byte-swap various sized integers from the file headers */
431 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
432 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
433 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
435 /* bfd_check_format: check the format of a file being read */
436 { _bfd_dummy_target, /* unknown format */
437 bfd_elfNN_object_p, /* assembler/linker output (object file) */
438 bfd_elfNN_archive_p, /* an archive */
439 bfd_elfNN_core_file_p /* a core file */
442 /* bfd_set_format: set the format of a file being written */
443 { bfd_false,
444 bfd_elfNN_mkobject,
445 bfd_elfNN_mkarchive,
446 bfd_elfNN_mkcorefile
449 /* bfd_write_contents: write cached information into a file being written */
450 { bfd_false,
451 bfd_elfNN_write_object_contents,
452 bfd_elfNN_write_archive_contents,
453 bfd_elfNN_write_corefile_contents,
456 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
457 BFD_JUMP_TABLE_COPY (bfd_elfNN),
458 BFD_JUMP_TABLE_CORE (bfd_elfNN),
459 #ifdef bfd_elfNN_archive_functions
460 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
461 #else
462 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
463 #endif
464 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
465 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
466 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
467 BFD_JUMP_TABLE_LINK (bfd_elfNN),
468 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
470 /* backend_data: */
471 (PTR) &elfNN_bed,
473 #endif
475 #ifdef TARGET_LITTLE_SYM
476 const bfd_target TARGET_LITTLE_SYM =
478 /* name: identify kind of target */
479 TARGET_LITTLE_NAME,
481 /* flavour: general indication about file */
482 bfd_target_elf_flavour,
484 /* byteorder: data is little endian */
485 BFD_ENDIAN_LITTLE,
487 /* header_byteorder: header is also little endian */
488 BFD_ENDIAN_LITTLE,
490 /* object_flags: mask of all file flags */
491 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
492 DYNAMIC | WP_TEXT | D_PAGED),
494 /* section_flags: mask of all section flags */
495 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
496 SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
498 /* leading_symbol_char: is the first char of a user symbol
499 predictable, and if so what is it */
500 elf_symbol_leading_char,
502 /* ar_pad_char: pad character for filenames within an archive header
503 FIXME: this really has nothing to do with ELF, this is a characteristic
504 of the archiver and/or os and should be independently tunable */
505 '/',
507 /* ar_max_namelen: maximum number of characters in an archive header
508 FIXME: this really has nothing to do with ELF, this is a characteristic
509 of the archiver and should be independently tunable. This value is
510 a WAG (wild a** guess) */
513 /* Routines to byte-swap various sized integers from the data sections */
514 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
515 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
516 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
518 /* Routines to byte-swap various sized integers from the file headers */
519 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
520 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
521 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
523 /* bfd_check_format: check the format of a file being read */
524 { _bfd_dummy_target, /* unknown format */
525 bfd_elfNN_object_p, /* assembler/linker output (object file) */
526 bfd_elfNN_archive_p, /* an archive */
527 bfd_elfNN_core_file_p /* a core file */
530 /* bfd_set_format: set the format of a file being written */
531 { bfd_false,
532 bfd_elfNN_mkobject,
533 bfd_elfNN_mkarchive,
534 bfd_elfNN_mkcorefile
537 /* bfd_write_contents: write cached information into a file being written */
538 { bfd_false,
539 bfd_elfNN_write_object_contents,
540 bfd_elfNN_write_archive_contents,
541 bfd_elfNN_write_corefile_contents,
544 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
545 BFD_JUMP_TABLE_COPY (bfd_elfNN),
546 BFD_JUMP_TABLE_CORE (bfd_elfNN),
547 #ifdef bfd_elfNN_archive_functions
548 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
549 #else
550 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
551 #endif
552 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
553 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
554 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
555 BFD_JUMP_TABLE_LINK (bfd_elfNN),
556 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
558 /* backend_data: */
559 (PTR) &elfNN_bed,
561 #endif