generate elf*-target.h from common elfxx-target.h source
[external/binutils.git] / bfd / elfxx-target.h
1 /* Target definitions for NN-bit ELF
2    Copyright 1993, 1994, 1995 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 /* This structure contains everything that BFD knows about a target.
21    It includes things like its byte order, name, what routines to call
22    to do various operations, etc.  Every BFD points to a target structure
23    with its "xvec" member.
24
25    There are two such structures here:  one for big-endian machines and
26    one for little-endian machines.   */
27
28 #define bfd_elfNN_close_and_cleanup _bfd_generic_close_and_cleanup
29 #define bfd_elfNN_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
30 #ifndef bfd_elfNN_get_section_contents
31 #define bfd_elfNN_get_section_contents _bfd_generic_get_section_contents
32 #endif
33
34 #define bfd_elfNN_bfd_debug_info_start  bfd_void
35 #define bfd_elfNN_bfd_debug_info_end    bfd_void
36 #define bfd_elfNN_bfd_debug_info_accumulate     (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
37
38 #ifndef bfd_elfNN_bfd_get_relocated_section_contents
39 #define bfd_elfNN_bfd_get_relocated_section_contents \
40  bfd_generic_get_relocated_section_contents
41 #endif
42
43 #define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
44 #define bfd_elfNN_bfd_make_debug_symbol \
45   ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
46
47 #ifndef bfd_elfNN_bfd_copy_private_symbol_data
48 #define bfd_elfNN_bfd_copy_private_symbol_data \
49   ((boolean (*) PARAMS ((bfd *, asymbol *, bfd *, asymbol *))) bfd_true)
50 #endif
51 #ifndef bfd_elfNN_bfd_copy_private_section_data
52 #define bfd_elfNN_bfd_copy_private_section_data \
53   ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
54 #endif
55 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
56 #define bfd_elfNN_bfd_copy_private_bfd_data \
57   ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
58 #endif
59 #ifndef bfd_elfNN_bfd_merge_private_bfd_data
60 #define bfd_elfNN_bfd_merge_private_bfd_data \
61   ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
62 #endif
63 #ifndef bfd_elfNN_bfd_set_private_flags
64 #define bfd_elfNN_bfd_set_private_flags \
65   ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
66 #endif
67 #ifndef bfd_elfNN_bfd_is_local_label
68 #define bfd_elfNN_bfd_is_local_label bfd_generic_is_local_label
69 #endif
70
71 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
72 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
73   _bfd_nodynamic_get_dynamic_reloc_upper_bound
74 #endif
75 #ifndef bfd_elfNN_canonicalize_dynamic_reloc
76 #define bfd_elfNN_canonicalize_dynamic_reloc \
77   _bfd_nodynamic_canonicalize_dynamic_reloc
78 #endif
79
80 #ifdef elf_backend_relocate_section
81 #ifndef bfd_elfNN_bfd_link_hash_table_create
82 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
83 #endif
84 #else /* ! defined (elf_backend_relocate_section) */
85 /* If no backend relocate_section routine, use the generic linker.  */
86 #ifndef bfd_elfNN_bfd_link_hash_table_create
87 #define bfd_elfNN_bfd_link_hash_table_create \
88   _bfd_generic_link_hash_table_create
89 #endif
90 #ifndef bfd_elfNN_bfd_link_add_symbols
91 #define bfd_elfNN_bfd_link_add_symbols  _bfd_generic_link_add_symbols
92 #endif
93 #ifndef bfd_elfNN_bfd_final_link
94 #define bfd_elfNN_bfd_final_link        _bfd_generic_final_link
95 #endif
96 #endif /* ! defined (elf_backend_relocate_section) */
97 #ifndef bfd_elfNN_bfd_link_split_section
98 #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
99 #endif
100
101 #ifndef elf_info_to_howto_rel
102 #define elf_info_to_howto_rel 0
103 #endif
104
105 #ifndef ELF_MAXPAGESIZE
106 #define ELF_MAXPAGESIZE 1
107 #endif
108
109 #ifndef elf_backend_collect
110 #define elf_backend_collect false
111 #endif
112
113 #ifndef elf_backend_sym_is_global
114 #define elf_backend_sym_is_global       0
115 #endif
116 #ifndef elf_backend_object_p
117 #define elf_backend_object_p            0
118 #endif
119 #ifndef elf_backend_symbol_processing
120 #define elf_backend_symbol_processing   0
121 #endif
122 #ifndef elf_backend_symbol_table_processing
123 #define elf_backend_symbol_table_processing     0
124 #endif
125 #ifndef elf_backend_section_processing
126 #define elf_backend_section_processing  0
127 #endif
128 #ifndef elf_backend_section_from_shdr
129 #define elf_backend_section_from_shdr   0
130 #endif
131 #ifndef elf_backend_fake_sections
132 #define elf_backend_fake_sections       0
133 #endif
134 #ifndef elf_backend_section_from_bfd_section
135 #define elf_backend_section_from_bfd_section    0
136 #endif
137 #ifndef elf_backend_add_symbol_hook
138 #define elf_backend_add_symbol_hook     0
139 #endif
140 #ifndef elf_backend_link_output_symbol_hook
141 #define elf_backend_link_output_symbol_hook 0
142 #endif
143 #ifndef elf_backend_create_dynamic_sections
144 #define elf_backend_create_dynamic_sections 0
145 #endif
146 #ifndef elf_backend_check_relocs
147 #define elf_backend_check_relocs        0
148 #endif
149 #ifndef elf_backend_adjust_dynamic_symbol
150 #define elf_backend_adjust_dynamic_symbol 0
151 #endif
152 #ifndef elf_backend_size_dynamic_sections
153 #define elf_backend_size_dynamic_sections 0
154 #endif
155 #ifndef elf_backend_relocate_section
156 #define elf_backend_relocate_section    0
157 #endif
158 #ifndef elf_backend_finish_dynamic_symbol
159 #define elf_backend_finish_dynamic_symbol       0
160 #endif
161 #ifndef elf_backend_finish_dynamic_sections
162 #define elf_backend_finish_dynamic_sections     0
163 #endif
164 #ifndef elf_backend_begin_write_processing
165 #define elf_backend_begin_write_processing      0
166 #endif
167 #ifndef elf_backend_final_write_processing
168 #define elf_backend_final_write_processing      0
169 #endif
170 #ifndef elf_backend_ecoff_debug_swap
171 #define elf_backend_ecoff_debug_swap    0
172 #endif
173
174 #ifndef ELF_MACHINE_ALT1
175 #define ELF_MACHINE_ALT1 0
176 #endif
177
178 #ifndef ELF_MACHINE_ALT2
179 #define ELF_MACHINE_ALT2 0
180 #endif
181
182 static CONST struct elf_backend_data elfNN_bed =
183 {
184 #ifdef USE_REL
185   0,                            /* use_rela_p */
186 #else
187   1,                            /* use_rela_p */
188 #endif
189 #if NN == 64
190   1,                            /* elf_64_p */
191 #else
192   0,                            /* elf_64_p */
193 #endif
194   ELF_ARCH,                     /* arch */
195   ELF_MACHINE_CODE,             /* elf_machine_code */
196   ELF_MAXPAGESIZE,              /* maxpagesize */
197   elf_backend_collect,
198   elf_info_to_howto,
199   elf_info_to_howto_rel,
200   elf_backend_sym_is_global,
201   elf_backend_object_p,
202   elf_backend_symbol_processing,
203   elf_backend_symbol_table_processing,
204   elf_backend_section_processing,
205   elf_backend_section_from_shdr,
206   elf_backend_fake_sections,
207   elf_backend_section_from_bfd_section,
208   elf_backend_add_symbol_hook,
209   elf_backend_link_output_symbol_hook,
210   elf_backend_create_dynamic_sections,
211   elf_backend_check_relocs,
212   elf_backend_adjust_dynamic_symbol,
213   elf_backend_size_dynamic_sections,
214   elf_backend_relocate_section,
215   elf_backend_finish_dynamic_symbol,
216   elf_backend_finish_dynamic_sections,
217   elf_backend_begin_write_processing,
218   elf_backend_final_write_processing,
219   elf_backend_ecoff_debug_swap,
220   ELF_MACHINE_ALT1,
221   ELF_MACHINE_ALT2
222 };
223
224 #ifdef TARGET_BIG_SYM
225 const bfd_target TARGET_BIG_SYM =
226 {
227   /* name: identify kind of target */
228   TARGET_BIG_NAME,
229
230   /* flavour: general indication about file */
231   bfd_target_elf_flavour,
232
233   /* byteorder_big_p: data is big endian */
234   true,
235
236   /* header_byteorder_big_p: header is also big endian */
237   true,
238
239   /* object_flags: mask of all file flags */
240   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
241    DYNAMIC | WP_TEXT | D_PAGED),
242   
243   /* section_flags: mask of all section flags */
244   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
245    SEC_CODE | SEC_DATA | SEC_DEBUGGING),
246
247    /* leading_symbol_char: is the first char of a user symbol
248       predictable, and if so what is it */
249    0,
250
251   /* ar_pad_char: pad character for filenames within an archive header
252      FIXME:  this really has nothing to do with ELF, this is a characteristic
253      of the archiver and/or os and should be independently tunable */
254   '/',
255
256   /* ar_max_namelen: maximum number of characters in an archive header
257      FIXME:  this really has nothing to do with ELF, this is a characteristic
258      of the archiver and should be independently tunable.  This value is
259      a WAG (wild a** guess) */
260   14,
261
262   /* align_power_min: minimum alignment restriction for any section
263      FIXME:  this value may be target machine dependent */
264   3,
265
266   /* Routines to byte-swap various sized integers from the data sections */
267   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
268     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
269     bfd_getb16, bfd_getb_signed_16, bfd_putb16,
270
271   /* Routines to byte-swap various sized integers from the file headers */
272   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
273     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
274     bfd_getb16, bfd_getb_signed_16, bfd_putb16,
275
276   /* bfd_check_format: check the format of a file being read */
277   { _bfd_dummy_target,          /* unknown format */
278     bfd_elfNN_object_p,         /* assembler/linker output (object file) */
279     bfd_generic_archive_p,      /* an archive */
280     bfd_elfNN_core_file_p       /* a core file */
281   },
282
283   /* bfd_set_format: set the format of a file being written */
284   { bfd_false,
285     bfd_elf_mkobject,
286     _bfd_generic_mkarchive,
287     bfd_false
288   },
289
290   /* bfd_write_contents: write cached information into a file being written */
291   { bfd_false,
292     bfd_elfNN_write_object_contents,
293     _bfd_write_archive_contents,
294     bfd_false
295   },
296
297       BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
298       BFD_JUMP_TABLE_COPY (bfd_elfNN),
299       BFD_JUMP_TABLE_CORE (bfd_elfNN),
300       BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
301       BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
302       BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
303       BFD_JUMP_TABLE_WRITE (bfd_elfNN),
304       BFD_JUMP_TABLE_LINK (bfd_elfNN),
305       BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
306
307   /* backend_data: */
308   (PTR) &elfNN_bed,
309 };
310 #endif
311
312 #ifdef TARGET_LITTLE_SYM
313 const bfd_target TARGET_LITTLE_SYM =
314 {
315   /* name: identify kind of target */
316   TARGET_LITTLE_NAME,
317
318   /* flavour: general indication about file */
319   bfd_target_elf_flavour,
320
321   /* byteorder_big_p: data is big endian */
322   false,                /* Nope -- this one's little endian */
323
324   /* header_byteorder_big_p: header is also big endian */
325   false,                /* Nope -- this one's little endian */
326
327   /* object_flags: mask of all file flags */
328   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
329    DYNAMIC | WP_TEXT | D_PAGED),
330   
331   /* section_flags: mask of all section flags */
332   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
333    SEC_CODE | SEC_DATA | SEC_DEBUGGING),
334
335    /* leading_symbol_char: is the first char of a user symbol
336       predictable, and if so what is it */
337    0,
338
339   /* ar_pad_char: pad character for filenames within an archive header
340      FIXME:  this really has nothing to do with ELF, this is a characteristic
341      of the archiver and/or os and should be independently tunable */
342   '/',
343
344   /* ar_max_namelen: maximum number of characters in an archive header
345      FIXME:  this really has nothing to do with ELF, this is a characteristic
346      of the archiver and should be independently tunable.  This value is
347      a WAG (wild a** guess) */
348   14,
349
350   /* align_power_min: minimum alignment restriction for any section
351      FIXME:  this value may be target machine dependent */
352   3,
353
354   /* Routines to byte-swap various sized integers from the data sections */
355   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
356     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
357     bfd_getl16, bfd_getl_signed_16, bfd_putl16,
358
359   /* Routines to byte-swap various sized integers from the file headers */
360   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
361     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
362     bfd_getl16, bfd_getl_signed_16, bfd_putl16,
363
364   /* bfd_check_format: check the format of a file being read */
365   { _bfd_dummy_target,          /* unknown format */
366     bfd_elfNN_object_p,         /* assembler/linker output (object file) */
367     bfd_generic_archive_p,      /* an archive */
368     bfd_elfNN_core_file_p       /* a core file */
369   },
370
371   /* bfd_set_format: set the format of a file being written */
372   { bfd_false,
373     bfd_elf_mkobject,
374     _bfd_generic_mkarchive,
375     bfd_false
376   },
377
378   /* bfd_write_contents: write cached information into a file being written */
379   { bfd_false,
380     bfd_elfNN_write_object_contents,
381     _bfd_write_archive_contents,
382     bfd_false
383   },
384
385       BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
386       BFD_JUMP_TABLE_COPY (bfd_elfNN),
387       BFD_JUMP_TABLE_CORE (bfd_elfNN),
388       BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
389       BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
390       BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
391       BFD_JUMP_TABLE_WRITE (bfd_elfNN),
392       BFD_JUMP_TABLE_LINK (bfd_elfNN),
393       BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
394
395   /* backend_data: */
396   (PTR) &elfNN_bed,
397 };
398 #endif