1 /* Target definitions for NN-bit ELF
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 /* This structure contains everything that BFD knows about a target.
22 It includes things like its byte order, name, what routines to call
23 to do various operations, etc. Every BFD points to a target structure
24 with its "xvec" member.
26 There are two such structures here: one for big-endian machines and
27 one for little-endian machines. */
29 #define bfd_elfNN_close_and_cleanup _bfd_elf_close_and_cleanup
30 #define bfd_elfNN_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
31 #ifndef bfd_elfNN_get_section_contents
32 #define bfd_elfNN_get_section_contents _bfd_generic_get_section_contents
35 #define bfd_elfNN_canonicalize_dynamic_symtab _bfd_elf_canonicalize_dynamic_symtab
36 #define bfd_elfNN_canonicalize_reloc _bfd_elf_canonicalize_reloc
37 #ifndef bfd_elfNN_find_nearest_line
38 #define bfd_elfNN_find_nearest_line _bfd_elf_find_nearest_line
40 #define bfd_elfNN_read_minisymbols _bfd_elf_read_minisymbols
41 #define bfd_elfNN_minisymbol_to_symbol _bfd_elf_minisymbol_to_symbol
42 #define bfd_elfNN_get_dynamic_symtab_upper_bound _bfd_elf_get_dynamic_symtab_upper_bound
43 #define bfd_elfNN_get_lineno _bfd_elf_get_lineno
44 #ifndef bfd_elfNN_get_reloc_upper_bound
45 #define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound
47 #define bfd_elfNN_get_symbol_info _bfd_elf_get_symbol_info
48 #define bfd_elfNN_get_symtab _bfd_elf_get_symtab
49 #define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
50 #if 0 /* done in elf-bfd.h */
51 #define bfd_elfNN_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
53 #define bfd_elfNN_make_empty_symbol _bfd_elf_make_empty_symbol
54 #define bfd_elfNN_new_section_hook _bfd_elf_new_section_hook
55 #define bfd_elfNN_set_arch_mach _bfd_elf_set_arch_mach
56 #ifndef bfd_elfNN_set_section_contents
57 #define bfd_elfNN_set_section_contents _bfd_elf_set_section_contents
59 #define bfd_elfNN_sizeof_headers _bfd_elf_sizeof_headers
60 #define bfd_elfNN_write_object_contents _bfd_elf_write_object_contents
61 #define bfd_elfNN_write_corefile_contents _bfd_elf_write_corefile_contents
63 #define bfd_elfNN_get_section_contents_in_window \
64 _bfd_generic_get_section_contents_in_window
66 #ifndef elf_backend_got_symbol_offset
67 #define elf_backend_got_symbol_offset (bfd_vma) 0
69 #ifndef elf_backend_want_got_plt
70 #define elf_backend_want_got_plt 0
72 #ifndef elf_backend_plt_readonly
73 #define elf_backend_plt_readonly 0
75 #ifndef elf_backend_want_plt_sym
76 #define elf_backend_want_plt_sym 0
78 #ifndef elf_backend_plt_not_loaded
79 #define elf_backend_plt_not_loaded 0
81 #ifndef elf_backend_plt_alignment
82 #define elf_backend_plt_alignment 2
84 #ifndef elf_backend_want_dynbss
85 #define elf_backend_want_dynbss 1
88 #define bfd_elfNN_bfd_debug_info_start bfd_void
89 #define bfd_elfNN_bfd_debug_info_end bfd_void
90 #define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
92 #ifndef bfd_elfNN_bfd_get_relocated_section_contents
93 #define bfd_elfNN_bfd_get_relocated_section_contents \
94 bfd_generic_get_relocated_section_contents
97 #ifndef bfd_elfNN_bfd_relax_section
98 #define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
101 #ifndef elf_backend_can_gc_sections
102 #define elf_backend_can_gc_sections 0
104 #ifndef elf_backend_want_got_sym
105 #define elf_backend_want_got_sym 1
107 #ifndef elf_backend_gc_mark_hook
108 #define elf_backend_gc_mark_hook NULL
110 #ifndef elf_backend_gc_sweep_hook
111 #define elf_backend_gc_sweep_hook NULL
113 #ifndef bfd_elfNN_bfd_gc_sections
114 #define bfd_elfNN_bfd_gc_sections _bfd_elfNN_gc_sections
117 #ifndef bfd_elfNN_bfd_merge_sections
118 #define bfd_elfNN_bfd_merge_sections \
119 _bfd_elf_merge_sections
122 #ifndef bfd_elfNN_bfd_make_debug_symbol
123 #define bfd_elfNN_bfd_make_debug_symbol \
124 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
127 #ifndef bfd_elfNN_bfd_copy_private_symbol_data
128 #define bfd_elfNN_bfd_copy_private_symbol_data \
129 _bfd_elf_copy_private_symbol_data
132 #ifndef bfd_elfNN_bfd_copy_private_section_data
133 #define bfd_elfNN_bfd_copy_private_section_data \
134 _bfd_elf_copy_private_section_data
136 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
137 #define bfd_elfNN_bfd_copy_private_bfd_data \
138 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
140 #ifndef bfd_elfNN_bfd_print_private_bfd_data
141 #define bfd_elfNN_bfd_print_private_bfd_data \
142 _bfd_elf_print_private_bfd_data
144 #ifndef bfd_elfNN_bfd_merge_private_bfd_data
145 #define bfd_elfNN_bfd_merge_private_bfd_data \
146 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
148 #ifndef bfd_elfNN_bfd_set_private_flags
149 #define bfd_elfNN_bfd_set_private_flags \
150 ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
152 #ifndef bfd_elfNN_bfd_is_local_label_name
153 #define bfd_elfNN_bfd_is_local_label_name _bfd_elf_is_local_label_name
156 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
157 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
158 _bfd_elf_get_dynamic_reloc_upper_bound
160 #ifndef bfd_elfNN_canonicalize_dynamic_reloc
161 #define bfd_elfNN_canonicalize_dynamic_reloc \
162 _bfd_elf_canonicalize_dynamic_reloc
165 #ifndef bfd_elfNN_bfd_link_hash_table_create
166 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
168 #ifndef elf_backend_relocate_section
169 /* If no backend relocate_section routine, use the generic linker. */
170 #ifndef bfd_elfNN_bfd_link_add_symbols
171 #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
173 #ifndef bfd_elfNN_bfd_final_link
174 #define bfd_elfNN_bfd_final_link _bfd_generic_final_link
176 #endif /* ! defined (elf_backend_relocate_section) */
177 #ifndef bfd_elfNN_bfd_link_split_section
178 #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
181 #ifndef bfd_elfNN_archive_p
182 #define bfd_elfNN_archive_p bfd_generic_archive_p
185 #ifndef bfd_elfNN_write_archive_contents
186 #define bfd_elfNN_write_archive_contents _bfd_write_archive_contents
189 #ifndef bfd_elfNN_mkobject
190 #define bfd_elfNN_mkobject bfd_elf_mkobject
193 #ifndef bfd_elfNN_mkcorefile
194 #define bfd_elfNN_mkcorefile bfd_elf_mkcorefile
197 #ifndef bfd_elfNN_mkarchive
198 #define bfd_elfNN_mkarchive _bfd_generic_mkarchive
201 #ifndef elf_symbol_leading_char
202 #define elf_symbol_leading_char 0
205 #ifndef elf_info_to_howto
206 #define elf_info_to_howto 0
209 #ifndef elf_info_to_howto_rel
210 #define elf_info_to_howto_rel 0
213 #ifndef ELF_MAXPAGESIZE
214 #error ELF_MAXPAGESIZE is not defined
215 #define ELF_MAXPAGESIZE 1
218 #ifndef elf_backend_collect
219 #define elf_backend_collect false
221 #ifndef elf_backend_type_change_ok
222 #define elf_backend_type_change_ok false
225 #ifndef elf_backend_sym_is_global
226 #define elf_backend_sym_is_global 0
228 #ifndef elf_backend_object_p
229 #define elf_backend_object_p 0
231 #ifndef elf_backend_symbol_processing
232 #define elf_backend_symbol_processing 0
234 #ifndef elf_backend_symbol_table_processing
235 #define elf_backend_symbol_table_processing 0
237 #ifndef elf_backend_get_symbol_type
238 #define elf_backend_get_symbol_type 0
240 #ifndef elf_backend_section_processing
241 #define elf_backend_section_processing 0
243 #ifndef elf_backend_section_from_shdr
244 #define elf_backend_section_from_shdr 0
246 #ifndef elf_backend_section_flags
247 #define elf_backend_section_flags 0
249 #ifndef elf_backend_section_from_phdr
250 #define elf_backend_section_from_phdr 0
252 #ifndef elf_backend_fake_sections
253 #define elf_backend_fake_sections 0
255 #ifndef elf_backend_section_from_bfd_section
256 #define elf_backend_section_from_bfd_section 0
258 #ifndef elf_backend_add_symbol_hook
259 #define elf_backend_add_symbol_hook 0
261 #ifndef elf_backend_link_output_symbol_hook
262 #define elf_backend_link_output_symbol_hook 0
264 #ifndef elf_backend_create_dynamic_sections
265 #define elf_backend_create_dynamic_sections 0
267 #ifndef elf_backend_check_relocs
268 #define elf_backend_check_relocs 0
270 #ifndef elf_backend_adjust_dynamic_symbol
271 #define elf_backend_adjust_dynamic_symbol 0
273 #ifndef elf_backend_always_size_sections
274 #define elf_backend_always_size_sections 0
276 #ifndef elf_backend_size_dynamic_sections
277 #define elf_backend_size_dynamic_sections 0
279 #ifndef elf_backend_relocate_section
280 #define elf_backend_relocate_section 0
282 #ifndef elf_backend_finish_dynamic_symbol
283 #define elf_backend_finish_dynamic_symbol 0
285 #ifndef elf_backend_finish_dynamic_sections
286 #define elf_backend_finish_dynamic_sections 0
288 #ifndef elf_backend_begin_write_processing
289 #define elf_backend_begin_write_processing 0
291 #ifndef elf_backend_final_write_processing
292 #define elf_backend_final_write_processing 0
294 #ifndef elf_backend_additional_program_headers
295 #define elf_backend_additional_program_headers 0
297 #ifndef elf_backend_modify_segment_map
298 #define elf_backend_modify_segment_map 0
300 #ifndef elf_backend_ecoff_debug_swap
301 #define elf_backend_ecoff_debug_swap 0
303 #ifndef elf_backend_got_header_size
304 #define elf_backend_got_header_size 0
306 #ifndef elf_backend_plt_header_size
307 #define elf_backend_plt_header_size 0
309 #ifndef elf_backend_post_process_headers
310 #define elf_backend_post_process_headers NULL
312 #ifndef elf_backend_print_symbol_all
313 #define elf_backend_print_symbol_all NULL
315 #ifndef elf_backend_output_arch_syms
316 #define elf_backend_output_arch_syms NULL
318 #ifndef elf_backend_copy_indirect_symbol
319 #define elf_backend_copy_indirect_symbol _bfd_elf_link_hash_copy_indirect
321 #ifndef elf_backend_hide_symbol
322 #define elf_backend_hide_symbol _bfd_elf_link_hash_hide_symbol
324 #ifndef elf_backend_emit_relocs
325 #define elf_backend_emit_relocs NULL
327 #ifndef elf_backend_count_relocs
328 #define elf_backend_count_relocs NULL
330 #ifndef elf_backend_grok_prstatus
331 #define elf_backend_grok_prstatus NULL
333 #ifndef elf_backend_grok_psinfo
334 #define elf_backend_grok_psinfo NULL
336 #ifndef elf_backend_sprintf_vma
337 #define elf_backend_sprintf_vma _bfd_elf_sprintf_vma
339 #ifndef elf_backend_fprintf_vma
340 #define elf_backend_fprintf_vma _bfd_elf_fprintf_vma
343 /* Previously, backends could only use SHT_REL or SHT_RELA relocation
344 sections, but not both. They defined USE_REL to indicate SHT_REL
345 sections, and left it undefined to indicated SHT_RELA sections.
346 For backwards compatibility, we still support this usage. */
354 /* Use these in new code. */
355 #ifndef elf_backend_may_use_rel_p
356 #define elf_backend_may_use_rel_p USE_REL
358 #ifndef elf_backend_may_use_rela_p
359 #define elf_backend_may_use_rela_p !USE_REL
361 #ifndef elf_backend_default_use_rela_p
362 #define elf_backend_default_use_rela_p !USE_REL
365 #ifndef ELF_MACHINE_ALT1
366 #define ELF_MACHINE_ALT1 0
369 #ifndef ELF_MACHINE_ALT2
370 #define ELF_MACHINE_ALT2 0
373 #ifndef elf_backend_size_info
374 #define elf_backend_size_info _bfd_elfNN_size_info
377 #ifndef elf_backend_sign_extend_vma
378 #define elf_backend_sign_extend_vma 0
381 extern const struct elf_size_info _bfd_elfNN_size_info;
383 #ifndef INCLUDED_TARGET_FILE
384 static CONST struct elf_backend_data elfNN_bed =
387 ELF_MACHINE_CODE, /* elf_machine_code */
388 ELF_MAXPAGESIZE, /* maxpagesize */
390 elf_info_to_howto_rel,
391 elf_backend_sym_is_global,
392 elf_backend_object_p,
393 elf_backend_symbol_processing,
394 elf_backend_symbol_table_processing,
395 elf_backend_get_symbol_type,
396 elf_backend_section_processing,
397 elf_backend_section_from_shdr,
398 elf_backend_section_flags,
399 elf_backend_section_from_phdr,
400 elf_backend_fake_sections,
401 elf_backend_section_from_bfd_section,
402 elf_backend_add_symbol_hook,
403 elf_backend_link_output_symbol_hook,
404 elf_backend_create_dynamic_sections,
405 elf_backend_check_relocs,
406 elf_backend_adjust_dynamic_symbol,
407 elf_backend_always_size_sections,
408 elf_backend_size_dynamic_sections,
409 elf_backend_relocate_section,
410 elf_backend_finish_dynamic_symbol,
411 elf_backend_finish_dynamic_sections,
412 elf_backend_begin_write_processing,
413 elf_backend_final_write_processing,
414 elf_backend_additional_program_headers,
415 elf_backend_modify_segment_map,
416 elf_backend_gc_mark_hook,
417 elf_backend_gc_sweep_hook,
418 elf_backend_post_process_headers,
419 elf_backend_print_symbol_all,
420 elf_backend_output_arch_syms,
421 elf_backend_copy_indirect_symbol,
422 elf_backend_hide_symbol,
423 elf_backend_emit_relocs,
424 elf_backend_count_relocs,
425 elf_backend_grok_prstatus,
426 elf_backend_grok_psinfo,
427 elf_backend_sprintf_vma,
428 elf_backend_fprintf_vma,
429 elf_backend_ecoff_debug_swap,
432 &elf_backend_size_info,
433 elf_backend_got_symbol_offset,
434 elf_backend_got_header_size,
435 elf_backend_plt_header_size,
437 elf_backend_type_change_ok,
438 elf_backend_may_use_rel_p,
439 elf_backend_may_use_rela_p,
440 elf_backend_default_use_rela_p,
441 elf_backend_sign_extend_vma,
442 elf_backend_want_got_plt,
443 elf_backend_plt_readonly,
444 elf_backend_want_plt_sym,
445 elf_backend_plt_not_loaded,
446 elf_backend_plt_alignment,
447 elf_backend_can_gc_sections,
448 elf_backend_want_dynbss,
449 elf_backend_want_got_sym
453 /* Forward declaration for use when initialising alternative_target field. */
454 #ifdef TARGET_LITTLE_SYM
455 extern const bfd_target TARGET_LITTLE_SYM;
458 #ifdef TARGET_BIG_SYM
459 const bfd_target TARGET_BIG_SYM =
461 /* name: identify kind of target */
464 /* flavour: general indication about file */
465 bfd_target_elf_flavour,
467 /* byteorder: data is big endian */
470 /* header_byteorder: header is also big endian */
473 /* object_flags: mask of all file flags */
474 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
475 DYNAMIC | WP_TEXT | D_PAGED),
477 /* section_flags: mask of all section flags */
478 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
479 SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
481 /* leading_symbol_char: is the first char of a user symbol
482 predictable, and if so what is it */
483 elf_symbol_leading_char,
485 /* ar_pad_char: pad character for filenames within an archive header
486 FIXME: this really has nothing to do with ELF, this is a characteristic
487 of the archiver and/or os and should be independently tunable */
490 /* ar_max_namelen: maximum number of characters in an archive header
491 FIXME: this really has nothing to do with ELF, this is a characteristic
492 of the archiver and should be independently tunable. This value is
493 a WAG (wild a** guess) */
496 /* Routines to byte-swap various sized integers from the data sections */
497 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
498 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
499 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
501 /* Routines to byte-swap various sized integers from the file headers */
502 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
503 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
504 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
506 /* bfd_check_format: check the format of a file being read */
507 { _bfd_dummy_target, /* unknown format */
508 bfd_elfNN_object_p, /* assembler/linker output (object file) */
509 bfd_elfNN_archive_p, /* an archive */
510 bfd_elfNN_core_file_p /* a core file */
513 /* bfd_set_format: set the format of a file being written */
520 /* bfd_write_contents: write cached information into a file being written */
522 bfd_elfNN_write_object_contents,
523 bfd_elfNN_write_archive_contents,
524 bfd_elfNN_write_corefile_contents,
527 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
528 BFD_JUMP_TABLE_COPY (bfd_elfNN),
529 BFD_JUMP_TABLE_CORE (bfd_elfNN),
530 #ifdef bfd_elfNN_archive_functions
531 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
533 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
535 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
536 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
537 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
538 BFD_JUMP_TABLE_LINK (bfd_elfNN),
539 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
541 /* Alternative endian target. */
542 #ifdef TARGET_LITTLE_SYM
553 #ifdef TARGET_LITTLE_SYM
554 const bfd_target TARGET_LITTLE_SYM =
556 /* name: identify kind of target */
559 /* flavour: general indication about file */
560 bfd_target_elf_flavour,
562 /* byteorder: data is little endian */
565 /* header_byteorder: header is also little endian */
568 /* object_flags: mask of all file flags */
569 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
570 DYNAMIC | WP_TEXT | D_PAGED),
572 /* section_flags: mask of all section flags */
573 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
574 SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
576 /* leading_symbol_char: is the first char of a user symbol
577 predictable, and if so what is it */
578 elf_symbol_leading_char,
580 /* ar_pad_char: pad character for filenames within an archive header
581 FIXME: this really has nothing to do with ELF, this is a characteristic
582 of the archiver and/or os and should be independently tunable */
585 /* ar_max_namelen: maximum number of characters in an archive header
586 FIXME: this really has nothing to do with ELF, this is a characteristic
587 of the archiver and should be independently tunable. This value is
588 a WAG (wild a** guess) */
591 /* Routines to byte-swap various sized integers from the data sections */
592 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
593 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
594 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
596 /* Routines to byte-swap various sized integers from the file headers */
597 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
598 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
599 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
601 /* bfd_check_format: check the format of a file being read */
602 { _bfd_dummy_target, /* unknown format */
603 bfd_elfNN_object_p, /* assembler/linker output (object file) */
604 bfd_elfNN_archive_p, /* an archive */
605 bfd_elfNN_core_file_p /* a core file */
608 /* bfd_set_format: set the format of a file being written */
615 /* bfd_write_contents: write cached information into a file being written */
617 bfd_elfNN_write_object_contents,
618 bfd_elfNN_write_archive_contents,
619 bfd_elfNN_write_corefile_contents,
622 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
623 BFD_JUMP_TABLE_COPY (bfd_elfNN),
624 BFD_JUMP_TABLE_CORE (bfd_elfNN),
625 #ifdef bfd_elfNN_archive_functions
626 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
628 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
630 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
631 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
632 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
633 BFD_JUMP_TABLE_LINK (bfd_elfNN),
634 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
636 /* Alternative endian target. */
637 #ifdef TARGET_BIG_SYM