Support for the alpha
[platform/upstream/binutils.git] / include / bfd.h
1 /* Main header file for the bfd library -- portable access to object files.
2    ==> The bfd.h file is generated from bfd-in.h and various .c files; if you
3    ==> change it, your changes will probably be lost.
4    Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
5    Contributed by Cygnus Support.
6
7 This file is part of BFD, the Binary File Descriptor library.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
22
23 /* bfd.h -- The only header file required by users of the bfd library 
24
25 The bfd.h file is generated from bfd-in.h and various .c files; if you
26 change it, your changes will probably be lost.
27
28 All the prototypes and definitions following the comment "THE FOLLOWING
29 IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
30 BFD.  If you change it, someone oneday will extract it from the source
31 again, and your changes will be lost.  To save yourself from this bind,
32 change the definitions in the source in the bfd directory.  Type "make
33 docs" and then "make headers" in that directory, and magically this file
34 will change to reflect your changes.
35
36 If you don't have the tools to perform the extraction, then you are
37 safe from someone on your system trampling over your header files.
38 You should still maintain the equivalence between the source and this
39 file though; every change you make to the .c file should be reflected
40 here.  */
41
42 #ifndef __BFD_H_SEEN__
43 #define __BFD_H_SEEN__
44
45 #include "ansidecl.h"
46 #include "obstack.h"
47
48 #define BFD_VERSION "2.1"
49
50 /* forward declaration */
51 typedef struct _bfd bfd;
52
53 /* To squelch erroneous compiler warnings ("illegal pointer
54    combination") from the SVR3 compiler, we would like to typedef
55    boolean to int (it doesn't like functions which return boolean.
56    Making sure they are never implicitly declared to return int
57    doesn't seem to help).  But this file is not configured based on
58    the host.  */
59 /* General rules: functions which are boolean return true on success
60    and false on failure (unless they're a predicate).   -- bfd.doc */
61 /* I'm sure this is going to break something and someone is going to
62    force me to change it. */
63 /* typedef enum boolean {false, true} boolean; */
64 /* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h>  -fnf */
65 typedef enum bfd_boolean {false, true} boolean;
66
67 /* A pointer to a position in a file.  */
68 /* FIXME:  This should be using off_t from <sys/types.h>.
69    For now, try to avoid breaking stuff by not including <sys/types.h> here.
70    This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
71    Probably the best long-term answer is to avoid using file_ptr AND off_t 
72    in this header file, and to handle this in the BFD implementation
73    rather than in its interface.  */
74 /* typedef off_t        file_ptr; */
75 typedef long int file_ptr;
76
77 /* Support for different sizes of target format ints and addresses.
78    If the host implements--and wants BFD to use--64-bit values, it
79    defines HOST_64_BIT (in BFD and in every program that calls it --
80    since this affects declarations in bfd.h).  */
81
82 #ifdef  HOST_64_BIT
83 typedef unsigned HOST_64_BIT bfd_vma;
84 typedef HOST_64_BIT bfd_signed_vma;
85 typedef unsigned HOST_64_BIT bfd_size_type;
86 typedef unsigned HOST_64_BIT symvalue;
87 #define fprintf_vma(s,x) \
88                 fprintf(s,"%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x))
89 #else /* not HOST_64_BIT.  */
90
91 /* Represent a target address.  Also used as a generic unsigned type
92    which is guaranteed to be big enough to hold any arithmetic types
93    we need to deal with.  */
94 typedef unsigned long bfd_vma;
95
96 /* A generic signed type which is guaranteed to be big enough to hold any
97    arithmetic types we need to deal with.  Can be assumed to be compatible
98    with bfd_vma in the same way that signed and unsigned ints are compatible
99    (as parameters, in assignment, etc).  */
100 typedef long bfd_signed_vma;
101
102 typedef unsigned long symvalue;
103 typedef unsigned long bfd_size_type;
104
105 /* Print a bfd_vma x on stream s.  */
106 #define fprintf_vma(s,x) fprintf(s, "%08lx", x)
107 #endif /* not HOST_64_BIT.  */
108 #define printf_vma(x) fprintf_vma(stdout,x)
109
110 typedef unsigned int flagword;  /* 32 bits of flags */
111 \f
112 /** File formats */
113
114 typedef enum bfd_format {
115               bfd_unknown = 0,  /* file format is unknown */
116               bfd_object,       /* linker/assember/compiler output */
117               bfd_archive,      /* object archive file */
118               bfd_core,         /* core dump */
119               bfd_type_end}     /* marks the end; don't use it! */
120          bfd_format;
121
122 /* Object file flag values */
123 #define NO_FLAGS        0x00
124 #define HAS_RELOC       0x01
125 #define EXEC_P          0x02
126 #define HAS_LINENO      0x04
127 #define HAS_DEBUG       0x08
128 #define HAS_SYMS        0x10
129 #define HAS_LOCALS      0x20
130 #define DYNAMIC         0x40
131 #define WP_TEXT         0x80
132 #define D_PAGED         0x100
133 #define BFD_IS_RELAXABLE 0x200
134 \f
135 /* symbols and relocation */
136
137 typedef unsigned long symindex;
138
139 #define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
140
141 typedef enum bfd_symclass {
142               bfd_symclass_unknown = 0,
143               bfd_symclass_fcommon, /* fortran common symbols */
144               bfd_symclass_global, /* global symbol, what a surprise */
145               bfd_symclass_debugger, /* some debugger symbol */
146               bfd_symclass_undefined /* none known */
147             } symclass;
148
149
150 typedef int symtype;            /* Who knows, yet? */
151
152
153 /* general purpose part of a symbol;
154    target specific parts will be found in libcoff.h, liba.out.h etc */
155
156
157 #define bfd_get_section(x) ((x)->section)
158 #define bfd_get_output_section(x) ((x)->section->output_section)
159 #define bfd_set_section(x,y) ((x)->section) = (y)
160 #define bfd_asymbol_base(x) ((x)->section->vma)
161 #define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
162 #define bfd_asymbol_name(x) ((x)->name)
163 /*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
164 #define bfd_asymbol_bfd(x) ((x)->the_bfd)
165 #define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
166
167 /* This is a type pun with struct ranlib on purpose! */
168 typedef struct carsym {
169   char *name;
170   file_ptr file_offset;         /* look here to find the file */
171 } carsym;                       /* to make these you call a carsymogen */
172
173   
174 /* Used in generating armaps.  Perhaps just a forward definition would do? */
175 struct orl {                    /* output ranlib */
176   char **name;                  /* symbol name */ 
177   file_ptr pos;                 /* bfd* or file position */
178   int namidx;                   /* index into string table */
179 };
180
181 \f
182
183 /* Linenumber stuff */
184 typedef struct lineno_cache_entry {
185   unsigned int line_number;     /* Linenumber from start of function*/  
186   union {
187  struct symbol_cache_entry *sym;                /* Function name */
188     unsigned long offset;       /* Offset into section */
189   } u;
190 } alent;
191 \f
192 /* object and core file sections */
193
194
195 #define align_power(addr, align)        \
196         ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
197
198 typedef struct sec *sec_ptr;
199
200 #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
201 #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
202 #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
203 #define bfd_section_name(bfd, ptr) ((ptr)->name)
204 #define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
205 #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
206 #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
207 #define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
208 #define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
209
210 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
211
212 #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = true), true)
213 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
214 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
215
216 typedef struct stat stat_type; 
217 \f
218 /** Error handling */
219
220 typedef enum bfd_error {
221               no_error = 0, system_call_error, invalid_target,
222               wrong_format, invalid_operation, no_memory,
223               no_symbols, no_relocation_info,
224               no_more_archived_files, malformed_archive,
225               symbol_not_found, file_not_recognized,
226               file_ambiguously_recognized, no_contents,
227               bfd_error_nonrepresentable_section,
228               no_debug_section, bad_value,
229
230               /* An input file is shorter than expected.  */
231               file_truncated,
232               
233               invalid_error_code} bfd_ec;
234
235 extern bfd_ec bfd_error;
236 struct reloc_cache_entry;
237 struct bfd_seclet;
238
239
240 typedef struct bfd_error_vector {
241   void (* nonrepresentable_section ) PARAMS ((CONST bfd  *CONST abfd,
242                                               CONST char *CONST name));
243   void (* undefined_symbol) PARAMS ((CONST struct reloc_cache_entry *rel,
244                                      CONST struct bfd_seclet *sec));
245   void (* reloc_value_truncated) PARAMS ((CONST struct
246                                           reloc_cache_entry *rel,
247                                           struct bfd_seclet *sec));
248
249   void (* reloc_dangerous) PARAMS ((CONST struct reloc_cache_entry *rel,
250                                     CONST struct bfd_seclet *sec));
251   
252 } bfd_error_vector_type;
253
254 CONST char *bfd_errmsg PARAMS ((bfd_ec error_tag));
255 void bfd_perror PARAMS ((CONST char *message));
256 \f
257
258 typedef enum bfd_print_symbol
259
260   bfd_print_symbol_name,
261   bfd_print_symbol_more,
262   bfd_print_symbol_all,
263   bfd_print_symbol_nm   /* Pretty format suitable for nm program. */
264 } bfd_print_symbol_type;
265     
266 \f
267 \f
268 /* The code that implements targets can initialize a jump table with this
269    macro.  It must name all its routines the same way (a prefix plus
270    the standard routine suffix), or it must #define the routines that
271    are not so named, before calling JUMP_TABLE in the initializer.  */
272
273 /* Semi-portable string concatenation in cpp */
274 #ifndef CAT
275 #ifdef __STDC__
276 #define CAT(a,b) a##b
277 #else
278 #define CAT(a,b) a/**/b
279 #endif
280 #endif
281
282 #define JUMP_TABLE(NAME)\
283 CAT(NAME,_core_file_failing_command),\
284 CAT(NAME,_core_file_failing_signal),\
285 CAT(NAME,_core_file_matches_executable_p),\
286 CAT(NAME,_slurp_armap),\
287 CAT(NAME,_slurp_extended_name_table),\
288 CAT(NAME,_truncate_arname),\
289 CAT(NAME,_write_armap),\
290 CAT(NAME,_close_and_cleanup),   \
291 CAT(NAME,_set_section_contents),\
292 CAT(NAME,_get_section_contents),\
293 CAT(NAME,_new_section_hook),\
294 CAT(NAME,_get_symtab_upper_bound),\
295 CAT(NAME,_get_symtab),\
296 CAT(NAME,_get_reloc_upper_bound),\
297 CAT(NAME,_canonicalize_reloc),\
298 CAT(NAME,_make_empty_symbol),\
299 CAT(NAME,_print_symbol),\
300 CAT(NAME,_get_lineno),\
301 CAT(NAME,_set_arch_mach),\
302 CAT(NAME,_openr_next_archived_file),\
303 CAT(NAME,_find_nearest_line),\
304 CAT(NAME,_generic_stat_arch_elt),\
305 CAT(NAME,_sizeof_headers),\
306 CAT(NAME,_bfd_debug_info_start),\
307 CAT(NAME,_bfd_debug_info_end),\
308 CAT(NAME,_bfd_debug_info_accumulate),\
309 CAT(NAME,_bfd_get_relocated_section_contents),\
310 CAT(NAME,_bfd_relax_section),\
311 CAT(NAME,_bfd_seclet_link),\
312 CAT(NAME,_bfd_reloc_type_lookup),\
313 CAT(NAME,_bfd_make_debug_symbol)
314
315 #define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
316
317 \f
318 /* User program access to BFD facilities */
319
320 extern CONST short _bfd_host_big_endian;
321 #define HOST_BYTE_ORDER_BIG_P   (*(char *)&_bfd_host_big_endian)
322
323 /* The bfd itself */
324
325 /* Cast from const char * to char * so that caller can assign to
326    a char * without a warning.  */
327 #define bfd_get_filename(abfd) ((char *) (abfd)->filename)
328 #define bfd_get_format(abfd) ((abfd)->format)
329 #define bfd_get_target(abfd) ((abfd)->xvec->name)
330 #define bfd_get_file_flags(abfd) ((abfd)->flags)
331 #define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
332 #define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
333 #define bfd_my_archive(abfd) ((abfd)->my_archive)
334 #define bfd_has_map(abfd) ((abfd)->has_armap)
335 #define bfd_header_twiddle_required(abfd) \
336         ((((abfd)->xvec->header_byteorder_big_p)                \
337           != (boolean)HOST_BYTE_ORDER_BIG_P) ? true:false)
338
339 #define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
340 #define bfd_usrdata(abfd) ((abfd)->usrdata)
341
342 #define bfd_get_start_address(abfd) ((abfd)->start_address)
343 #define bfd_get_symcount(abfd) ((abfd)->symcount)
344 #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
345 #define bfd_count_sections(abfd) ((abfd)->section_count)
346 #define bfd_get_architecture(abfd) ((abfd)->obj_arch)
347 #define bfd_get_machine(abfd) ((abfd)->obj_machine)
348
349 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
350
351 #define BYTE_SIZE 1
352 #define SHORT_SIZE 2
353 #define LONG_SIZE 4
354
355 /* And more from the source.  */
356 void 
357 bfd_init PARAMS ((void));
358
359 bfd *
360 bfd_openr PARAMS ((CONST char *filename, CONST char*target));
361
362 bfd *
363 bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd));
364
365 bfd *
366 bfd_openw PARAMS ((CONST char *filename, CONST char *target));
367
368 boolean 
369 bfd_close PARAMS ((bfd *));
370
371 boolean 
372 bfd_close_all_done PARAMS ((bfd *));
373
374 bfd_size_type 
375 bfd_alloc_size PARAMS ((bfd *abfd));
376
377 bfd *
378 bfd_create PARAMS ((CONST char *filename, bfd *template));
379
380
381  /* Byte swapping macros for user section data.  */
382
383 #define bfd_put_8(abfd, val, ptr) \
384                 (*((unsigned char *)(ptr)) = (unsigned char)val)
385 #define bfd_put_signed_8 \
386                 bfd_put_8
387 #define bfd_get_8(abfd, ptr) \
388                 (*(unsigned char *)(ptr))
389 #define bfd_get_signed_8(abfd, ptr) \
390                 ((*(unsigned char *)(ptr) ^ 0x80) - 0x80)
391
392 #define bfd_put_16(abfd, val, ptr) \
393                 BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
394 #define bfd_put_signed_16 \
395                  bfd_put_16
396 #define bfd_get_16(abfd, ptr) \
397                 BFD_SEND(abfd, bfd_getx16, (ptr))
398 #define bfd_get_signed_16(abfd, ptr) \
399                  BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
400
401 #define bfd_put_32(abfd, val, ptr) \
402                 BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
403 #define bfd_put_signed_32 \
404                  bfd_put_32
405 #define bfd_get_32(abfd, ptr) \
406                 BFD_SEND(abfd, bfd_getx32, (ptr))
407 #define bfd_get_signed_32(abfd, ptr) \
408                  BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
409
410 #define bfd_put_64(abfd, val, ptr) \
411                 BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
412 #define bfd_put_signed_64 \
413                  bfd_put_64
414 #define bfd_get_64(abfd, ptr) \
415                 BFD_SEND(abfd, bfd_getx64, (ptr))
416 #define bfd_get_signed_64(abfd, ptr) \
417                  BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
418
419
420  /* Byte swapping macros for file header data.  */
421
422 #define bfd_h_put_8(abfd, val, ptr) \
423                 bfd_put_8 (abfd, val, ptr)
424 #define bfd_h_put_signed_8(abfd, val, ptr) \
425                 bfd_put_8 (abfd, val, ptr)
426 #define bfd_h_get_8(abfd, ptr) \
427                 bfd_get_8 (abfd, ptr)
428 #define bfd_h_get_signed_8(abfd, ptr) \
429                 bfd_get_signed_8 (abfd, ptr)
430
431 #define bfd_h_put_16(abfd, val, ptr) \
432                 BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
433 #define bfd_h_put_signed_16 \
434                  bfd_h_put_16
435 #define bfd_h_get_16(abfd, ptr) \
436                 BFD_SEND(abfd, bfd_h_getx16,(ptr))
437 #define bfd_h_get_signed_16(abfd, ptr) \
438                  BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
439
440 #define bfd_h_put_32(abfd, val, ptr) \
441                 BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
442 #define bfd_h_put_signed_32 \
443                  bfd_h_put_32
444 #define bfd_h_get_32(abfd, ptr) \
445                 BFD_SEND(abfd, bfd_h_getx32,(ptr))
446 #define bfd_h_get_signed_32(abfd, ptr) \
447                  BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
448
449 #define bfd_h_put_64(abfd, val, ptr) \
450                 BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
451 #define bfd_h_put_signed_64 \
452                  bfd_h_put_64
453 #define bfd_h_get_64(abfd, ptr) \
454                 BFD_SEND(abfd, bfd_h_getx64,(ptr))
455 #define bfd_h_get_signed_64(abfd, ptr) \
456                  BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
457
458 typedef struct sec 
459 {
460          /* The name of the section, the name isn't a copy, the pointer is
461         the same as that passed to bfd_make_section. */
462
463     CONST char *name;
464
465
466          /* Which section is it 0.nth      */
467
468    int index;                      
469
470          /* The next section in the list belonging to the BFD, or NULL. */
471
472     struct sec *next;
473
474          /* The field flags contains attributes of the section. Some of
475            flags are read in from the object file, and some are
476            synthesized from other information.  */         
477
478     flagword flags;
479
480 #define SEC_NO_FLAGS   0x000
481
482          /* Tells the OS to allocate space for this section when loaded.
483            This would clear for a section containing debug information
484            only. */
485           
486
487 #define SEC_ALLOC      0x001
488          /* Tells the OS to load the section from the file when loading.
489            This would be clear for a .bss section */
490
491 #define SEC_LOAD       0x002
492          /* The section contains data still to be relocated, so there will
493            be some relocation information too. */
494
495 #define SEC_RELOC      0x004
496
497          /* Obsolete ? */
498
499 #define SEC_BALIGN     0x008
500
501          /* A signal to the OS that the section contains read only
502           data. */
503 #define SEC_READONLY   0x010
504
505          /* The section contains code only. */
506
507 #define SEC_CODE       0x020
508
509          /* The section contains data only. */
510
511 #define SEC_DATA        0x040
512
513          /* The section will reside in ROM. */
514
515 #define SEC_ROM        0x080
516
517          /* The section contains constructor information. This section
518            type is used by the linker to create lists of constructors and
519            destructors used by <<g++>>. When a back end sees a symbol
520            which should be used in a constructor list, it creates a new
521            section for the type of name (eg <<__CTOR_LIST__>>), attaches
522            the symbol to it and builds a relocation. To build the lists
523            of constructors, all the linker has to to is catenate all the
524            sections called <<__CTOR_LIST__>> and relocte the data
525            contained within - exactly the operations it would peform on
526            standard data. */
527
528 #define SEC_CONSTRUCTOR 0x100
529
530          /* The section is a constuctor, and should be placed at the
531           end of the . */
532
533 #define SEC_CONSTRUCTOR_TEXT 0x1100
534
535 #define SEC_CONSTRUCTOR_DATA 0x2100
536
537 #define SEC_CONSTRUCTOR_BSS  0x3100
538
539          /* The section has contents - a data section could be
540            <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>, a debug section could be
541            <<SEC_HAS_CONTENTS>> */
542
543 #define SEC_HAS_CONTENTS 0x200
544
545          /* An instruction to the linker not to output sections
546           containing this flag even if they have information which
547           would normally be written. */
548
549 #define SEC_NEVER_LOAD 0x400
550
551          /* The section is a shared library section.  The linker must leave
552            these completely alone, as the vma and size are used when
553            the executable is loaded. */
554
555 #define SEC_SHARED_LIBRARY 0x800
556
557          /* The section is a common section (symbols may be defined
558            multiple times, the value of a symbol is the amount of
559            space it requires, and the largest symbol value is the one
560            used).  Most targets have exactly one of these (.bss), but
561            ECOFF has two. */
562
563 #define SEC_IS_COMMON 0x8000
564
565         /*  The virtual memory address of the section - where it will be
566            at run time - the symbols are relocated against this */
567    bfd_vma vma;
568
569         /*  The load address of the section - where it would be in a
570            rom image, really only used for writing section header information */
571    bfd_vma lma;
572
573    boolean user_set_vma;
574
575          /* The size of the section in bytes, as it will be output.
576            contains a value even if the section has no contents (eg, the
577            size of <<.bss>>). This will be filled in after relocation */
578
579    bfd_size_type _cooked_size;    
580
581          /* The size on disk of the section in bytes originally.  Normally this
582             value is the same as the size, but if some relaxing has
583             been done, then this value will be bigger.  */
584
585    bfd_size_type _raw_size;    
586
587          /* If this section is going to be output, then this value is the
588            offset into the output section of the first byte in the input
589            section. Eg, if this was going to start at the 100th byte in
590            the output section, this value would be 100. */
591
592    bfd_vma output_offset;
593
594          /* The output section through which to map on output. */
595
596    struct sec *output_section;
597
598          /* The alignment requirement of the section, as an exponent - eg
599            3 aligns to 2^3 (or 8) */
600
601    unsigned int alignment_power;
602
603          /* If an input section, a pointer to a vector of relocation
604            records for the data in this section. */
605
606    struct reloc_cache_entry *relocation;
607
608          /* If an output section, a pointer to a vector of pointers to
609            relocation records for the data in this section. */
610
611    struct reloc_cache_entry **orelocation;
612
613          /* The number of relocation records in one of the above  */
614
615    unsigned reloc_count;
616
617          /* Information below is back end specific - and not always used
618            or updated 
619
620            File position of section data    */
621
622    file_ptr filepos;      
623         
624          /* File position of relocation info */
625
626    file_ptr rel_filepos;
627
628          /* File position of line data       */
629
630    file_ptr line_filepos;
631
632          /* Pointer to data for applications */
633
634    PTR userdata;
635
636    struct lang_output_section *otheruserdata;
637
638          /* Attached line number information */
639
640    alent *lineno;
641         
642          /* Number of line number records   */
643
644    unsigned int lineno_count;
645
646          /* When a section is being output, this value changes as more
647            linenumbers are written out */
648
649    file_ptr moving_line_filepos;
650
651          /* what the section number is in the target world  */
652
653    int target_index;
654
655    PTR used_by_bfd;
656
657          /* If this is a constructor section then here is a list of the
658            relocations created to relocate items within it. */
659
660    struct relent_chain *constructor_chain;
661
662          /* The BFD which owns the section. */
663
664    bfd *owner;
665
666    boolean reloc_done;
667           /* A symbol which points at this section only */
668    struct symbol_cache_entry *symbol;  
669    struct symbol_cache_entry **symbol_ptr_ptr;
670    struct bfd_seclet *seclets_head;
671    struct bfd_seclet *seclets_tail;
672 } asection ;
673
674
675 #define BFD_ABS_SECTION_NAME "*ABS*"
676 #define BFD_UND_SECTION_NAME "*UND*"
677 #define BFD_COM_SECTION_NAME "*COM*"
678 #define BFD_IND_SECTION_NAME "*IND*"
679
680      /* the absolute section */
681  extern   asection bfd_abs_section;
682      /* Pointer to the undefined section */
683  extern   asection bfd_und_section;
684      /* Pointer to the common section */
685  extern asection bfd_com_section;
686      /* Pointer to the indirect section */
687  extern asection bfd_ind_section;
688
689  extern struct symbol_cache_entry *bfd_abs_symbol;
690  extern struct symbol_cache_entry *bfd_com_symbol;
691  extern struct symbol_cache_entry *bfd_und_symbol;
692  extern struct symbol_cache_entry *bfd_ind_symbol;
693 #define bfd_get_section_size_before_reloc(section) \
694      (section->reloc_done ? (abort(),1): (section)->_raw_size)
695 #define bfd_get_section_size_after_reloc(section) \
696      ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
697 asection *
698 bfd_get_section_by_name PARAMS ((bfd *abfd, CONST char *name));
699
700 asection *
701 bfd_make_section_old_way PARAMS ((bfd *, CONST char *name));
702
703 asection * 
704 bfd_make_section PARAMS ((bfd *, CONST char *name));
705
706 boolean 
707 bfd_set_section_flags PARAMS ((bfd *, asection *, flagword));
708
709 void 
710 bfd_map_over_sections PARAMS ((bfd *abfd,
711     void (*func)(bfd *abfd,
712     asection *sect,
713     PTR obj),
714     PTR obj));
715
716 boolean 
717 bfd_set_section_size PARAMS ((bfd *, asection *, bfd_size_type val));
718
719 boolean 
720 bfd_set_section_contents
721  PARAMS ((bfd *abfd,        
722     asection *section,
723     PTR data,
724     file_ptr offset,
725     bfd_size_type count));
726
727 boolean 
728 bfd_get_section_contents 
729  PARAMS ((bfd *abfd, asection *section, PTR location,
730     file_ptr offset, bfd_size_type count));
731
732 enum bfd_architecture 
733 {
734   bfd_arch_unknown,    /* File arch not known */
735   bfd_arch_obscure,    /* Arch known, not one of these */
736   bfd_arch_m68k,       /* Motorola 68xxx */
737   bfd_arch_vax,        /* DEC Vax */   
738   bfd_arch_i960,       /* Intel 960 */
739      /* The order of the following is important.
740        lower number indicates a machine type that 
741        only accepts a subset of the instructions
742        available to machines with higher numbers.
743        The exception is the "ca", which is
744        incompatible with all other machines except 
745        "core". */
746
747 #define bfd_mach_i960_core      1
748 #define bfd_mach_i960_ka_sa     2
749 #define bfd_mach_i960_kb_sb     3
750 #define bfd_mach_i960_mc        4
751 #define bfd_mach_i960_xa        5
752 #define bfd_mach_i960_ca        6
753
754   bfd_arch_a29k,       /* AMD 29000 */
755   bfd_arch_sparc,      /* SPARC */
756   bfd_arch_mips,       /* MIPS Rxxxx */
757   bfd_arch_i386,       /* Intel 386 */
758   bfd_arch_we32k,      /* AT&T WE32xxx */
759   bfd_arch_tahoe,      /* CCI/Harris Tahoe */
760   bfd_arch_i860,       /* Intel 860 */
761   bfd_arch_romp,       /* IBM ROMP PC/RT */
762   bfd_arch_alliant,    /* Alliant */
763   bfd_arch_convex,     /* Convex */
764   bfd_arch_m88k,       /* Motorola 88xxx */
765   bfd_arch_pyramid,    /* Pyramid Technology */
766   bfd_arch_h8300,      /* Hitachi H8/300 */
767   bfd_arch_rs6000,     /* IBM RS/6000 */
768   bfd_arch_hppa,       /* HP PA RISC */
769   bfd_arch_z8k,        /* Zilog Z8000 */
770 #define bfd_mach_z8001          1
771 #define bfd_mach_z8002          2
772   bfd_arch_h8500,      /* Hitachi H8/500 */
773   bfd_arch_alpha,      /* Dec Alpha */
774   bfd_arch_last
775   };
776
777 typedef struct bfd_arch_info 
778 {
779   int bits_per_word;
780   int bits_per_address;
781   int bits_per_byte;
782   enum bfd_architecture arch;
783   long mach;
784   char *arch_name;
785   CONST  char *printable_name;
786   unsigned int section_align_power;
787   /* true if this is the default machine for the architecture */
788   boolean the_default;  
789   CONST struct bfd_arch_info * (*compatible)
790         PARAMS ((CONST struct bfd_arch_info *a,
791                  CONST struct bfd_arch_info *b));
792
793   boolean (*scan) PARAMS ((CONST struct bfd_arch_info *, CONST char *));
794    /* How to disassemble an instruction, producing a printable
795      representation on a specified stdio stream.  This isn't
796      defined for most processors at present, because of the size
797      of the additional tables it would drag in, and because gdb
798      wants to use a different interface.  */
799   unsigned int (*disassemble) PARAMS ((bfd_vma addr, CONST char *data,
800                                         PTR stream));
801
802   struct bfd_arch_info *next;
803 } bfd_arch_info_type;
804 CONST char *
805 bfd_printable_name PARAMS ((bfd *abfd));
806
807 bfd_arch_info_type *
808 bfd_scan_arch PARAMS ((CONST char *));
809
810 CONST bfd_arch_info_type *
811 bfd_arch_get_compatible PARAMS ((
812     CONST bfd *abfd,
813     CONST bfd *bbfd));
814
815 void 
816 bfd_set_arch_info PARAMS ((bfd *, bfd_arch_info_type *));
817
818 enum bfd_architecture 
819 bfd_get_arch PARAMS ((bfd *abfd));
820
821 unsigned long 
822 bfd_get_mach PARAMS ((bfd *abfd));
823
824 unsigned int 
825 bfd_arch_bits_per_byte PARAMS ((bfd *abfd));
826
827 unsigned int 
828 bfd_arch_bits_per_address PARAMS ((bfd *abfd));
829
830 bfd_arch_info_type * 
831 bfd_get_arch_info PARAMS ((bfd *));
832
833 bfd_arch_info_type *
834 bfd_lookup_arch
835  PARAMS ((enum bfd_architecture
836     arch,
837     long machine));
838
839 CONST char * 
840 bfd_printable_arch_mach
841  PARAMS ((enum bfd_architecture arch, unsigned long machine));
842
843 typedef enum bfd_reloc_status 
844 {
845         /* No errors detected */
846   bfd_reloc_ok,
847
848         /* The relocation was performed, but there was an overflow. */
849   bfd_reloc_overflow,
850
851         /* The address to relocate was not within the section supplied. */
852   bfd_reloc_outofrange,
853
854         /* Used by special functions */
855   bfd_reloc_continue,
856
857         /* Unused */
858   bfd_reloc_notsupported,
859
860         /* Unsupported relocation size requested. */
861   bfd_reloc_other,
862
863         /* The symbol to relocate against was undefined. */
864   bfd_reloc_undefined,
865
866         /* The relocation was performed, but may not be ok - presently
867           generated only when linking i960 coff files with i960 b.out
868           symbols. */
869   bfd_reloc_dangerous
870  }
871  bfd_reloc_status_type;
872
873
874 typedef struct reloc_cache_entry 
875 {
876         /* A pointer into the canonical table of pointers  */
877   struct symbol_cache_entry **sym_ptr_ptr;
878
879         /* offset in section */
880   bfd_size_type address;
881
882         /* addend for relocation value */
883   bfd_vma addend;    
884
885         /* Pointer to how to perform the required relocation */
886   CONST struct reloc_howto_struct *howto;
887
888 } arelent;
889
890 typedef CONST struct reloc_howto_struct 
891
892         /*  The type field has mainly a documetary use - the back end can
893            to what it wants with it, though the normally the back end's
894            external idea of what a reloc number would be would be stored
895            in this field. For example, the a PC relative word relocation
896            in a coff environment would have the type 023 - because that's
897            what the outside world calls a R_PCRWORD reloc. */
898   unsigned int type;
899
900         /*  The value the final relocation is shifted right by. This drops
901            unwanted data from the relocation.  */
902   unsigned int rightshift;
903
904         /*  The size of the item to be relocated - 0, is one byte, 1 is 2
905            bytes, 2 is four bytes.  A negative value indicates that the
906             result is to be subtracted from the data.  */
907   int size;
908
909         /*  Now obsolete?  But m68k-coff still uses it... */
910   unsigned int bitsize;
911
912         /*  Notes that the relocation is relative to the location in the
913            data section of the addend. The relocation function will
914            subtract from the relocation value the address of the location
915            being relocated. */
916   boolean pc_relative;
917
918   unsigned int bitpos;
919
920         /*  Now obsolete */
921   boolean absolute;
922
923         /* Causes the relocation routine to return an error if overflow
924           is detected when relocating. */
925   boolean complain_on_overflow;
926
927         /* If this field is non null, then the supplied function is
928           called rather than the normal function. This allows really
929           strange relocation methods to be accomodated (e.g., i960 callj
930           instructions). */
931   bfd_reloc_status_type (*special_function) 
932                                     PARAMS ((bfd *abfd,
933                                              arelent *reloc_entry,
934                                             struct symbol_cache_entry *symbol,
935                                             PTR data,
936                                             asection *input_section, 
937                                             bfd *output_bfd));
938
939         /* The textual name of the relocation type. */
940   char *name;
941
942         /* When performing a partial link, some formats must modify the
943           relocations rather than the data - this flag signals this.*/
944   boolean partial_inplace;
945
946         /* The src_mask is used to select what parts of the read in data
947           are to be used in the relocation sum.  E.g., if this was an 8 bit
948           bit of data which we read and relocated, this would be
949           0x000000ff. When we have relocs which have an addend, such as
950           sun4 extended relocs, the value in the offset part of a
951           relocating field is garbage so we never use it. In this case
952           the mask would be 0x00000000. */
953   bfd_vma src_mask;
954
955         /* The dst_mask is what parts of the instruction are replaced
956           into the instruction. In most cases src_mask == dst_mask,
957           except in the above special case, where dst_mask would be
958           0x000000ff, and src_mask would be 0x00000000.   */
959   bfd_vma dst_mask;           
960
961         /* When some formats create PC relative instructions, they leave
962           the value of the pc of the place being relocated in the offset
963           slot of the instruction, so that a PC relative relocation can
964           be made just by adding in an ordinary offset (e.g., sun3 a.out).
965           Some formats leave the displacement part of an instruction
966           empty (e.g., m88k bcs), this flag signals the fact.*/
967   boolean pcrel_offset;
968
969 } reloc_howto_type;
970 #define HOWTO(C, R,S,B, P, BI, ABS, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
971   {(unsigned)C,R,S,B, P, BI, ABS,O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
972 #define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,false,false,FUNCTION, NAME,false,0,0,IN)
973
974 #define HOWTO_PREPARE(relocation, symbol)      \
975   {                                            \
976   if (symbol != (asymbol *)NULL) {             \
977     if (bfd_is_com_section (symbol->section)) { \
978       relocation = 0;                          \
979     }                                          \
980     else {                                     \
981       relocation = symbol->value;              \
982     }                                          \
983   }                                            \
984 }                      
985 typedef unsigned char bfd_byte;
986
987 typedef struct relent_chain {
988   arelent relent;
989   struct   relent_chain *next;
990 } arelent_chain;
991 bfd_reloc_status_type
992
993 bfd_perform_relocation
994  PARAMS ((bfd * abfd,
995     arelent *reloc_entry,
996     PTR data,
997     asection *input_section,
998     bfd *output_bfd));
999
1000 typedef enum bfd_reloc_code_real 
1001
1002 {
1003         /* 16 bits wide, simple reloc */
1004   BFD_RELOC_16,        
1005
1006         /* 8 bits wide, but used to form an address like 0xffnn */
1007   BFD_RELOC_8_FFnn,
1008
1009         /* 8 bits wide, simple */
1010   BFD_RELOC_8,
1011
1012         /* 8 bits wide, pc relative */
1013   BFD_RELOC_8_PCREL,
1014
1015         /* The type of reloc used to build a contructor table - at the
1016           moment probably a 32 bit wide abs address, but the cpu can
1017           choose. */
1018
1019   BFD_RELOC_CTOR,
1020
1021         /* 32 bits wide, simple reloc */
1022   BFD_RELOC_32,
1023          /* 32 bits, PC-relative */
1024   BFD_RELOC_32_PCREL,
1025
1026          /* High 22 bits of 32-bit value; simple reloc.  */
1027   BFD_RELOC_HI22,
1028          /* Low 10 bits.  */
1029   BFD_RELOC_LO10,
1030
1031          /* Reloc types used for i960/b.out.  */
1032   BFD_RELOC_24_PCREL,
1033   BFD_RELOC_I960_CALLJ,
1034
1035   BFD_RELOC_16_PCREL,
1036          /* 32-bit pc-relative, shifted right 2 bits (i.e., 30-bit
1037            word displacement, e.g. for SPARC) */
1038   BFD_RELOC_32_PCREL_S2,
1039
1040    /* now for the sparc/elf codes */
1041   BFD_RELOC_NONE,                /* actually used */
1042   BFD_RELOC_SPARC_WDISP22,
1043   BFD_RELOC_SPARC22,
1044   BFD_RELOC_SPARC13,
1045   BFD_RELOC_SPARC_BASE13,
1046   BFD_RELOC_SPARC_GOT10,
1047   BFD_RELOC_SPARC_GOT13,
1048   BFD_RELOC_SPARC_GOT22,
1049   BFD_RELOC_SPARC_PC10,
1050   BFD_RELOC_SPARC_PC22,
1051   BFD_RELOC_SPARC_WPLT30,
1052   BFD_RELOC_SPARC_COPY,
1053   BFD_RELOC_SPARC_GLOB_DAT,
1054   BFD_RELOC_SPARC_JMP_SLOT,
1055   BFD_RELOC_SPARC_RELATIVE,
1056   BFD_RELOC_SPARC_UA32,
1057
1058    /* this one is a.out specific? */
1059   BFD_RELOC_SPARC_BASE22,
1060
1061         /* Bits 27..2 of the relocation address shifted right 2 bits;
1062          simple reloc otherwise.  */
1063   BFD_RELOC_MIPS_JMP,
1064
1065         /* signed 16-bit pc-relative, shifted right 2 bits (e.g. for MIPS) */
1066   BFD_RELOC_16_PCREL_S2,
1067
1068         /* High 16 bits of 32-bit value; simple reloc.  */
1069   BFD_RELOC_HI16,
1070         /* High 16 bits of 32-bit value but the low 16 bits will be sign
1071           extended and added to form the final result.  If the low 16
1072           bits form a negative number, we need to add one to the high value
1073           to compensate for the borrow when the low bits are added.  */
1074   BFD_RELOC_HI16_S,
1075         /* Low 16 bits.  */
1076   BFD_RELOC_LO16,
1077
1078          /* 16 bit relocation relative to the global pointer.  */
1079   BFD_RELOC_MIPS_GPREL,
1080
1081    /* this must be the highest numeric value */
1082   BFD_RELOC_UNUSED
1083  } bfd_reloc_code_real_type;
1084 CONST struct reloc_howto_struct *
1085
1086 bfd_reloc_type_lookup  PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
1087
1088 typedef struct symbol_cache_entry 
1089 {
1090          /* A pointer to the BFD which owns the symbol. This information
1091            is necessary so that a back end can work out what additional
1092            information (invisible to the application writer) is carried
1093            with the symbol.
1094
1095            This field is *almost* redundant, since you can use section->owner
1096            instead, except that some symbols point to the global sections
1097            bfd_{abs,com,und}_section.  This could be fixed by making
1098            these globals be per-bfd (or per-target-flavor).  FIXME. */
1099
1100   struct _bfd *the_bfd;  /* Use bfd_asymbol_bfd(sym) to access this field. */
1101
1102          /* The text of the symbol. The name is left alone, and not copied - the
1103            application may not alter it. */
1104   CONST char *name;
1105
1106          /* The value of the symbol.*/
1107   symvalue value;
1108
1109          /* Attributes of a symbol: */
1110
1111 #define BSF_NO_FLAGS    0x00
1112
1113          /* The symbol has local scope; <<static>> in <<C>>. The value
1114            is the offset into the section of the data. */
1115 #define BSF_LOCAL       0x01
1116
1117          /* The symbol has global scope; initialized data in <<C>>. The
1118            value is the offset into the section of the data. */
1119 #define BSF_GLOBAL      0x02
1120
1121          /* Obsolete; should be deleted? */
1122 #define BSF_IMPORT      0x04
1123
1124          /* The symbol has global scope, and is exported. The value is
1125            the offset into the section of the data. */
1126 #define BSF_EXPORT      0x08
1127
1128          /* The symbol is undefined. <<extern>> in <<C>>. The value has
1129            no meaning.  Obsolete; should be deleted? */
1130 #define BSF_UNDEFINED_OBS 0x10  
1131
1132          /* The symbol is common, initialized to zero; default in
1133            <<C>>. The value is the size of the object in bytes. */
1134 #define BSF_FORT_COMM_OBS       0x20    
1135
1136          /* A normal C symbol would be one of:
1137            <<BSF_LOCAL>>, <<BSF_FORT_COMM>>,  <<BSF_UNDEFINED>> or
1138            <<BSF_EXPORT|BSD_GLOBAL>> */
1139
1140          /* The symbol is a debugging record. The value has an arbitary
1141            meaning. */
1142 #define BSF_DEBUGGING   0x40
1143
1144          /* Used by the linker. */
1145 #define BSF_KEEP        0x10000
1146 #define BSF_KEEP_G      0x80000
1147
1148          /* Unused; should be deleted? */
1149 #define BSF_WEAK        0x100000
1150 #define BSF_CTOR        0x200000 
1151
1152         /* This symbol was created to point to a section, e.g. ELF's
1153            STT_SECTION symbols.  */
1154 #define BSF_SECTION_SYM 0x400000 
1155
1156          /* The symbol used to be a common symbol, but now it is
1157            allocated. */
1158 #define BSF_OLD_COMMON  0x800000  
1159
1160          /* The default value for common data. */
1161 #define BFD_FORT_COMM_DEFAULT_VALUE 0
1162
1163          /* In some files the type of a symbol sometimes alters its
1164            location in an output file - ie in coff a <<ISFCN>> symbol
1165            which is also <<C_EXT>> symbol appears where it was
1166            declared and not at the end of a section.  This bit is set
1167            by the target BFD part to convey this information. */
1168
1169 #define BSF_NOT_AT_END    0x40000
1170
1171          /* Signal that the symbol is the label of constructor section. */
1172 #define BSF_CONSTRUCTOR   0x1000000
1173
1174          /* Signal that the symbol is a warning symbol. If the symbol
1175            is a warning symbol, then the value field (I know this is
1176            tacky) will point to the asymbol which when referenced will
1177            cause the warning. */
1178 #define BSF_WARNING       0x2000000
1179
1180          /* Signal that the symbol is indirect. The value of the symbol
1181            is a pointer to an undefined asymbol which contains the
1182            name to use instead. */
1183 #define BSF_INDIRECT      0x4000000
1184
1185          /* BSF_FILE marks symbols that contain a file name.  This is used
1186            for ELF STT_FILE symbols.  */
1187 #define BSF_FILE          0x08000000
1188
1189   flagword flags;
1190
1191          /* A pointer to the section to which this symbol is 
1192            relative.  This will always be non NULL, there are special
1193           sections for undefined and absolute symbols */
1194   struct sec *section;
1195
1196          /* Back end special data. This is being phased out in favour
1197            of making this a union. */
1198   PTR udata;
1199
1200 } asymbol;
1201 #define get_symtab_upper_bound(abfd) \
1202      BFD_SEND (abfd, _get_symtab_upper_bound, (abfd))
1203 #define bfd_canonicalize_symtab(abfd, location) \
1204      BFD_SEND (abfd, _bfd_canonicalize_symtab,\
1205                   (abfd, location))
1206 boolean 
1207 bfd_set_symtab  PARAMS ((bfd *, asymbol **, unsigned int ));
1208
1209 void 
1210 bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol));
1211
1212 #define bfd_make_empty_symbol(abfd) \
1213      BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
1214 #define bfd_make_debug_symbol(abfd,ptr,size) \
1215         BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
1216 int 
1217 bfd_decode_symclass PARAMS ((asymbol *symbol));
1218
1219 struct _bfd 
1220 {
1221      /* The filename the application opened the BFD with.  */
1222     CONST char *filename;                
1223
1224      /* A pointer to the target jump table.             */
1225     struct bfd_target *xvec;
1226
1227      /* To avoid dragging too many header files into every file that
1228        includes `<<bfd.h>>', IOSTREAM has been declared as a "char
1229        *", and MTIME as a "long".  Their correct types, to which they
1230        are cast when used, are "FILE *" and "time_t".    The iostream
1231        is the result of an fopen on the filename. */
1232     char *iostream;
1233
1234      /* Is the file being cached */
1235
1236     boolean cacheable;
1237
1238      /* Marks whether there was a default target specified when the
1239        BFD was opened. This is used to select what matching algorithm
1240        to use to chose the back end. */
1241
1242     boolean target_defaulted;
1243
1244      /* The caching routines use these to maintain a
1245        least-recently-used list of BFDs */
1246
1247     struct _bfd *lru_prev, *lru_next;
1248
1249      /* When a file is closed by the caching routines, BFD retains
1250        state information on the file here: 
1251      */
1252
1253     file_ptr where;              
1254
1255      /* and here:*/
1256
1257     boolean opened_once;
1258
1259      /* Set if we have a locally maintained mtime value, rather than
1260        getting it from the file each time: */
1261
1262     boolean mtime_set;
1263
1264      /* File modified time, if mtime_set is true: */
1265
1266     long mtime;          
1267
1268      /* Reserved for an unimplemented file locking extension.*/
1269
1270     int ifd;
1271
1272      /* The format which belongs to the BFD.*/
1273
1274     bfd_format format;
1275
1276      /* The direction the BFD was opened with*/
1277
1278     enum bfd_direction {no_direction = 0,
1279                         read_direction = 1,
1280                         write_direction = 2,
1281                         both_direction = 3} direction;
1282
1283      /* Format_specific flags*/
1284
1285     flagword flags;              
1286
1287      /* Currently my_archive is tested before adding origin to
1288        anything. I believe that this can become always an add of
1289        origin, with origin set to 0 for non archive files.   */
1290
1291     file_ptr origin;             
1292
1293      /* Remember when output has begun, to stop strange things
1294        happening. */
1295     boolean output_has_begun;
1296
1297      /* Pointer to linked list of sections*/
1298     struct sec  *sections;
1299
1300      /* The number of sections */
1301     unsigned int section_count;
1302
1303      /* Stuff only useful for object files: 
1304        The start address. */
1305     bfd_vma start_address;
1306
1307      /* Used for input and output*/
1308     unsigned int symcount;
1309
1310      /* Symbol table for output BFD*/
1311     struct symbol_cache_entry  **outsymbols;             
1312
1313      /* Pointer to structure which contains architecture information*/
1314     struct bfd_arch_info *arch_info;
1315
1316      /* Stuff only useful for archives:*/
1317     PTR arelt_data;              
1318     struct _bfd *my_archive;     
1319     struct _bfd *next;           
1320     struct _bfd *archive_head;   
1321     boolean has_armap;           
1322
1323      /* Used by the back end to hold private data. */
1324
1325     union 
1326       {
1327       struct aout_data_struct *aout_data;
1328       struct artdata *aout_ar_data;
1329       struct _oasys_data *oasys_obj_data;
1330       struct _oasys_ar_data *oasys_ar_data;
1331       struct coff_tdata *coff_obj_data;
1332       struct ecoff_tdata *ecoff_obj_data;
1333       struct ieee_data_struct *ieee_data;
1334       struct ieee_ar_data_struct *ieee_ar_data;
1335       struct srec_data_struct *srec_data;
1336       struct tekhex_data_struct *tekhex_data;
1337       struct elf_obj_tdata *elf_obj_data;
1338       struct bout_data_struct *bout_data;
1339       struct sun_core_struct *sun_core_data;
1340       struct trad_core_struct *trad_core_data;
1341       struct hppa_data_struct *hppa_data;
1342       struct hppa_core_struct *hppa_core_data;
1343       struct sgi_core_struct *sgi_core_data;
1344       PTR any;
1345       } tdata;
1346   
1347      /* Used by the application to hold private data*/
1348     PTR usrdata;
1349
1350      /* Where all the allocated stuff under this BFD goes */
1351     struct obstack memory;
1352
1353      /* Is this really needed in addition to usrdata?  */
1354     asymbol **ld_symbols;
1355 };
1356
1357 unsigned int 
1358 bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
1359
1360 unsigned int 
1361 bfd_canonicalize_reloc
1362  PARAMS ((bfd *abfd,
1363     asection *sec,
1364     arelent **loc,
1365     asymbol     **syms));
1366
1367 boolean 
1368 bfd_set_file_flags PARAMS ((bfd *abfd, flagword flags));
1369
1370 void 
1371 bfd_set_reloc
1372  PARAMS ((bfd *abfd, asection *sec, arelent **rel, unsigned int count)
1373     
1374     );
1375
1376 boolean 
1377 bfd_set_start_address PARAMS ((bfd *, bfd_vma));
1378
1379 long 
1380 bfd_get_mtime PARAMS ((bfd *));
1381
1382 long 
1383 bfd_get_size PARAMS ((bfd *));
1384
1385 int 
1386 bfd_get_gp_size PARAMS ((bfd *));
1387
1388 void 
1389 bfd_set_gp_size PARAMS ((bfd *, int));
1390
1391 #define bfd_sizeof_headers(abfd, reloc) \
1392      BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
1393
1394 #define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
1395      BFD_SEND (abfd, _bfd_find_nearest_line,  (abfd, sec, syms, off, file, func, line))
1396
1397         /* Do these three do anything useful at all, for any back end?  */
1398 #define bfd_debug_info_start(abfd) \
1399         BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
1400
1401 #define bfd_debug_info_end(abfd) \
1402         BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
1403
1404 #define bfd_debug_info_accumulate(abfd, section) \
1405         BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
1406
1407
1408 #define bfd_stat_arch_elt(abfd, stat) \
1409         BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
1410
1411 #define bfd_set_arch_mach(abfd, arch, mach)\
1412         BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
1413
1414 #define bfd_get_relocated_section_contents(abfd, seclet, data, relocateable) \
1415         BFD_SEND (abfd, _bfd_get_relocated_section_contents, (abfd, seclet, data, relocateable))
1416  
1417 #define bfd_relax_section(abfd, section, symbols) \
1418        BFD_SEND (abfd, _bfd_relax_section, (abfd, section, symbols))
1419
1420 #define bfd_seclet_link(abfd, data, relocateable) \
1421        BFD_SEND (abfd, _bfd_seclet_link, (abfd, data, relocateable))
1422 symindex 
1423 bfd_get_next_mapent PARAMS ((bfd *, symindex previous, carsym ** sym));
1424
1425 boolean 
1426 bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head));
1427
1428 bfd *
1429 bfd_get_elt_at_index PARAMS ((bfd * archive, int index));
1430
1431 bfd* 
1432 bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous));
1433
1434 CONST char *
1435 bfd_core_file_failing_command PARAMS ((bfd *));
1436
1437 int 
1438 bfd_core_file_failing_signal PARAMS ((bfd *));
1439
1440 boolean 
1441 core_file_matches_executable_p
1442  PARAMS ((bfd *core_bfd, bfd *exec_bfd));
1443
1444 #define BFD_SEND(bfd, message, arglist) \
1445                ((*((bfd)->xvec->message)) arglist)
1446 #define BFD_SEND_FMT(bfd, message, arglist) \
1447             (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
1448 typedef struct bfd_target
1449 {
1450   char *name;
1451   enum target_flavour {
1452     bfd_target_unknown_flavour,
1453     bfd_target_aout_flavour,
1454     bfd_target_coff_flavour,
1455     bfd_target_ecoff_flavour,
1456     bfd_target_elf_flavour,
1457     bfd_target_ieee_flavour,
1458     bfd_target_oasys_flavour,
1459     bfd_target_tekhex_flavour,
1460     bfd_target_srec_flavour,
1461     bfd_target_hppa_flavour} flavour;
1462   boolean byteorder_big_p;
1463   boolean header_byteorder_big_p;
1464   flagword object_flags;       
1465   flagword section_flags;
1466   char symbol_leading_char;
1467   char ar_pad_char;            
1468   unsigned short ar_max_namelen;
1469   unsigned int align_power_min;
1470   bfd_vma      (*bfd_getx64) PARAMS ((bfd_byte *));
1471   bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((bfd_byte *));
1472   void         (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
1473   bfd_vma      (*bfd_getx32) PARAMS ((bfd_byte *));
1474   bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((bfd_byte *));
1475   void         (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
1476   bfd_vma      (*bfd_getx16) PARAMS ((bfd_byte *));
1477   bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((bfd_byte *));
1478   void         (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
1479   bfd_vma      (*bfd_h_getx64) PARAMS ((bfd_byte *));
1480   bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((bfd_byte *));
1481   void         (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
1482   bfd_vma      (*bfd_h_getx32) PARAMS ((bfd_byte *));
1483   bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((bfd_byte *));
1484   void         (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
1485   bfd_vma      (*bfd_h_getx16) PARAMS ((bfd_byte *));
1486   bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((bfd_byte *));
1487   void         (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
1488   struct bfd_target * (*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
1489   boolean             (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
1490   boolean             (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
1491   char *   (*_core_file_failing_command) PARAMS ((bfd *));
1492   int      (*_core_file_failing_signal) PARAMS ((bfd *));
1493   boolean  (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
1494   boolean  (*_bfd_slurp_armap) PARAMS ((bfd *));
1495   boolean  (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
1496   void     (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
1497   boolean  (*write_armap) PARAMS ((bfd *arch, 
1498                               unsigned int elength,
1499                               struct orl *map,
1500                               unsigned int orl_count, 
1501                               int stridx));
1502   boolean       (*_close_and_cleanup) PARAMS ((bfd *));
1503   boolean       (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
1504                                             file_ptr, bfd_size_type));
1505   boolean       (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR, 
1506                                             file_ptr, bfd_size_type));
1507   boolean       (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
1508   unsigned int  (*_get_symtab_upper_bound) PARAMS ((bfd *));
1509   unsigned int  (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
1510                                               struct symbol_cache_entry **));
1511   unsigned int  (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
1512   unsigned int  (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
1513                                               struct symbol_cache_entry **));
1514   struct symbol_cache_entry  *
1515                 (*_bfd_make_empty_symbol) PARAMS ((bfd *));
1516   void          (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
1517                                       struct symbol_cache_entry *,
1518                                       bfd_print_symbol_type));
1519 #define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
1520   alent *    (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
1521
1522   boolean    (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
1523                     unsigned long));
1524
1525   bfd *      (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
1526  
1527   boolean    (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
1528                     struct sec *section, struct symbol_cache_entry **symbols,
1529                     bfd_vma offset, CONST char **file, CONST char **func,
1530                     unsigned int *line));
1531  
1532   int        (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
1533
1534   int        (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
1535
1536   void       (*_bfd_debug_info_start) PARAMS ((bfd *));
1537   void       (*_bfd_debug_info_end) PARAMS ((bfd *));
1538   void       (*_bfd_debug_info_accumulate) PARAMS ((bfd *, struct sec *));
1539
1540   bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
1541                     struct bfd_seclet *, bfd_byte *data,
1542                     boolean relocateable));
1543
1544   boolean    (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
1545                     struct symbol_cache_entry **));
1546
1547   boolean    (*_bfd_seclet_link) PARAMS ((bfd *, PTR data,
1548                      boolean relocateable));
1549   /* See documentation on reloc types.  */
1550  CONST struct reloc_howto_struct *
1551        (*reloc_type_lookup) PARAMS ((bfd *abfd,
1552                                      bfd_reloc_code_real_type code));
1553
1554   /* Back-door to allow format-aware applications to create debug symbols
1555     while using BFD for everything else.  Currently used by the assembler
1556     when creating COFF files.  */
1557  asymbol *  (*_bfd_make_debug_symbol) PARAMS ((
1558        bfd *abfd,
1559        void *ptr,
1560        unsigned long size));
1561  PTR backend_data;
1562 } bfd_target;
1563 bfd_target *
1564 bfd_find_target PARAMS ((CONST char *, bfd *));
1565
1566 CONST char **
1567 bfd_target_list PARAMS ((void));
1568
1569 boolean 
1570 bfd_check_format PARAMS ((bfd *abfd, bfd_format format));
1571
1572 boolean 
1573 bfd_set_format PARAMS ((bfd *, bfd_format));
1574
1575 CONST char *
1576 bfd_format_string PARAMS ((bfd_format));
1577
1578 #endif