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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [bfd/] [doc/] [bfd.info-4] - Blame information for rev 578

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

Line No. Rev Author Line
1 578 markom
This is bfd.info, produced by makeinfo version 4.0 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 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: Core Files,  Next: Targets,  Prev: Relocations,  Up: BFD front end
20
 
21
Core files
22
==========
23
 
24
   *Description*
25
These are functions pertaining to core files.
26
 
27
`bfd_core_file_failing_command'
28
...............................
29
 
30
   *Synopsis*
31
     CONST char *bfd_core_file_failing_command(bfd *abfd);
32
   *Description*
33
Return a read-only string explaining which program was running when it
34
failed and produced the core file ABFD.
35
 
36
`bfd_core_file_failing_signal'
37
..............................
38
 
39
   *Synopsis*
40
     int bfd_core_file_failing_signal(bfd *abfd);
41
   *Description*
42
Returns the signal number which caused the core dump which generated
43
the file the BFD ABFD is attached to.
44
 
45
`core_file_matches_executable_p'
46
................................
47
 
48
   *Synopsis*
49
     boolean core_file_matches_executable_p
50
        (bfd *core_bfd, bfd *exec_bfd);
51
   *Description*
52
Return `true' if the core file attached to CORE_BFD was generated by a
53
run of the executable file attached to EXEC_BFD, `false' otherwise.
54
 
55

56
File: bfd.info,  Node: Targets,  Next: Architectures,  Prev: Core Files,  Up: BFD front end
57
 
58
Targets
59
=======
60
 
61
   *Description*
62
Each port of BFD to a different machine requries the creation of a
63
target back end. All the back end provides to the root part of BFD is a
64
structure containing pointers to functions which perform certain low
65
level operations on files. BFD translates the applications's requests
66
through a pointer into calls to the back end routines.
67
 
68
   When a file is opened with `bfd_openr', its format and target are
69
unknown. BFD uses various mechanisms to determine how to interpret the
70
file. The operations performed are:
71
 
72
   * Create a BFD by calling the internal routine `_bfd_new_bfd', then
73
     call `bfd_find_target' with the target string supplied to
74
     `bfd_openr' and the new BFD pointer.
75
 
76
   * If a null target string was provided to `bfd_find_target', look up
77
     the environment variable `GNUTARGET' and use that as the target
78
     string.
79
 
80
   * If the target string is still `NULL', or the target string is
81
     `default', then use the first item in the target vector as the
82
     target type, and set `target_defaulted' in the BFD to cause
83
     `bfd_check_format' to loop through all the targets.  *Note
84
     bfd_target::.  *Note Formats::.
85
 
86
   * Otherwise, inspect the elements in the target vector one by one,
87
     until a match on target name is found. When found, use it.
88
 
89
   * Otherwise return the error `bfd_error_invalid_target' to
90
     `bfd_openr'.
91
 
92
   * `bfd_openr' attempts to open the file using `bfd_open_file', and
93
     returns the BFD.
94
   Once the BFD has been opened and the target selected, the file
95
format may be determined. This is done by calling `bfd_check_format' on
96
the BFD with a suggested format.  If `target_defaulted' has been set,
97
each possible target type is tried to see if it recognizes the
98
specified format.  `bfd_check_format' returns `true' when the caller
99
guesses right.
100
 
101
* Menu:
102
 
103
* bfd_target::
104
 
105

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

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

950
File: bfd.info,  Node: Opening and Closing,  Next: Internal,  Prev: Architectures,  Up: BFD front end
951
 
952
Opening and closing BFDs
953
========================
954
 
955
`bfd_openr'
956
...........
957
 
958
   *Synopsis*
959
     bfd *bfd_openr(CONST char *filename, CONST char *target);
960
   *Description*
961
Open the file FILENAME (using `fopen') with the target TARGET.  Return
962
a pointer to the created BFD.
963
 
964
   Calls `bfd_find_target', so TARGET is interpreted as by that
965
function.
966
 
967
   If `NULL' is returned then an error has occured.   Possible errors
968
are `bfd_error_no_memory', `bfd_error_invalid_target' or `system_call'
969
error.
970
 
971
`bfd_fdopenr'
972
.............
973
 
974
   *Synopsis*
975
     bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd);
976
   *Description*
977
`bfd_fdopenr' is to `bfd_fopenr' much like `fdopen' is to `fopen'.  It
978
opens a BFD on a file already described by the FD supplied.
979
 
