* libelf.h: Added some comments.
[external/binutils.git] / bfd / elf32-target.h
1 /* Target definitions for 32-bit ELF
2    Copyright 1993 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 /* Archives are generic or unimplemented.  */
29 #ifndef bfd_elf32_slurp_armap
30 #define bfd_elf32_slurp_armap           bfd_slurp_coff_armap
31 #endif
32 #define bfd_elf32_slurp_extended_name_table     _bfd_slurp_extended_name_table
33 #define bfd_elf32_truncate_arname               bfd_dont_truncate_arname
34 #define bfd_elf32_openr_next_archived_file      bfd_generic_openr_next_archived_file
35 #define bfd_elf32_generic_stat_arch_elt bfd_generic_stat_arch_elt
36 #ifndef bfd_elf32_write_armap
37 #define bfd_elf32_write_armap           coff_write_armap
38 #endif
39
40 /* Ordinary section reading and writing */
41 #define bfd_elf32_get_section_contents  bfd_generic_get_section_contents
42 #define bfd_elf32_close_and_cleanup             bfd_generic_close_and_cleanup
43
44 #define bfd_elf32_bfd_debug_info_start  bfd_void
45 #define bfd_elf32_bfd_debug_info_end    bfd_void
46 #define bfd_elf32_bfd_debug_info_accumulate     (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
47 #define bfd_elf32_bfd_get_relocated_section_contents \
48  bfd_generic_get_relocated_section_contents
49 #define bfd_elf32_bfd_relax_section bfd_generic_relax_section
50 #ifndef bfd_elf32_bfd_seclet_link
51 #define bfd_elf32_bfd_seclet_link bfd_generic_seclet_link
52 #endif
53 #define bfd_elf32_bfd_make_debug_symbol \
54   ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
55
56 #ifndef elf_info_to_howto_rel
57 #define elf_info_to_howto_rel 0
58 #endif
59
60 #ifndef ELF_MAXPAGESIZE
61 #define ELF_MAXPAGESIZE 1
62 #endif
63
64 #ifndef elf_backend_symbol_processing
65 #define elf_backend_symbol_processing   0       /* elf_backend_symbol_processing */
66 #endif
67 #ifndef elf_backend_symbol_table_processing
68 #define elf_backend_symbol_table_processing     0       /* elf_backend_symbol_table_processing */
69 #endif
70 #ifndef elf_backend_section_processing
71 #define elf_backend_section_processing  0       /* elf_backend_section_processing */
72 #endif
73 #ifndef elf_backend_section_from_shdr
74 #define elf_backend_section_from_shdr   0       /* elf_backend_section_from_shdr */
75 #endif
76 #ifndef elf_backend_fake_sections
77 #define elf_backend_fake_sections       0       /* elf_backend_fake_sections */
78 #endif
79 #ifndef elf_backend_section_from_bfd_section
80 #define elf_backend_section_from_bfd_section    0       /* elf_backend_section_from_bfd_section */
81 #endif
82 #ifndef elf_backend_ecoff_debug_swap
83 #define elf_backend_ecoff_debug_swap    0       /* elf_backed_ecoff_debug_swap */
84 #endif
85
86 static CONST struct elf_backend_data elf32_bed =
87 {
88 #ifdef USE_REL
89   0,                            /* use_rela_p */
90 #else
91   1,                            /* use_rela_p */
92 #endif
93   0,                            /* elf_64_p */
94   ELF_ARCH,                     /* arch */
95   ELF_MAXPAGESIZE,              /* maxpagesize */
96   elf_info_to_howto,            /* elf_info_to_howto */
97   elf_info_to_howto_rel,        /* elf_info_to_howto_rel */
98   elf_backend_symbol_processing,        /* elf_backend_symbol_processing */
99   elf_backend_symbol_table_processing,  /* elf_backend_symbol_table_processing */
100   elf_backend_section_processing,       /* elf_backend_section_processing */
101   elf_backend_section_from_shdr,        /* elf_backend_section_from_shdr */
102   elf_backend_fake_sections,            /* elf_backend_fake_sections */
103   elf_backend_section_from_bfd_section, /* elf_backend_section_from_bfd_section */
104   elf_backend_ecoff_debug_swap          /* elf_backend_ecoff_debug_swap */
105 };
106
107 #ifdef TARGET_BIG_SYM
108 bfd_target TARGET_BIG_SYM =
109 {
110   /* name: identify kind of target */
111   TARGET_BIG_NAME,
112
113   /* flavour: general indication about file */
114   bfd_target_elf_flavour,
115
116   /* byteorder_big_p: data is big endian */
117   true,
118
119   /* header_byteorder_big_p: header is also big endian */
120   true,
121
122   /* object_flags: mask of all file flags */
123   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
124    DYNAMIC | WP_TEXT),
125   
126   /* section_flags: mask of all section flags */
127   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
128    SEC_CODE | SEC_DATA | SEC_DEBUGGING),
129
130    /* leading_symbol_char: is the first char of a user symbol
131       predictable, and if so what is it */
132    0,
133
134   /* ar_pad_char: pad character for filenames within an archive header
135      FIXME:  this really has nothing to do with ELF, this is a characteristic
136      of the archiver and/or os and should be independently tunable */
137   '/',
138
139   /* ar_max_namelen: maximum number of characters in an archive header
140      FIXME:  this really has nothing to do with ELF, this is a characteristic
141      of the archiver and should be independently tunable.  This value is
142      a WAG (wild a** guess) */
143   15,
144
145   /* align_power_min: minimum alignment restriction for any section
146      FIXME:  this value may be target machine dependent */
147   3,
148
149   /* Routines to byte-swap various sized integers from the data sections */
150   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
151     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
152     bfd_getb16, bfd_getb_signed_16, bfd_putb16,
153
154   /* Routines to byte-swap various sized integers from the file headers */
155   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
156     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
157     bfd_getb16, bfd_getb_signed_16, bfd_putb16,
158
159   /* bfd_check_format: check the format of a file being read */
160   { _bfd_dummy_target,          /* unknown format */
161     bfd_elf32_object_p,         /* assembler/linker output (object file) */
162     bfd_generic_archive_p,      /* an archive */
163     bfd_elf32_core_file_p       /* a core file */
164   },
165
166   /* bfd_set_format: set the format of a file being written */
167   { bfd_false,
168     bfd_elf_mkobject,
169     _bfd_generic_mkarchive,
170     bfd_false
171   },
172
173   /* bfd_write_contents: write cached information into a file being written */
174   { bfd_false,
175     bfd_elf32_write_object_contents,
176     _bfd_write_archive_contents,
177     bfd_false
178   },
179
180   /* Initialize a jump table with the standard macro.  All names start with
181      "elf" */
182   JUMP_TABLE(bfd_elf32),
183
184   /* backend_data: */
185   (PTR) &elf32_bed,
186 };
187 #endif
188
189 #ifdef TARGET_LITTLE_SYM
190 bfd_target TARGET_LITTLE_SYM =
191 {
192   /* name: identify kind of target */
193   TARGET_LITTLE_NAME,
194
195   /* flavour: general indication about file */
196   bfd_target_elf_flavour,
197
198   /* byteorder_big_p: data is big endian */
199   false,                /* Nope -- this one's little endian */
200
201   /* header_byteorder_big_p: header is also big endian */
202   false,                /* Nope -- this one's little endian */
203
204   /* object_flags: mask of all file flags */
205   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
206    DYNAMIC | WP_TEXT),
207   
208   /* section_flags: mask of all section flags */
209   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
210    SEC_CODE | SEC_DATA | SEC_DEBUGGING),
211
212    /* leading_symbol_char: is the first char of a user symbol
213       predictable, and if so what is it */
214    0,
215
216   /* ar_pad_char: pad character for filenames within an archive header
217      FIXME:  this really has nothing to do with ELF, this is a characteristic
218      of the archiver and/or os and should be independently tunable */
219   '/',
220
221   /* ar_max_namelen: maximum number of characters in an archive header
222      FIXME:  this really has nothing to do with ELF, this is a characteristic
223      of the archiver and should be independently tunable.  This value is
224      a WAG (wild a** guess) */
225   15,
226
227   /* align_power_min: minimum alignment restriction for any section
228      FIXME:  this value may be target machine dependent */
229   3,
230
231   /* Routines to byte-swap various sized integers from the data sections */
232   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
233     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
234     bfd_getl16, bfd_getl_signed_16, bfd_putl16,
235
236   /* Routines to byte-swap various sized integers from the file headers */
237   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
238     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
239     bfd_getl16, bfd_getl_signed_16, bfd_putl16,
240
241   /* bfd_check_format: check the format of a file being read */
242   { _bfd_dummy_target,          /* unknown format */
243     bfd_elf32_object_p,         /* assembler/linker output (object file) */
244     bfd_generic_archive_p,      /* an archive */
245     bfd_elf32_core_file_p       /* a core file */
246   },
247
248   /* bfd_set_format: set the format of a file being written */
249   { bfd_false,
250     bfd_elf_mkobject,
251     _bfd_generic_mkarchive,
252     bfd_false
253   },
254
255   /* bfd_write_contents: write cached information into a file being written */
256   { bfd_false,
257     bfd_elf32_write_object_contents,
258     _bfd_write_archive_contents,
259     bfd_false
260   },
261
262   /* Initialize a jump table with the standard macro.  All names start with
263      "elf" */
264   JUMP_TABLE(bfd_elf32),
265
266   /* backend_data: */
267   (PTR) &elf32_bed,
268 };
269 #endif