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