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