Commit generated files for 2.12.1.
[binutils.git] / bfd / doc / bfd.info-5
blobd24b26158b7f3521b8399e767e8a3404e06957a6
1 This is bfd.info, produced by makeinfo version 4.1 from bfd.texinfo.
3 START-INFO-DIR-ENTRY
4 * Bfd: (bfd).                   The Binary File Descriptor library.
5 END-INFO-DIR-ENTRY
7    This file documents the BFD library.
9    Copyright (C) 1991, 2000, 2001 Free Software Foundation, Inc.
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".
18 \x1f
19 File: bfd.info,  Node: bfd_target,  Prev: Targets,  Up: Targets
21 bfd_target
22 ----------
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.
29    Every BFD points to a target structure with its `xvec' member.
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.
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.
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.
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_add_symbols), \
326      CONCAT2 (NAME,_bfd_final_link), \
327      CONCAT2 (NAME,_bfd_link_split_section), \
328      CONCAT2 (NAME,_bfd_gc_sections), \
329      CONCAT2 (NAME,_bfd_merge_sections)
330        int      (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
331        bfd_byte *(*_bfd_get_relocated_section_contents)
332          PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
333                   bfd_byte *, boolean, struct symbol_cache_entry **));
334      
335        boolean  (*_bfd_relax_section)
336          PARAMS ((bfd *, struct sec *, struct bfd_link_info *, boolean *));
337      
338        /* Create a hash table for the linker.  Different backends store
339           different information in this table.  */
340        struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
341      
342        /* Add symbols from this object file into the hash table.  */
343        boolean  (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
344      
345        /* Do a link based on the link_order structures attached to each
346           section of the BFD.  */
347        boolean  (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
348      
349        /* Should this section be split up into smaller pieces during linking.  */
350        boolean  (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
351      
352        /* Remove sections that are not referenced from the output.  */
353        boolean  (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
354      
355        /* Attempt to merge SEC_MERGE sections.  */
356        boolean  (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *));
357      
358        /* Routines to handle dynamic symbols and relocs.  */
359      #define BFD_JUMP_TABLE_DYNAMIC(NAME) \
360      CONCAT2 (NAME,_get_dynamic_symtab_upper_bound), \
361      CONCAT2 (NAME,_canonicalize_dynamic_symtab), \
362      CONCAT2 (NAME,_get_dynamic_reloc_upper_bound), \
363      CONCAT2 (NAME,_canonicalize_dynamic_reloc)
364        /* Get the amount of memory required to hold the dynamic symbols.  */
365        long     (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
366        /* Read in the dynamic symbols.  */
367        long     (*_bfd_canonicalize_dynamic_symtab)
368          PARAMS ((bfd *, struct symbol_cache_entry **));
369        /* Get the amount of memory required to hold the dynamic relocs.  */
370        long     (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
371        /* Read in the dynamic relocs.  */
372        long     (*_bfd_canonicalize_dynamic_reloc)
373          PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
374    A pointer to an alternative bfd_target in case the current one is not
375 satisfactory.  This can happen when the target cpu supports both big
376 and little endian code, and target chosen by the linker has the wrong
377 endianness.  The function open_output() in ld/ldlang.c uses this field
378 to find an alternative output format that is suitable.
379        /* Opposite endian version of this target.  */
380        const struct bfd_target * alternative_target;
381      
382        /* Data for use by back-end routines, which isn't
383           generic enough to belong in this structure.  */
384        PTR backend_data;
385      
386      } bfd_target;
388 `bfd_set_default_target'
389 ........................
391    *Synopsis*
392      boolean bfd_set_default_target (const char *name);
393    *Description*
394 Set the default target vector to use when recognizing a BFD.  This
395 takes the name of the target, which may be a BFD target name or a
396 configuration triplet.
398 `bfd_find_target'
399 .................
401    *Synopsis*
402      const bfd_target *bfd_find_target(const char *target_name, bfd *abfd);
403    *Description*
404 Return a pointer to the transfer vector for the object target named
405 TARGET_NAME.  If TARGET_NAME is `NULL', choose the one in the
406 environment variable `GNUTARGET'; if that is null or not defined, then
407 choose the first entry in the target list.  Passing in the string
408 "default" or setting the environment variable to "default" will cause
409 the first entry in the target list to be returned, and
410 "target_defaulted" will be set in the BFD.  This causes
411 `bfd_check_format' to loop over all the targets to find the one that
412 matches the file being read.
414 `bfd_target_list'
415 .................
417    *Synopsis*
418      const char **bfd_target_list(void);
419    *Description*
420 Return a freshly malloced NULL-terminated vector of the names of all
421 the valid BFD targets. Do not modify the names.
423 `bfd_seach_for_target'
424 ......................
426    *Synopsis*
427      const bfd_target * bfd_search_for_target (int (* search_func) (const bfd_target *, void *), void *);
428    *Description*
429 Return a pointer to the first transfer vector in the list of transfer
430 vectors maintained by BFD that produces a non-zero result when passed
431 to the function SEARCH_FUNC.  The parameter DATA is passed, unexamined,
432 to the search function.
434 \x1f
435 File: bfd.info,  Node: Architectures,  Next: Opening and Closing,  Prev: Targets,  Up: BFD front end
437 Architectures
438 =============
440    BFD keeps one atom in a BFD describing the architecture of the data
441 attached to the BFD: a pointer to a `bfd_arch_info_type'.
443    Pointers to structures can be requested independently of a BFD so
444 that an architecture's information can be interrogated without access
445 to an open BFD.
447    The architecture information is provided by each architecture
448 package.  The set of default architectures is selected by the macro
449 `SELECT_ARCHITECTURES'.  This is normally set up in the
450 `config/TARGET.mt' file of your choice.  If the name is not defined,
451 then all the architectures supported are included.
453    When BFD starts up, all the architectures are called with an
454 initialize method.  It is up to the architecture back end to insert as
455 many items into the list of architectures as it wants to; generally
456 this would be one for each machine and one for the default case (an
457 item with a machine field of 0).
459    BFD's idea of an architecture is implemented in `archures.c'.
461 bfd_architecture
462 ----------------
464    *Description*
465 This enum gives the object file's CPU architecture, in a global
466 sense--i.e., what processor family does it belong to?  Another field
467 indicates which processor within the family is in use.  The machine
468 gives a number which distinguishes different versions of the
469 architecture, containing, for example, 2 and 3 for Intel i960 KA and
470 i960 KB, and 68020 and 68030 for Motorola 68020 and 68030.
471      enum bfd_architecture
472      {
473        bfd_arch_unknown,   /* File arch not known.  */
474        bfd_arch_obscure,   /* Arch known, not one of these.  */
475        bfd_arch_m68k,      /* Motorola 68xxx */
476      #define bfd_mach_m68000 1
477      #define bfd_mach_m68008 2
478      #define bfd_mach_m68010 3
479      #define bfd_mach_m68020 4
480      #define bfd_mach_m68030 5
481      #define bfd_mach_m68040 6
482      #define bfd_mach_m68060 7
483      #define bfd_mach_cpu32  8
484      #define bfd_mach_mcf5200  9
485      #define bfd_mach_mcf5206e 10
486      #define bfd_mach_mcf5307  11
487      #define bfd_mach_mcf5407  12
488        bfd_arch_vax,       /* DEC Vax */
489        bfd_arch_i960,      /* Intel 960 */
490          /* The order of the following is important.
491             lower number indicates a machine type that
492             only accepts a subset of the instructions
493             available to machines with higher numbers.
494             The exception is the "ca", which is
495             incompatible with all other machines except
496             "core".  */
497      
498      #define bfd_mach_i960_core      1
499      #define bfd_mach_i960_ka_sa     2
500      #define bfd_mach_i960_kb_sb     3
501      #define bfd_mach_i960_mc        4
502      #define bfd_mach_i960_xa        5
503      #define bfd_mach_i960_ca        6
504      #define bfd_mach_i960_jx        7
505      #define bfd_mach_i960_hx        8
506      
507        bfd_arch_or32,      /* OpenRISC 32 */
508      
509        bfd_arch_a29k,      /* AMD 29000 */
510        bfd_arch_sparc,     /* SPARC */
511      #define bfd_mach_sparc                 1
512      /* The difference between v8plus and v9 is that v9 is a true 64 bit env.  */
513      #define bfd_mach_sparc_sparclet        2
514      #define bfd_mach_sparc_sparclite       3
515      #define bfd_mach_sparc_v8plus          4
516      #define bfd_mach_sparc_v8plusa         5 /* with ultrasparc add'ns.  */
517      #define bfd_mach_sparc_sparclite_le    6
518      #define bfd_mach_sparc_v9              7
519      #define bfd_mach_sparc_v9a             8 /* with ultrasparc add'ns.  */
520      #define bfd_mach_sparc_v8plusb         9 /* with cheetah add'ns.  */
521      #define bfd_mach_sparc_v9b             10 /* with cheetah add'ns.  */
522      /* Nonzero if MACH has the v9 instruction set.  */
523      #define bfd_mach_sparc_v9_p(mach) \
524        ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \
525         && (mach) != bfd_mach_sparc_sparclite_le)
526        bfd_arch_mips,      /* MIPS Rxxxx */
527      #define bfd_mach_mips3000              3000
528      #define bfd_mach_mips3900              3900
529      #define bfd_mach_mips4000              4000
530      #define bfd_mach_mips4010              4010
531      #define bfd_mach_mips4100              4100
532      #define bfd_mach_mips4111              4111
533      #define bfd_mach_mips4300              4300
534      #define bfd_mach_mips4400              4400
535      #define bfd_mach_mips4600              4600
536      #define bfd_mach_mips4650              4650
537      #define bfd_mach_mips5000              5000
538      #define bfd_mach_mips6000              6000
539      #define bfd_mach_mips8000              8000
540      #define bfd_mach_mips10000             10000
541      #define bfd_mach_mips12000             12000
542      #define bfd_mach_mips16                16
543      #define bfd_mach_mips5                 5
544      #define bfd_mach_mips_sb1              12310201 /* octal 'SB', 01 */
545      #define bfd_mach_mipsisa32             32
546      #define bfd_mach_mipsisa64             64
547        bfd_arch_i386,      /* Intel 386 */
548      #define bfd_mach_i386_i386 0
549      #define bfd_mach_i386_i8086 1
550      #define bfd_mach_i386_i386_intel_syntax 2
551      #define bfd_mach_x86_64 3
552      #define bfd_mach_x86_64_intel_syntax 4
553        bfd_arch_we32k,     /* AT&T WE32xxx */
554        bfd_arch_tahoe,     /* CCI/Harris Tahoe */
555        bfd_arch_i860,      /* Intel 860 */
556        bfd_arch_i370,      /* IBM 360/370 Mainframes */
557        bfd_arch_romp,      /* IBM ROMP PC/RT */
558        bfd_arch_alliant,   /* Alliant */
559        bfd_arch_convex,    /* Convex */
560        bfd_arch_m88k,      /* Motorola 88xxx */
561        bfd_arch_pyramid,   /* Pyramid Technology */
562        bfd_arch_h8300,     /* Hitachi H8/300 */
563      #define bfd_mach_h8300   1
564      #define bfd_mach_h8300h  2
565      #define bfd_mach_h8300s  3
566        bfd_arch_pdp11,     /* DEC PDP-11 */
567        bfd_arch_powerpc,   /* PowerPC */
568      #define bfd_mach_ppc           0
569      #define bfd_mach_ppc64         1
570      #define bfd_mach_ppc_403       403
571      #define bfd_mach_ppc_403gc     4030
572      #define bfd_mach_ppc_505       505
573      #define bfd_mach_ppc_601       601
574      #define bfd_mach_ppc_602       602
575      #define bfd_mach_ppc_603       603
576      #define bfd_mach_ppc_ec603e    6031
577      #define bfd_mach_ppc_604       604
578      #define bfd_mach_ppc_620       620
579      #define bfd_mach_ppc_630       630
580      #define bfd_mach_ppc_750       750
581      #define bfd_mach_ppc_860       860
582      #define bfd_mach_ppc_a35       35
583      #define bfd_mach_ppc_rs64ii    642
584      #define bfd_mach_ppc_rs64iii   643
585      #define bfd_mach_ppc_7400      7400
586        bfd_arch_rs6000,    /* IBM RS/6000 */
587      #define bfd_mach_rs6k          0
588      #define bfd_mach_rs6k_rs1      6001
589      #define bfd_mach_rs6k_rsc      6003
590      #define bfd_mach_rs6k_rs2      6002
591        bfd_arch_hppa,      /* HP PA RISC */
592        bfd_arch_d10v,      /* Mitsubishi D10V */
593      #define bfd_mach_d10v          0
594      #define bfd_mach_d10v_ts2      2
595      #define bfd_mach_d10v_ts3      3
596        bfd_arch_d30v,      /* Mitsubishi D30V */
597        bfd_arch_m68hc11,   /* Motorola 68HC11 */
598        bfd_arch_m68hc12,   /* Motorola 68HC12 */
599        bfd_arch_z8k,       /* Zilog Z8000 */
600      #define bfd_mach_z8001         1
601      #define bfd_mach_z8002         2
602        bfd_arch_h8500,     /* Hitachi H8/500 */
603        bfd_arch_sh,        /* Hitachi SH */
604      #define bfd_mach_sh            0
605      #define bfd_mach_sh2        0x20
606      #define bfd_mach_sh_dsp     0x2d
607      #define bfd_mach_sh3        0x30
608      #define bfd_mach_sh3_dsp    0x3d
609      #define bfd_mach_sh3e       0x3e
610      #define bfd_mach_sh4        0x40
611      #define bfd_mach_sh5        0x50
612        bfd_arch_alpha,     /* Dec Alpha */
613      #define bfd_mach_alpha_ev4  0x10
614      #define bfd_mach_alpha_ev5  0x20
615      #define bfd_mach_alpha_ev6  0x30
616        bfd_arch_arm,       /* Advanced Risc Machines ARM.  */
617      #define bfd_mach_arm_2         1
618      #define bfd_mach_arm_2a        2
619      #define bfd_mach_arm_3         3
620      #define bfd_mach_arm_3M        4
621      #define bfd_mach_arm_4         5
622      #define bfd_mach_arm_4T        6
623      #define bfd_mach_arm_5         7
624      #define bfd_mach_arm_5T        8
625      #define bfd_mach_arm_5TE       9
626      #define bfd_mach_arm_XScale    10
627        bfd_arch_ns32k,     /* National Semiconductors ns32000 */
628        bfd_arch_w65,       /* WDC 65816 */
629        bfd_arch_tic30,     /* Texas Instruments TMS320C30 */
630        bfd_arch_tic54x,    /* Texas Instruments TMS320C54X */
631        bfd_arch_tic80,     /* TI TMS320c80 (MVP) */
632        bfd_arch_v850,      /* NEC V850 */
633      #define bfd_mach_v850          0
634      #define bfd_mach_v850e         'E'
635      #define bfd_mach_v850ea        'A'
636        bfd_arch_arc,       /* ARC Cores */
637      #define bfd_mach_arc_5         0
638      #define bfd_mach_arc_6         1
639      #define bfd_mach_arc_7         2
640      #define bfd_mach_arc_8         3
641        bfd_arch_m32r,      /* Mitsubishi M32R/D */
642      #define bfd_mach_m32r          0 /* For backwards compatibility.  */
643      #define bfd_mach_m32rx         'x'
644        bfd_arch_mn10200,   /* Matsushita MN10200 */
645        bfd_arch_mn10300,   /* Matsushita MN10300 */
646      #define bfd_mach_mn10300               300
647      #define bfd_mach_am33          330
648        bfd_arch_fr30,
649      #define bfd_mach_fr30          0x46523330
650        bfd_arch_mcore,
651        bfd_arch_ia64,      /* HP/Intel ia64 */
652      #define bfd_mach_ia64_elf64    0
653      #define bfd_mach_ia64_elf32    1
654        bfd_arch_pj,
655        bfd_arch_avr,       /* Atmel AVR microcontrollers.  */
656      #define bfd_mach_avr1          1
657      #define bfd_mach_avr2          2
658      #define bfd_mach_avr3          3
659      #define bfd_mach_avr4          4
660      #define bfd_mach_avr5          5
661        bfd_arch_cris,      /* Axis CRIS */
662        bfd_arch_s390,      /* IBM s390 */
663      #define bfd_mach_s390_31       0
664      #define bfd_mach_s390_64       1
665        bfd_arch_openrisc,  /* OpenRISC */
666        bfd_arch_mmix,      /* Donald Knuth's educational processor.  */
667        bfd_arch_xstormy16,
668      #define bfd_mach_xstormy16     0
669        bfd_arch_last
670        };
672 bfd_arch_info
673 -------------
675    *Description*
676 This structure contains information on architectures for use within BFD.
678      typedef struct bfd_arch_info
679      {
680        int bits_per_word;
681        int bits_per_address;
682        int bits_per_byte;
683        enum bfd_architecture arch;
684        unsigned long mach;
685        const char *arch_name;
686        const char *printable_name;
687        unsigned int section_align_power;
688        /* True if this is the default machine for the architecture.
689           The default arch should be the first entry for an arch so that
690           all the entries for that arch can be accessed via `next'.  */
691        boolean the_default;
692        const struct bfd_arch_info * (*compatible)
693             PARAMS ((const struct bfd_arch_info *a,
694                      const struct bfd_arch_info *b));
695      
696        boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
697      
698        const struct bfd_arch_info *next;
699      }
700      bfd_arch_info_type;
702 `bfd_printable_name'
703 ....................
705    *Synopsis*
706      const char *bfd_printable_name(bfd *abfd);
707    *Description*
708 Return a printable string representing the architecture and machine
709 from the pointer to the architecture info structure.
711 `bfd_scan_arch'
712 ...............
714    *Synopsis*
715      const bfd_arch_info_type *bfd_scan_arch(const char *string);
716    *Description*
717 Figure out if BFD supports any cpu which could be described with the
718 name STRING.  Return a pointer to an `arch_info' structure if a machine
719 is found, otherwise NULL.
721 `bfd_arch_list'
722 ...............
724    *Synopsis*
725      const char **bfd_arch_list(void);
726    *Description*
727 Return a freshly malloced NULL-terminated vector of the names of all
728 the valid BFD architectures.  Do not modify the names.
730 `bfd_arch_get_compatible'
731 .........................
733    *Synopsis*
734      const bfd_arch_info_type *bfd_arch_get_compatible(
735          const bfd *abfd,
736          const bfd *bbfd);
737    *Description*
738 Determine whether two BFDs' architectures and machine types are
739 compatible.  Calculates the lowest common denominator between the two
740 architectures and machine types implied by the BFDs and returns a
741 pointer to an `arch_info' structure describing the compatible machine.
743 `bfd_default_arch_struct'
744 .........................
746    *Description*
747 The `bfd_default_arch_struct' is an item of `bfd_arch_info_type' which
748 has been initialized to a fairly generic state.  A BFD starts life by
749 pointing to this structure, until the correct back end has determined
750 the real architecture of the file.
751      extern const bfd_arch_info_type bfd_default_arch_struct;
753 `bfd_set_arch_info'
754 ...................
756    *Synopsis*
757      void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg);
758    *Description*
759 Set the architecture info of ABFD to ARG.
761 `bfd_default_set_arch_mach'
762 ...........................
764    *Synopsis*
765      boolean bfd_default_set_arch_mach(bfd *abfd,
766          enum bfd_architecture arch,
767          unsigned long mach);
768    *Description*
769 Set the architecture and machine type in BFD ABFD to ARCH and MACH.
770 Find the correct pointer to a structure and insert it into the
771 `arch_info' pointer.
773 `bfd_get_arch'
774 ..............
776    *Synopsis*
777      enum bfd_architecture bfd_get_arch(bfd *abfd);
778    *Description*
779 Return the enumerated type which describes the BFD ABFD's architecture.
781 `bfd_get_mach'
782 ..............
784    *Synopsis*
785      unsigned long bfd_get_mach(bfd *abfd);
786    *Description*
787 Return the long type which describes the BFD ABFD's machine.
789 `bfd_arch_bits_per_byte'
790 ........................
792    *Synopsis*
793      unsigned int bfd_arch_bits_per_byte(bfd *abfd);
794    *Description*
795 Return the number of bits in one of the BFD ABFD's architecture's bytes.
797 `bfd_arch_bits_per_address'
798 ...........................
800    *Synopsis*
801      unsigned int bfd_arch_bits_per_address(bfd *abfd);
802    *Description*
803 Return the number of bits in one of the BFD ABFD's architecture's
804 addresses.
806 `bfd_default_compatible'
807 ........................
809    *Synopsis*
810      const bfd_arch_info_type *bfd_default_compatible
811         (const bfd_arch_info_type *a,
812          const bfd_arch_info_type *b);
813    *Description*
814 The default function for testing for compatibility.
816 `bfd_default_scan'
817 ..................
819    *Synopsis*
820      boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string);
821    *Description*
822 The default function for working out whether this is an architecture
823 hit and a machine hit.
825 `bfd_get_arch_info'
826 ...................
828    *Synopsis*
829      const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
830    *Description*
831 Return the architecture info struct in ABFD.
833 `bfd_lookup_arch'
834 .................
836    *Synopsis*
837      const bfd_arch_info_type *bfd_lookup_arch
838         (enum bfd_architecture
839          arch,
840          unsigned long machine);
841    *Description*
842 Look for the architecure info structure which matches the arguments
843 ARCH and MACHINE. A machine of 0 matches the machine/architecture
844 structure which marks itself as the default.
846 `bfd_printable_arch_mach'
847 .........................
849    *Synopsis*
850      const char *bfd_printable_arch_mach
851         (enum bfd_architecture arch, unsigned long machine);
852    *Description*
853 Return a printable string representing the architecture and machine
854 type.
856    This routine is depreciated.
858 `bfd_octets_per_byte'
859 .....................
861    *Synopsis*
862      unsigned int bfd_octets_per_byte(bfd *abfd);
863    *Description*
864 Return the number of octets (8-bit quantities) per target byte (minimum
865 addressable unit).  In most cases, this will be one, but some DSP
866 targets have 16, 32, or even 48 bits per byte.
868 `bfd_arch_mach_octets_per_byte'
869 ...............................
871    *Synopsis*
872      unsigned int bfd_arch_mach_octets_per_byte(enum bfd_architecture arch,
873          unsigned long machine);
874    *Description*
875 See bfd_octets_per_byte.
877    This routine is provided for those cases where a bfd * is not
878 available
880 \x1f
881 File: bfd.info,  Node: Opening and Closing,  Next: Internal,  Prev: Architectures,  Up: BFD front end
883 Opening and closing BFDs
884 ========================
886 `bfd_openr'
887 ...........
889    *Synopsis*
890      bfd *bfd_openr(const char *filename, const char *target);
891    *Description*
892 Open the file FILENAME (using `fopen') with the target TARGET.  Return
893 a pointer to the created BFD.
895    Calls `bfd_find_target', so TARGET is interpreted as by that
896 function.
898    If `NULL' is returned then an error has occured.   Possible errors
899 are `bfd_error_no_memory', `bfd_error_invalid_target' or `system_call'
900 error.
902 `bfd_fdopenr'
903 .............
905    *Synopsis*
906      bfd *bfd_fdopenr(const char *filename, const char *target, int fd);
907    *Description*
908 `bfd_fdopenr' is to `bfd_fopenr' much like `fdopen' is to `fopen'.  It
909 opens a BFD on a file already described by the FD supplied.
911    When the file is later `bfd_close'd, the file descriptor will be
912 closed.
914    If the caller desires that this file descriptor be cached by BFD
915 (opened as needed, closed as needed to free descriptors for other
916 opens), with the supplied FD used as an initial file descriptor (but
917 subject to closure at any time), call bfd_set_cacheable(bfd, 1) on the
918 returned BFD.  The default is to assume no cacheing; the file
919 descriptor will remain open until `bfd_close', and will not be affected
920 by BFD operations on other files.
922    Possible errors are `bfd_error_no_memory',
923 `bfd_error_invalid_target' and `bfd_error_system_call'.
925 `bfd_openstreamr'
926 .................
928    *Synopsis*
929      bfd *bfd_openstreamr(const char *, const char *, PTR);
930    *Description*
931 Open a BFD for read access on an existing stdio stream.  When the BFD
932 is passed to `bfd_close', the stream will be closed.
934 `bfd_openw'
935 ...........
937    *Synopsis*
938      bfd *bfd_openw(const char *filename, const char *target);
939    *Description*
940 Create a BFD, associated with file FILENAME, using the file format
941 TARGET, and return a pointer to it.
943    Possible errors are `bfd_error_system_call', `bfd_error_no_memory',
944 `bfd_error_invalid_target'.
946 `bfd_close'
947 ...........
949    *Synopsis*
950      boolean bfd_close(bfd *abfd);
951    *Description*
952 Close a BFD. If the BFD was open for writing, then pending operations
953 are completed and the file written out and closed. If the created file
954 is executable, then `chmod' is called to mark it as such.
956    All memory attached to the BFD is released.
958    The file descriptor associated with the BFD is closed (even if it
959 was passed in to BFD by `bfd_fdopenr').
961    *Returns*
962 `true' is returned if all is ok, otherwise `false'.
964 `bfd_close_all_done'
965 ....................
967    *Synopsis*
968      boolean bfd_close_all_done(bfd *);
969    *Description*
970 Close a BFD.  Differs from `bfd_close' since it does not complete any
971 pending operations.  This routine would be used if the application had
972 just used BFD for swapping and didn't want to use any of the writing
973 code.
975    If the created file is executable, then `chmod' is called to mark it
976 as such.
978    All memory attached to the BFD is released.
980    *Returns*
981 `true' is returned if all is ok, otherwise `false'.
983 `bfd_create'
984 ............
986    *Synopsis*
987      bfd *bfd_create(const char *filename, bfd *templ);
988    *Description*
989 Create a new BFD in the manner of `bfd_openw', but without opening a
990 file. The new BFD takes the target from the target used by TEMPLATE. The
991 format is always set to `bfd_object'.
993 `bfd_make_writable'
994 ...................
996    *Synopsis*
997      boolean bfd_make_writable(bfd *abfd);
998    *Description*
999 Takes a BFD as created by `bfd_create' and converts it into one like as
1000 returned by `bfd_openw'.  It does this by converting the BFD to
1001 BFD_IN_MEMORY.  It's assumed that you will call `bfd_make_readable' on
1002 this bfd later.
1004    *Returns*
1005 `true' is returned if all is ok, otherwise `false'.
1007 `bfd_make_readable'
1008 ...................
1010    *Synopsis*
1011      boolean bfd_make_readable(bfd *abfd);
1012    *Description*
1013 Takes a BFD as created by `bfd_create' and `bfd_make_writable' and
1014 converts it into one like as returned by `bfd_openr'.  It does this by
1015 writing the contents out to the memory buffer, then reversing the
1016 direction.
1018    *Returns*
1019 `true' is returned if all is ok, otherwise `false'.
1021 `bfd_alloc'
1022 ...........
1024    *Synopsis*
1025      PTR bfd_alloc (bfd *abfd, size_t wanted);
1026    *Description*
1027 Allocate a block of WANTED bytes of memory attached to `abfd' and
1028 return a pointer to it.
1030 \x1f
1031 File: bfd.info,  Node: Internal,  Next: File Caching,  Prev: Opening and Closing,  Up: BFD front end
1033 Internal functions
1034 ==================
1036    *Description*
1037 These routines are used within BFD.  They are not intended for export,
1038 but are documented here for completeness.
1040 `bfd_write_bigendian_4byte_int'
1041 ...............................
1043    *Synopsis*
1044      boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
1045    *Description*
1046 Write a 4 byte integer I to the output BFD ABFD, in big endian order
1047 regardless of what else is going on.  This is useful in archives.
1049 `bfd_put_size'
1050 ..............
1052 `bfd_get_size'
1053 ..............
1055    *Description*
1056 These macros as used for reading and writing raw data in sections; each
1057 access (except for bytes) is vectored through the target format of the
1058 BFD and mangled accordingly. The mangling performs any necessary endian
1059 translations and removes alignment restrictions.  Note that types
1060 accepted and returned by these macros are identical so they can be
1061 swapped around in macros--for example, `libaout.h' defines `GET_WORD'
1062 to either `bfd_get_32' or `bfd_get_64'.
1064    In the put routines, VAL must be a `bfd_vma'.  If we are on a system
1065 without prototypes, the caller is responsible for making sure that is
1066 true, with a cast if necessary.  We don't cast them in the macro
1067 definitions because that would prevent `lint' or `gcc -Wall' from
1068 detecting sins such as passing a pointer.  To detect calling these with
1069 less than a `bfd_vma', use `gcc -Wconversion' on a host with 64 bit
1070 `bfd_vma''s.
1072      /* Byte swapping macros for user section data.  */
1073      
1074      #define bfd_put_8(abfd, val, ptr) \
1075                      ((void) (*((unsigned char *) (ptr)) = (unsigned char) (val)))
1076      #define bfd_put_signed_8 \
1077                     bfd_put_8
1078      #define bfd_get_8(abfd, ptr) \
1079                      (*(unsigned char *) (ptr) & 0xff)
1080      #define bfd_get_signed_8(abfd, ptr) \
1081                     (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
1082      
1083      #define bfd_put_16(abfd, val, ptr) \
1084                      BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
1085      #define bfd_put_signed_16 \
1086                      bfd_put_16
1087      #define bfd_get_16(abfd, ptr) \
1088                      BFD_SEND(abfd, bfd_getx16, (ptr))
1089      #define bfd_get_signed_16(abfd, ptr) \
1090                      BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
1091      
1092      #define bfd_put_32(abfd, val, ptr) \
1093                      BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
1094      #define bfd_put_signed_32 \
1095                      bfd_put_32
1096      #define bfd_get_32(abfd, ptr) \
1097                      BFD_SEND(abfd, bfd_getx32, (ptr))
1098      #define bfd_get_signed_32(abfd, ptr) \
1099                      BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
1100      
1101      #define bfd_put_64(abfd, val, ptr) \
1102                      BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
1103      #define bfd_put_signed_64 \
1104                      bfd_put_64
1105      #define bfd_get_64(abfd, ptr) \
1106                      BFD_SEND(abfd, bfd_getx64, (ptr))
1107      #define bfd_get_signed_64(abfd, ptr) \
1108                      BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
1109      
1110      #define bfd_get(bits, abfd, ptr)                               \
1111                      ( (bits) ==  8 ? (bfd_vma) bfd_get_8 (abfd, ptr)       \
1112                      : (bits) == 16 ? bfd_get_16 (abfd, ptr)        \
1113                      : (bits) == 32 ? bfd_get_32 (abfd, ptr)        \
1114                      : (bits) == 64 ? bfd_get_64 (abfd, ptr)        \
1115                      : (abort (), (bfd_vma) - 1))
1116      
1117      #define bfd_put(bits, abfd, val, ptr)                          \
1118                      ( (bits) ==  8 ? bfd_put_8  (abfd, val, ptr)   \
1119                      : (bits) == 16 ? bfd_put_16 (abfd, val, ptr)   \
1120                      : (bits) == 32 ? bfd_put_32 (abfd, val, ptr)   \
1121                      : (bits) == 64 ? bfd_put_64 (abfd, val, ptr)   \
1122                      : (abort (), (void) 0))
1124 `bfd_h_put_size'
1125 ................
1127    *Description*
1128 These macros have the same function as their `bfd_get_x' brethren,
1129 except that they are used for removing information for the header
1130 records of object files. Believe it or not, some object files keep
1131 their header records in big endian order and their data in little
1132 endian order.
1134      /* Byte swapping macros for file header data.  */
1135      
1136      #define bfd_h_put_8(abfd, val, ptr) \
1137        bfd_put_8 (abfd, val, ptr)
1138      #define bfd_h_put_signed_8(abfd, val, ptr) \
1139        bfd_put_8 (abfd, val, ptr)
1140      #define bfd_h_get_8(abfd, ptr) \
1141        bfd_get_8 (abfd, ptr)
1142      #define bfd_h_get_signed_8(abfd, ptr) \
1143        bfd_get_signed_8 (abfd, ptr)
1144      
1145      #define bfd_h_put_16(abfd, val, ptr) \
1146        BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
1147      #define bfd_h_put_signed_16 \
1148        bfd_h_put_16
1149      #define bfd_h_get_16(abfd, ptr) \
1150        BFD_SEND (abfd, bfd_h_getx16, (ptr))
1151      #define bfd_h_get_signed_16(abfd, ptr) \
1152        BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
1153      
1154      #define bfd_h_put_32(abfd, val, ptr) \
1155        BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
1156      #define bfd_h_put_signed_32 \
1157        bfd_h_put_32
1158      #define bfd_h_get_32(abfd, ptr) \
1159        BFD_SEND (abfd, bfd_h_getx32, (ptr))
1160      #define bfd_h_get_signed_32(abfd, ptr) \
1161        BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
1162      
1163      #define bfd_h_put_64(abfd, val, ptr) \
1164        BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
1165      #define bfd_h_put_signed_64 \
1166        bfd_h_put_64
1167      #define bfd_h_get_64(abfd, ptr) \
1168        BFD_SEND (abfd, bfd_h_getx64, (ptr))
1169      #define bfd_h_get_signed_64(abfd, ptr) \
1170        BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
1171      
1172      /* Refinements on the above, which should eventually go away.  Save
1173         cluttering the source with (bfd_vma) and (bfd_byte *) casts.  */
1174      
1175      #define H_PUT_64(abfd, val, where) \
1176        bfd_h_put_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1177      
1178      #define H_PUT_32(abfd, val, where) \
1179        bfd_h_put_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1180      
1181      #define H_PUT_16(abfd, val, where) \
1182        bfd_h_put_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1183      
1184      #define H_PUT_8 bfd_h_put_8
1185      
1186      #define H_PUT_S64(abfd, val, where) \
1187        bfd_h_put_signed_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1188      
1189      #define H_PUT_S32(abfd, val, where) \
1190        bfd_h_put_signed_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1191      
1192      #define H_PUT_S16(abfd, val, where) \
1193        bfd_h_put_signed_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1194      
1195      #define H_PUT_S8 bfd_h_put_signed_8
1196      
1197      #define H_GET_64(abfd, where) \
1198        bfd_h_get_64 ((abfd), (bfd_byte *) (where))
1199      
1200      #define H_GET_32(abfd, where) \
1201        bfd_h_get_32 ((abfd), (bfd_byte *) (where))
1202      
1203      #define H_GET_16(abfd, where) \
1204        bfd_h_get_16 ((abfd), (bfd_byte *) (where))
1205      
1206      #define H_GET_8 bfd_h_get_8
1207      
1208      #define H_GET_S64(abfd, where) \
1209        bfd_h_get_signed_64 ((abfd), (bfd_byte *) (where))
1210      
1211      #define H_GET_S32(abfd, where) \
1212        bfd_h_get_signed_32 ((abfd), (bfd_byte *) (where))
1213      
1214      #define H_GET_S16(abfd, where) \
1215        bfd_h_get_signed_16 ((abfd), (bfd_byte *) (where))
1216      
1217      #define H_GET_S8 bfd_h_get_signed_8
1219 `bfd_log2'
1220 ..........
1222    *Synopsis*
1223      unsigned int bfd_log2 (bfd_vma x);
1224    *Description*
1225 Return the log base 2 of the value supplied, rounded up.  E.g., an X of
1226 1025 returns 11.  A X of 0 returns 0.