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