OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [VER_5_3/] [gdb-5.3/] [bfd/] [doc/] [bfd.info-5] - Blame information for rev 1182

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
This is bfd.info, produced by makeinfo version 4.1 from bfd.texinfo.
2
 
3
START-INFO-DIR-ENTRY
4
* Bfd: (bfd).                   The Binary File Descriptor library.
5
END-INFO-DIR-ENTRY
6
 
7
   This file documents the BFD library.
8
 
9
   Copyright (C) 1991, 2000, 2001 Free Software Foundation, Inc.
10
 
11
   Permission is granted to copy, distribute and/or modify this document
12
     under the terms of the GNU Free Documentation License, Version 1.1
13
     or any later version published by the Free Software Foundation;
14
   with no Invariant Sections, with no Front-Cover Texts, and with no
15
    Back-Cover Texts.  A copy of the license is included in the
16
section entitled "GNU Free Documentation License".
17
 
18

19
File: bfd.info,  Node: bfd_target,  Prev: Targets,  Up: Targets
20
 
21
bfd_target
22
----------
23
 
24
   *Description*
25
This structure contains everything that BFD knows about a target. It
26
includes things like its byte order, name, and which routines to call
27
to do various operations.
28
 
29
   Every BFD points to a target structure with its `xvec' member.
30
 
31
   The macros below are used to dispatch to functions through the
32
`bfd_target' vector. They are used in a number of macros further down
33
in `bfd.h', and are also used when calling various routines by hand
34
inside the BFD implementation.  The ARGLIST argument must be
35
parenthesized; it contains all the arguments to the called function.
36
 
37
   They make the documentation (more) unpleasant to read, so if someone
38
wants to fix this and not break the above, please do.
39
     #define BFD_SEND(bfd, message, arglist) \
40
                    ((*((bfd)->xvec->message)) arglist)
41
 
42
     #ifdef DEBUG_BFD_SEND
43
     #undef BFD_SEND
44
     #define BFD_SEND(bfd, message, arglist) \
45
       (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
46
         ((*((bfd)->xvec->message)) arglist) : \
47
         (bfd_assert (__FILE__,__LINE__), NULL))
48
     #endif
49
   For operations which index on the BFD format:
50
     #define BFD_SEND_FMT(bfd, message, arglist) \
51
                 (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist)
52
 
53
     #ifdef DEBUG_BFD_SEND
54
     #undef BFD_SEND_FMT
55
     #define BFD_SEND_FMT(bfd, message, arglist) \
56
       (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
57
        (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \
58
        (bfd_assert (__FILE__,__LINE__), NULL))
59
     #endif
60
   This is the structure which defines the type of BFD this is.  The
61
`xvec' member of the struct `bfd' itself points here.  Each module that
62
implements access to a different target under BFD, defines one of these.
63
 
64
   FIXME, these names should be rationalised with the names of the
65
entry points which call them. Too bad we can't have one macro to define
66
them both!
67
     enum bfd_flavour
68
     {
69
       bfd_target_unknown_flavour,
70
       bfd_target_aout_flavour,
71
       bfd_target_coff_flavour,
72
       bfd_target_ecoff_flavour,
73
       bfd_target_xcoff_flavour,
74
       bfd_target_elf_flavour,
75
       bfd_target_ieee_flavour,
76
       bfd_target_nlm_flavour,
77
       bfd_target_oasys_flavour,
78
       bfd_target_tekhex_flavour,
79
       bfd_target_srec_flavour,
80
       bfd_target_ihex_flavour,
81
       bfd_target_som_flavour,
82
       bfd_target_os9k_flavour,
83
       bfd_target_versados_flavour,
84
       bfd_target_msdos_flavour,
85
       bfd_target_ovax_flavour,
86
       bfd_target_evax_flavour,
87
       bfd_target_mmo_flavour
88
     };
89
 
90
     enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
91
 
92
     /* Forward declaration.  */
93
     typedef struct bfd_link_info _bfd_link_info;
94
 
95
     typedef struct bfd_target
