Add support for non-ELF targets to check their relocs.
[external/binutils.git] / bfd / elfxx-target.h
1 /* Target definitions for NN-bit ELF
2    Copyright (C) 1993-2016 Free Software Foundation, Inc.
3
4    This file is part of BFD, the Binary File Descriptor library.
5
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 3 of the License, or
9    (at your option) any later version.
10
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.
15
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., 51 Franklin Street - Fifth Floor, Boston,
19    MA 02110-1301, USA.  */
20
21
22 /* This structure contains everything that BFD knows about a target.
23    It includes things like its byte order, name, what routines to call
24    to do various operations, etc.  Every BFD points to a target structure
25    with its "xvec" member.
26
27    There are two such structures here:  one for big-endian machines and
28    one for little-endian machines.   */
29
30 #ifndef bfd_elfNN_close_and_cleanup
31 #define bfd_elfNN_close_and_cleanup _bfd_elf_close_and_cleanup
32 #endif
33 #ifndef bfd_elfNN_bfd_free_cached_info
34 #define bfd_elfNN_bfd_free_cached_info _bfd_free_cached_info
35 #endif
36 #ifndef bfd_elfNN_get_section_contents
37 #define bfd_elfNN_get_section_contents _bfd_generic_get_section_contents
38 #endif
39
40 #define bfd_elfNN_canonicalize_dynamic_symtab \
41   _bfd_elf_canonicalize_dynamic_symtab
42 #ifndef bfd_elfNN_get_synthetic_symtab
43 #define bfd_elfNN_get_synthetic_symtab \
44   _bfd_elf_get_synthetic_symtab
45 #endif
46 #ifndef bfd_elfNN_canonicalize_reloc
47 #define bfd_elfNN_canonicalize_reloc    _bfd_elf_canonicalize_reloc
48 #endif
49 #ifndef bfd_elfNN_find_nearest_line
50 #define bfd_elfNN_find_nearest_line     _bfd_elf_find_nearest_line
51 #endif
52 #ifndef bfd_elfNN_find_line
53 #define bfd_elfNN_find_line             _bfd_elf_find_line
54 #endif
55 #ifndef bfd_elfNN_find_inliner_info
56 #define bfd_elfNN_find_inliner_info     _bfd_elf_find_inliner_info
57 #endif
58 #define bfd_elfNN_read_minisymbols      _bfd_elf_read_minisymbols
59 #define bfd_elfNN_minisymbol_to_symbol  _bfd_elf_minisymbol_to_symbol
60 #define bfd_elfNN_get_dynamic_symtab_upper_bound \
61   _bfd_elf_get_dynamic_symtab_upper_bound
62 #define bfd_elfNN_get_lineno            _bfd_elf_get_lineno
63 #ifndef bfd_elfNN_get_reloc_upper_bound
64 #define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound
65 #endif
66 #ifndef bfd_elfNN_get_symbol_info
67 #define bfd_elfNN_get_symbol_info       _bfd_elf_get_symbol_info
68 #endif
69 #ifndef bfd_elfNN_get_symbol_version_string
70 #define bfd_elfNN_get_symbol_version_string \
71   _bfd_elf_get_symbol_version_string
72 #endif
73 #define bfd_elfNN_canonicalize_symtab   _bfd_elf_canonicalize_symtab
74 #define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
75 #define bfd_elfNN_make_empty_symbol     _bfd_elf_make_empty_symbol
76 #ifndef bfd_elfNN_new_section_hook
77 #define bfd_elfNN_new_section_hook      _bfd_elf_new_section_hook
78 #endif
79 #define bfd_elfNN_set_arch_mach         _bfd_elf_set_arch_mach
80 #ifndef bfd_elfNN_set_section_contents
81 #define bfd_elfNN_set_section_contents  _bfd_elf_set_section_contents
82 #endif
83 #define bfd_elfNN_sizeof_headers        _bfd_elf_sizeof_headers
84 #define bfd_elfNN_write_object_contents _bfd_elf_write_object_contents
85 #define bfd_elfNN_write_corefile_contents _bfd_elf_write_corefile_contents
86
87 #define bfd_elfNN_get_section_contents_in_window \
88   _bfd_generic_get_section_contents_in_window
89
90 #ifndef elf_backend_can_refcount
91 #define elf_backend_can_refcount 0
92 #endif
93 #ifndef elf_backend_want_got_plt
94 #define elf_backend_want_got_plt 0
95 #endif
96 #ifndef elf_backend_plt_readonly
97 #define elf_backend_plt_readonly 0
98 #endif
99 #ifndef elf_backend_want_plt_sym
100 #define elf_backend_want_plt_sym 0
101 #endif
102 #ifndef elf_backend_plt_not_loaded
103 #define elf_backend_plt_not_loaded 0
104 #endif
105 #ifndef elf_backend_plt_alignment
106 #define elf_backend_plt_alignment 2
107 #endif
108 #ifndef elf_backend_want_dynbss
109 #define elf_backend_want_dynbss 1
110 #endif
111 #ifndef elf_backend_want_p_paddr_set_to_zero
112 #define elf_backend_want_p_paddr_set_to_zero 0
113 #endif
114 #ifndef elf_backend_default_execstack
115 #define elf_backend_default_execstack 1
116 #endif
117 #ifndef elf_backend_caches_rawsize
118 #define elf_backend_caches_rawsize 0
119 #endif
120 #ifndef elf_backend_extern_protected_data
121 #define elf_backend_extern_protected_data 0
122 #endif
123 #ifndef elf_backend_stack_align
124 #define elf_backend_stack_align 16
125 #endif
126 #ifndef elf_backend_strtab_flags
127 #define elf_backend_strtab_flags 0
128 #endif
129
130 #define bfd_elfNN_bfd_debug_info_start  bfd_void
131 #define bfd_elfNN_bfd_debug_info_end    bfd_void
132 #define bfd_elfNN_bfd_debug_info_accumulate \
133   ((void (*) (bfd*, struct bfd_section *)) bfd_void)
134
135 #ifndef bfd_elfNN_bfd_get_relocated_section_contents
136 #define bfd_elfNN_bfd_get_relocated_section_contents \
137   bfd_generic_get_relocated_section_contents
138 #endif
139
140 #ifndef bfd_elfNN_bfd_relax_section
141 #define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
142 #endif
143
144 #ifndef elf_backend_can_gc_sections
145 #define elf_backend_can_gc_sections 0
146 #endif
147 #ifndef elf_backend_can_refcount
148 #define elf_backend_can_refcount 0
149 #endif
150 #ifndef elf_backend_want_got_sym
151 #define elf_backend_want_got_sym 1
152 #endif
153 #ifndef elf_backend_gc_keep
154 #define elf_backend_gc_keep             _bfd_elf_gc_keep
155 #endif
156 #ifndef elf_backend_gc_mark_dynamic_ref
157 #define elf_backend_gc_mark_dynamic_ref bfd_elf_gc_mark_dynamic_ref_symbol
158 #endif
159 #ifndef elf_backend_gc_mark_hook
160 #define elf_backend_gc_mark_hook        _bfd_elf_gc_mark_hook
161 #endif
162 #ifndef elf_backend_gc_mark_extra_sections
163 #define elf_backend_gc_mark_extra_sections _bfd_elf_gc_mark_extra_sections
164 #endif
165 #ifndef elf_backend_gc_sweep_hook
166 #define elf_backend_gc_sweep_hook       NULL
167 #endif
168 #ifndef bfd_elfNN_bfd_gc_sections
169 #define bfd_elfNN_bfd_gc_sections bfd_elf_gc_sections
170 #endif
171
172 #ifndef bfd_elfNN_bfd_merge_sections
173 #define bfd_elfNN_bfd_merge_sections \
174   _bfd_elf_merge_sections
175 #endif
176
177 #ifndef bfd_elfNN_bfd_is_group_section
178 #define bfd_elfNN_bfd_is_group_section bfd_elf_is_group_section
179 #endif
180
181 #ifndef bfd_elfNN_bfd_discard_group
182 #define bfd_elfNN_bfd_discard_group bfd_generic_discard_group
183 #endif
184
185 #ifndef bfd_elfNN_section_already_linked
186 #define bfd_elfNN_section_already_linked \
187   _bfd_elf_section_already_linked
188 #endif
189
190 #ifndef bfd_elfNN_bfd_define_common_symbol
191 #define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol
192 #endif
193
194 #ifndef bfd_elfNN_bfd_lookup_section_flags
195 #define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags
196 #endif
197
198 #ifndef bfd_elfNN_bfd_make_debug_symbol
199 #define bfd_elfNN_bfd_make_debug_symbol \
200   ((asymbol * (*) (bfd *, void *, unsigned long)) bfd_nullvoidptr)
201 #endif
202
203 #ifndef bfd_elfNN_bfd_copy_private_symbol_data
204 #define bfd_elfNN_bfd_copy_private_symbol_data \
205   _bfd_elf_copy_private_symbol_data
206 #endif
207
208 #ifndef bfd_elfNN_bfd_copy_private_section_data
209 #define bfd_elfNN_bfd_copy_private_section_data \
210   _bfd_elf_copy_private_section_data
211 #endif
212 #ifndef bfd_elfNN_bfd_copy_private_header_data
213 #define bfd_elfNN_bfd_copy_private_header_data \
214   _bfd_elf_copy_private_header_data
215 #endif
216 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
217 #define bfd_elfNN_bfd_copy_private_bfd_data \
218   _bfd_elf_copy_private_bfd_data
219 #endif
220 #ifndef bfd_elfNN_bfd_print_private_bfd_data
221 #define bfd_elfNN_bfd_print_private_bfd_data \
222   _bfd_elf_print_private_bfd_data
223 #endif
224 #ifndef bfd_elfNN_bfd_merge_private_bfd_data
225 #define bfd_elfNN_bfd_merge_private_bfd_data \
226   ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
227 #endif
228 #ifndef bfd_elfNN_bfd_set_private_flags
229 #define bfd_elfNN_bfd_set_private_flags \
230   ((bfd_boolean (*) (bfd *, flagword)) bfd_true)
231 #endif
232 #ifndef bfd_elfNN_bfd_is_local_label_name
233 #define bfd_elfNN_bfd_is_local_label_name _bfd_elf_is_local_label_name
234 #endif
235 #ifndef bfd_elfNN_bfd_is_target_special_symbol
236 #define bfd_elfNN_bfd_is_target_special_symbol \
237   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
238 #endif
239
240 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
241 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
242   _bfd_elf_get_dynamic_reloc_upper_bound
243 #endif
244 #ifndef bfd_elfNN_canonicalize_dynamic_reloc
245 #define bfd_elfNN_canonicalize_dynamic_reloc \
246   _bfd_elf_canonicalize_dynamic_reloc
247 #endif
248
249 #ifdef elf_backend_relocate_section
250 #ifndef bfd_elfNN_bfd_link_hash_table_create
251 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
252 #endif
253 #ifndef bfd_elfNN_bfd_link_add_symbols
254 #define bfd_elfNN_bfd_link_add_symbols  bfd_elf_link_add_symbols
255 #endif
256 #ifndef bfd_elfNN_bfd_final_link
257 #define bfd_elfNN_bfd_final_link        bfd_elf_final_link
258 #endif
259 #else /* ! defined (elf_backend_relocate_section) */
260 /* If no backend relocate_section routine, use the generic linker.
261    Note - this will prevent the port from being able to use some of
262    the other features of the ELF linker, because the generic hash structure
263    does not have the fields needed by the ELF linker.  In particular it
264    means that linking directly to S-records will not work.  */
265 #ifndef bfd_elfNN_bfd_link_hash_table_create
266 #define bfd_elfNN_bfd_link_hash_table_create \
267   _bfd_generic_link_hash_table_create
268 #endif
269 #ifndef bfd_elfNN_bfd_link_add_symbols
270 #define bfd_elfNN_bfd_link_add_symbols  _bfd_generic_link_add_symbols
271 #endif
272 #ifndef bfd_elfNN_bfd_final_link
273 #define bfd_elfNN_bfd_final_link        _bfd_generic_final_link
274 #endif
275 #endif /* ! defined (elf_backend_relocate_section) */
276
277 #ifndef bfd_elfNN_bfd_link_just_syms
278 #define bfd_elfNN_bfd_link_just_syms    _bfd_elf_link_just_syms
279 #endif
280
281 #ifndef bfd_elfNN_bfd_copy_link_hash_symbol_type
282 #define bfd_elfNN_bfd_copy_link_hash_symbol_type \
283   _bfd_elf_copy_link_hash_symbol_type
284 #endif
285
286 #ifndef bfd_elfNN_bfd_link_split_section
287 #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
288 #endif
289
290 #ifndef bfd_elfNN_bfd_link_check_relocs
291 #define bfd_elfNN_bfd_link_check_relocs  _bfd_elf_link_check_relocs
292 #endif
293
294 #ifndef bfd_elfNN_archive_p
295 #define bfd_elfNN_archive_p bfd_generic_archive_p
296 #endif
297
298 #ifndef bfd_elfNN_write_archive_contents
299 #define bfd_elfNN_write_archive_contents _bfd_write_archive_contents
300 #endif
301
302 #ifndef bfd_elfNN_mkobject
303 #define bfd_elfNN_mkobject bfd_elf_make_object
304 #endif
305
306 #ifndef bfd_elfNN_mkcorefile
307 #define bfd_elfNN_mkcorefile bfd_elf_mkcorefile
308 #endif
309
310 #ifndef bfd_elfNN_mkarchive
311 #define bfd_elfNN_mkarchive _bfd_generic_mkarchive
312 #endif
313
314 #ifndef bfd_elfNN_print_symbol
315 #define bfd_elfNN_print_symbol bfd_elf_print_symbol
316 #endif
317
318 #ifndef elf_symbol_leading_char
319 #define elf_symbol_leading_char 0
320 #endif
321
322 #ifndef elf_info_to_howto
323 #define elf_info_to_howto 0
324 #endif
325
326 #ifndef elf_info_to_howto_rel
327 #define elf_info_to_howto_rel 0
328 #endif
329
330 #ifndef elf_backend_arch_data
331 #define elf_backend_arch_data NULL
332 #endif
333
334 #ifndef ELF_TARGET_ID
335 #define ELF_TARGET_ID   GENERIC_ELF_DATA
336 #endif
337
338 #ifndef ELF_OSABI
339 #define ELF_OSABI ELFOSABI_NONE
340 #endif
341
342 #ifndef ELF_MAXPAGESIZE
343 # error ELF_MAXPAGESIZE is not defined
344 #define ELF_MAXPAGESIZE 1
345 #endif
346
347 #ifndef ELF_COMMONPAGESIZE
348 #define ELF_COMMONPAGESIZE ELF_MAXPAGESIZE
349 #endif
350
351 #ifndef ELF_MINPAGESIZE
352 #define ELF_MINPAGESIZE ELF_COMMONPAGESIZE
353 #endif
354
355 #if ELF_COMMONPAGESIZE > ELF_MAXPAGESIZE
356 # error ELF_COMMONPAGESIZE > ELF_MAXPAGESIZE
357 #endif
358 #if ELF_MINPAGESIZE > ELF_COMMONPAGESIZE
359 # error ELF_MINPAGESIZE > ELF_COMMONPAGESIZE
360 #endif
361
362 #ifndef ELF_DYNAMIC_SEC_FLAGS
363 /* Note that we set the SEC_IN_MEMORY flag for these sections.  */
364 #define ELF_DYNAMIC_SEC_FLAGS                   \
365   (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS      \
366    | SEC_IN_MEMORY | SEC_LINKER_CREATED)
367 #endif
368
369 #ifndef elf_backend_collect
370 #define elf_backend_collect FALSE
371 #endif
372 #ifndef elf_backend_type_change_ok
373 #define elf_backend_type_change_ok FALSE
374 #endif
375
376 #ifndef elf_backend_sym_is_global
377 #define elf_backend_sym_is_global       0
378 #endif
379 #ifndef elf_backend_object_p
380 #define elf_backend_object_p            0
381 #endif
382 #ifndef elf_backend_symbol_processing
383 #define elf_backend_symbol_processing   0
384 #endif
385 #ifndef elf_backend_symbol_table_processing
386 #define elf_backend_symbol_table_processing     0
387 #endif
388 #ifndef elf_backend_get_symbol_type
389 #define elf_backend_get_symbol_type 0
390 #endif
391 #ifndef elf_backend_archive_symbol_lookup
392 #define elf_backend_archive_symbol_lookup _bfd_elf_archive_symbol_lookup
393 #endif
394 #ifndef elf_backend_name_local_section_symbols
395 #define elf_backend_name_local_section_symbols  0
396 #endif
397 #ifndef elf_backend_section_processing
398 #define elf_backend_section_processing  0
399 #endif
400 #ifndef elf_backend_section_from_shdr
401 #define elf_backend_section_from_shdr   _bfd_elf_make_section_from_shdr
402 #endif
403 #ifndef elf_backend_section_flags
404 #define elf_backend_section_flags       0
405 #endif
406 #ifndef elf_backend_get_sec_type_attr
407 #define elf_backend_get_sec_type_attr   _bfd_elf_get_sec_type_attr
408 #endif
409 #ifndef elf_backend_section_from_phdr
410 #define elf_backend_section_from_phdr   _bfd_elf_make_section_from_phdr
411 #endif
412 #ifndef elf_backend_fake_sections
413 #define elf_backend_fake_sections       0
414 #endif
415 #ifndef elf_backend_section_from_bfd_section
416 #define elf_backend_section_from_bfd_section    0
417 #endif
418 #ifndef elf_backend_add_symbol_hook
419 #define elf_backend_add_symbol_hook     0
420 #endif
421 #ifndef elf_backend_link_output_symbol_hook
422 #define elf_backend_link_output_symbol_hook 0
423 #endif
424 #ifndef elf_backend_create_dynamic_sections
425 #define elf_backend_create_dynamic_sections 0
426 #endif
427 #ifndef elf_backend_omit_section_dynsym
428 #define elf_backend_omit_section_dynsym _bfd_elf_link_omit_section_dynsym
429 #endif
430 #ifndef elf_backend_relocs_compatible
431 #define elf_backend_relocs_compatible _bfd_elf_default_relocs_compatible
432 #endif
433 #ifndef elf_backend_check_relocs
434 #define elf_backend_check_relocs        0
435 #endif
436 #ifndef elf_backend_check_directives
437 #define elf_backend_check_directives    0
438 #endif
439 #ifndef elf_backend_notice_as_needed
440 #define elf_backend_notice_as_needed    _bfd_elf_notice_as_needed
441 #endif
442 #ifndef elf_backend_adjust_dynamic_symbol
443 #define elf_backend_adjust_dynamic_symbol 0
444 #endif
445 #ifndef elf_backend_always_size_sections
446 #define elf_backend_always_size_sections 0
447 #endif
448 #ifndef elf_backend_size_dynamic_sections
449 #define elf_backend_size_dynamic_sections 0
450 #endif
451 #ifndef elf_backend_init_index_section
452 #define elf_backend_init_index_section \
453  ((void (*) (bfd *, struct bfd_link_info *)) bfd_void)
454 #endif
455 #ifndef elf_backend_relocate_section
456 #define elf_backend_relocate_section    0
457 #endif
458 #ifndef elf_backend_finish_dynamic_symbol
459 #define elf_backend_finish_dynamic_symbol       0
460 #endif
461 #ifndef elf_backend_finish_dynamic_sections
462 #define elf_backend_finish_dynamic_sections     0
463 #endif
464 #ifndef elf_backend_begin_write_processing
465 #define elf_backend_begin_write_processing      0
466 #endif
467 #ifndef elf_backend_final_write_processing
468 #define elf_backend_final_write_processing      0
469 #endif
470 #ifndef elf_backend_additional_program_headers
471 #define elf_backend_additional_program_headers  0
472 #endif
473 #ifndef elf_backend_modify_segment_map
474 #define elf_backend_modify_segment_map  0
475 #endif
476 #ifndef elf_backend_modify_program_headers
477 #define elf_backend_modify_program_headers      0
478 #endif
479 #ifndef elf_backend_ecoff_debug_swap
480 #define elf_backend_ecoff_debug_swap    0
481 #endif
482 #ifndef elf_backend_bfd_from_remote_memory
483 #define elf_backend_bfd_from_remote_memory _bfd_elfNN_bfd_from_remote_memory
484 #endif
485 #ifndef elf_backend_got_header_size
486 #define elf_backend_got_header_size     0
487 #endif
488 #ifndef elf_backend_got_elt_size
489 #define elf_backend_got_elt_size _bfd_elf_default_got_elt_size
490 #endif
491 #ifndef elf_backend_obj_attrs_vendor
492 #define elf_backend_obj_attrs_vendor            NULL
493 #endif
494 #ifndef elf_backend_obj_attrs_section
495 #define elf_backend_obj_attrs_section           NULL
496 #endif
497 #ifndef elf_backend_obj_attrs_arg_type
498 #define elf_backend_obj_attrs_arg_type          NULL
499 #endif
500 #ifndef elf_backend_obj_attrs_section_type
501 #define elf_backend_obj_attrs_section_type              SHT_GNU_ATTRIBUTES
502 #endif
503 #ifndef elf_backend_obj_attrs_order
504 #define elf_backend_obj_attrs_order             NULL
505 #endif
506 #ifndef elf_backend_obj_attrs_handle_unknown
507 #define elf_backend_obj_attrs_handle_unknown    NULL
508 #endif
509 #ifndef elf_backend_static_tls_alignment
510 #define elf_backend_static_tls_alignment        1
511 #endif
512 #ifndef elf_backend_post_process_headers
513 #define elf_backend_post_process_headers        _bfd_elf_post_process_headers
514 #endif
515 #ifndef elf_backend_print_symbol_all
516 #define elf_backend_print_symbol_all            NULL
517 #endif
518 #ifndef elf_backend_output_arch_local_syms
519 #define elf_backend_output_arch_local_syms      NULL
520 #endif
521 #ifndef elf_backend_output_arch_syms
522 #define elf_backend_output_arch_syms            NULL
523 #endif
524 #ifndef elf_backend_copy_indirect_symbol
525 #define elf_backend_copy_indirect_symbol  _bfd_elf_link_hash_copy_indirect
526 #endif
527 #ifndef elf_backend_hide_symbol
528 #define elf_backend_hide_symbol         _bfd_elf_link_hash_hide_symbol
529 #endif
530 #ifndef elf_backend_fixup_symbol
531 #define elf_backend_fixup_symbol                NULL
532 #endif
533 #ifndef elf_backend_merge_symbol_attribute
534 #define elf_backend_merge_symbol_attribute      NULL
535 #endif
536 #ifndef elf_backend_get_target_dtag
537 #define elf_backend_get_target_dtag             NULL
538 #endif
539 #ifndef elf_backend_ignore_undef_symbol
540 #define elf_backend_ignore_undef_symbol         NULL
541 #endif
542 #ifndef elf_backend_emit_relocs
543 #define elf_backend_emit_relocs                 _bfd_elf_link_output_relocs
544 #endif
545 #ifndef elf_backend_count_relocs
546 #define elf_backend_count_relocs                NULL
547 #endif
548 #ifndef elf_backend_count_additional_relocs
549 #define elf_backend_count_additional_relocs     NULL
550 #endif
551 #ifndef elf_backend_sort_relocs_p
552 #define elf_backend_sort_relocs_p               NULL
553 #endif
554 #ifndef elf_backend_grok_prstatus
555 #define elf_backend_grok_prstatus               NULL
556 #endif
557 #ifndef elf_backend_grok_psinfo
558 #define elf_backend_grok_psinfo                 NULL
559 #endif
560 #ifndef elf_backend_write_core_note
561 #define elf_backend_write_core_note             NULL
562 #endif
563 #ifndef elf_backend_lookup_section_flags_hook
564 #define elf_backend_lookup_section_flags_hook   NULL
565 #endif
566 #ifndef elf_backend_reloc_type_class
567 #define elf_backend_reloc_type_class            _bfd_elf_reloc_type_class
568 #endif
569 #ifndef elf_backend_discard_info
570 #define elf_backend_discard_info                NULL
571 #endif
572 #ifndef elf_backend_ignore_discarded_relocs
573 #define elf_backend_ignore_discarded_relocs     NULL
574 #endif
575 #ifndef elf_backend_action_discarded
576 #define elf_backend_action_discarded _bfd_elf_default_action_discarded
577 #endif
578 #ifndef elf_backend_eh_frame_address_size
579 #define elf_backend_eh_frame_address_size _bfd_elf_eh_frame_address_size
580 #endif
581 #ifndef elf_backend_can_make_relative_eh_frame
582 #define elf_backend_can_make_relative_eh_frame  _bfd_elf_can_make_relative
583 #endif
584 #ifndef elf_backend_can_make_lsda_relative_eh_frame
585 #define elf_backend_can_make_lsda_relative_eh_frame     _bfd_elf_can_make_relative
586 #endif
587 #ifndef elf_backend_encode_eh_address
588 #define elf_backend_encode_eh_address           _bfd_elf_encode_eh_address
589 #endif
590 #ifndef elf_backend_write_section
591 #define elf_backend_write_section               NULL
592 #endif
593 #ifndef elf_backend_mips_irix_compat
594 #define elf_backend_mips_irix_compat            NULL
595 #endif
596 #ifndef elf_backend_mips_rtype_to_howto
597 #define elf_backend_mips_rtype_to_howto         NULL
598 #endif
599
600 /* Previously, backends could only use SHT_REL or SHT_RELA relocation
601    sections, but not both.  They defined USE_REL to indicate SHT_REL
602    sections, and left it undefined to indicated SHT_RELA sections.
603    For backwards compatibility, we still support this usage.  */
604 #ifndef USE_REL
605 #define USE_REL 0
606 #endif
607
608 /* Use these in new code.  */
609 #ifndef elf_backend_may_use_rel_p
610 #define elf_backend_may_use_rel_p USE_REL
611 #endif
612 #ifndef elf_backend_may_use_rela_p
613 #define elf_backend_may_use_rela_p !USE_REL
614 #endif
615 #ifndef elf_backend_default_use_rela_p
616 #define elf_backend_default_use_rela_p !USE_REL
617 #endif
618 #ifndef elf_backend_rela_plts_and_copies_p
619 #define elf_backend_rela_plts_and_copies_p elf_backend_default_use_rela_p
620 #endif
621
622 #ifndef elf_backend_rela_normal
623 #define elf_backend_rela_normal 0
624 #endif
625
626 #ifndef elf_backend_plt_sym_val
627 #define elf_backend_plt_sym_val NULL
628 #endif
629 #ifndef elf_backend_relplt_name
630 #define elf_backend_relplt_name NULL
631 #endif
632
633 #ifndef ELF_MACHINE_ALT1
634 #define ELF_MACHINE_ALT1 0
635 #endif
636
637 #ifndef ELF_MACHINE_ALT2
638 #define ELF_MACHINE_ALT2 0
639 #endif
640
641 #ifndef elf_backend_size_info
642 #define elf_backend_size_info _bfd_elfNN_size_info
643 #endif
644
645 #ifndef elf_backend_special_sections
646 #define elf_backend_special_sections NULL
647 #endif
648
649 #ifndef elf_backend_sign_extend_vma
650 #define elf_backend_sign_extend_vma 0
651 #endif
652
653 #ifndef elf_backend_link_order_error_handler
654 #define elf_backend_link_order_error_handler _bfd_default_error_handler
655 #endif
656
657 #ifndef elf_backend_common_definition
658 #define elf_backend_common_definition _bfd_elf_common_definition
659 #endif
660
661 #ifndef elf_backend_common_section_index
662 #define elf_backend_common_section_index _bfd_elf_common_section_index
663 #endif
664
665 #ifndef elf_backend_common_section
666 #define elf_backend_common_section _bfd_elf_common_section
667 #endif
668
669 #ifndef elf_backend_merge_symbol
670 #define elf_backend_merge_symbol NULL
671 #endif
672
673 #ifndef elf_backend_hash_symbol
674 #define elf_backend_hash_symbol _bfd_elf_hash_symbol
675 #endif
676
677 #ifndef elf_backend_is_function_type
678 #define elf_backend_is_function_type _bfd_elf_is_function_type
679 #endif
680
681 #ifndef elf_backend_maybe_function_sym
682 #define elf_backend_maybe_function_sym _bfd_elf_maybe_function_sym
683 #endif
684
685 #ifndef elf_backend_get_reloc_section
686 #define elf_backend_get_reloc_section _bfd_elf_get_reloc_section
687 #endif
688
689 #ifndef elf_backend_set_special_section_info_and_link
690 #define elf_backend_set_special_section_info_and_link NULL
691 #endif
692
693 #ifndef elf_backend_compact_eh_encoding
694 #define elf_backend_compact_eh_encoding NULL
695 #endif
696
697 #ifndef elf_backend_cant_unwind_opcode
698 #define elf_backend_cant_unwind_opcode 0
699 #endif
700
701 #ifndef elf_match_priority
702 #define elf_match_priority \
703   (ELF_ARCH == bfd_arch_unknown ? 2 : ELF_OSABI == ELFOSABI_NONE ? 1 : 0)
704 #endif
705
706 extern const struct elf_size_info _bfd_elfNN_size_info;
707
708 static struct elf_backend_data elfNN_bed =
709 {
710   ELF_ARCH,                     /* arch */
711   ELF_TARGET_ID,                /* target_id */
712   ELF_MACHINE_CODE,             /* elf_machine_code */
713   ELF_OSABI,                    /* elf_osabi  */
714   ELF_MAXPAGESIZE,              /* maxpagesize */
715   ELF_MINPAGESIZE,              /* minpagesize */
716   ELF_COMMONPAGESIZE,           /* commonpagesize */
717   ELF_DYNAMIC_SEC_FLAGS,        /* dynamic_sec_flags */
718   elf_backend_arch_data,
719   elf_info_to_howto,
720   elf_info_to_howto_rel,
721   elf_backend_sym_is_global,
722   elf_backend_object_p,
723   elf_backend_symbol_processing,
724   elf_backend_symbol_table_processing,
725   elf_backend_get_symbol_type,
726   elf_backend_archive_symbol_lookup,
727   elf_backend_name_local_section_symbols,
728   elf_backend_section_processing,
729   elf_backend_section_from_shdr,
730   elf_backend_section_flags,
731   elf_backend_get_sec_type_attr,
732   elf_backend_section_from_phdr,
733   elf_backend_fake_sections,
734   elf_backend_section_from_bfd_section,
735   elf_backend_add_symbol_hook,
736   elf_backend_link_output_symbol_hook,
737   elf_backend_create_dynamic_sections,
738   elf_backend_omit_section_dynsym,
739   elf_backend_relocs_compatible,
740   elf_backend_check_relocs,
741   elf_backend_check_directives,
742   elf_backend_notice_as_needed,
743   elf_backend_adjust_dynamic_symbol,
744   elf_backend_always_size_sections,
745   elf_backend_size_dynamic_sections,
746   elf_backend_init_index_section,
747   elf_backend_relocate_section,
748   elf_backend_finish_dynamic_symbol,
749   elf_backend_finish_dynamic_sections,
750   elf_backend_begin_write_processing,
751   elf_backend_final_write_processing,
752   elf_backend_additional_program_headers,
753   elf_backend_modify_segment_map,
754   elf_backend_modify_program_headers,
755   elf_backend_gc_keep,
756   elf_backend_gc_mark_dynamic_ref,
757   elf_backend_gc_mark_hook,
758   elf_backend_gc_mark_extra_sections,
759   elf_backend_gc_sweep_hook,
760   elf_backend_post_process_headers,
761   elf_backend_print_symbol_all,
762   elf_backend_output_arch_local_syms,
763   elf_backend_output_arch_syms,
764   elf_backend_copy_indirect_symbol,
765   elf_backend_hide_symbol,
766   elf_backend_fixup_symbol,
767   elf_backend_merge_symbol_attribute,
768   elf_backend_get_target_dtag,
769   elf_backend_ignore_undef_symbol,
770   elf_backend_emit_relocs,
771   elf_backend_count_relocs,
772   elf_backend_count_additional_relocs,
773   elf_backend_sort_relocs_p,
774   elf_backend_grok_prstatus,
775   elf_backend_grok_psinfo,
776   elf_backend_write_core_note,
777   elf_backend_lookup_section_flags_hook,
778   elf_backend_reloc_type_class,
779   elf_backend_discard_info,
780   elf_backend_ignore_discarded_relocs,
781   elf_backend_action_discarded,
782   elf_backend_eh_frame_address_size,
783   elf_backend_can_make_relative_eh_frame,
784   elf_backend_can_make_lsda_relative_eh_frame,
785   elf_backend_encode_eh_address,
786   elf_backend_write_section,
787   elf_backend_mips_irix_compat,
788   elf_backend_mips_rtype_to_howto,
789   elf_backend_ecoff_debug_swap,
790   elf_backend_bfd_from_remote_memory,
791   elf_backend_plt_sym_val,
792   elf_backend_common_definition,
793   elf_backend_common_section_index,
794   elf_backend_common_section,
795   elf_backend_merge_symbol,
796   elf_backend_hash_symbol,
797   elf_backend_is_function_type,
798   elf_backend_maybe_function_sym,
799   elf_backend_get_reloc_section,
800   elf_backend_set_special_section_info_and_link,
801   elf_backend_link_order_error_handler,
802   elf_backend_relplt_name,
803   ELF_MACHINE_ALT1,
804   ELF_MACHINE_ALT2,
805   &elf_backend_size_info,
806   elf_backend_special_sections,
807   elf_backend_got_header_size,
808   elf_backend_got_elt_size,
809   elf_backend_obj_attrs_vendor,
810   elf_backend_obj_attrs_section,
811   elf_backend_obj_attrs_arg_type,
812   elf_backend_obj_attrs_section_type,
813   elf_backend_obj_attrs_order,
814   elf_backend_obj_attrs_handle_unknown,
815   elf_backend_compact_eh_encoding,
816   elf_backend_cant_unwind_opcode,
817   elf_backend_static_tls_alignment,
818   elf_backend_stack_align,
819   elf_backend_strtab_flags,
820   elf_backend_collect,
821   elf_backend_type_change_ok,
822   elf_backend_may_use_rel_p,
823   elf_backend_may_use_rela_p,
824   elf_backend_default_use_rela_p,
825   elf_backend_rela_plts_and_copies_p,
826   elf_backend_rela_normal,
827   elf_backend_sign_extend_vma,
828   elf_backend_want_got_plt,
829   elf_backend_plt_readonly,
830   elf_backend_want_plt_sym,
831   elf_backend_plt_not_loaded,
832   elf_backend_plt_alignment,
833   elf_backend_can_gc_sections,
834   elf_backend_can_refcount,
835   elf_backend_want_got_sym,
836   elf_backend_want_dynbss,
837   elf_backend_want_p_paddr_set_to_zero,
838   elf_backend_default_execstack,
839   elf_backend_caches_rawsize,
840   elf_backend_extern_protected_data
841 };
842
843 /* Forward declaration for use when initialising alternative_target field.  */
844 #ifdef TARGET_LITTLE_SYM
845 extern const bfd_target TARGET_LITTLE_SYM;
846 #endif
847
848 #ifdef TARGET_BIG_SYM
849 const bfd_target TARGET_BIG_SYM =
850 {
851   /* name: identify kind of target */
852   TARGET_BIG_NAME,
853
854   /* flavour: general indication about file */
855   bfd_target_elf_flavour,
856
857   /* byteorder: data is big endian */
858   BFD_ENDIAN_BIG,
859
860   /* header_byteorder: header is also big endian */
861   BFD_ENDIAN_BIG,
862
863   /* object_flags: mask of all file flags */
864   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
865    | DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS
866    | BFD_COMPRESS_GABI | BFD_CONVERT_ELF_COMMON | BFD_USE_ELF_STT_COMMON),
867
868   /* section_flags: mask of all section flags */
869   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY
870    | SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES
871    | SEC_SMALL_DATA | SEC_MERGE | SEC_STRINGS | SEC_GROUP),
872
873    /* leading_symbol_char: is the first char of a user symbol
874       predictable, and if so what is it */
875   elf_symbol_leading_char,
876
877   /* ar_pad_char: pad character for filenames within an archive header
878      FIXME:  this really has nothing to do with ELF, this is a characteristic
879      of the archiver and/or os and should be independently tunable */
880   '/',
881
882   /* ar_max_namelen: maximum number of characters in an archive header
883      FIXME:  this really has nothing to do with ELF, this is a characteristic
884      of the archiver and should be independently tunable.  The System V ABI,
885      Chapter 7 (Formats & Protocols), Archive section sets this as 15.  */
886   15,
887
888   elf_match_priority,
889
890   /* Routines to byte-swap various sized integers from the data sections */
891   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
892     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
893     bfd_getb16, bfd_getb_signed_16, bfd_putb16,
894
895   /* Routines to byte-swap various sized integers from the file headers */
896   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
897     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
898     bfd_getb16, bfd_getb_signed_16, bfd_putb16,
899
900   /* bfd_check_format: check the format of a file being read */
901   { _bfd_dummy_target,          /* unknown format */
902     bfd_elfNN_object_p,         /* assembler/linker output (object file) */
903     bfd_elfNN_archive_p,        /* an archive */
904     bfd_elfNN_core_file_p       /* a core file */
905   },
906
907   /* bfd_set_format: set the format of a file being written */
908   { bfd_false,
909     bfd_elfNN_mkobject,
910     bfd_elfNN_mkarchive,
911     bfd_elfNN_mkcorefile
912   },
913
914   /* bfd_write_contents: write cached information into a file being written */
915   { bfd_false,
916     bfd_elfNN_write_object_contents,
917     bfd_elfNN_write_archive_contents,
918     bfd_elfNN_write_corefile_contents,
919   },
920
921   BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
922   BFD_JUMP_TABLE_COPY (bfd_elfNN),
923   BFD_JUMP_TABLE_CORE (bfd_elfNN),
924 #ifdef bfd_elfNN_archive_functions
925   BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
926 #else
927   BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
928 #endif
929   BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
930   BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
931   BFD_JUMP_TABLE_WRITE (bfd_elfNN),
932   BFD_JUMP_TABLE_LINK (bfd_elfNN),
933   BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
934
935   /* Alternative endian target.  */
936 #ifdef TARGET_LITTLE_SYM
937   & TARGET_LITTLE_SYM,
938 #else
939   NULL,
940 #endif
941
942   /* backend_data: */
943   &elfNN_bed
944 };
945 #endif
946
947 #ifdef TARGET_LITTLE_SYM
948 const bfd_target TARGET_LITTLE_SYM =
949 {
950   /* name: identify kind of target */
951   TARGET_LITTLE_NAME,
952
953   /* flavour: general indication about file */
954   bfd_target_elf_flavour,
955
956   /* byteorder: data is little endian */
957   BFD_ENDIAN_LITTLE,
958
959   /* header_byteorder: header is also little endian */
960   BFD_ENDIAN_LITTLE,
961
962   /* object_flags: mask of all file flags */
963   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
964    | DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS
965    | BFD_COMPRESS_GABI | BFD_CONVERT_ELF_COMMON | BFD_USE_ELF_STT_COMMON),
966
967   /* section_flags: mask of all section flags */
968   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY
969    | SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES
970    | SEC_SMALL_DATA | SEC_MERGE | SEC_STRINGS | SEC_GROUP),
971
972    /* leading_symbol_char: is the first char of a user symbol
973       predictable, and if so what is it */
974   elf_symbol_leading_char,
975
976   /* ar_pad_char: pad character for filenames within an archive header
977      FIXME:  this really has nothing to do with ELF, this is a characteristic
978      of the archiver and/or os and should be independently tunable */
979   '/',
980
981   /* ar_max_namelen: maximum number of characters in an archive header
982      FIXME:  this really has nothing to do with ELF, this is a characteristic
983      of the archiver and should be independently tunable.  The System V ABI,
984      Chapter 7 (Formats & Protocols), Archive section sets this as 15.  */
985   15,
986
987   elf_match_priority,
988
989   /* Routines to byte-swap various sized integers from the data sections */
990   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
991     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
992     bfd_getl16, bfd_getl_signed_16, bfd_putl16,
993
994   /* Routines to byte-swap various sized integers from the file headers */
995   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
996     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
997     bfd_getl16, bfd_getl_signed_16, bfd_putl16,
998
999   /* bfd_check_format: check the format of a file being read */
1000   { _bfd_dummy_target,          /* unknown format */
1001     bfd_elfNN_object_p,         /* assembler/linker output (object file) */
1002     bfd_elfNN_archive_p,        /* an archive */
1003     bfd_elfNN_core_file_p       /* a core file */
1004   },
1005
1006   /* bfd_set_format: set the format of a file being written */
1007   { bfd_false,
1008     bfd_elfNN_mkobject,
1009     bfd_elfNN_mkarchive,
1010     bfd_elfNN_mkcorefile
1011   },
1012
1013   /* bfd_write_contents: write cached information into a file being written */
1014   { bfd_false,
1015     bfd_elfNN_write_object_contents,
1016     bfd_elfNN_write_archive_contents,
1017     bfd_elfNN_write_corefile_contents,
1018   },
1019
1020   BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
1021   BFD_JUMP_TABLE_COPY (bfd_elfNN),
1022   BFD_JUMP_TABLE_CORE (bfd_elfNN),
1023 #ifdef bfd_elfNN_archive_functions
1024   BFD_JUMP_TABLE_ARCHIVE (bfd_elfNN_archive),
1025 #else
1026   BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
1027 #endif
1028   BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
1029   BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
1030   BFD_JUMP_TABLE_WRITE (bfd_elfNN),
1031   BFD_JUMP_TABLE_LINK (bfd_elfNN),
1032   BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
1033
1034   /* Alternative endian target.  */
1035 #ifdef TARGET_BIG_SYM
1036   & TARGET_BIG_SYM,
1037 #else
1038   NULL,
1039 #endif
1040
1041   /* backend_data: */
1042   &elfNN_bed
1043 };
1044 #endif