2 /* A -*- C -*- header file for the bfd library */
5 /*** bfd.h -- The only header file required by users of the bfd library */
7 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
9 This file is part of BFD, the Binary File Diddler.
11 BFD is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 1, or (at your option)
16 BFD is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with BFD; see the file COPYING. If not, write to
23 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 /* executable_object_p is gone -- you can check the bfd flags and call
28 #ifndef __BFD_H_SEEN__
29 #define __BFD_H_SEEN__
35 /* Make it easier to declare prototypes (puts conditional here) */
38 # define PROTO(type, name, arglist) type name arglist
40 # define PROTO(type, name, arglist) type name ()
44 #define BFD_VERSION "1.10"
46 /* forward declaration */
47 typedef struct _bfd bfd;
49 /* General rules: functions which are boolean return true on success
50 and false on failure (unless they're a predicate). -- bfd.doc */
51 /* I'm sure this is going to break something and someone is going to
52 force me to change it. */
53 typedef enum boolean {false, true} boolean;
55 /* Try to avoid breaking stuff */
56 typedef long int file_ptr;
58 /* Support for different sizes of target format ints */
61 /* 64 bit machines use these items */
62 typedef uint64_type rawdata_offset;
63 typedef uint64_type bfd_vma;
64 typedef uint64_type bfd_word;
65 typedef uint64_type bfd_offset;
66 typedef uint64_type bfd_size_type;
67 typedef uint64_type symvalue;
68 #define printf_vma(x) printf("%08x%08x",uint64_typeHIGH(x), uint64_typeLOW(x))
69 #define fprintf_vma(s,x) fprintf(s,"%08x%08x",uint64_typeHIGH(x), uint64_typeLOW(x))
71 typedef unsigned long int rawdata_offset;
72 typedef unsigned long bfd_vma;
73 typedef unsigned long bfd_offset;
74 typedef unsigned long bfd_word;
75 typedef unsigned long bfd_size;
76 typedef unsigned long symvalue;
77 typedef unsigned long bfd_size_type;
78 #define printf_vma(x) printf("%08x",x)
79 #define fprintf_vma(s,x) fprintf(s,"%08x",x)
82 typedef unsigned int flagword; /* 32 bits of flags */
86 typedef enum bfd_format {
87 bfd_unknown = 0, /* file format is unknown */
88 bfd_object, /* linker/assember/compiler output */
89 bfd_archive, /* object archive file */
90 bfd_core, /* core dump */
91 bfd_type_end} /* marks the end; don't use it! */
94 /* Object file flag values */
98 #define HAS_LINENO 004
101 #define HAS_LOCALS 040
106 /* This enum gives the object file's CPU architecture, in a global sense.
107 E.g. what processor family does it belong to? There is another field,
108 which indicates what processor within the family is in use. */
109 enum bfd_architecture {
110 bfd_arch_unknown, /* File arch not known */
111 bfd_arch_obscure, /* File arch known, not one of these */
112 bfd_arch_m68k, /* Motorola 68xxx */
113 bfd_arch_vax, /* DEC Vax */
114 bfd_arch_i960, /* Intel 960 */
116 /* The order of the following is important.
117 * A lower number indicates a machine type
118 * that only accepts a subset of the
119 * instructions available to machines with
122 * The exception is the "ca", which is
123 * incompatible with all other machines except
126 #define bfd_mach_i960_core 1
127 #define bfd_mach_i960_ka_sa 2
128 #define bfd_mach_i960_kb_sb 3
129 #define bfd_mach_i960_mc 4
130 #define bfd_mach_i960_xa 5
131 #define bfd_mach_i960_ca 6
134 bfd_arch_a29k, /* AMD 29000 */
135 bfd_arch_sparc, /* Sun (SPARC International) SPARC */
136 bfd_arch_mips, /* MIPS Rxxxx */
137 bfd_arch_i386, /* Intel 386 */
138 bfd_arch_ns32k, /* National Semiconductor 32xxx */
139 bfd_arch_tahoe, /* CCI/Harris Tahoe */
140 bfd_arch_i860, /* Intel 860 */
141 bfd_arch_romp, /* IBM ROMP RS/6000 */
142 bfd_arch_alliant, /* Alliant */
143 bfd_arch_convex, /* Convex */
144 bfd_arch_m88k, /* Motorola 88xxx */
145 bfd_arch_pyramid, /* Pyramid Technology */
146 bfd_arch_h8_300, /* Hitachi H8/300 */
150 /* symbols and relocation */
152 typedef unsigned long symindex;
154 #define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
156 typedef enum {bfd_symclass_unknown = 0,
157 bfd_symclass_fcommon, /* fortran common symbols */
158 bfd_symclass_global, /* global symbol, what a surprise */
159 bfd_symclass_debugger, /* some debugger symbol */
160 bfd_symclass_undefined /* none known */
164 typedef int symtype; /* Who knows, yet? */
166 /* Symbol cache classifications: (Bfd-Symbol-Flag_FOOBAR) */
167 #define BSF_NO_FLAGS 0x00
168 #define BSF_LOCAL 0x01 /* bfd_symclass_unknown */
169 #define BSF_GLOBAL 0x02 /* bfd_symclass_global */
170 #define BSF_IMPORT 0x04
171 #define BSF_EXPORT 0x08
172 #define BSF_UNDEFINED 0x10 /* bfd_symclass_undefined */
173 #define BSF_FORT_COMM 0x20 /* bfd_symclass_fcommon */
174 #define BSF_DEBUGGING 0x40 /* bfd_symclass_debugger */
175 #define BSF_ABSOLUTE 0x80
176 #define BSF_KEEP 0x10000
177 #define BSF_WARNING 0x20000
178 #define BSF_KEEP_G 0x80000
179 #define BSF_WEAK 0x100000
180 #define BSF_CTOR 0x200000 /* Symbol is a con/destructor */
181 #define BSF_FAKE 0x400000 /* SYmbol doesn't really exist */
182 #define BSF_OLD_COMMON 0x800000 /* Symbol used to be common,
183 but now is allocated */
184 /* If symbol is fort_comm, then value is size, and this is the */
186 #define BFD_FORT_COMM_DEFAULT_VALUE 0
188 /* in some files the type of a symbol sometimes alters its location
189 * in an output file - ie in coff a ISFCN symbol which is also C_EXT
190 * symbol appears where it was declared and not at the end of a section.
191 * This bit is set by the target bfd part to convey this information.
193 #define BSF_NOT_AT_END 0x40000
196 /* general purpose part of a symbol
197 * target specific parts will be found in libcoff.h, liba.out.h etc
199 typedef struct symbol_cache_entry
201 struct _bfd *the_bfd; /* Just a way to find out host type */
206 PTR udata; /* Target-specific stuff */
209 #define bfd_get_section(x) ((x)->section)
210 #define bfd_get_output_section(x) ((x)->section->output_section)
211 #define bfd_set_section(x,y) ((x)->section) = (y)
212 #define bfd_asymbol_base(x) ((x)->section?((x)->section->vma):0)
213 #define bfd_asymbol_value(x) (bfd_asymbol_base(x) + x->value)
214 #define bfd_asymbol_name(x) ((x)->name)
217 /* This is a type pun with struct ranlib on purpose! */
218 typedef struct carsym {
220 file_ptr file_offset; /* look here to find the file */
221 } carsym; /* to make these you call a carsymogen */
223 /* Relocation stuff */
225 /* Either: sym will point to a symbol and isextern will be 0, *OR*
226 sym will be NULL and isextern will be a symbol type (eg N_TEXT)
227 which means the location should be relocated relative to the
228 segment origin. This is because we won't necessarily have a symbol
229 which is guaranteed to point to the segment origin. */
231 typedef enum bfd_reloc_status {
234 bfd_reloc_outofrange,
236 bfd_reloc_notsupported,
240 bfd_reloc_status_enum_type;
242 typedef CONST struct rint
245 unsigned int rightshift;
247 unsigned int bitsize;
252 boolean complain_on_overflow;
253 bfd_reloc_status_enum_type (*special_function)();
255 boolean partial_inplace;
257 the src_mask is used to select what parts of the read in data are to
258 be used in the relocation sum. Eg, if this was an 8 bit bit of data
259 which we read and relocated, this would be 0x000000ff. When we have
260 relocs which have an addend, such as sun4 extended relocs, the value
261 in the offset part of a relocating field is garbage so we never use
262 it. In this case the mask would be 0x00000000.
264 The dst_mask is what parts of the instruction are replaced into the
265 instruction. In most cases src_mask == dst_mask, except in the above
266 special case, where dst_mask would be 0x000000ff, and src_mask would
269 bfd_word src_mask; /* What things to take from the source */
270 bfd_word dst_mask; /* What things to put into the dest */
272 /* Does a pc rel offset already have the offset of the jump from the
273 beginnining of the module in place - eg on the sun3, a pcrel
274 instruction always has a negative number in place, containing the
275 displacement from the beginning of the module. 88k bcs has a zero
276 in there, so you have to work out the offset yourself. */
277 boolean pcrel_offset;
280 #define HOWTO(CODE, RT,SIZE,BITSIZE, PCREL, BITPOS, ABS, OVERFLOW, SF, NAME, INPLACE, MASKSRC, MASKDST, PCRELDONE) \
281 {(unsigned)CODE,RT,SIZE,BITSIZE, PCREL, BITPOS,ABS,OVERFLOW,SF,NAME,INPLACE,MASKSRC,MASKDST,PCRELDONE}
283 typedef unsigned char bfd_byte;
285 typedef struct reloc_cache_entry
287 /* A pointer into the canonicalized table for the symbol */
288 asymbol **sym_ptr_ptr;
290 rawdata_offset address; /* offset in section */
291 bfd_vma addend; /* addend for relocation value */
292 struct sec *section; /* if sym is null this is the section */
293 reloc_howto_type *howto;
297 typedef struct relent_chain {
299 struct relent_chain *next;
302 /* Used in generating armaps. Perhaps just a forward definition would do? */
303 struct orl { /* output ranlib */
304 char **name; /* symbol name */
305 file_ptr pos; /* element number or file position */
306 int namidx; /* index into string table */
311 /* Linenumber stuff */
312 typedef struct lineno_cache_entry {
313 unsigned int line_number; /* Linenumber from start of function*/
315 asymbol *sym; /* Function name */
316 unsigned long offset; /* Offset into section */
320 /* object and core file sections */
322 /* Section flag definitions */
323 #define SEC_NO_FLAGS 000
324 #define SEC_ALLOC 001
326 #define SEC_RELOC 004
327 #define SEC_BALIGN 010
328 #define SEC_READONLY 020
330 #define SEC_DATA 0100
332 #define SEC_CONSTRUCTOR 0400
333 #define SEC_HAS_CONTENTS (0x200)
344 /* The output_offset is the indent into the output section of
345 this section. If this is the first section to go into
346 an output section, this value will be 0...
348 bfd_vma output_offset;
349 struct sec *output_section;
350 unsigned int alignment_power; /* eg 4 aligns to 2^4*/
352 arelent *relocation; /* for input files */
353 arelent **orelocation; /* for output files */
355 unsigned reloc_count;
356 file_ptr filepos; /* File position of section data */
357 file_ptr rel_filepos; /* File position of relocation info */
358 file_ptr line_filepos;
359 struct user_section *userdata;
360 struct lang_output_section *otheruserdata;
361 int index; /* Which section is it 0..nth */
363 unsigned int lineno_count;
365 /* When a section is being output, this value changes as more
366 linenumbers are written out */
367 file_ptr moving_line_filepos;
369 /* what the section number is in the target world */
370 unsigned int target_index;
374 /* If this is a constructor section then here is a list of relents */
375 arelent_chain *constructor_chain;
378 #define align_power(addr, align) \
379 ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
383 typedef struct sec *sec_ptr;
385 #define bfd_section_name(bfd, ptr) ((ptr)->name)
386 #define bfd_section_size(bfd, ptr) ((ptr)->size)
387 #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
388 #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
389 #define bfd_get_section_flags(bfd, ptr) ((ptr)->flags)
390 #define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
392 #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (val)), true)
393 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
394 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
396 typedef struct stat stat_type;
398 /** Error handling */
400 typedef enum {no_error = 0, system_call_error, invalid_target,
401 wrong_format, invalid_operation, no_memory,
402 no_symbols, no_relocation_info,
403 no_more_archived_files, malformed_archive,
404 symbol_not_found, file_not_recognized,
405 file_ambiguously_recognized, no_contents,
406 bfd_error_nonrepresentable_section,
407 invalid_error_code} bfd_ec;
409 extern bfd_ec bfd_error;
411 typedef struct bfd_error_vector {
412 PROTO(void,(* nonrepresentable_section ),(CONST bfd *CONST abfd,
413 CONST char *CONST name));
414 } bfd_error_vector_type;
416 PROTO (char *, bfd_errmsg, ());
417 PROTO (void, bfd_perror, (CONST char *message));
422 bfd_print_symbol_name_enum,
423 bfd_print_symbol_type_enum,
424 bfd_print_symbol_all_enum
425 } bfd_print_symbol_enum_type;
428 /* The BFD target structure.
430 This structure is how to find out everything BFD knows about a target.
431 It includes things like its byte order, name, what routines to call
432 to do various operations, etc.
434 Every BFD points to a target structure with its "xvec" member. */
436 /* Shortcut for declaring fields which are prototyped function pointers,
437 while avoiding anguish on compilers that don't support protos. */
439 #define SDEF(ret, name, arglist) PROTO(ret,(*name),arglist)
440 #define SDEF_FMT(ret, name, arglist) PROTO(ret,(*name[bfd_type_end]),arglist)
442 /* These macros are used to dispatch to functions through the bfd_target
443 vector. They are used in a number of macros further down in bfd.h,
444 and are also used when calling various routines by hand inside the
445 bfd implementation. The "arglist" argument must be parenthesized;
446 it contains all the arguments to the called function. */
448 #define BFD_SEND(bfd, message, arglist) ((*((bfd)->xvec->message)) arglist)
449 /* For operations which index on the bfd format */
450 #define BFD_SEND_FMT(bfd, message, arglist) \
451 (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
453 /* This is the struct which defines the type of BFD this is. The
454 "xvec" member of the struct bfd itself points here. Each module
455 that implements access to a different target under BFD, defines
458 /* FIXME, these names should be rationalised with the names of the entry points
459 which call them. Too bad we can't have one macro to define them both! */
460 typedef struct bfd_target
462 /* identifies the kind of target, eg SunOS4, Ultrix, etc */
465 /* This is bogus. Anything that can be told from the "flavour"
466 by some user program should be an independent attribute that can
467 be queried instead. FIXME. -- gnu@cygnus.com */
468 enum target_flavour_enum {
469 bfd_target_aout_flavour_enum,
470 bfd_target_coff_flavour_enum,
471 bfd_target_ieee_flavour_enum,
472 bfd_target_oasys_flavour_enum,
473 bfd_target_srec_flavour_enum} flavour;
475 boolean byteorder_big_p; /* Order of bytes in data sections */
476 boolean header_byteorder_big_p; /* Order of bytes in header */
478 flagword object_flags; /* these are the ones that may be set */
479 flagword section_flags; /* ditto */
481 char ar_pad_char; /* filenames in archives padded w/this char */
482 unsigned short ar_max_namelen; /* this could be a char too! */
484 /* Byte swapping for data */
485 /* Note that these don't take bfd as first arg. Certain other handlers
486 could do the same. */
487 SDEF (uint64_type,bfd_getx64, (bfd_byte *));
488 SDEF (void, bfd_putx64, (uint64_type, bfd_byte *));
489 SDEF (uint32_type, bfd_getx32, (bfd_byte *));
490 SDEF (void, bfd_putx32, (unsigned long, bfd_byte *));
491 SDEF (uint16_type, bfd_getx16, (bfd_byte *));
492 SDEF (void, bfd_putx16, (int, bfd_byte *));
494 /* Byte swapping for headers */
495 SDEF (uint64_type, bfd_h_getx64, (bfd_byte *));
496 SDEF (void, bfd_h_putx64, (uint64_type, bfd_byte *));
497 SDEF (uint32_type, bfd_h_getx32, (bfd_byte *));
498 SDEF (void, bfd_h_putx32, (unsigned long, bfd_byte *));
499 SDEF (uint16_type, bfd_h_getx16, (bfd_byte *));
500 SDEF (void, bfd_h_putx16, (int, bfd_byte *));
502 /* Format-dependent */
503 SDEF_FMT (struct bfd_target *, _bfd_check_format, (bfd *));/* file fmt or 0 */
504 SDEF_FMT (boolean, _bfd_set_format, (bfd *)); /* make it an object file */
505 SDEF_FMT (boolean, _bfd_write_contents, (bfd *)); /* write it out at close */
507 /* All these are defined in JUMP_TABLE */
509 SDEF (char *, _core_file_failing_command, (bfd *));
510 SDEF (int, _core_file_failing_signal, (bfd *));
511 SDEF (boolean, _core_file_matches_executable_p, (bfd *, bfd *));
514 SDEF (boolean, _bfd_slurp_armap, (bfd *));
515 SDEF (boolean, _bfd_slurp_extended_name_table, (bfd *));
516 SDEF (void, _bfd_truncate_arname, (bfd *, CONST char *, char *));
517 SDEF (boolean, write_armap, (bfd *arch, unsigned int elength,
518 struct orl *map, int orl_count, int
521 /* All the standard stuff */
522 SDEF (boolean, _close_and_cleanup, (bfd *)); /* free any allocated data */
523 SDEF (boolean, _bfd_set_section_contents, (bfd *, sec_ptr, PTR,
524 file_ptr, bfd_size_type));
525 SDEF (boolean, _bfd_get_section_contents, (bfd *, sec_ptr, PTR,
526 file_ptr, bfd_size_type));
527 SDEF (boolean, _new_section_hook, (bfd *, sec_ptr));
529 /* Symbols and relocation */
530 SDEF (unsigned int, _get_symtab_upper_bound, (bfd *));
531 SDEF (unsigned int, _bfd_canonicalize_symtab, (bfd *, asymbol **));
532 SDEF (unsigned int, _get_reloc_upper_bound, (bfd *, sec_ptr));
533 SDEF (unsigned int, _bfd_canonicalize_reloc, (bfd *, sec_ptr, arelent **,
537 SDEF (asymbol *, _bfd_make_empty_symbol, (bfd *));
538 SDEF (void, _bfd_print_symbol, (bfd *, PTR, asymbol *,
539 bfd_print_symbol_enum_type));
540 SDEF (alent *, _get_lineno, (bfd *, asymbol *));
542 SDEF (boolean, _bfd_set_arch_mach, (bfd *, enum bfd_architecture,
545 SDEF (bfd *, openr_next_archived_file, (bfd *arch, bfd *prev));
546 SDEF (boolean, _bfd_find_nearest_line,
547 (bfd *abfd, asection *section, asymbol **symbols,bfd_vma offset,
548 CONST char **file, CONST char **func, unsigned int *line));
549 SDEF (int, _bfd_stat_arch_elt, (bfd *, struct stat *));
550 SDEF (int, _bfd_sizeof_headers, (bfd *, boolean));
553 /* The code that implements targets can initialize a jump table with this
554 macro. It must name all its routines the same way (a prefix plus
555 the standard routine suffix), or it must #define the routines that
556 are not so named, before calling JUMP_TABLE in the initializer. */
558 /* Semi-portable string concatenation in cpp */
561 #define CAT(a,b) a##b
563 #define CAT(a,b) a/**/b
567 #define JUMP_TABLE(NAME)\
568 CAT(NAME,_core_file_failing_command),\
569 CAT(NAME,_core_file_failing_signal),\
570 CAT(NAME,_core_file_matches_executable_p),\
571 CAT(NAME,_slurp_armap),\
572 CAT(NAME,_slurp_extended_name_table),\
573 CAT(NAME,_truncate_arname),\
574 CAT(NAME,_write_armap),\
575 CAT(NAME,_close_and_cleanup), \
576 CAT(NAME,_set_section_contents),\
577 CAT(NAME,_get_section_contents),\
578 CAT(NAME,_new_section_hook),\
579 CAT(NAME,_get_symtab_upper_bound),\
580 CAT(NAME,_get_symtab),\
581 CAT(NAME,_get_reloc_upper_bound),\
582 CAT(NAME,_canonicalize_reloc),\
583 CAT(NAME,_make_empty_symbol),\
584 CAT(NAME,_print_symbol),\
585 CAT(NAME,_get_lineno),\
586 CAT(NAME,_set_arch_mach),\
587 CAT(NAME,_openr_next_archived_file),\
588 CAT(NAME,_find_nearest_line),\
589 CAT(NAME,_generic_stat_arch_elt),\
590 CAT(NAME,_sizeof_headers)
592 /* User program access to BFD facilities */
594 extern CONST short _bfd_host_big_endian;
595 #define HOST_BYTE_ORDER_BIG_P (*(char *)&_bfd_host_big_endian)
599 /* Cast from const char * to char * so that caller can assign to
600 a char * without a warning. */
601 #define bfd_get_filename(abfd) ((char *) (abfd)->filename)
602 #define bfd_get_format(abfd) ((abfd)->format)
603 #define bfd_get_target(abfd) ((abfd)->xvec->name)
604 #define bfd_get_file_flags(abfd) ((abfd)->flags)
605 #define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
606 #define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
607 #define bfd_my_archive(abfd) ((abfd)->my_archive);
608 #define bfd_has_map(abfd) ((abfd)->has_armap)
609 #define bfd_header_twiddle_required(abfd) \
610 ((((abfd)->xvec->header_byteorder_big_p) \
611 != (boolean)HOST_BYTE_ORDER_BIG_P) ? true:false)
613 #define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
614 #define bfd_usrdata(abfd) ((abfd)->usrdata)
616 #define bfd_get_start_address(abfd) ((abfd)->start_address)
617 #define bfd_get_symcount(abfd) ((abfd)->symcount)
618 #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
619 #define bfd_count_sections(abfd) ((abfd)->section_count)
620 #define bfd_get_architecture(abfd) ((abfd)->obj_arch)
621 #define bfd_get_machine(abfd) ((abfd)->obj_machine)
623 /* Finally! The BFD struct itself. This contains the major data about
624 the file, and contains pointers to the rest of the data.
626 To avoid dragging too many header files into every file that
627 includes bfd.h, IOSTREAM has been declared as a "char *", and MTIME
628 as a "long". Their correct types, to which they are cast when used,
629 are "FILE *" and "time_t". If these had been declared as structs
630 rather than typedefs, we wouldn't have this problem. */
635 CONST char *filename; /* could be null; filename user opened with */
636 bfd_target *xvec; /* operation jump table */
637 char *iostream; /* stdio FILE *, unless an archive element */
639 boolean cacheable; /* iostream can be closed if desired */
640 struct _bfd *lru_prev; /* Used for file caching */
641 struct _bfd *lru_next; /* Used for file caching */
642 file_ptr where; /* Where the file was when closed */
644 boolean mtime_set; /* Flag indicating mtime is available */
645 long mtime; /* File modified time */
646 int ifd; /* for output files, channel we locked. */
648 enum bfd_direction {no_direction = 0,
651 both_direction = 3} direction;
653 flagword flags; /* format_specific */
655 Currently my_archive is tested before adding origin to anything. I
656 believe that this can become always an add of origin, with origin set
657 to 0 for non archive files
660 file_ptr origin; /* for archive contents */
661 boolean output_has_begun; /* cf bfd_set_section_size */
662 asection *sections; /* Pointer to linked list of sections */
663 unsigned int section_count; /* The number of sections */
665 /* Some object file stuff */
666 bfd_vma start_address; /* for object files only, of course */
667 unsigned int symcount; /* used for input and output */
668 asymbol **outsymbols; /* symtab for output bfd */
669 enum bfd_architecture obj_arch; /* Architecture of object machine, eg m68k */
670 unsigned long obj_machine; /* Particular machine within arch, e.g. 68010 */
672 /* Archive stuff. strictly speaking we don't need all three bfd* vars,
673 but doing so would allow recursive archives! */
674 PTR arelt_data; /* needed if this came from an archive */
675 struct _bfd *my_archive; /* if this is an archive element */
676 struct _bfd *next; /* output chain pointer */
677 struct _bfd *archive_head; /* for output archive */
678 boolean has_armap; /* if an arch; has it an armap? */
680 PTR tdata; /* target-specific storage */
681 PTR usrdata; /* application-specific storage */
683 /* Should probably be enabled here always, so that library may be changed
684 to switch this on and off, while user code may remain unchanged */
687 char *actual_name; /* for output files, name given to open() */
690 /* Where all the allocated stuff under this BFD goes */
691 struct obstack memory;
694 /* The various callable routines */
695 PROTO(bfd_size_type, bfd_alloc_size,(bfd *abfd));
696 PROTO (char *, bfd_printable_arch_mach,(enum bfd_architecture, unsigned long));
697 PROTO (char *, bfd_format_string, (bfd_format format));
699 PROTO (char**, bfd_target_list, ());
700 PROTO (bfd *, bfd_openr, (CONST char *filename, CONST char *target));
701 PROTO (bfd *, bfd_fdopenr, (CONST char *filename, CONST char *target, int fd));
702 PROTO (bfd *, bfd_openw, (CONST char *filename, CONST char *target));
703 PROTO (bfd *, bfd_create, (CONST char *filename, CONST bfd *abfd));
704 PROTO (boolean, bfd_close, (bfd *abfd));
705 PROTO (long, bfd_get_mtime, (bfd *abfd));
706 PROTO (bfd *, bfd_openr_next_archived_file, (bfd *obfd, bfd *last_file));
707 PROTO (boolean, bfd_set_archive_head, (bfd *output_archive, bfd *new_head));
708 PROTO (boolean, bfd_check_format, (bfd *abfd, bfd_format format));
709 PROTO (boolean, bfd_set_format, (bfd *abfd, bfd_format format));
710 PROTO (char *, bfd_core_file_failing_command, (bfd *abfd));
711 PROTO (int, bfd_core_file_failing_signal, (bfd *abfd));
712 PROTO (boolean, core_file_matches_executable_p, (bfd *core_bfd, bfd *exec_bfd));
713 PROTO (sec_ptr, bfd_get_section_by_name, (bfd *abfd, CONST char *name));
714 PROTO (void, bfd_map_over_sections, (bfd *abfd, void (*operation)(),
716 PROTO (sec_ptr, bfd_make_section, (bfd *abfd, CONST char *CONST name));
717 PROTO (boolean, bfd_set_section_flags, (bfd *abfd, sec_ptr section,
719 PROTO (boolean, bfd_set_file_flags, (bfd *abfd, flagword flags));
720 PROTO (boolean, bfd_arch_compatible, (bfd *abfd, bfd *bbfd,
721 enum bfd_architecture *res_arch,
722 unsigned long *res_machine));
724 PROTO (boolean, bfd_set_section_size, (bfd *abfd, sec_ptr ptr,
726 PROTO (boolean, bfd_get_section_contents, (bfd *abfd, sec_ptr section,
728 file_ptr offset, bfd_size_type count));
729 PROTO (boolean, bfd_set_section_contents, (bfd *abfd, sec_ptr section,
731 file_ptr offset, bfd_size_type count));
733 PROTO (unsigned long, bfd_get_next_mapent, (bfd *abfd, symindex prev, carsym **entry));
734 PROTO (bfd *, bfd_get_elt_at_index, (bfd *abfd, int index));
735 PROTO (boolean, bfd_set_symtab, (bfd *abfd, asymbol **location,
736 unsigned int symcount));
737 PROTO (unsigned int, get_reloc_upper_bound, (bfd *abfd, sec_ptr asect));
738 PROTO (unsigned int, bfd_canonicalize_reloc, (bfd *abfd, sec_ptr asect,
741 PROTO (void, bfd_set_reloc, (bfd *abfd, sec_ptr asect, arelent **location,
742 unsigned int count));
743 PROTO (boolean, bfd_set_start_address, (bfd *,bfd_vma));
745 PROTO (void, bfd_print_symbol_vandf, (PTR, asymbol *));
746 PROTO (bfd_reloc_status_enum_type, bfd_perform_relocation,
747 (bfd *, arelent*, PTR, asection *, bfd*));
749 PROTO (bfd_vma, bfd_log2, (bfd_vma));
750 #define bfd_symbol_same_target(abfd, symbol) \
751 ( ( ((symbol)->the_bfd->xvec) == (abfd)->xvec) ? true:false)
753 PROTO(boolean, bfd_scan_arch_mach,(CONST char *, enum bfd_architecture *,
756 /* For speed we turn calls to these interface routines directly into
757 jumps through the transfer vector. This makes error-checking somewhat
758 confusing; the user basically has to read the documentation since there
759 are no longer prototypes, only declarations in the xfer vector (which
760 should be enough for some compilers).
762 To bad the preprocessor is too dumb to allow us to clean this up with
765 #define bfd_set_arch_mach(abfd, arch, mach) \
766 BFD_SEND (abfd, _bfd_set_arch_mach, (abfd, arch, mach))
768 #define bfd_sizeof_headers(abfd, reloc) \
769 BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
771 #define bfd_symbol_value(abfd, idx) \
772 BFD_SEND (abfd, _bfd_symbol_value, (abfd, idx))
774 #define bfd_symbol_name(abfd, idx) \
775 BFD_SEND (abfd, _bfd_symbol_name, (abfd, idx))
778 #define bfd_get_first_symbol(abfd) \
779 BFD_SEND (abfd, _bfd_get_first_symbol, (abfd))
781 #define bfd_get_next_symbol(abfd, oidx) \
782 BFD_SEND (abfd, _bfd_get_next_symbol, (abfd, oidx))
784 #define bfd_classify_symbol(abfd, idx) \
785 BFD_SEND (abfd, _bfd_classify_symbol, (abfd, idx))
787 #define bfd_symbol_hasclass(abfd, idx, class) \
788 BFD_SEND (abfd, _bfd_symbol_hasclass, (abfd, idx, class))
790 #define get_symtab_upper_bound(abfd) \
791 BFD_SEND (abfd, _get_symtab_upper_bound, (abfd))
793 #define bfd_canonicalize_symtab(abfd, location) \
794 BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location))
797 #define bfd_make_empty_symbol(abfd) \
798 BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
800 #define bfd_print_symbol(abfd, file, symbol, how) \
801 BFD_SEND (abfd, _bfd_print_symbol, (abfd, file, symbol, how))
803 #define bfd_get_lineno(abfd, symbol) \
804 BFD_SEND (abfd, _get_lineno, (abfd, symbol))
806 #define bfd_stat_arch_elt(abfd, buf) \
807 BFD_SEND(abfd, _bfd_stat_arch_elt, (abfd, buf))
809 #define bfd_find_nearest_line(abfd, section, symbols, offset,filename_ptr, func, line_ptr) \
810 BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, section,symbols, offset, filename_ptr, func, line_ptr))
813 /* Some byte-swapping i/o operations */
814 #define LONGLONG_SIZE 8
818 #define bfd_put_8(abfd, val, ptr) (*((char *)ptr) = (char)val)
819 #define bfd_get_8(abfd, ptr) (*((char *)ptr))
821 #define bfd_put_32(abfd, val, ptr) BFD_SEND(abfd, bfd_putx32, (val,ptr))
822 #define bfd_get_32(abfd, ptr) BFD_SEND(abfd, bfd_getx32, (ptr))
824 #define bfd_put_64(abfd, val, ptr) BFD_SEND(abfd, bfd_putx64, (val,ptr))
825 #define bfd_get_64(abfd, ptr) BFD_SEND(abfd, bfd_getx64, (ptr))
827 #define bfd_put_16(abfd, val, ptr) BFD_SEND(abfd, bfd_putx16, (val,ptr))
828 #define bfd_get_16(abfd, ptr) BFD_SEND(abfd, bfd_getx16, (ptr))
830 #define bfd_h_put_8(abfd, val, ptr) bfd_put_8 (abfd, val, ptr)
831 #define bfd_h_get_8(abfd, ptr) bfd_get_8 (abfd, ptr)
833 #define bfd_h_put_32(abfd, val, ptr) BFD_SEND(abfd, bfd_h_putx32, (val, (bfd_byte *) ptr))
834 #define bfd_h_get_32(abfd, ptr) BFD_SEND(abfd, bfd_h_getx32, ((bfd_byte *) ptr))
836 #define bfd_h_put_64(abfd, val, ptr) BFD_SEND(abfd, bfd_h_putx64, (val, (bfd_byte *) ptr))
837 #define bfd_h_get_64(abfd, ptr) BFD_SEND(abfd, bfd_h_getx64, ((bfd_byte *) ptr))
839 #define bfd_h_put_16(abfd, val, ptr) BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
840 #define bfd_h_get_16(abfd, ptr) BFD_SEND(abfd, bfd_h_getx16,(ptr))
842 /* General purpose one fits all. The do { } while (0) makes a single
843 statement out of it, for use in things like nested if-statements.
845 The idea is to create your external ref as a byte array of the
849 then you may do things like:
850 bfd_h_put_x(abfd, 1, &foo);
851 and bfd_h_get_x(abfd,& bar);
854 #define bfd_h_put_x(abfd, val, ptr) \
856 if (sizeof((ptr)) == LONGLONG_SIZE) \
857 bfd_h_put_64 (abfd, val, (ptr));\
858 if (sizeof((ptr)) == LONG_SIZE) \
859 bfd_h_put_32 (abfd, val, (ptr));\
860 else if (sizeof((ptr)) == SHORT_SIZE) \
861 bfd_h_put_16 (abfd, val, (ptr));\
862 else if (sizeof((ptr)) == BYTE_SIZE) \
863 bfd_h_put_8 (abfd, val, (ptr));\
864 else abort(); } while (0)
866 #define bfd_h_get_x(abfd, ptr) \
867 ((sizeof((ptr))==LONGLONG_SIZE) ? bfd_h_get_64 (abfd, &(ptr[0])):\
868 (sizeof((ptr))==LONG_SIZE) ? bfd_h_get_32 (abfd, &(ptr[0])):\
869 (sizeof((ptr))==SHORT_SIZE) ? bfd_h_get_16(abfd, &(ptr[0])):\
870 bfd_h_get_8 (abfd, &(ptr[0])))
873 #define BFD_COFF_FORMAT bfd_target_coff_flavour_enum
874 #define BFD_BOUT_FORMAT bfd_target_aout_flavour_enum
877 * Return nonzero iff specified bfd is for big-endian target
879 #define BFD_BIG_ENDIAN_FILE_P(abfd) \
880 ((abfd)->xvec->header_byteorder_big_p == true)
883 * Return nonzero iff specified bfd is for coff target
885 #define BFD_COFF_FILE_P(abfd) ((abfd)->xvec->flavour == BFD_COFF_FORMAT)
888 * The names of the only targets the GNU/960 release cares about
890 #define BFD_BIG_COFF_TARG "coff-Intel-big"
891 #define BFD_LITTLE_COFF_TARG "coff-Intel-little"
892 #define BFD_BIG_BOUT_TARG "b.out.big"
893 #define BFD_LITTLE_BOUT_TARG "b.out.little"
895 extern PROTO (char *, bfd_make_targ_name,( enum target_flavour_enum format, int bigendian));
901 #endif /* __BFD_H_SEEN__ */