96
     {
97
       /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc.  */
98
       char *name;
99
 
100
      /* The "flavour" of a back end is a general indication about
101
         the contents of a file.  */
102
       enum bfd_flavour flavour;
103
 
104
       /* The order of bytes within the data area of a file.  */
105
       enum bfd_endian byteorder;
106
 
107
      /* The order of bytes within the header parts of a file.  */
108
       enum bfd_endian header_byteorder;
109
 
110
       /* A mask of all the flags which an executable may have set -
111
          from the set `BFD_NO_FLAGS', `HAS_RELOC', ...`D_PAGED'.  */
112
       flagword object_flags;
113
 
114
      /* A mask of all the flags which a section may have set - from
115
         the set `SEC_NO_FLAGS', `SEC_ALLOC', ...`SET_NEVER_LOAD'.  */
116
       flagword section_flags;
117
 
118
      /* The character normally found at the front of a symbol.
119
         (if any), perhaps `_'.  */
120
       char symbol_leading_char;
121
 
122
      /* The pad character for file names within an archive header.  */
123
       char ar_pad_char;
124
 
125
       /* The maximum number of characters in an archive header.  */
126
       unsigned short ar_max_namelen;
127
 
128
       /* Entries for byte swapping for data. These are different from the
129
          other entry points, since they don't take a BFD asthe first argument.
130
          Certain other handlers could do the same.  */
131
       bfd_vma        (*bfd_getx64) PARAMS ((const bfd_byte *));
132
       bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
133
       void           (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
134
       bfd_vma        (*bfd_getx32) PARAMS ((const bfd_byte *));
135
       bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
136
       void           (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
137
       bfd_vma        (*bfd_getx16) PARAMS ((const bfd_byte *));
138
       bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
139
       void           (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
140
 
141
       /* Byte swapping for the headers.  */
142
       bfd_vma        (*bfd_h_getx64) PARAMS ((const bfd_byte *));
143
       bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
144
       void           (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
145
       bfd_vma        (*bfd_h_getx32) PARAMS ((const bfd_byte *));
146
       bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
147
       void           (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
148
       bfd_vma        (*bfd_h_getx16) PARAMS ((const bfd_byte *));
149
       bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
150
       void           (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
151
 
152
       /* Format dependent routines: these are vectors of entry points
153
          within the target vector structure, one for each format to check.  */
154
 
155
       /* Check the format of a file being read.  Return a `bfd_target *' or zero.  */
156
       const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
157
 
158
       /* Set the format of a file being written.  */
159
       boolean  (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
160
 
161
       /* Write cached information into a file being written, at `bfd_close'.  */
162
       boolean  (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
163
   The general target vector.  These vectors are initialized using the
164
BFD_JUMP_TABLE macros.
165
 
166
       /* Generic entry points.  */
167
   Do not "beautify" the CONCAT* macro args.  Traditional C will not
168
remove whitespace added here, and thus will fail to concatenate the
169
tokens.
170
     #define BFD_JUMP_TABLE_GENERIC(NAME) \
171
     CONCAT2 (NAME,_close_and_cleanup), \
172
     CONCAT2 (NAME,_bfd_free_cached_info), \
173
     CONCAT2 (NAME,_new_section_hook), \
174
     CONCAT2 (NAME,_get_section_contents), \
175
     CONCAT2 (NAME,_get_section_contents_in_window)
176
 
177
       /* Called when the BFD is being closed to do any necessary cleanup.  */
178
       boolean  (*_close_and_cleanup) PARAMS ((bfd *));
179
       /* Ask the BFD to free all cached information.  */
180
       boolean  (*_bfd_free_cached_info) PARAMS ((bfd *));
181
       /* Called when a new section is created.  */
182
       boolean  (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
183
       /* Read the contents of a section.  */
184
       boolean  (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
185
                                                      file_ptr, bfd_size_type));
186
       boolean  (*_bfd_get_section_contents_in_window)
187
         PARAMS ((bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type));
188
 
189
       /* Entry points to copy private data.  */
190
     #define BFD_JUMP_TABLE_COPY(NAME) \
191
     CONCAT2 (NAME,_bfd_copy_private_bfd_data), \
192
     CONCAT2 (NAME,_bfd_merge_private_bfd_data), \
193
     CONCAT2 (NAME,_bfd_copy_private_section_data), \
194
     CONCAT2 (NAME,_bfd_copy_private_symbol_data), \
195
     CONCAT2 (NAME,_bfd_set_private_flags), \
196
     CONCAT2 (NAME,_bfd_print_private_bfd_data) \
197
       /* Called to copy BFD general private data from one object file
198
          to another.  */
199
       boolean  (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
200
       /* Called to merge BFD general private data from one object file
201
          to a common output file when linking.  */
202
       boolean  (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
203
       /* Called to copy BFD private section data from one object file
204
          to another.  */
205
       boolean  (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
206
                                                           bfd *, sec_ptr));
207
       /* Called to copy BFD private symbol data from one symbol
208
          to another.  */
209
       boolean  (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
210
                                                          bfd *, asymbol *));
211
       /* Called to set private backend flags.  */
212
       boolean  (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
213
 
214
       /* Called to print private BFD data.  */
215
       boolean  (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
216
 
217
       /* Core file entry points.  */
218
     #define BFD_JUMP_TABLE_CORE(NAME) \
219
     CONCAT2 (NAME,_core_file_failing_command), \
220
     CONCAT2 (NAME,_core_file_failing_signal), \
221
     CONCAT2 (NAME,_core_file_matches_executable_p)
222
       char *   (*_core_file_failing_command) PARAMS ((bfd *));
223
       int      (*_core_file_failing_signal) PARAMS ((bfd *));
224
       boolean  (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
225
 
226
       /* Archive entry points.  */
227
     #define BFD_JUMP_TABLE_ARCHIVE(NAME) \
228
     CONCAT2 (NAME,_slurp_armap), \
229
     CONCAT2 (NAME,_slurp_extended_name_table), \
230
     CONCAT2 (NAME,_construct_extended_name_table), \
231
     CONCAT2 (NAME,_truncate_arname), \
232
     CONCAT2 (NAME,_write_armap), \
233
     CONCAT2 (NAME,_read_ar_hdr), \
234
     CONCAT2 (NAME,_openr_next_archived_file), \
235
     CONCAT2 (NAME,_get_elt_at_index), \
236
     CONCAT2 (NAME,_generic_stat_arch_elt), \
237
     CONCAT2 (NAME,_update_armap_timestamp)
238
       boolean  (*_bfd_slurp_armap) PARAMS ((bfd *));
239
       boolean  (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
240
       boolean  (*_bfd_construct_extended_name_table)
241
         PARAMS ((bfd *, char **, bfd_size_type *, const char **));
242
       void     (*_bfd_truncate_arname) PARAMS ((bfd *, const char *, char *));
243
       boolean  (*write_armap)
244
         PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
245
       PTR      (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
246
       bfd *    (*openr_next_archived_file) PARAMS ((bfd *, bfd *));
247
     #define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
248
       bfd *    (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
249
       int      (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
250
       boolean  (*_bfd_update_armap_timestamp) PARAMS ((bfd *));
251
 
252
       /* Entry points used for symbols.  */
253
     #define BFD_JUMP_TABLE_SYMBOLS(NAME) \
254
     CONCAT2 (NAME,_get_symtab_upper_bound), \
255
     CONCAT2 (NAME,_get_symtab), \
256
     CONCAT2 (NAME,_make_empty_symbol), \
257
     CONCAT2 (NAME,_print_symbol), \
258
     CONCAT2 (NAME,_get_symbol_info), \
259
     CONCAT2 (NAME,_bfd_is_local_label_name), \
260
     CONCAT2 (NAME,_get_lineno), \
261
     CONCAT2 (NAME,_find_nearest_line), \
262
     CONCAT2 (NAME,_bfd_make_debug_symbol), \
263
     CONCAT2 (NAME,_read_minisymbols), \
264
     CONCAT2 (NAME,_minisymbol_to_symbol)
265
       long     (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
266
       long     (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
267
                                                     struct symbol_cache_entry **));
268
       struct symbol_cache_entry *
269
                (*_bfd_make_empty_symbol) PARAMS ((bfd *));
270
       void     (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
271
                                              struct symbol_cache_entry *,
272
                                              bfd_print_symbol_type));
273
     #define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
274
       void     (*_bfd_get_symbol_info) PARAMS ((bfd *,
275
                                                 struct symbol_cache_entry *,
276
                                                 symbol_info *));
277
     #define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
278
       boolean  (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *));
279
 
280
       alent *  (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
281
       boolean  (*_bfd_find_nearest_line)
282
         PARAMS ((bfd *, struct sec *, struct symbol_cache_entry **, bfd_vma,
283
                  const char **, const char **, unsigned int *));
284
      /* Back-door to allow format-aware applications to create debug symbols
285
         while using BFD for everything else.  Currently used by the assembler
286
         when creating COFF files.  */
287
       asymbol *(*_bfd_make_debug_symbol) PARAMS ((bfd *, void *,
288
                                                   unsigned long size));
289
     #define bfd_read_minisymbols(b, d, m, s) \
290
       BFD_SEND (b, _read_minisymbols, (b, d, m, s))
291
       long     (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
292
                                              unsigned int *));
293
     #define bfd_minisymbol_to_symbol(b, d, m, f) \
294
       BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
295
       asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
296
                                                  asymbol *));
297
 
298
       /* Routines for relocs.  */
299
     #define BFD_JUMP_TABLE_RELOCS(NAME) \
300
     CONCAT2 (NAME,_get_reloc_upper_bound), \
301
     CONCAT2 (NAME,_canonicalize_reloc), \
302
     CONCAT2 (NAME,_bfd_reloc_type_lookup)
303
       long     (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
304
       long     (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
305
                                                    struct symbol_cache_entry **));
306
       /* See documentation on reloc types.  */
307
       reloc_howto_type *
308
                (*reloc_type_lookup) PARAMS ((bfd *, bfd_reloc_code_real_type));
309
 
310
       /* Routines used when writing an object file.  */
311
     #define BFD_JUMP_TABLE_WRITE(NAME) \
312
     CONCAT2 (NAME,_set_arch_mach), \
313
     CONCAT2 (NAME,_set_section_contents)
314
       boolean  (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
315
                                               unsigned long));
316
       boolean  (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
317
                                                      file_ptr, bfd_size_type));
318
 
319
       /* Routines used by the linker.  */
320
     #define BFD_JUMP_TABLE_LINK(NAME) \
321
     CONCAT2 (NAME,_sizeof_headers), \
322
     CONCAT2 (NAME,_bfd_get_relocated_section_contents), \
323
     CONCAT2 (NAME,_bfd_relax_section), \
324
     CONCAT2 (NAME,_bfd_link_hash_table_create), \
325
     CONCAT2 (NAME,_bfd_link_hash_table_free), \
326
     CONCAT2 (NAME,_bfd_link_add_symbols), \
327
     CONCAT2 (NAME,_bfd_link_just_syms), \
328
     CONCAT2 (NAME,_bfd_final_link), \
329
     CONCAT2 (NAME,_bfd_link_split_section), \
330
     CONCAT2 (NAME,_bfd_gc_sections), \
331
     CONCAT2 (NAME,_bfd_merge_sections), \
332
     CONCAT2 (NAME,_bfd_discard_group)
333
       int      (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
334
       bfd_byte *(*_bfd_get_relocated_section_contents)
335
         PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
336
                  bfd_byte *, boolean, struct symbol_cache_entry **));
337
 
338
       boolean  (*_bfd_relax_section)
339
         PARAMS ((bfd *, struct sec *, struct bfd_link_info *, boolean *));
340
 
341
       /* Create a hash table for the linker.  Different backends store
342
          different information in this table.  */
343
       struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
344
 
345
       /* Release the memory associated with the linker hash table.  */
346
       void (*_bfd_link_hash_table_free) PARAMS ((struct bfd_link_hash_table *));
347
 
348
       /* Add symbols from this object file into the hash table.  */
349
       boolean  (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
350
 
351
       /* Indicate that we are only retrieving symbol values from this section.  */
352
       void     (*_bfd_link_just_syms) PARAMS ((asection *, struct bfd_link_info *));
353
 
354
       /* Do a link based on the link_order structures attached to each
355
          section of the BFD.  */
356
       boolean  (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
357
 
358
       /* Should this section be split up into smaller pieces during linking.  */
359
       boolean  (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
360
 
361
       /* Remove sections that are not referenced from the output.  */
362
       boolean  (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
363
 
364
       /* Attempt to merge SEC_MERGE sections.  */
365
       boolean  (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *));
366
 
367
       /* Discard members of a group.  */
368
       boolean  (*_bfd_discard_group) PARAMS ((bfd *, struct sec *));
369
 
370
       /* Routines to handle dynamic symbols and relocs.  */
371
     #define BFD_JUMP_TABLE_DYNAMIC(NAME) \
372
     CONCAT2 (NAME,_get_dynamic_symtab_upper_bound), \
373
     CONCAT2 (NAME,_canonicalize_dynamic_symtab), \
374
     CONCAT2 (NAME,_get_dynamic_reloc_upper_bound), \
375
     CONCAT2 (NAME,_canonicalize_dynamic_reloc)
376
       /* Get the amount of memory required to hold the dynamic symbols.  */
377
       long     (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
378
       /* Read in the dynamic symbols.  */
379
       long     (*_bfd_canonicalize_dynamic_symtab)
380
         PARAMS ((bfd *, struct symbol_cache_entry **));
381
       /* Get the amount of memory required to hold the dynamic relocs.  */
382
       long     (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
383
       /* Read in the dynamic relocs.  */
384
       long     (*_bfd_canonicalize_dynamic_reloc)
385
         PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
386
   A pointer to an alternative bfd_target in case the current one is not
387
satisfactory.  This can happen when the target cpu supports both big
388
and little endian code, and target chosen by the linker has the wrong
389
endianness.  The function open_output() in ld/ldlang.c uses this field
390
to find an alternative output format that is suitable.
391
       /* Opposite endian version of this target.  */
392
       const struct bfd_target * alternative_target;
393
 
394
       /* Data for use by back-end routines, which isn't
395
          generic enough to belong in this structure.  */
396
       PTR backend_data;
397
 
398
     } bfd_target;
399
 
400
`bfd_set_default_target'
401
........................
402
 
403
   *Synopsis*
404
     boolean bfd_set_default_target (const char *name);
405
   *Description*
406
Set the default target vector to use when recognizing a BFD.  This
407
takes the name of the target, which may be a BFD target name or a
408
configuration triplet.
409
 
410
`bfd_find_target'
411
.................
412
 
413
   *Synopsis*
414
     const bfd_target *bfd_find_target(const char *target_name, bfd *abfd);
415
   *Description*
416
Return a pointer to the transfer vector for the object target named
417
TARGET_NAME.  If TARGET_NAME is `NULL', choose the one in the
418
environment variable `GNUTARGET'; if that is null or not defined, then
419
choose the first entry in the target list.  Passing in the string
420
"default" or setting the environment variable to "default" will cause
421
the first entry in the target list to be returned, and
422
"target_defaulted" will be set in the BFD.  This causes
423
`bfd_check_format' to loop over all the targets to find the one that
424
matches the file being read.
425
 
426
`bfd_target_list'
427
.................
428
 
429
   *Synopsis*
430
     const char **bfd_target_list(void);
431
   *Description*
432
Return a freshly malloced NULL-terminated vector of the names of all
433
the valid BFD targets. Do not modify the names.
434
 
435
`bfd_seach_for_target'
436
......................
437
 
438
   *Synopsis*
439
     const bfd_target * bfd_search_for_target (int (* search_func) (const bfd_target *, void *), void *);
440
   *Description*
441
Return a pointer to the first transfer vector in the list of transfer
442
vectors maintained by BFD that produces a non-zero result when passed
443
to the function SEARCH_FUNC.  The parameter DATA is passed, unexamined,
444
to the search function.
445
 
446

447
File: bfd.info,  Node: Architectures,  Next: Opening and Closing,  Prev: Targets,  Up: BFD front end
448
 
449
Architectures
450
=============
451
 
452
   BFD keeps one atom in a BFD describing the architecture of the data
453
attached to the BFD: a pointer to a `bfd_arch_info_type'.
454
 
455
   Pointers to structures can be requested independently of a BFD so
456
that an architecture's information can be interrogated without access
457
to an open BFD.
458
 
459
   The architecture information is provided by each architecture
460
package.  The set of default architectures is selected by the macro
461
`SELECT_ARCHITECTURES'.  This is normally set up in the
462
`config/TARGET.mt' file of your choice.  If the name is not defined,
463
then all the architectures supported are included.
464
 
465
   When BFD starts up, all the architectures are called with an
466
initialize method.  It is up to the architecture back end to insert as
467
many items into the list of architectures as it wants to; generally
468
this would be one for each machine and one for the default case (an
469
item with a machine field of 0).
470
 
471
   BFD's idea of an architecture is implemented in `archures.c'.
472
 
473
bfd_architecture
474
----------------
475
 
476
   *Description*
477
This enum gives the object file's CPU architecture, in a global
478
sense--i.e., what processor family does it belong to?  Another field
479
indicates which processor within the family is in use.  The machine
480
gives a number which distinguishes different versions of the
481
architecture, containing, for example, 2 and 3 for Intel i960 KA and
482
i960 KB, and 68020 and 68030 for Motorola 68020 and 68030.
483
     enum bfd_architecture
484
     {
485
       bfd_arch_unknown,   /* File arch not known.  */
486
       bfd_arch_obscure,   /* Arch known, not one of these.  */
487
       bfd_arch_m68k,      /* Motorola 68xxx */
488
     #define bfd_mach_m68000 1
489
     #define bfd_mach_m68008 2
490
     #define bfd_mach_m68010 3
491
     #define bfd_mach_m68020 4
492
     #define bfd_mach_m68030 5
493
     #define bfd_mach_m68040 6
494
     #define bfd_mach_m68060 7
495
     #define bfd_mach_cpu32  8
496
     #define bfd_mach_mcf5200  9
497
     #define bfd_mach_mcf5206e 10
498
     #define bfd_mach_mcf5307  11
499
     #define bfd_mach_mcf5407  12
500
       bfd_arch_vax,       /* DEC Vax */
501
       bfd_arch_i960,      /* Intel 960 */
502
         /* The order of the following is important.
503
            lower number indicates a machine type that
504
            only accepts a subset of the instructions
505
            available to machines with higher numbers.
506
            The exception is the "ca", which is
507
            incompatible with all other machines except
508
            "core".  */
509
 
510
     #define bfd_mach_i960_core      1
511
     #define bfd_mach_i960_ka_sa     2
512
     #define bfd_mach_i960_kb_sb     3
513
     #define bfd_mach_i960_mc        4
514
     #define bfd_mach_i960_xa        5
515
     #define bfd_mach_i960_ca        6
516
     #define bfd_mach_i960_jx        7
517
     #define bfd_mach_i960_hx        8
518
 
519
       bfd_arch_or32,      /* OpenRISC 32 */
520
 
521
       bfd_arch_a29k,      /* AMD 29000 */
522
       bfd_arch_sparc,     /* SPARC */
523
     #define bfd_mach_sparc                 1
524
     /* The difference between v8plus and v9 is that v9 is a true 64 bit env.  */
525
     #define bfd_mach_sparc_sparclet        2
526
     #define bfd_mach_sparc_sparclite       3
527
     #define bfd_mach_sparc_v8plus          4
528
     #define bfd_mach_sparc_v8plusa         5 /* with ultrasparc add'ns.  */
529
     #define bfd_mach_sparc_sparclite_le    6
530
     #define bfd_mach_sparc_v9              7
531
     #define bfd_mach_sparc_v9a             8 /* with ultrasparc add'ns.  */
532
     #define bfd_mach_sparc_v8plusb         9 /* with cheetah add'ns.  */
533
     #define bfd_mach_sparc_v9b             10 /* with cheetah add'ns.  */
534
     /* Nonzero if MACH has the v9 instruction set.  */
535
     #define bfd_mach_sparc_v9_p(mach) \
536
       ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \
537
        && (mach) != bfd_mach_sparc_sparclite_le)
538
       bfd_arch_mips,      /* MIPS Rxxxx */
539
     #define bfd_mach_mips3000              3000
540
     #define bfd_mach_mips3900              3900
541
     #define bfd_mach_mips4000              4000
542
     #define bfd_mach_mips4010              4010
543
     #define bfd_mach_mips4100              4100
544
     #define bfd_mach_mips4111              4111
545
     #define bfd_mach_mips4300              4300
546
     #define bfd_mach_mips4400              4400
547
     #define bfd_mach_mips4600              4600
548
     #define bfd_mach_mips4650              4650
549
     #define bfd_mach_mips5000              5000
550
     #define bfd_mach_mips6000              6000
551
     #define bfd_mach_mips8000              8000
552
     #define bfd_mach_mips10000             10000
553
     #define bfd_mach_mips12000             12000
554
     #define bfd_mach_mips16                16
555
     #define bfd_mach_mips5                 5
556
     #define bfd_mach_mips_sb1              12310201 /* octal 'SB', 01 */
557
     #define bfd_mach_mipsisa32             32
558
     #define bfd_mach_mipsisa64             64
559
       bfd_arch_i386,      /* Intel 386 */
560
     #define bfd_mach_i386_i386 0
561
     #define bfd_mach_i386_i8086 1
562
     #define bfd_mach_i386_i386_intel_syntax 2
563
     #define bfd_mach_x86_64 3
564
     #define bfd_mach_x86_64_intel_syntax 4
565
       bfd_arch_we32k,     /* AT&T WE32xxx */
566
       bfd_arch_tahoe,     /* CCI/Harris Tahoe */
567
       bfd_arch_i860,      /* Intel 860 */
568
       bfd_arch_i370,      /* IBM 360/370 Mainframes */
569
       bfd_arch_romp,      /* IBM ROMP PC/RT */
570
       bfd_arch_alliant,   /* Alliant */
571
       bfd_arch_convex,    /* Convex */
572
       bfd_arch_m88k,      /* Motorola 88xxx */
573
       bfd_arch_pyramid,   /* Pyramid Technology */
574
       bfd_arch_h8300,     /* Hitachi H8/300 */
575
     #define bfd_mach_h8300   1
576
     #define bfd_mach_h8300h  2
577
     #define bfd_mach_h8300s  3
578
       bfd_arch_pdp11,     /* DEC PDP-11 */
579
       bfd_arch_powerpc,   /* PowerPC */
580
     #define bfd_mach_ppc           0
581
     #define bfd_mach_ppc64         1
582
     #define bfd_mach_ppc_403       403
583
     #define bfd_mach_ppc_403gc     4030
584
     #define bfd_mach_ppc_505       505
585
     #define bfd_mach_ppc_601       601
586
     #define bfd_mach_ppc_602       602
587
     #define bfd_mach_ppc_603       603
588
     #define bfd_mach_ppc_ec603e    6031
589
     #define bfd_mach_ppc_604       604
590
     #define bfd_mach_ppc_620       620
591
     #define bfd_mach_ppc_630       630
592
     #define bfd_mach_ppc_750       750
593
     #define bfd_mach_ppc_860       860
594
     #define bfd_mach_ppc_a35       35
595
     #define bfd_mach_ppc_rs64ii    642
596
     #define bfd_mach_ppc_rs64iii   643
597
     #define bfd_mach_ppc_7400      7400
598
     #define bfd_mach_ppc_e500      500
599
       bfd_arch_rs6000,    /* IBM RS/6000 */
600
     #define bfd_mach_rs6k          0
601
     #define bfd_mach_rs6k_rs1      6001
602
     #define bfd_mach_rs6k_rsc      6003
603
     #define bfd_mach_rs6k_rs2      6002
604
       bfd_arch_hppa,      /* HP PA RISC */
605
       bfd_arch_d10v,      /* Mitsubishi D10V */
606
     #define bfd_mach_d10v          0
607
     #define bfd_mach_d10v_ts2      2
608
     #define bfd_mach_d10v_ts3      3
609
       bfd_arch_d30v,      /* Mitsubishi D30V */
610
       bfd_arch_dlx,       /* DLX */
611
       bfd_arch_m68hc11,   /* Motorola 68HC11 */
612
       bfd_arch_m68hc12,   /* Motorola 68HC12 */
613
       bfd_arch_z8k,       /* Zilog Z8000 */
614
     #define bfd_mach_z8001         1
615
     #define bfd_mach_z8002         2
616
       bfd_arch_h8500,     /* Hitachi H8/500 */
617
       bfd_arch_sh,        /* Hitachi SH */
618
     #define bfd_mach_sh            0
619
     #define bfd_mach_sh2        0x20
620
     #define bfd_mach_sh_dsp     0x2d
621
     #define bfd_mach_sh3        0x30
622
     #define bfd_mach_sh3_dsp    0x3d
623
     #define bfd_mach_sh3e       0x3e
624
     #define bfd_mach_sh4        0x40
625
     #define bfd_mach_sh5        0x50
626
       bfd_arch_alpha,     /* Dec Alpha */
627
     #define bfd_mach_alpha_ev4  0x10
628
     #define bfd_mach_alpha_ev5  0x20
629
     #define bfd_mach_alpha_ev6  0x30
630
       bfd_arch_arm,       /* Advanced Risc Machines ARM.  */
631
     #define bfd_mach_arm_2         1
632
     #define bfd_mach_arm_2a        2
633
     #define bfd_mach_arm_3         3
634
     #define bfd_mach_arm_3M        4
635
     #define bfd_mach_arm_4         5
636
     #define bfd_mach_arm_4T        6
637
     #define bfd_mach_arm_5         7
638
     #define bfd_mach_arm_5T        8
639
     #define bfd_mach_arm_5TE       9
640
     #define bfd_mach_arm_XScale    10
641
       bfd_arch_ns32k,     /* National Semiconductors ns32000 */
642
       bfd_arch_w65,       /* WDC 65816 */
643
       bfd_arch_tic30,     /* Texas Instruments TMS320C30 */
644
       bfd_arch_tic4x,     /* Texas Instruments TMS320C3X/4X */
645
     #define bfd_mach_c3x           30
646
     #define bfd_mach_c4x           40
647
       bfd_arch_tic54x,    /* Texas Instruments TMS320C54X */
648
       bfd_arch_tic80,     /* TI TMS320c80 (MVP) */
649
       bfd_arch_v850,      /* NEC V850 */
650
     #define bfd_mach_v850          0
651
     #define bfd_mach_v850e         'E'
652
       bfd_arch_arc,       /* ARC Cores */
653
     #define bfd_mach_arc_5         0
654
     #define bfd_mach_arc_6         1
655
     #define bfd_mach_arc_7         2
656
     #define bfd_mach_arc_8         3
657
       bfd_arch_m32r,      /* Mitsubishi M32R/D */
658
     #define bfd_mach_m32r          0 /* For backwards compatibility.  */
659
     #define bfd_mach_m32rx         'x'
660
       bfd_arch_mn10200,   /* Matsushita MN10200 */
661
       bfd_arch_mn10300,   /* Matsushita MN10300 */
662
     #define bfd_mach_mn10300               300
663
     #define bfd_mach_am33          330
664
       bfd_arch_fr30,
665
     #define bfd_mach_fr30          0x46523330
666
       bfd_arch_frv,
667
     #define bfd_mach_frv           0
668
     #define bfd_mach_frvsimple     1
669
     #define bfd_mach_fr300         300
670
     #define bfd_mach_fr400         400
671
     #define bfd_mach_frvtomcat     499     /* fr500 prototype */
672
     #define bfd_mach_fr500         500
673
       bfd_arch_mcore,
674
       bfd_arch_ia64,      /* HP/Intel ia64 */
675
     #define bfd_mach_ia64_elf64    0
676
     #define bfd_mach_ia64_elf32    1
677
       bfd_arch_ip2k,      /* Ubicom IP2K microcontrollers. */
678
     #define bfd_mach_ip2022        0
679
     #define bfd_mach_ip2022ext     1
680
       bfd_arch_pj,
681
       bfd_arch_avr,       /* Atmel AVR microcontrollers.  */
682
     #define bfd_mach_avr1          1
683
     #define bfd_mach_avr2          2
684
     #define bfd_mach_avr3          3
685
     #define bfd_mach_avr4          4
686
     #define bfd_mach_avr5          5
687
       bfd_arch_cris,      /* Axis CRIS */
688
       bfd_arch_s390,      /* IBM s390 */
689
     #define bfd_mach_s390_31       0
690
     #define bfd_mach_s390_64       1
691
       bfd_arch_openrisc,  /* OpenRISC */
692
       bfd_arch_mmix,      /* Donald Knuth's educational processor.  */
693
       bfd_arch_xstormy16,
694
     #define bfd_mach_xstormy16     0
695
       bfd_arch_last
696
       };
697
 
698
bfd_arch_info
699
-------------
700
 
701
   *Description*
702
This structure contains information on architectures for use within BFD.
703
 
704
     typedef struct bfd_arch_info
705
     {
706
       int bits_per_word;
707
       int bits_per_address;
708
       int bits_per_byte;
709
       enum bfd_architecture arch;
710
       unsigned long mach;
711
       const char *arch_name;
712
       const char *printable_name;
713
       unsigned int section_align_power;
714
       /* True if this is the default machine for the architecture.
715
          The default arch should be the first entry for an arch so that
716
          all the entries for that arch can be accessed via `next'.  */
717
       boolean the_default;
718
       const struct bfd_arch_info * (*compatible)
719
            PARAMS ((const struct bfd_arch_info *a,
720
                     const struct bfd_arch_info *b));
721
 
722
       boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
723
 
724
       const struct bfd_arch_info *next;
725
     }
726
     bfd_arch_info_type;
727
 
728
`bfd_printable_name'
729
....................
730
 
731
   *Synopsis*
732
     const char *bfd_printable_name(bfd *abfd);
733
   *Description*
734
Return a printable string representing the architecture and machine
735
from the pointer to the architecture info structure.
736
 
737
`bfd_scan_arch'
738
...............
739
 
740
   *Synopsis*
741
     const bfd_arch_info_type *bfd_scan_arch(const char *string);
742
   *Description*
743
Figure out if BFD supports any cpu which could be described with the
744
name STRING.  Return a pointer to an `arch_info' structure if a machine
745
is found, otherwise NULL.
746
 
747
`bfd_arch_list'
748
...............
749
 
750
   *Synopsis*
751
     const char **bfd_arch_list(void);
752
   *Description*
753
Return a freshly malloced NULL-terminated vector of the names of all
754
the valid BFD architectures.  Do not modify the names.
755
 
756
`bfd_arch_get_compatible'
757
.........................
758
 
759
   *Synopsis*
760
     const bfd_arch_info_type *bfd_arch_get_compatible(
761
         const bfd *abfd,
762
         const bfd *bbfd);
763
   *Description*
764
Determine whether two BFDs' architectures and machine types are
765
compatible.  Calculates the lowest common denominator between the two
766
architectures and machine types implied by the BFDs and returns a
767
pointer to an `arch_info' structure describing the compatible machine.
768
 
769
`bfd_default_arch_struct'
770
.........................
771
 
772
   *Description*
773
The `bfd_default_arch_struct' is an item of `bfd_arch_info_type' which
774
has been initialized to a fairly generic state.  A BFD starts life by
775
pointing to this structure, until the correct back end has determined
776
the real architecture of the file.
777
     extern const bfd_arch_info_type bfd_default_arch_struct;
778
 
779
`bfd_set_arch_info'
780
...................
781
 
782
   *Synopsis*
783
     void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg);
784
   *Description*
785
Set the architecture info of ABFD to ARG.
786
 
787
`bfd_default_set_arch_mach'
788
...........................
789
 
790
   *Synopsis*
791
     boolean bfd_default_set_arch_mach(bfd *abfd,
792
         enum bfd_architecture arch,
793
         unsigned long mach);
794
   *Description*
795
Set the architecture and machine type in BFD ABFD to ARCH and MACH.
796
Find the correct pointer to a structure and insert it into the
797
`arch_info' pointer.
798
 
799
`bfd_get_arch'
800
..............
801
 
802
   *Synopsis*
803
     enum bfd_architecture bfd_get_arch(bfd *abfd);
804
   *Description*
805
Return the enumerated type which describes the BFD ABFD's architecture.
806
 
807
`bfd_get_mach'
808
..............
809
 
810
   *Synopsis*
811
     unsigned long bfd_get_mach(bfd *abfd);
812
   *Description*
813
Return the long type which describes the BFD ABFD's machine.
814
 
815
`bfd_arch_bits_per_byte'
816
........................
817
 
818
   *Synopsis*
819
     unsigned int bfd_arch_bits_per_byte(bfd *abfd);
820
   *Description*
821
Return the number of bits in one of the BFD ABFD's architecture's bytes.
822
 
823
`bfd_arch_bits_per_address'
824
...........................
825
 
826
   *Synopsis*
827
     unsigned int bfd_arch_bits_per_address(bfd *abfd);
828
   *Description*
829
Return the number of bits in one of the BFD ABFD's architecture's
830
addresses.
831
 
832
`bfd_default_compatible'
833
........................
834
 
835
   *Synopsis*
836
     const bfd_arch_info_type *bfd_default_compatible
837
        (const bfd_arch_info_type *a,
838
         const bfd_arch_info_type *b);
839
   *Description*
840
The default function for testing for compatibility.
841
 
842
`bfd_default_scan'
843
..................
844
 
845
   *Synopsis*
846
     boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string);
847
   *Description*
848
The default function for working out whether this is an architecture
849
hit and a machine hit.
850
 
851
`bfd_get_arch_info'
852
...................
853
 
854
   *Synopsis*
855
     const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
856
   *Description*
857
Return the architecture info struct in ABFD.
858
 
859
`bfd_lookup_arch'
860
.................
861
 
862
   *Synopsis*
863
     const bfd_arch_info_type *bfd_lookup_arch
864
        (enum bfd_architecture
865
         arch,
866
         unsigned long machine);
867
   *Description*
868
Look for the architecure info structure which matches the arguments
869
ARCH and MACHINE. A machine of 0 matches the machine/architecture
870
structure which marks itself as the default.
871
 
872
`bfd_printable_arch_mach'
873
.........................
874
 
875
   *Synopsis*
876
     const char *bfd_printable_arch_mach
877
        (enum bfd_architecture arch, unsigned long machine);
878
   *Description*
879
Return a printable string representing the architecture and machine
880
type.
881
 
882
   This routine is depreciated.
883
 
884
`bfd_octets_per_byte'
885
.....................
886
 
887
   *Synopsis*
888
     unsigned int bfd_octets_per_byte(bfd *abfd);
889
   *Description*
890
Return the number of octets (8-bit quantities) per target byte (minimum
891
addressable unit).  In most cases, this will be one, but some DSP
892
targets have 16, 32, or even 48 bits per byte.
893
 
894
`bfd_arch_mach_octets_per_byte'
895
...............................
896
 
897
   *Synopsis*
898
     unsigned int bfd_arch_mach_octets_per_byte(enum bfd_architecture arch,
899
         unsigned long machine);
900
   *Description*
901
See bfd_octets_per_byte.
902
 
903
   This routine is provided for those cases where a bfd * is not
904
available
905
 
906

907
File: bfd.info,  Node: Opening and Closing,  Next: Internal,  Prev: Architectures,  Up: BFD front end
908
 
909
Opening and closing BFDs
910
========================
911
 
912
`bfd_openr'
913
...........
914
 
915
   *Synopsis*
916
     bfd *bfd_openr(const char *filename, const char *target);
917
   *Description*
918
Open the file FILENAME (using `fopen') with the target TARGET.  Return
919
a pointer to the created BFD.
920
 
921
   Calls `bfd_find_target', so TARGET is interpreted as by that
922
function.
923
 
924
   If `NULL' is returned then an error has occured.   Possible errors
925
are `bfd_error_no_memory', `bfd_error_invalid_target' or `system_call'
926
error.
927
 
928
`bfd_fdopenr'
929
.............
930
 
931
   *Synopsis*
932
     bfd *bfd_fdopenr(const char *filename, const char *target, int fd);
933
   *Description*
934
`bfd_fdopenr' is to `bfd_fopenr' much like `fdopen' is to `fopen'.  It
935
opens a BFD on a file already described by the FD supplied.
936
 
937
   When the file is later `bfd_close'd, the file descriptor will be
938
closed.
939
 
940
   If the caller desires that this file descriptor be cached by BFD
941
(opened as needed, closed as needed to free descriptors for other
942
opens), with the supplied FD used as an initial file descriptor (but
943
subject to closure at any time), call bfd_set_cacheable(bfd, 1) on the
944
returned BFD.  The default is to assume no cacheing; the file
945
descriptor will remain open until `bfd_close', and will not be affected
946
by BFD operations on other files.
947
 
948
   Possible errors are `bfd_error_no_memory',
949
`bfd_error_invalid_target' and `bfd_error_system_call'.
950
 
951
`bfd_openstreamr'
952
.................
953
 
954
   *Synopsis*
955
     bfd *bfd_openstreamr(const char *, const char *, PTR);
956
   *Description*
957
Open a BFD for read access on an existing stdio stream.  When the BFD
958
is passed to `bfd_close', the stream will be closed.
959
 
960
`bfd_openw'
961
...........
962
 
963
   *Synopsis*
964
     bfd *bfd_openw(const char *filename, const char *target);
965
   *Description*
966
Create a BFD, associated with file FILENAME, using the file format
967
TARGET, and return a pointer to it.
968
 
969
   Possible errors are `bfd_error_system_call', `bfd_error_no_memory',
970
`bfd_error_invalid_target'.
971
 
972
`bfd_close'
973
...........
974
 
975
   *Synopsis*
976
     boolean bfd_close(bfd *abfd);
977
   *Description*
978
Close a BFD. If the BFD was open for writing, then pending operations
979
are completed and the file written out and closed. If the created file
980
is executable, then `chmod' is called to mark it as such.
981
 
982
   All memory attached to the BFD is released.
983
 
984
   The file descriptor associated with the BFD is closed (even if it
985
was passed in to BFD by `bfd_fdopenr').
986
 
987
   *Returns*
988
`true' is returned if all is ok, otherwise `false'.
989
 
990
`bfd_close_all_done'
991
....................
992
 
993
   *Synopsis*
994
     boolean bfd_close_all_done(bfd *);
995
   *Description*
996
Close a BFD.  Differs from `bfd_close' since it does not complete any
997
pending operations.  This routine would be used if the application had
998
just used BFD for swapping and didn't want to use any of the writing
999
code.
1000
 
1001
   If the created file is executable, then `chmod' is called to mark it
1002
as such.
1003
 
1004
   All memory attached to the BFD is released.
1005
 
1006
   *Returns*
1007
`true' is returned if all is ok, otherwise `false'.
1008
 
1009
`bfd_create'
1010
............
1011
 
1012
   *Synopsis*
1013
     bfd *bfd_create(const char *filename, bfd *templ);
1014
   *Description*
1015
Create a new BFD in the manner of `bfd_openw', but without opening a
1016
file. The new BFD takes the target from the target used by TEMPLATE. The
1017
format is always set to `bfd_object'.
1018
 
1019
`bfd_make_writable'
1020
...................
1021
 
1022
   *Synopsis*
1023
     boolean bfd_make_writable(bfd *abfd);
1024
   *Description*
1025
Takes a BFD as created by `bfd_create' and converts it into one like as
1026
returned by `bfd_openw'.  It does this by converting the BFD to
1027
BFD_IN_MEMORY.  It's assumed that you will call `bfd_make_readable' on
1028
this bfd later.
1029
 
1030
   *Returns*
1031
`true' is returned if all is ok, otherwise `false'.
1032
 
1033
`bfd_make_readable'
1034
...................
1035
 
1036
   *Synopsis*
1037
     boolean bfd_make_readable(bfd *abfd);
1038
   *Description*
1039
Takes a BFD as created by `bfd_create' and `bfd_make_writable' and
1040
converts it into one like as returned by `bfd_openr'.  It does this by
1041
writing the contents out to the memory buffer, then reversing the
1042
direction.
1043
 
1044
   *Returns*
1045
`true' is returned if all is ok, otherwise `false'.
1046
 
1047
`bfd_alloc'
1048
...........
1049
 
1050
   *Synopsis*
1051
     PTR bfd_alloc (bfd *abfd, size_t wanted);
1052
   *Description*
1053
Allocate a block of WANTED bytes of memory attached to `abfd' and
1054
return a pointer to it.
1055
 
1056

1057
File: bfd.info,  Node: Internal,  Next: File Caching,  Prev: Opening and Closing,  Up: BFD front end
1058
 
1059
Internal functions
1060
==================
1061
 
1062
   *Description*
1063
These routines are used within BFD.  They are not intended for export,
1064
but are documented here for completeness.
1065
 
1066
`bfd_write_bigendian_4byte_int'
1067
...............................
1068
 
1069
   *Synopsis*
1070
     boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
1071
   *Description*
1072
Write a 4 byte integer I to the output BFD ABFD, in big endian order
1073
regardless of what else is going on.  This is useful in archives.
1074
 
1075
`bfd_put_size'
1076
..............
1077
 
1078
`bfd_get_size'
1079
..............
1080
 
1081
   *Description*
1082
These macros as used for reading and writing raw data in sections; each
1083
access (except for bytes) is vectored through the target format of the
1084
BFD and mangled accordingly. The mangling performs any necessary endian
1085
translations and removes alignment restrictions.  Note that types
1086
accepted and returned by these macros are identical so they can be
1087
swapped around in macros--for example, `libaout.h' defines `GET_WORD'
1088
to either `bfd_get_32' or `bfd_get_64'.
1089
 
1090
   In the put routines, VAL must be a `bfd_vma'.  If we are on a system
1091
without prototypes, the caller is responsible for making sure that is
1092
true, with a cast if necessary.  We don't cast them in the macro
1093
definitions because that would prevent `lint' or `gcc -Wall' from
1094
detecting sins such as passing a pointer.  To detect calling these with
1095
less than a `bfd_vma', use `gcc -Wconversion' on a host with 64 bit
1096
`bfd_vma''s.
1097
 
1098
     /* Byte swapping macros for user section data.  */
1099
 
1100
     #define bfd_put_8(abfd, val, ptr) \
1101
                     ((void) (*((unsigned char *) (ptr)) = (unsigned char) (val)))
1102
     #define bfd_put_signed_8 \
1103
                    bfd_put_8
1104
     #define bfd_get_8(abfd, ptr) \
1105
                     (*(unsigned char *) (ptr) & 0xff)
1106
     #define bfd_get_signed_8(abfd, ptr) \
1107
                    (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
1108
 
1109
     #define bfd_put_16(abfd, val, ptr) \
1110
                     BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
1111
     #define bfd_put_signed_16 \
1112
                     bfd_put_16
1113
     #define bfd_get_16(abfd, ptr) \
1114
                     BFD_SEND(abfd, bfd_getx16, (ptr))
1115
     #define bfd_get_signed_16(abfd, ptr) \
1116
                     BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
1117
 
1118
     #define bfd_put_32(abfd, val, ptr) \
1119
                     BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
1120
     #define bfd_put_signed_32 \
1121
                     bfd_put_32
1122
     #define bfd_get_32(abfd, ptr) \
1123
                     BFD_SEND(abfd, bfd_getx32, (ptr))
1124
     #define bfd_get_signed_32(abfd, ptr) \
1125
                     BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
1126
 
1127
     #define bfd_put_64(abfd, val, ptr) \
1128
                     BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
1129
     #define bfd_put_signed_64 \
1130
                     bfd_put_64
1131
     #define bfd_get_64(abfd, ptr) \
1132
                     BFD_SEND(abfd, bfd_getx64, (ptr))
1133
     #define bfd_get_signed_64(abfd, ptr) \
1134
                     BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
1135
 
1136
     #define bfd_get(bits, abfd, ptr)                               \
1137
                     ( (bits) ==  8 ? (bfd_vma) bfd_get_8 (abfd, ptr)       \
1138
                     : (bits) == 16 ? bfd_get_16 (abfd, ptr)        \
1139
                     : (bits) == 32 ? bfd_get_32 (abfd, ptr)        \
1140
                     : (bits) == 64 ? bfd_get_64 (abfd, ptr)        \
1141
                     : (abort (), (bfd_vma) - 1))
1142
 
1143
     #define bfd_put(bits, abfd, val, ptr)                          \
1144
                     ( (bits) ==  8 ? bfd_put_8  (abfd, val, ptr)   \
1145
                     : (bits) == 16 ? bfd_put_16 (abfd, val, ptr)   \
1146
                     : (bits) == 32 ? bfd_put_32 (abfd, val, ptr)   \
1147
                     : (bits) == 64 ? bfd_put_64 (abfd, val, ptr)   \
1148
                     : (abort (), (void) 0))
1149
 
1150
`bfd_h_put_size'
1151
................
1152
 
1153
   *Description*
1154
These macros have the same function as their `bfd_get_x' brethren,
1155
except that they are used for removing information for the header
1156
records of object files. Believe it or not, some object files keep
1157
their header records in big endian order and their data in little
1158
endian order.
1159
 
1160
     /* Byte swapping macros for file header data.  */
1161
 
1162
     #define bfd_h_put_8(abfd, val, ptr) \
1163
       bfd_put_8 (abfd, val, ptr)
1164
     #define bfd_h_put_signed_8(abfd, val, ptr) \
1165
       bfd_put_8 (abfd, val, ptr)
1166
     #define bfd_h_get_8(abfd, ptr) \
1167
       bfd_get_8 (abfd, ptr)
1168
     #define bfd_h_get_signed_8(abfd, ptr) \
1169
       bfd_get_signed_8 (abfd, ptr)
1170
 
1171
     #define bfd_h_put_16(abfd, val, ptr) \
1172
       BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
1173
     #define bfd_h_put_signed_16 \
1174
       bfd_h_put_16
1175
     #define bfd_h_get_16(abfd, ptr) \
1176
       BFD_SEND (abfd, bfd_h_getx16, (ptr))
1177
     #define bfd_h_get_signed_16(abfd, ptr) \
1178
       BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
1179
 
1180
     #define bfd_h_put_32(abfd, val, ptr) \
1181
       BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
1182
     #define bfd_h_put_signed_32 \
1183
       bfd_h_put_32
1184
     #define bfd_h_get_32(abfd, ptr) \
1185
       BFD_SEND (abfd, bfd_h_getx32, (ptr))
1186
     #define bfd_h_get_signed_32(abfd, ptr) \
1187
       BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
1188
 
1189
     #define bfd_h_put_64(abfd, val, ptr) \
1190
       BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
1191
     #define bfd_h_put_signed_64 \
1192
       bfd_h_put_64
1193
     #define bfd_h_get_64(abfd, ptr) \
1194
       BFD_SEND (abfd, bfd_h_getx64, (ptr))
1195
     #define bfd_h_get_signed_64(abfd, ptr) \
1196
       BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
1197
 
1198
     /* Refinements on the above, which should eventually go away.  Save
1199
        cluttering the source with (bfd_vma) and (bfd_byte *) casts.  */
1200
 
1201
     #define H_PUT_64(abfd, val, where) \
1202
       bfd_h_put_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1203
 
1204
     #define H_PUT_32(abfd, val, where) \
1205
       bfd_h_put_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1206
 
1207
     #define H_PUT_16(abfd, val, where) \
1208
       bfd_h_put_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1209
 
1210
     #define H_PUT_8 bfd_h_put_8
1211
 
1212
     #define H_PUT_S64(abfd, val, where) \
1213
       bfd_h_put_signed_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1214
 
1215
     #define H_PUT_S32(abfd, val, where) \
1216
       bfd_h_put_signed_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1217
 
1218
     #define H_PUT_S16(abfd, val, where) \
1219
       bfd_h_put_signed_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1220
 
1221
     #define H_PUT_S8 bfd_h_put_signed_8
1222
 
1223
     #define H_GET_64(abfd, where) \
1224
       bfd_h_get_64 ((abfd), (bfd_byte *) (where))
1225
 
1226
     #define H_GET_32(abfd, where) \
1227
       bfd_h_get_32 ((abfd), (bfd_byte *) (where))
1228
 
1229
     #define H_GET_16(abfd, where) \
1230
       bfd_h_get_16 ((abfd), (bfd_byte *) (where))
1231
 
1232
     #define H_GET_8 bfd_h_get_8
1233
 
1234
     #define H_GET_S64(abfd, where) \
1235
       bfd_h_get_signed_64 ((abfd), (bfd_byte *) (where))
1236
 
1237
     #define H_GET_S32(abfd, where) \
1238
       bfd_h_get_signed_32 ((abfd), (bfd_byte *) (where))
1239
 
1240
     #define H_GET_S16(abfd, where) \
1241
       bfd_h_get_signed_16 ((abfd), (bfd_byte *) (where))
1242
 
1243
     #define H_GET_S8 bfd_h_get_signed_8
1244
 
1245
`bfd_log2'
1246
..........
1247
 
1248
   *Synopsis*
1249
     unsigned int bfd_log2 (bfd_vma x);
1250
   *Description*
1251
Return the log base 2 of the value supplied, rounded up.  E.g., an X of
1252
1025 returns 11.  A X of 0 returns 0.
1253
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.