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 #ifndef bfd_elfNN_bfd_merge_sections
115 #define bfd_elfNN_bfd_merge_sections \
116 _bfd_elf_merge_sections
119 #ifndef bfd_elfNN_bfd_make_debug_symbol
120 #define bfd_elfNN_bfd_make_debug_symbol \
121 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
124 #ifndef bfd_elfNN_bfd_copy_private_symbol_data
125 #define bfd_elfNN_bfd_copy_private_symbol_data \
126 _bfd_elf_copy_private_symbol_data
129 #ifndef bfd_elfNN_bfd_copy_private_section_data
130 #define bfd_elfNN_bfd_copy_private_section_data \
131 _bfd_elf_copy_private_section_data
133 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
134 #define bfd_elfNN_bfd_copy_private_bfd_data \
135 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
137 #ifndef bfd_elfNN_bfd_print_private_bfd_data
138 #define bfd_elfNN_bfd_print_private_bfd_data \
139 _bfd_elf_print_private_bfd_data
141 #ifndef bfd_elfNN_bfd_merge_private_bfd_data
142 #define bfd_elfNN_bfd_merge_private_bfd_data \
143 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
145 #ifndef bfd_elfNN_bfd_set_private_flags
146 #define bfd_elfNN_bfd_set_private_flags \
147 ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
149 #ifndef bfd_elfNN_bfd_is_local_label_name
150 #define bfd_elfNN_bfd_is_local_label_name _bfd_elf_is_local_label_name
153 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
154 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
155 _bfd_elf_get_dynamic_reloc_upper_bound
157 #ifndef bfd_elfNN_canonicalize_dynamic_reloc
158 #define bfd_elfNN_canonicalize_dynamic_reloc \
159 _bfd_elf_canonicalize_dynamic_reloc
162 #ifdef elf_backend_relocate_section
163 #ifndef bfd_elfNN_bfd_link_hash_table_create
164 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
166 #else /* ! defined (elf_backend_relocate_section) */
167 /* If no backend relocate_section routine, use the generic linker. */
168 #ifndef bfd_elfNN_bfd_link_hash_table_create
169 #define bfd_elfNN_bfd_link_hash_table_create \
170 _bfd_generic_link_hash_table_create
172 #ifndef bfd_elfNN_bfd_link_add_symbols
173 #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
175 #ifndef bfd_elfNN_bfd_final_link
176 #define bfd_elfNN_bfd_final_link _bfd_generic_final_link
178 #endif /* ! defined (elf_backend_relocate_section) */
179 #ifndef bfd_elfNN_bfd_link_split_section
180 #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
183 #ifndef bfd_elfNN_archive_p
184 #define bfd_elfNN_archive_p bfd_generic_archive_p
187 #ifndef bfd_elfNN_write_archive_contents
188 #define bfd_elfNN_write_archive_contents _bfd_write_archive_contents
191 #ifndef bfd_elfNN_mkobject
192 #define bfd_elfNN_mkobject bfd_elf_mkobject
195 #ifndef bfd_elfNN_mkcorefile
196 #define bfd_elfNN_mkcorefile bfd_elf_mkcorefile
199 #ifndef bfd_elfNN_mkarchive
200 #define bfd_elfNN_mkarchive _bfd_generic_mkarchive
203 #ifndef elf_symbol_leading_char
204 #define elf_symbol_leading_char 0
207 #ifndef elf_info_to_howto
208 #define elf_info_to_howto 0
211 #ifndef elf_info_to_howto_rel
212 #define elf_info_to_howto_rel 0
215 #ifndef ELF_MAXPAGESIZE
216 #error ELF_MAXPAGESIZE is not defined
217 #define ELF_MAXPAGESIZE 1
220 #ifndef elf_backend_collect
221 #define elf_backend_collect false
223 #ifndef elf_backend_type_change_ok
224 #define elf_backend_type_change_ok false
227 #ifndef elf_backend_sym_is_global
228 #define elf_backend_sym_is_global 0
230 #ifndef elf_backend_object_p
231 #define elf_backend_object_p 0
233 #ifndef elf_backend_symbol_processing
234 #define elf_backend_symbol_processing 0
236 #ifndef elf_backend_symbol_table_processing
237 #define elf_backend_symbol_table_processing 0
239 #ifndef elf_backend_get_symbol_type
240 #define elf_backend_get_symbol_type 0
242 #ifndef elf_backend_section_processing
243 #define elf_backend_section_processing 0
245 #ifndef elf_backend_section_from_shdr
246 #define elf_backend_section_from_shdr 0
248 #ifndef elf_backend_section_flags
249 #define elf_backend_section_flags 0
251 #ifndef elf_backend_section_from_phdr
252 #define elf_backend_section_from_phdr 0
254 #ifndef elf_backend_fake_sections
255 #define elf_backend_fake_sections 0
257 #ifndef elf_backend_section_from_bfd_section
258 #define elf_backend_section_from_bfd_section 0
260 #ifndef elf_backend_add_symbol_hook
261 #define elf_backend_add_symbol_hook 0
263 #ifndef elf_backend_link_output_symbol_hook
264 #define elf_backend_link_output_symbol_hook 0
266 #ifndef elf_backend_create_dynamic_sections
267 #define elf_backend_create_dynamic_sections 0
269 #ifndef elf_backend_check_relocs
270 #define elf_backend_check_relocs 0
272 #ifndef elf_backend_adjust_dynamic_symbol
273 #define elf_backend_adjust_dynamic_symbol 0
275 #ifndef elf_backend_always_size_sections
276 #define elf_backend_always_size_sections 0
278 #ifndef elf_backend_size_dynamic_sections
279 #define elf_backend_size_dynamic_sections 0
281 #ifndef elf_backend_relocate_section
282 #define elf_backend_relocate_section 0
284 #ifndef elf_backend_finish_dynamic_symbol
285 #define elf_backend_finish_dynamic_symbol 0
287 #ifndef elf_backend_finish_dynamic_sections
288 #define elf_backend_finish_dynamic_sections 0
290 #ifndef elf_backend_begin_write_processing
291 #define elf_backend_begin_write_processing 0
293 #ifndef elf_backend_final_write_processing
294 #define elf_backend_final_write_processing 0
296 #ifndef elf_backend_additional_program_headers
297 #define elf_backend_additional_program_headers 0
299 #ifndef elf_backend_modify_segment_map
300 #define elf_backend_modify_segment_map 0
302 #ifndef elf_backend_ecoff_debug_swap
303 #define elf_backend_ecoff_debug_swap 0
305 #ifndef elf_backend_got_header_size
306 #define elf_backend_got_header_size 0
308 #ifndef elf_backend_plt_header_size
309 #define elf_backend_plt_header_size 0
311 #ifndef elf_backend_post_process_headers
312 #define elf_backend_post_process_headers NULL
314 #ifndef elf_backend_print_symbol_all
315 #define elf_backend_print_symbol_all NULL
317 #ifndef elf_backend_output_arch_syms
318 #define elf_backend_output_arch_syms NULL
320 #ifndef elf_backend_copy_indirect_symbol
321 #define elf_backend_copy_indirect_symbol _bfd_elf_link_hash_copy_indirect
323 #ifndef elf_backend_hide_symbol
324 #define elf_backend_hide_symbol _bfd_elf_link_hash_hide_symbol
327 /* Previously, backends could only use SHT_REL or SHT_RELA relocation
328 sections, but not both. They defined USE_REL to indicate SHT_REL
329 sections, and left it undefined to indicated SHT_RELA sections.
330 For backwards compatibility, we still support this usage. */
338 /* Use these in new code. */
339 #ifndef elf_backend_may_use_rel_p
340 #define elf_backend_may_use_rel_p USE_REL
342 #ifndef elf_backend_may_use_rela_p
343 #define elf_backend_may_use_rela_p !USE_REL
345 #ifndef elf_backend_default_use_rela_p
346 #define elf_backend_default_use_rela_p !USE_REL
349 #ifndef ELF_MACHINE_ALT1
350 #define ELF_MACHINE_ALT1 0
353 #ifndef ELF_MACHINE_ALT2
354 #define ELF_MACHINE_ALT2 0
357 #ifndef elf_backend_size_info
358 #define elf_backend_size_info _bfd_elfNN_size_info
361 #ifndef elf_backend_sign_extend_vma
362 #define elf_backend_sign_extend_vma 0
365 extern const struct elf_size_info _bfd_elfNN_size_info
;
367 #ifndef INCLUDED_TARGET_FILE
368 static CONST
struct elf_backend_data elfNN_bed
=
371 ELF_MACHINE_CODE
, /* elf_machine_code */
372 ELF_MAXPAGESIZE
, /* maxpagesize */
374 elf_info_to_howto_rel
,
375 elf_backend_sym_is_global
,
376 elf_backend_object_p
,
377 elf_backend_symbol_processing
,
378 elf_backend_symbol_table_processing
,
379 elf_backend_get_symbol_type
,
380 elf_backend_section_processing
,
381 elf_backend_section_from_shdr
,
382 elf_backend_section_flags
,
383 elf_backend_section_from_phdr
,
384 elf_backend_fake_sections
,
385 elf_backend_section_from_bfd_section
,
386 elf_backend_add_symbol_hook
,
387 elf_backend_link_output_symbol_hook
,
388 elf_backend_create_dynamic_sections
,
389 elf_backend_check_relocs
,
390 elf_backend_adjust_dynamic_symbol
,
391 elf_backend_always_size_sections
,
392 elf_backend_size_dynamic_sections
,
393 elf_backend_relocate_section
,
394 elf_backend_finish_dynamic_symbol
,
395 elf_backend_finish_dynamic_sections
,
396 elf_backend_begin_write_processing
,
397 elf_backend_final_write_processing
,
398 elf_backend_additional_program_headers
,
399 elf_backend_modify_segment_map
,
400 elf_backend_gc_mark_hook
,
401 elf_backend_gc_sweep_hook
,
402 elf_backend_post_process_headers
,
403 elf_backend_print_symbol_all
,
404 elf_backend_output_arch_syms
,
405 elf_backend_copy_indirect_symbol
,
406 elf_backend_hide_symbol
,
407 elf_backend_ecoff_debug_swap
,
410 &elf_backend_size_info
,
411 elf_backend_got_symbol_offset
,
412 elf_backend_got_header_size
,
413 elf_backend_plt_header_size
,
415 elf_backend_type_change_ok
,
416 elf_backend_may_use_rel_p
,
417 elf_backend_may_use_rela_p
,
418 elf_backend_default_use_rela_p
,
419 elf_backend_sign_extend_vma
,
420 elf_backend_want_got_plt
,
421 elf_backend_plt_readonly
,
422 elf_backend_want_plt_sym
,
423 elf_backend_plt_not_loaded
,
424 elf_backend_plt_alignment
,
425 elf_backend_can_gc_sections
,
426 elf_backend_want_dynbss
430 /* Forward declaration for use when initialising alternative_target field. */
431 #ifdef TARGET_LITTLE_SYM
432 extern const bfd_target TARGET_LITTLE_SYM
;
435 #ifdef TARGET_BIG_SYM
436 const bfd_target TARGET_BIG_SYM
=
438 /* name: identify kind of target */
441 /* flavour: general indication about file */
442 bfd_target_elf_flavour
,
444 /* byteorder: data is big endian */
447 /* header_byteorder: header is also big endian */
450 /* object_flags: mask of all file flags */
451 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
|
452 DYNAMIC
| WP_TEXT
| D_PAGED
),
454 /* section_flags: mask of all section flags */
455 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_READONLY
|
456 SEC_CODE
| SEC_DATA
| SEC_DEBUGGING
| SEC_EXCLUDE
| SEC_SORT_ENTRIES
),
458 /* leading_symbol_char: is the first char of a user symbol
459 predictable, and if so what is it */
460 elf_symbol_leading_char
,
462 /* ar_pad_char: pad character for filenames within an archive header
463 FIXME: this really has nothing to do with ELF, this is a characteristic
464 of the archiver and/or os and should be independently tunable */
467 /* ar_max_namelen: maximum number of characters in an archive header
468 FIXME: this really has nothing to do with ELF, this is a characteristic
469 of the archiver and should be independently tunable. This value is
470 a WAG (wild a** guess) */
473 /* Routines to byte-swap various sized integers from the data sections */
474 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
475 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
476 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
,
478 /* Routines to byte-swap various sized integers from the file headers */
479 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
480 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
481 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
,
483 /* bfd_check_format: check the format of a file being read */
484 { _bfd_dummy_target
, /* unknown format */
485 bfd_elfNN_object_p
, /* assembler/linker output (object file) */
486 bfd_elfNN_archive_p
, /* an archive */
487 bfd_elfNN_core_file_p
/* a core file */
490 /* bfd_set_format: set the format of a file being written */
497 /* bfd_write_contents: write cached information into a file being written */
499 bfd_elfNN_write_object_contents
,
500 bfd_elfNN_write_archive_contents
,
501 bfd_elfNN_write_corefile_contents
,
504 BFD_JUMP_TABLE_GENERIC (bfd_elfNN
),
505 BFD_JUMP_TABLE_COPY (bfd_elfNN
),
506 BFD_JUMP_TABLE_CORE (bfd_elfNN
),
507 #ifdef bfd_elfNN_archive_functions
508 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive
),
510 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff
),
512 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN
),
513 BFD_JUMP_TABLE_RELOCS (bfd_elfNN
),
514 BFD_JUMP_TABLE_WRITE (bfd_elfNN
),
515 BFD_JUMP_TABLE_LINK (bfd_elfNN
),
516 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN
),
518 /* Alternative endian target. */
519 #ifdef TARGET_LITTLE_SYM
530 #ifdef TARGET_LITTLE_SYM
531 const bfd_target TARGET_LITTLE_SYM
=
533 /* name: identify kind of target */
536 /* flavour: general indication about file */
537 bfd_target_elf_flavour
,
539 /* byteorder: data is little endian */
542 /* header_byteorder: header is also little endian */
545 /* object_flags: mask of all file flags */
546 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
|
547 DYNAMIC
| WP_TEXT
| D_PAGED
),
549 /* section_flags: mask of all section flags */
550 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
| SEC_READONLY
|
551 SEC_CODE
| SEC_DATA
| SEC_DEBUGGING
| SEC_EXCLUDE
| SEC_SORT_ENTRIES
),
553 /* leading_symbol_char: is the first char of a user symbol
554 predictable, and if so what is it */
555 elf_symbol_leading_char
,
557 /* ar_pad_char: pad character for filenames within an archive header
558 FIXME: this really has nothing to do with ELF, this is a characteristic
559 of the archiver and/or os and should be independently tunable */
562 /* ar_max_namelen: maximum number of characters in an archive header
563 FIXME: this really has nothing to do with ELF, this is a characteristic
564 of the archiver and should be independently tunable. This value is
565 a WAG (wild a** guess) */
568 /* Routines to byte-swap various sized integers from the data sections */
569 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
570 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
571 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
573 /* Routines to byte-swap various sized integers from the file headers */
574 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
575 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
576 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
578 /* bfd_check_format: check the format of a file being read */
579 { _bfd_dummy_target
, /* unknown format */
580 bfd_elfNN_object_p
, /* assembler/linker output (object file) */
581 bfd_elfNN_archive_p
, /* an archive */
582 bfd_elfNN_core_file_p
/* a core file */
585 /* bfd_set_format: set the format of a file being written */
592 /* bfd_write_contents: write cached information into a file being written */
594 bfd_elfNN_write_object_contents
,
595 bfd_elfNN_write_archive_contents
,
596 bfd_elfNN_write_corefile_contents
,
599 BFD_JUMP_TABLE_GENERIC (bfd_elfNN
),
600 BFD_JUMP_TABLE_COPY (bfd_elfNN
),
601 BFD_JUMP_TABLE_CORE (bfd_elfNN
),
602 #ifdef bfd_elfNN_archive_functions
603 BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive
),
605 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff
),
607 BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN
),
608 BFD_JUMP_TABLE_RELOCS (bfd_elfNN
),
609 BFD_JUMP_TABLE_WRITE (bfd_elfNN
),
610 BFD_JUMP_TABLE_LINK (bfd_elfNN
),
611 BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN
),
613 /* Alternative endian target. */
614 #ifdef TARGET_BIG_SYM