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
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
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
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
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
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
68 #ifndef elf_backend_want_got_plt
69 #define elf_backend_want_got_plt 0
71 #ifndef elf_backend_plt_readonly
72 #define elf_backend_plt_readonly 0
74 #ifndef elf_backend_want_plt_sym
75 #define elf_backend_want_plt_sym 0
77 #ifndef elf_backend_plt_not_loaded
78 #define elf_backend_plt_not_loaded 0
80 #ifndef elf_backend_plt_alignment
81 #define elf_backend_plt_alignment 2
83 #ifndef elf_backend_want_dynbss
84 #define elf_backend_want_dynbss 1
87 #define bfd_elfNN_bfd_debug_info_start bfd_void
88 #define bfd_elfNN_bfd_debug_info_end bfd_void
89 #define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
91 #ifndef bfd_elfNN_bfd_get_relocated_section_contents
92 #define bfd_elfNN_bfd_get_relocated_section_contents \
93 bfd_generic_get_relocated_section_contents
96 #ifndef bfd_elfNN_bfd_relax_section
97 #define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
100 #ifndef elf_backend_can_gc_sections
101 #define elf_backend_can_gc_sections 0
103 #ifndef elf_backend_gc_mark_hook
104 #define elf_backend_gc_mark_hook NULL
106 #ifndef elf_backend_gc_sweep_hook
107 #define elf_backend_gc_sweep_hook NULL
109 #ifndef bfd_elfNN_bfd_gc_sections
110 #define bfd_elfNN_bfd_gc_sections _bfd_elfNN_gc_sections
113 #define bfd_elfNN_bfd_make_debug_symbol \
114 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
116 #ifndef bfd_elfNN_bfd_copy_private_symbol_data
117 #define bfd_elfNN_bfd_copy_private_symbol_data \
118 _bfd_elf_copy_private_symbol_data
121 #ifndef bfd_elfNN_bfd_copy_private_section_data
122 #define bfd_elfNN_bfd_copy_private_section_data \
123 _bfd_elf_copy_private_section_data
125 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
126 #define bfd_elfNN_bfd_copy_private_bfd_data \
127 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
129 #ifndef bfd_elfNN_bfd_print_private_bfd_data
130 #define bfd_elfNN_bfd_print_private_bfd_data \
131 _bfd_elf_print_private_bfd_data
133 #ifndef bfd_elfNN_bfd_merge_private_bfd_data
134 #define bfd_elfNN_bfd_merge_private_bfd_data \
135 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
137 #ifndef bfd_elfNN_bfd_set_private_flags
138 #define bfd_elfNN_bfd_set_private_flags \
139 ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
141 #ifndef bfd_elfNN_bfd_is_local_label_name
142 #define bfd_elfNN_bfd_is_local_label_name _bfd_elf_is_local_label_name
145 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
146 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
147 _bfd_elf_get_dynamic_reloc_upper_bound
149 #ifndef bfd_elfNN_canonicalize_dynamic_reloc
150 #define bfd_elfNN_canonicalize_dynamic_reloc \
151 _bfd_elf_canonicalize_dynamic_reloc
154 #ifdef elf_backend_relocate_section
155 #ifndef bfd_elfNN_bfd_link_hash_table_create
156 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
158 #else /* ! defined (elf_backend_relocate_section) */
159 /* If no backend relocate_section routine, use the generic linker. */
160 #ifndef bfd_elfNN_bfd_link_hash_table_create
161 #define bfd_elfNN_bfd_link_hash_table_create \
162 _bfd_generic_link_hash_table_create
164 #ifndef bfd_elfNN_bfd_link_add_symbols
165 #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
167 #ifndef bfd_elfNN_bfd_final_link
168 #define bfd_elfNN_bfd_final_link _bfd_generic_final_link
170 #endif /* ! defined (elf_backend_relocate_section) */
171 #ifndef bfd_elfNN_bfd_link_split_section
172 #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
175 #ifndef bfd_elfNN_archive_p
176 #define bfd_elfNN_archive_p bfd_generic_archive_p
179 #ifndef bfd_elfNN_write_archive_contents
180 #define bfd_elfNN_write_archive_contents _bfd_write_archive_contents
183 #ifndef bfd_elfNN_mkobject
184 #define bfd_elfNN_mkobject bfd_elf_mkobject
187 #ifndef bfd_elfNN_mkcorefile
188 #define bfd_elfNN_mkcorefile bfd_elf_mkcorefile
191 #ifndef bfd_elfNN_mkarchive
192 #define bfd_elfNN_mkarchive _bfd_generic_mkarchive
195 #ifndef elf_symbol_leading_char
196 #define elf_symbol_leading_char 0
199 #ifndef elf_info_to_howto
200 #define elf_info_to_howto 0
203 #ifndef elf_info_to_howto_rel
204 #define elf_info_to_howto_rel 0
207 #ifndef ELF_MAXPAGESIZE
208 #error ELF_MAXPAGESIZE is not defined
209 #define ELF_MAXPAGESIZE 1
212 #ifndef elf_backend_collect
213 #define elf_backend_collect false
215 #ifndef elf_backend_type_change_ok
216 #define elf_backend_type_change_ok false
219 #ifndef elf_backend_sym_is_global
220 #define elf_backend_sym_is_global 0
222 #ifndef elf_backend_object_p
223 #define elf_backend_object_p 0
225 #ifndef elf_backend_symbol_processing
226 #define elf_backend_symbol_processing 0
228 #ifndef elf_backend_symbol_table_processing
229 #define elf_backend_symbol_table_processing 0
231 #ifndef elf_backend_get_symbol_type
232 #define elf_backend_get_symbol_type 0
234 #ifndef elf_backend_section_processing
235 #define elf_backend_section_processing 0
237 #ifndef elf_backend_section_from_shdr
238 #define elf_backend_section_from_shdr 0
240 #ifndef elf_backend_fake_sections
241 #define elf_backend_fake_sections 0
243 #ifndef elf_backend_section_from_bfd_section
244 #define elf_backend_section_from_bfd_section 0
246 #ifndef elf_backend_add_symbol_hook
247 #define elf_backend_add_symbol_hook 0
249 #ifndef elf_backend_link_output_symbol_hook
250 #define elf_backend_link_output_symbol_hook 0
252 #ifndef elf_backend_create_dynamic_sections
253 #define elf_backend_create_dynamic_sections 0
255 #ifndef elf_backend_check_relocs
256 #define elf_backend_check_relocs 0
258 #ifndef elf_backend_adjust_dynamic_symbol
259 #define elf_backend_adjust_dynamic_symbol 0
261 #ifndef elf_backend_always_size_sections
262 #define elf_backend_always_size_sections 0
264 #ifndef elf_backend_size_dynamic_sections
265 #define elf_backend_size_dynamic_sections 0
267 #ifndef elf_backend_relocate_section
268 #define elf_backend_relocate_section 0
270 #ifndef elf_backend_finish_dynamic_symbol
271 #define elf_backend_finish_dynamic_symbol 0
273 #ifndef elf_backend_finish_dynamic_sections
274 #define elf_backend_finish_dynamic_sections 0
276 #ifndef elf_backend_begin_write_processing
277 #define elf_backend_begin_write_processing 0
279 #ifndef elf_backend_final_write_processing
280 #define elf_backend_final_write_processing 0
282 #ifndef elf_backend_additional_program_headers
283 #define elf_backend_additional_program_headers 0
285 #ifndef elf_backend_modify_segment_map
286 #define elf_backend_modify_segment_map 0
288 #ifndef elf_backend_ecoff_debug_swap
289 #define elf_backend_ecoff_debug_swap 0
291 #ifndef elf_backend_got_header_size
292 #define elf_backend_got_header_size 0
294 #ifndef elf_backend_plt_header_size
295 #define elf_backend_plt_header_size 0
297 #ifndef elf_backend_post_process_headers
298 #define elf_backend_post_process_headers NULL
300 #ifndef elf_backend_print_symbol_all
301 #define elf_backend_print_symbol_all NULL
303 #ifndef elf_backend_output_arch_syms
304 #define elf_backend_output_arch_syms NULL
307 /* Previously, backends could only use SHT_REL or SHT_RELA relocation
308 sections, but not both. They defined USE_REL to indicate SHT_REL
309 sections, and left it undefined to indicated SHT_RELA sections.
310 For backwards compatibility, we still support this usage. */
318 /* Use these in new code. */
319 #ifndef elf_backend_may_use_rel_p
320 #define elf_backend_may_use_rel_p USE_REL
322 #ifndef elf_backend_may_use_rela_p
323 #define elf_backend_may_use_rela_p !USE_REL
325 #ifndef elf_backend_default_use_rela_p
326 #define elf_backend_default_use_rela_p !USE_REL
329 #ifndef ELF_MACHINE_ALT1
330 #define ELF_MACHINE_ALT1 0
333 #ifndef ELF_MACHINE_ALT2
334 #define ELF_MACHINE_ALT2 0
337 #ifndef elf_backend_size_info
338 #define elf_backend_size_info _bfd_elfNN_size_info
341 #ifndef elf_backend_sign_extend_vma
342 #define elf_backend_sign_extend_vma 0
345 extern const struct elf_size_info _bfd_elfNN_size_info;
347 static CONST struct elf_backend_data elfNN_bed =
350 ELF_MACHINE_CODE, /* elf_machine_code */
351 ELF_MAXPAGESIZE, /* maxpagesize */
353 elf_info_to_howto_rel,
354 elf_backend_sym_is_global,
355 elf_backend_object_p,
356 elf_backend_symbol_processing,
357 elf_backend_symbol_table_processing,
358 elf_backend_get_symbol_type,
359 elf_backend_section_processing,
360 elf_backend_section_from_shdr,
361 elf_backend_fake_sections,
362 elf_backend_section_from_bfd_section,
363 elf_backend_add_symbol_hook,
364 elf_backend_link_output_symbol_hook,
365 elf_backend_create_dynamic_sections,
366 elf_backend_check_relocs,
367 elf_backend_adjust_dynamic_symbol,
368 elf_backend_always_size_sections,
369 elf_backend_size_dynamic_sections,
370 elf_backend_relocate_section,
371 elf_backend_finish_dynamic_symbol,
372 elf_backend_finish_dynamic_sections,
373 elf_backend_begin_write_processing,
374 elf_backend_final_write_processing,
375 elf_backend_additional_program_headers,
376 elf_backend_modify_segment_map,
377 elf_backend_gc_mark_hook,
378 elf_backend_gc_sweep_hook,
379 elf_backend_post_process_headers,
380 elf_backend_print_symbol_all,
381 elf_backend_output_arch_syms,
382 elf_backend_ecoff_debug_swap,
385 &elf_backend_size_info,
386 elf_backend_got_symbol_offset,
387 elf_backend_got_header_size,
388 elf_backend_plt_header_size,
390 elf_backend_type_change_ok,
391 elf_backend_may_use_rel_p,
392 elf_backend_may_use_rela_p,
393 elf_backend_default_use_rela_p,
394 elf_backend_sign_extend_vma,
395 elf_backend_want_got_plt,
396 elf_backend_plt_readonly,
397 elf_backend_want_plt_sym,
398 elf_backend_plt_not_loaded,
399 elf_backend_plt_alignment,
400 elf_backend_can_gc_sections,
401 elf_backend_want_dynbss
404 /* Forward declaration for use when initialising alternative_target field. */
405 #ifdef TARGET_LITTLE_SYM
406 extern const bfd_target TARGET_LITTLE_SYM;
409 #ifdef TARGET_BIG_SYM
410 const bfd_target TARGET_BIG_SYM =
412 /* name: identify kind of target */
415 /* flavour: general indication about file */
416 bfd_target_elf_flavour,
418 /* byteorder: data is big endian */
421 /* header_byteorder: header is also big endian */
424 /* object_flags: mask of all file flags */
425 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
426 DYNAMIC | WP_TEXT | D_PAGED),
428 /* section_flags: mask of all section flags */
429 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
430 SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
432 /* leading_symbol_char: is the first char of a user symbol
433 predictable, and if so what is it */
434 elf_symbol_leading_char,
436 /* ar_pad_char: pad character for filenames within an archive header
437 FIXME: this really has nothing to do with ELF, this is a characteristic
438 of the archiver and/or os and should be independently tunable */
441 /* ar_max_namelen: maximum number of characters in an archive header
442 FIXME: this really has nothing to do with ELF, this is a characteristic
443 of the archiver and should be independently tunable. This value is
444 a WAG (wild a** guess) */
447 /* Routines to byte-swap various sized integers from the data sections */
448 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
449 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
450 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
452 /* Routines to byte-swap various sized integers from the file headers */
453 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
454 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
455 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
457 /* bfd_check_format: check the format of a file being read */
458 { _bfd_dummy_target, /* unknown format */
459 bfd_elfNN_object_p, /* assembler/linker output (object file) */
460 bfd_elfNN_archive_p, /* an archive */
461 bfd_elfNN_core_file_p /* a core file */
464 /* bfd_set_format: set the format of a file being written */
471 /* bfd_write_contents: write cached information into a file being written */
473 bfd_elfNN_write_object_contents,
474 bfd_elfNN_write_archive_contents,
475 bfd_elfNN_write_corefile_contents,
478 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
479 BFD_JUMP_TABLE_COPY (bfd_elfNN),
480 BFD_JUMP_TABLE_CORE (bfd_elfNN),
481 #ifdef bfd_elfNN_archive_functions
482 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
484 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
486 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
487 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
488 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
489 BFD_JUMP_TABLE_LINK (bfd_elfNN),
490 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
492 /* Alternative endian target. */
493 #ifdef TARGET_LITTLE_SYM
504 #ifdef TARGET_LITTLE_SYM
505 const bfd_target TARGET_LITTLE_SYM =
507 /* name: identify kind of target */
510 /* flavour: general indication about file */
511 bfd_target_elf_flavour,
513 /* byteorder: data is little endian */
516 /* header_byteorder: header is also little endian */
519 /* object_flags: mask of all file flags */
520 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
521 DYNAMIC | WP_TEXT | D_PAGED),
523 /* section_flags: mask of all section flags */
524 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
525 SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
527 /* leading_symbol_char: is the first char of a user symbol
528 predictable, and if so what is it */
529 elf_symbol_leading_char,
531 /* ar_pad_char: pad character for filenames within an archive header
532 FIXME: this really has nothing to do with ELF, this is a characteristic
533 of the archiver and/or os and should be independently tunable */
536 /* ar_max_namelen: maximum number of characters in an archive header
537 FIXME: this really has nothing to do with ELF, this is a characteristic
538 of the archiver and should be independently tunable. This value is
539 a WAG (wild a** guess) */
542 /* Routines to byte-swap various sized integers from the data sections */
543 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
544 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
545 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
547 /* Routines to byte-swap various sized integers from the file headers */
548 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
549 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
550 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
552 /* bfd_check_format: check the format of a file being read */
553 { _bfd_dummy_target, /* unknown format */
554 bfd_elfNN_object_p, /* assembler/linker output (object file) */
555 bfd_elfNN_archive_p, /* an archive */
556 bfd_elfNN_core_file_p /* a core file */
559 /* bfd_set_format: set the format of a file being written */
566 /* bfd_write_contents: write cached information into a file being written */
568 bfd_elfNN_write_object_contents,
569 bfd_elfNN_write_archive_contents,
570 bfd_elfNN_write_corefile_contents,
573 BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
574 BFD_JUMP_TABLE_COPY (bfd_elfNN),
575 BFD_JUMP_TABLE_CORE (bfd_elfNN),
576 #ifdef bfd_elfNN_archive_functions
577 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
579 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
581 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
582 BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
583 BFD_JUMP_TABLE_WRITE (bfd_elfNN),
584 BFD_JUMP_TABLE_LINK (bfd_elfNN),
585 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
587 /* Alternative endian target. */
588 #ifdef TARGET_BIG_SYM