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_gc_mark_hook
105 #define elf_backend_gc_mark_hook NULL
107 #ifndef elf_backend_gc_sweep_hook
108 #define elf_backend_gc_sweep_hook NULL
110 #ifndef bfd_elfNN_bfd_gc_sections
111 #define bfd_elfNN_bfd_gc_sections _bfd_elfNN_gc_sections
114 #define bfd_elfNN_bfd_make_debug_symbol \
115 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
117 #ifndef bfd_elfNN_bfd_copy_private_symbol_data
118 #define bfd_elfNN_bfd_copy_private_symbol_data \
119 _bfd_elf_copy_private_symbol_data
122 #ifndef bfd_elfNN_bfd_copy_private_section_data
123 #define bfd_elfNN_bfd_copy_private_section_data \
124 _bfd_elf_copy_private_section_data
126 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
127 #define bfd_elfNN_bfd_copy_private_bfd_data \
128 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
130 #ifndef bfd_elfNN_bfd_print_private_bfd_data
131 #define bfd_elfNN_bfd_print_private_bfd_data \
132 _bfd_elf_print_private_bfd_data
134 #ifndef bfd_elfNN_bfd_merge_private_bfd_data
135 #define bfd_elfNN_bfd_merge_private_bfd_data \
136 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
138 #ifndef bfd_elfNN_bfd_set_private_flags
139 #define bfd_elfNN_bfd_set_private_flags \
140 ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
142 #ifndef bfd_elfNN_bfd_is_local_label_name
143 #define bfd_elfNN_bfd_is_local_label_name _bfd_elf_is_local_label_name
146 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
147 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
148 _bfd_elf_get_dynamic_reloc_upper_bound
150 #ifndef bfd_elfNN_canonicalize_dynamic_reloc
151 #define bfd_elfNN_canonicalize_dynamic_reloc \
152 _bfd_elf_canonicalize_dynamic_reloc
155 #ifdef elf_backend_relocate_section
156 #ifndef bfd_elfNN_bfd_link_hash_table_create
157 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
159 #else /* ! defined (elf_backend_relocate_section) */
160 /* If no backend relocate_section routine, use the generic linker. */
161 #ifndef bfd_elfNN_bfd_link_hash_table_create
162 #define bfd_elfNN_bfd_link_hash_table_create \
163 _bfd_generic_link_hash_table_create
165 #ifndef bfd_elfNN_bfd_link_add_symbols
166 #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
168 #ifndef bfd_elfNN_bfd_final_link
169 #define bfd_elfNN_bfd_final_link _bfd_generic_final_link
171 #endif /* ! defined (elf_backend_relocate_section) */
172 #ifndef bfd_elfNN_bfd_link_split_section
173 #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
176 #ifndef bfd_elfNN_archive_p
177 #define bfd_elfNN_archive_p bfd_generic_archive_p
180 #ifndef bfd_elfNN_write_archive_contents
181 #define bfd_elfNN_write_archive_contents _bfd_write_archive_contents
184 #ifndef bfd_elfNN_mkobject
185 #define bfd_elfNN_mkobject bfd_elf_mkobject
188 #ifndef bfd_elfNN_mkcorefile
189 #define bfd_elfNN_mkcorefile bfd_elf_mkcorefile
192 #ifndef bfd_elfNN_mkarchive
193 #define bfd_elfNN_mkarchive _bfd_generic_mkarchive
196 #ifndef elf_symbol_leading_char
197 #define elf_symbol_leading_char 0
200 #ifndef elf_info_to_howto
201 #define elf_info_to_howto 0
204 #ifndef elf_info_to_howto_rel
205 #define elf_info_to_howto_rel 0
208 #ifndef ELF_MAXPAGESIZE
209 #error ELF_MAXPAGESIZE is not defined
210 #define ELF_MAXPAGESIZE 1
213 #ifndef elf_backend_collect
214 #define elf_backend_collect false
216 #ifndef elf_backend_type_change_ok
217 #define elf_backend_type_change_ok false
220 #ifndef elf_backend_sym_is_global
221 #define elf_backend_sym_is_global 0
223 #ifndef elf_backend_object_p
224 #define elf_backend_object_p 0
226 #ifndef elf_backend_symbol_processing
227 #define elf_backend_symbol_processing 0
229 #ifndef elf_backend_symbol_table_processing
230 #define elf_backend_symbol_table_processing 0
232 #ifndef elf_backend_get_symbol_type
233 #define elf_backend_get_symbol_type 0
235 #ifndef elf_backend_section_processing
236 #define elf_backend_section_processing 0
238 #ifndef elf_backend_section_from_shdr
239 #define elf_backend_section_from_shdr 0
241 #ifndef elf_backend_section_flags
242 #define elf_backend_section_flags 0
244 #ifndef elf_backend_section_from_phdr
245 #define elf_backend_section_from_phdr 0
247 #ifndef elf_backend_fake_sections
248 #define elf_backend_fake_sections 0
250 #ifndef elf_backend_section_from_bfd_section
251 #define elf_backend_section_from_bfd_section 0
253 #ifndef elf_backend_add_symbol_hook
254 #define elf_backend_add_symbol_hook 0
256 #ifndef elf_backend_link_output_symbol_hook
257 #define elf_backend_link_output_symbol_hook 0
259 #ifndef elf_backend_create_dynamic_sections
260 #define elf_backend_create_dynamic_sections 0
262 #ifndef elf_backend_check_relocs
263 #define elf_backend_check_relocs 0
265 #ifndef elf_backend_adjust_dynamic_symbol
266 #define elf_backend_adjust_dynamic_symbol 0
268 #ifndef elf_backend_always_size_sections
269 #define elf_backend_always_size_sections 0
271 #ifndef elf_backend_size_dynamic_sections
272 #define elf_backend_size_dynamic_sections 0
274 #ifndef elf_backend_relocate_section
275 #define elf_backend_relocate_section 0
277 #ifndef elf_backend_finish_dynamic_symbol
278 #define elf_backend_finish_dynamic_symbol 0
280 #ifndef elf_backend_finish_dynamic_sections
281 #define elf_backend_finish_dynamic_sections 0
283 #ifndef elf_backend_begin_write_processing
284 #define elf_backend_begin_write_processing 0
286 #ifndef elf_backend_final_write_processing
287 #define elf_backend_final_write_processing 0
289 #ifndef elf_backend_additional_program_headers
290 #define elf_backend_additional_program_headers 0
292 #ifndef elf_backend_modify_segment_map
293 #define elf_backend_modify_segment_map 0
295 #ifndef elf_backend_ecoff_debug_swap
296 #define elf_backend_ecoff_debug_swap 0
298 #ifndef elf_backend_got_header_size
299 #define elf_backend_got_header_size 0
301 #ifndef elf_backend_plt_header_size
302 #define elf_backend_plt_header_size 0
304 #ifndef elf_backend_post_process_headers
305 #define elf_backend_post_process_headers NULL
307 #ifndef elf_backend_print_symbol_all
308 #define elf_backend_print_symbol_all NULL
310 #ifndef elf_backend_output_arch_syms
311 #define elf_backend_output_arch_syms NULL
313 #ifndef elf_backend_copy_indirect_symbol
314 #define elf_backend_copy_indirect_symbol _bfd_elf_link_hash_copy_indirect
316 #ifndef elf_backend_hide_symbol
317 #define elf_backend_hide_symbol _bfd_elf_link_hash_hide_symbol
320 /* Previously, backends could only use SHT_REL or SHT_RELA relocation
321 sections, but not both. They defined USE_REL to indicate SHT_REL
322 sections, and left it undefined to indicated SHT_RELA sections.
323 For backwards compatibility, we still support this usage. */
331 /* Use these in new code. */
332 #ifndef elf_backend_may_use_rel_p
333 #define elf_backend_may_use_rel_p USE_REL
335 #ifndef elf_backend_may_use_rela_p
336 #define elf_backend_may_use_rela_p !USE_REL
338 #ifndef elf_backend_default_use_rela_p
339 #define elf_backend_default_use_rela_p !USE_REL
342 #ifndef ELF_MACHINE_ALT1
343 #define ELF_MACHINE_ALT1 0
346 #ifndef ELF_MACHINE_ALT2
347 #define ELF_MACHINE_ALT2 0
350 #ifndef elf_backend_size_info
351 #define elf_backend_size_info _bfd_elfNN_size_info
354 #ifndef elf_backend_sign_extend_vma
355 #define elf_backend_sign_extend_vma 0
358 extern const struct elf_size_info _bfd_elfNN_size_info;
360 #ifndef INCLUDED_TARGET_FILE
361 static CONST struct elf_backend_data elfNN_bed =
364 ELF_MACHINE_CODE, /* elf_machine_code */
365 ELF_MAXPAGESIZE, /* maxpagesize */
367 elf_info_to_howto_rel,
368 elf_backend_sym_is_global,
369 elf_backend_object_p,
370 elf_backend_symbol_processing,
371 elf_backend_symbol_table_processing,
372 elf_backend_get_symbol_type,
373 elf_backend_section_processing,
374 elf_backend_section_from_shdr,
375 elf_backend_section_flags,
376 elf_backend_section_from_phdr,
377 elf_backend_fake_sections,
378 elf_backend_section_from_bfd_section,
379 elf_backend_add_symbol_hook,
380 elf_backend_link_output_symbol_hook,
381 elf_backend_create_dynamic_sections,
382 elf_backend_check_relocs,
383 elf_backend_adjust_dynamic_symbol,
384 elf_backend_always_size_sections,
385 elf_backend_size_dynamic_sections,
386 elf_backend_relocate_section,
387 elf_backend_finish_dynamic_symbol,
388 elf_backend_finish_dynamic_sections,
389 elf_backend_begin_write_processing,
390 elf_backend_final_write_processing,
391 elf_backend_additional_program_headers,
392 elf_backend_modify_segment_map,
393 elf_backend_gc_mark_hook,
394 elf_backend_gc_sweep_hook,
395 elf_backend_post_process_headers,
396 elf_backend_print_symbol_all,
397 elf_backend_output_arch_syms,
398 elf_backend_copy_indirect_symbol,
399 elf_backend_hide_symbol,
400 elf_backend_ecoff_debug_swap,
403 &elf_backend_size_info,
404 elf_backend_got_symbol_offset,
405 elf_backend_got_header_size,
406 elf_backend_plt_header_size,
408 elf_backend_type_change_ok,
409 elf_backend_may_use_rel_p,
410 elf_backend_may_use_rela_p,
411 elf_backend_default_use_rela_p,
412 elf_backend_sign_extend_vma,
413 elf_backend_want_got_plt,
414 elf_backend_plt_readonly,
415 elf_backend_want_plt_sym,
416 elf_backend_plt_not_loaded,
417 elf_backend_plt_alignment,
418 elf_backend_can_gc_sections,
419 elf_backend_want_dynbss
423 /* Forward declaration for use when initialising alternative_target field. */
424 #ifdef TARGET_LITTLE_SYM
425 extern const bfd_target TARGET_LITTLE_SYM;
428 #ifdef TARGET_BIG_SYM
429 const bfd_target TARGET_BIG_SYM =
431 /* name: identify kind of target */
434 /* flavour: general indication about file */
435 bfd_target_elf_flavour,
437 /* byteorder: data is big endian */
440 /* header_byteorder: header is also big endian */
443 /* object_flags: mask of all file flags */
444 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
445 DYNAMIC | WP_TEXT | D_PAGED),
447 /* section_flags: mask of all section flags */
448 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
449 SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
451 /* leading_symbol_char: is the first char of a user symbol
452 predictable, and if so what is it */
453 elf_symbol_leading_char,
455 /* ar_pad_char: pad character for filenames within an archive header
456 FIXME: this really has nothing to do with ELF, this is a characteristic
457 of the archiver and/or os and should be independently tunable */
460 /* ar_max_namelen: maximum number of characters in an archive header
461 FIXME: this really has nothing to do with ELF, this is a characteristic
462 of the archiver and should be independently tunable. This value is
463 a WAG (wild a** guess) */
466 /* Routines to byte-swap various sized integers from the data sections */
467 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
468 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
469 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
471 /* Routines to byte-swap various sized integers from the file headers */
472 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
473 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
474 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
476 /* bfd_check_format: check the format of a file being read */
477 { _bfd_dummy_target, /* unknown format */
478 bfd_elfNN_object_p, /* assembler/linker output (object file) */
479 bfd_elfNN_archive_p, /* an archive */
480 bfd_elfNN_core_file_p /* a core file */
483 /* bfd_set_format: set the format of a file being written */
490 /* bfd_write_contents: write cached information into a file being written */
492 bfd_elfNN_write_object_contents,
493 bfd_elfNN_write_archive_contents,
494 bfd_elfNN_write_corefile_contents,
497 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
498 BFD_JUMP_TABLE_COPY (bfd_elfNN),
499 BFD_JUMP_TABLE_CORE (bfd_elfNN),
500 #ifdef bfd_elfNN_archive_functions
501 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
503 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
505 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
506 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
507 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
508 BFD_JUMP_TABLE_LINK (bfd_elfNN),
509 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
511 /* Alternative endian target. */
512 #ifdef TARGET_LITTLE_SYM
523 #ifdef TARGET_LITTLE_SYM
524 const bfd_target TARGET_LITTLE_SYM =
526 /* name: identify kind of target */
529 /* flavour: general indication about file */
530 bfd_target_elf_flavour,
532 /* byteorder: data is little endian */
535 /* header_byteorder: header is also little endian */
538 /* object_flags: mask of all file flags */
539 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
540 DYNAMIC | WP_TEXT | D_PAGED),
542 /* section_flags: mask of all section flags */
543 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
544 SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
546 /* leading_symbol_char: is the first char of a user symbol
547 predictable, and if so what is it */
548 elf_symbol_leading_char,
550 /* ar_pad_char: pad character for filenames within an archive header
551 FIXME: this really has nothing to do with ELF, this is a characteristic
552 of the archiver and/or os and should be independently tunable */
555 /* ar_max_namelen: maximum number of characters in an archive header
556 FIXME: this really has nothing to do with ELF, this is a characteristic
557 of the archiver and should be independently tunable. This value is
558 a WAG (wild a** guess) */
561 /* Routines to byte-swap various sized integers from the data sections */
562 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
563 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
564 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
566 /* Routines to byte-swap various sized integers from the file headers */
567 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
568 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
569 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
571 /* bfd_check_format: check the format of a file being read */
572 { _bfd_dummy_target, /* unknown format */
573 bfd_elfNN_object_p, /* assembler/linker output (object file) */
574 bfd_elfNN_archive_p, /* an archive */
575 bfd_elfNN_core_file_p /* a core file */
578 /* bfd_set_format: set the format of a file being written */
585 /* bfd_write_contents: write cached information into a file being written */
587 bfd_elfNN_write_object_contents,
588 bfd_elfNN_write_archive_contents,
589 bfd_elfNN_write_corefile_contents,
592 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
593 BFD_JUMP_TABLE_COPY (bfd_elfNN),
594 BFD_JUMP_TABLE_CORE (bfd_elfNN),
595 #ifdef bfd_elfNN_archive_functions
596 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
598 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
600 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
601 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
602 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
603 BFD_JUMP_TABLE_LINK (bfd_elfNN),
604 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
606 /* Alternative endian target. */
607 #ifdef TARGET_BIG_SYM