1 This is bfd.info, produced by makeinfo version 4.1 from bfd.texinfo.
4 * Bfd: (bfd). The Binary File Descriptor library.
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".
19 File: bfd.info, Node: bfd_target, Prev: Targets, Up: Targets
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)
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))
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)
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))
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
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
90 enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
92 /* Forward declaration. */
93 typedef struct bfd_link_info _bfd_link_info;
95 typedef struct bfd_target
97 /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. */
100 /* The "flavour" of a back end is a general indication about
101 the contents of a file. */
102 enum bfd_flavour flavour;
104 /* The order of bytes within the data area of a file. */
105 enum bfd_endian byteorder;
107 /* The order of bytes within the header parts of a file. */
108 enum bfd_endian header_byteorder;
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;
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;
118 /* The character normally found at the front of a symbol.
119 (if any), perhaps `_'. */
120 char symbol_leading_char;
122 /* The pad character for file names within an archive header. */
125 /* The maximum number of characters in an archive header. */
126 unsigned short ar_max_namelen;
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 *));
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 *));
152 /* Format dependent routines: these are vectors of entry points
153 within the target vector structure, one for each format to check. */
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 *));
158 /* Set the format of a file being written. */
159 boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
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
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)
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));
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
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
205 boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
207 /* Called to copy BFD private symbol data from one symbol
209 boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
211 /* Called to set private backend flags. */
212 boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
214 /* Called to print private BFD data. */
215 boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
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 *));
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 *));
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 *,
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 *));
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 *,
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,
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. */
308 (*reloc_type_lookup) PARAMS ((bfd *, bfd_reloc_code_real_type));
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,
316 boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
317 file_ptr, bfd_size_type));
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 **));
335 boolean (*_bfd_relax_section)
336 PARAMS ((bfd *, struct sec *, struct bfd_link_info *, boolean *));
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 *));
342 /* Add symbols from this object file into the hash table. */
343 boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
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 *));
349 /* Should this section be split up into smaller pieces during linking. */
350 boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
352 /* Remove sections that are not referenced from the output. */
353 boolean (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
355 /* Attempt to merge SEC_MERGE sections. */
356 boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *));
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;
382 /* Data for use by back-end routines, which isn't
383 generic enough to belong in this structure. */
388 `bfd_set_default_target'
389 ........................
392 boolean bfd_set_default_target (const char *name);
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.
402 const bfd_target *bfd_find_target(const char *target_name, bfd *abfd);
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.
418 const char **bfd_target_list(void);
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 ......................
427 const bfd_target * bfd_search_for_target (int (* search_func) (const bfd_target *, void *), void *);
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.
435 File: bfd.info, Node: Architectures, Next: Opening and Closing, Prev: Targets, Up: BFD front end
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
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'.
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
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
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
507 bfd_arch_or32, /* OpenRISC 32 */
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
649 #define bfd_mach_fr30 0x46523330
651 bfd_arch_ia64, /* HP/Intel ia64 */
652 #define bfd_mach_ia64_elf64 0
653 #define bfd_mach_ia64_elf32 1
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. */
668 #define bfd_mach_xstormy16 0
676 This structure contains information on architectures for use within BFD.
678 typedef struct bfd_arch_info
681 int bits_per_address;
683 enum bfd_architecture arch;
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'. */
692 const struct bfd_arch_info * (*compatible)
693 PARAMS ((const struct bfd_arch_info *a,
694 const struct bfd_arch_info *b));
696 boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
698 const struct bfd_arch_info *next;
706 const char *bfd_printable_name(bfd *abfd);
708 Return a printable string representing the architecture and machine
709 from the pointer to the architecture info structure.
715 const bfd_arch_info_type *bfd_scan_arch(const char *string);
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.
725 const char **bfd_arch_list(void);
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 .........................
734 const bfd_arch_info_type *bfd_arch_get_compatible(
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 .........................
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;
757 void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg);
759 Set the architecture info of ABFD to ARG.
761 `bfd_default_set_arch_mach'
762 ...........................
765 boolean bfd_default_set_arch_mach(bfd *abfd,
766 enum bfd_architecture arch,
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
777 enum bfd_architecture bfd_get_arch(bfd *abfd);
779 Return the enumerated type which describes the BFD ABFD's architecture.
785 unsigned long bfd_get_mach(bfd *abfd);
787 Return the long type which describes the BFD ABFD's machine.
789 `bfd_arch_bits_per_byte'
790 ........................
793 unsigned int bfd_arch_bits_per_byte(bfd *abfd);
795 Return the number of bits in one of the BFD ABFD's architecture's bytes.
797 `bfd_arch_bits_per_address'
798 ...........................
801 unsigned int bfd_arch_bits_per_address(bfd *abfd);
803 Return the number of bits in one of the BFD ABFD's architecture's
806 `bfd_default_compatible'
807 ........................
810 const bfd_arch_info_type *bfd_default_compatible
811 (const bfd_arch_info_type *a,
812 const bfd_arch_info_type *b);
814 The default function for testing for compatibility.
820 boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string);
822 The default function for working out whether this is an architecture
823 hit and a machine hit.
829 const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
831 Return the architecture info struct in ABFD.
837 const bfd_arch_info_type *bfd_lookup_arch
838 (enum bfd_architecture
840 unsigned long machine);
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 .........................
850 const char *bfd_printable_arch_mach
851 (enum bfd_architecture arch, unsigned long machine);
853 Return a printable string representing the architecture and machine
856 This routine is depreciated.
858 `bfd_octets_per_byte'
859 .....................
862 unsigned int bfd_octets_per_byte(bfd *abfd);
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 ...............................
872 unsigned int bfd_arch_mach_octets_per_byte(enum bfd_architecture arch,
873 unsigned long machine);
875 See bfd_octets_per_byte.
877 This routine is provided for those cases where a bfd * is not
881 File: bfd.info, Node: Opening and Closing, Next: Internal, Prev: Architectures, Up: BFD front end
883 Opening and closing BFDs
884 ========================
890 bfd *bfd_openr(const char *filename, const char *target);
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
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'
906 bfd *bfd_fdopenr(const char *filename, const char *target, int fd);
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
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'.
929 bfd *bfd_openstreamr(const char *, const char *, PTR);
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.
938 bfd *bfd_openw(const char *filename, const char *target);
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'.
950 boolean bfd_close(bfd *abfd);
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').
962 `true' is returned if all is ok, otherwise `false'.
968 boolean bfd_close_all_done(bfd *);
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
975 If the created file is executable, then `chmod' is called to mark it
978 All memory attached to the BFD is released.
981 `true' is returned if all is ok, otherwise `false'.
987 bfd *bfd_create(const char *filename, bfd *templ);
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'.
997 boolean bfd_make_writable(bfd *abfd);
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
1005 `true' is returned if all is ok, otherwise `false'.
1011 boolean bfd_make_readable(bfd *abfd);
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
1019 `true' is returned if all is ok, otherwise `false'.
1025 PTR bfd_alloc (bfd *abfd, size_t wanted);
1027 Allocate a block of WANTED bytes of memory attached to `abfd' and
1028 return a pointer to it.
1031 File: bfd.info, Node: Internal, Next: File Caching, Prev: Opening and Closing, Up: BFD front end
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 ...............................
1044 boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
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.
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
1072 /* Byte swapping macros for user section data. */
1074 #define bfd_put_8(abfd, val, ptr) \
1075 ((void) (*((unsigned char *) (ptr)) = (unsigned char) (val)))
1076 #define bfd_put_signed_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)
1083 #define bfd_put_16(abfd, val, ptr) \
1084 BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
1085 #define bfd_put_signed_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))
1092 #define bfd_put_32(abfd, val, ptr) \
1093 BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
1094 #define bfd_put_signed_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))
1101 #define bfd_put_64(abfd, val, ptr) \
1102 BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
1103 #define bfd_put_signed_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))
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))
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))
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
1134 /* Byte swapping macros for file header data. */
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)
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 \
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))
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 \
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))
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 \
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))
1172 /* Refinements on the above, which should eventually go away. Save
1173 cluttering the source with (bfd_vma) and (bfd_byte *) casts. */
1175 #define H_PUT_64(abfd, val, where) \
1176 bfd_h_put_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1178 #define H_PUT_32(abfd, val, where) \
1179 bfd_h_put_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1181 #define H_PUT_16(abfd, val, where) \
1182 bfd_h_put_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1184 #define H_PUT_8 bfd_h_put_8
1186 #define H_PUT_S64(abfd, val, where) \
1187 bfd_h_put_signed_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1189 #define H_PUT_S32(abfd, val, where) \
1190 bfd_h_put_signed_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1192 #define H_PUT_S16(abfd, val, where) \
1193 bfd_h_put_signed_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
1195 #define H_PUT_S8 bfd_h_put_signed_8
1197 #define H_GET_64(abfd, where) \
1198 bfd_h_get_64 ((abfd), (bfd_byte *) (where))
1200 #define H_GET_32(abfd, where) \
1201 bfd_h_get_32 ((abfd), (bfd_byte *) (where))
1203 #define H_GET_16(abfd, where) \
1204 bfd_h_get_16 ((abfd), (bfd_byte *) (where))
1206 #define H_GET_8 bfd_h_get_8
1208 #define H_GET_S64(abfd, where) \
1209 bfd_h_get_signed_64 ((abfd), (bfd_byte *) (where))
1211 #define H_GET_S32(abfd, where) \
1212 bfd_h_get_signed_32 ((abfd), (bfd_byte *) (where))
1214 #define H_GET_S16(abfd, where) \
1215 bfd_h_get_signed_16 ((abfd), (bfd_byte *) (where))
1217 #define H_GET_S8 bfd_h_get_signed_8
1223 unsigned int bfd_log2 (bfd_vma x);
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.