980
   When the file is later `bfd_close'd, the file descriptor will be
981
closed.
982
 
983
   If the caller desires that this file descriptor be cached by BFD
984
(opened as needed, closed as needed to free descriptors for other
985
opens), with the supplied FD used as an initial file descriptor (but
986
subject to closure at any time), call bfd_set_cacheable(bfd, 1) on the
987
returned BFD.  The default is to assume no cacheing; the file
988
descriptor will remain open until `bfd_close', and will not be affected
989
by BFD operations on other files.
990
 
991
   Possible errors are `bfd_error_no_memory',
992
`bfd_error_invalid_target' and `bfd_error_system_call'.
993
 
994
`bfd_openstreamr'
995
.................
996
 
997
   *Synopsis*
998
     bfd *bfd_openstreamr(const char *, const char *, PTR);
999
   *Description*
1000
Open a BFD for read access on an existing stdio stream.  When the BFD
1001
is passed to `bfd_close', the stream will be closed.
1002
 
1003
`bfd_openw'
1004
...........
1005
 
1006
   *Synopsis*
1007
     bfd *bfd_openw(CONST char *filename, CONST char *target);
1008
   *Description*
1009
Create a BFD, associated with file FILENAME, using the file format
1010
TARGET, and return a pointer to it.
1011
 
1012
   Possible errors are `bfd_error_system_call', `bfd_error_no_memory',
1013
`bfd_error_invalid_target'.
1014
 
1015
`bfd_close'
1016
...........
1017
 
1018
   *Synopsis*
1019
     boolean bfd_close(bfd *abfd);
1020
   *Description*
1021
Close a BFD. If the BFD was open for writing, then pending operations
1022
are completed and the file written out and closed. If the created file
1023
is executable, then `chmod' is called to mark it as such.
1024
 
1025
   All memory attached to the BFD is released.
1026
 
1027
   The file descriptor associated with the BFD is closed (even if it
1028
was passed in to BFD by `bfd_fdopenr').
1029
 
1030
   *Returns*
1031
`true' is returned if all is ok, otherwise `false'.
1032
 
1033
`bfd_close_all_done'
1034
....................
1035
 
1036
   *Synopsis*
1037
     boolean bfd_close_all_done(bfd *);
1038
   *Description*
1039
Close a BFD.  Differs from `bfd_close' since it does not complete any
1040
pending operations.  This routine would be used if the application had
1041
just used BFD for swapping and didn't want to use any of the writing
1042
code.
1043
 
1044
   If the created file is executable, then `chmod' is called to mark it
1045
as such.
1046
 
1047
   All memory attached to the BFD is released.
1048
 
1049
   *Returns*
1050
`true' is returned if all is ok, otherwise `false'.
1051
 
1052
`bfd_create'
1053
............
1054
 
1055
   *Synopsis*
1056
     bfd *bfd_create(CONST char *filename, bfd *templ);
1057
   *Description*
1058
Create a new BFD in the manner of `bfd_openw', but without opening a
1059
file. The new BFD takes the target from the target used by TEMPLATE. The
1060
format is always set to `bfd_object'.
1061
 
1062
`bfd_make_writable'
1063
...................
1064
 
1065
   *Synopsis*
1066
     boolean bfd_make_writable(bfd *abfd);
1067
   *Description*
1068
Takes a BFD as created by `bfd_create' and converts it into one like as
1069
returned by `bfd_openw'.  It does this by converting the BFD to
1070
BFD_IN_MEMORY.  It's assumed that you will call `bfd_make_readable' on
1071
this bfd later.
1072
 
1073
   *Returns*
1074
`true' is returned if all is ok, otherwise `false'.
1075
 
1076
`bfd_make_readable'
1077
...................
1078
 
1079
   *Synopsis*
1080
     boolean bfd_make_readable(bfd *abfd);
1081
   *Description*
1082
Takes a BFD as created by `bfd_create' and `bfd_make_writable' and
1083
converts it into one like as returned by `bfd_openr'.  It does this by
1084
writing the contents out to the memory buffer, then reversing the
1085
direction.
1086
 
1087
   *Returns*
1088
`true' is returned if all is ok, otherwise `false'.
1089
 
1090
`bfd_alloc'
1091
...........
1092
 
1093
   *Synopsis*
1094
     PTR bfd_alloc (bfd *abfd, size_t wanted);
1095
   *Description*
1096
Allocate a block of WANTED bytes of memory attached to `abfd' and
1097
return a pointer to it.
1098
 
1099

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

powered by: WebSVN 2.1.0

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