daily update
[binutils.git] / bfd / bfd-in.h
blob3b1f9abfd65118efb000940b774f4a0f09f3c361
1 /* Main header file for the bfd library -- portable access to object files.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002
4 Free Software Foundation, Inc.
5 Contributed by Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #ifndef __BFD_H_SEEN__
24 #define __BFD_H_SEEN__
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
30 #include "ansidecl.h"
31 #include "symcat.h"
32 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
33 #ifndef SABER
34 /* This hack is to avoid a problem with some strict ANSI C preprocessors.
35 The problem is, "32_" is not a valid preprocessing token, and we don't
36 want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will
37 cause the inner CONCAT2 macros to be evaluated first, producing
38 still-valid pp-tokens. Then the final concatenation can be done. */
39 #undef CONCAT4
40 #define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
41 #endif
42 #endif
44 /* The word size used by BFD on the host. This may be 64 with a 32
45 bit target if the host is 64 bit, or if other 64 bit targets have
46 been selected with --enable-targets, or if --enable-64-bit-bfd. */
47 #define BFD_ARCH_SIZE @wordsize@
49 /* The word size of the default bfd target. */
50 #define BFD_DEFAULT_TARGET_SIZE @bfd_default_target_size@
52 #define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
53 #if @BFD_HOST_64_BIT_DEFINED@
54 #define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
55 #define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
56 #endif
58 #if BFD_ARCH_SIZE >= 64
59 #define BFD64
60 #endif
62 #ifndef INLINE
63 #if __GNUC__ >= 2
64 #define INLINE __inline__
65 #else
66 #define INLINE
67 #endif
68 #endif
70 /* Forward declaration. */
71 typedef struct _bfd bfd;
73 /* Boolean type used in bfd. Too many systems define their own
74 versions of "boolean" for us to safely typedef a "boolean" of
75 our own. Using an enum for "bfd_boolean" has its own set of
76 problems, with strange looking casts required to avoid warnings
77 on some older compilers. Thus we just use an int.
79 General rule: Functions which are bfd_boolean return TRUE on
80 success and FALSE on failure (unless they're a predicate). */
82 typedef int bfd_boolean;
83 #undef FALSE
84 #undef TRUE
85 #define FALSE 0
86 #define TRUE 1
88 #if 0
89 /* Poison. */
90 #undef false
91 #undef true
92 #define false dont_use_false_in_bfd
93 #define true dont_use_true_in_bfd
94 #endif
96 /* Support for different sizes of target format ints and addresses.
97 If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
98 set to 1 above. Otherwise, if gcc is being used, this code will
99 use gcc's "long long" type. Otherwise, BFD_HOST_64_BIT must be
100 defined above. */
102 #ifndef BFD_HOST_64_BIT
103 # if BFD_HOST_64BIT_LONG
104 # define BFD_HOST_64_BIT long
105 # define BFD_HOST_U_64_BIT unsigned long
106 # else
107 # ifdef __GNUC__
108 # if __GNUC__ >= 2
109 # define BFD_HOST_64_BIT long long
110 # define BFD_HOST_U_64_BIT unsigned long long
111 # endif /* __GNUC__ >= 2 */
112 # endif /* ! defined (__GNUC__) */
113 # endif /* ! BFD_HOST_64BIT_LONG */
114 #endif /* ! defined (BFD_HOST_64_BIT) */
116 #ifdef BFD64
118 #ifndef BFD_HOST_64_BIT
119 #error No 64 bit integer type available
120 #endif /* ! defined (BFD_HOST_64_BIT) */
122 typedef BFD_HOST_U_64_BIT bfd_vma;
123 typedef BFD_HOST_64_BIT bfd_signed_vma;
124 typedef BFD_HOST_U_64_BIT bfd_size_type;
125 typedef BFD_HOST_U_64_BIT symvalue;
127 #ifndef fprintf_vma
128 #if BFD_HOST_64BIT_LONG
129 #define sprintf_vma(s,x) sprintf (s, "%016lx", x)
130 #define fprintf_vma(f,x) fprintf (f, "%016lx", x)
131 #else
132 #define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
133 #define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
134 #define fprintf_vma(s,x) \
135 fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
136 #define sprintf_vma(s,x) \
137 sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
138 #endif
139 #endif
141 #else /* not BFD64 */
143 /* Represent a target address. Also used as a generic unsigned type
144 which is guaranteed to be big enough to hold any arithmetic types
145 we need to deal with. */
146 typedef unsigned long bfd_vma;
148 /* A generic signed type which is guaranteed to be big enough to hold any
149 arithmetic types we need to deal with. Can be assumed to be compatible
150 with bfd_vma in the same way that signed and unsigned ints are compatible
151 (as parameters, in assignment, etc). */
152 typedef long bfd_signed_vma;
154 typedef unsigned long symvalue;
155 typedef unsigned long bfd_size_type;
157 /* Print a bfd_vma x on stream s. */
158 #define fprintf_vma(s,x) fprintf (s, "%08lx", x)
159 #define sprintf_vma(s,x) sprintf (s, "%08lx", x)
161 #endif /* not BFD64 */
163 /* A pointer to a position in a file. */
164 /* FIXME: This should be using off_t from <sys/types.h>.
165 For now, try to avoid breaking stuff by not including <sys/types.h> here.
166 This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
167 Probably the best long-term answer is to avoid using file_ptr AND off_t
168 in this header file, and to handle this in the BFD implementation
169 rather than in its interface. */
170 /* typedef off_t file_ptr; */
171 typedef bfd_signed_vma file_ptr;
172 typedef bfd_vma ufile_ptr;
174 extern void bfd_sprintf_vma
175 PARAMS ((bfd *, char *, bfd_vma));
176 extern void bfd_fprintf_vma
177 PARAMS ((bfd *, PTR, bfd_vma));
179 #define printf_vma(x) fprintf_vma(stdout,x)
180 #define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
182 typedef unsigned int flagword; /* 32 bits of flags */
183 typedef unsigned char bfd_byte;
185 /* File formats. */
187 typedef enum bfd_format
189 bfd_unknown = 0, /* File format is unknown. */
190 bfd_object, /* Linker/assember/compiler output. */
191 bfd_archive, /* Object archive file. */
192 bfd_core, /* Core dump. */
193 bfd_type_end /* Marks the end; don't use it! */
195 bfd_format;
197 /* Values that may appear in the flags field of a BFD. These also
198 appear in the object_flags field of the bfd_target structure, where
199 they indicate the set of flags used by that backend (not all flags
200 are meaningful for all object file formats) (FIXME: at the moment,
201 the object_flags values have mostly just been copied from backend
202 to another, and are not necessarily correct). */
204 /* No flags. */
205 #define BFD_NO_FLAGS 0x00
207 /* BFD contains relocation entries. */
208 #define HAS_RELOC 0x01
210 /* BFD is directly executable. */
211 #define EXEC_P 0x02
213 /* BFD has line number information (basically used for F_LNNO in a
214 COFF header). */
215 #define HAS_LINENO 0x04
217 /* BFD has debugging information. */
218 #define HAS_DEBUG 0x08
220 /* BFD has symbols. */
221 #define HAS_SYMS 0x10
223 /* BFD has local symbols (basically used for F_LSYMS in a COFF
224 header). */
225 #define HAS_LOCALS 0x20
227 /* BFD is a dynamic object. */
228 #define DYNAMIC 0x40
230 /* Text section is write protected (if D_PAGED is not set, this is
231 like an a.out NMAGIC file) (the linker sets this by default, but
232 clears it for -r or -N). */
233 #define WP_TEXT 0x80
235 /* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
236 linker sets this by default, but clears it for -r or -n or -N). */
237 #define D_PAGED 0x100
239 /* BFD is relaxable (this means that bfd_relax_section may be able to
240 do something) (sometimes bfd_relax_section can do something even if
241 this is not set). */
242 #define BFD_IS_RELAXABLE 0x200
244 /* This may be set before writing out a BFD to request using a
245 traditional format. For example, this is used to request that when
246 writing out an a.out object the symbols not be hashed to eliminate
247 duplicates. */
248 #define BFD_TRADITIONAL_FORMAT 0x400
250 /* This flag indicates that the BFD contents are actually cached in
251 memory. If this is set, iostream points to a bfd_in_memory struct. */
252 #define BFD_IN_MEMORY 0x800
254 /* The sections in this BFD specify a memory page. */
255 #define HAS_LOAD_PAGE 0x1000
257 /* Symbols and relocation. */
259 /* A count of carsyms (canonical archive symbols). */
260 typedef unsigned long symindex;
262 /* How to perform a relocation. */
263 typedef const struct reloc_howto_struct reloc_howto_type;
265 #define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
267 /* General purpose part of a symbol X;
268 target specific parts are in libcoff.h, libaout.h, etc. */
270 #define bfd_get_section(x) ((x)->section)
271 #define bfd_get_output_section(x) ((x)->section->output_section)
272 #define bfd_set_section(x,y) ((x)->section) = (y)
273 #define bfd_asymbol_base(x) ((x)->section->vma)
274 #define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
275 #define bfd_asymbol_name(x) ((x)->name)
276 /*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
277 #define bfd_asymbol_bfd(x) ((x)->the_bfd)
278 #define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
280 /* A canonical archive symbol. */
281 /* This is a type pun with struct ranlib on purpose! */
282 typedef struct carsym
284 char *name;
285 file_ptr file_offset; /* Look here to find the file. */
287 carsym; /* To make these you call a carsymogen. */
289 /* Used in generating armaps (archive tables of contents).
290 Perhaps just a forward definition would do? */
291 struct orl /* Output ranlib. */
293 char **name; /* Symbol name. */
294 union
296 file_ptr pos;
297 bfd *abfd;
298 } u; /* bfd* or file position. */
299 int namidx; /* Index into string table. */
302 /* Linenumber stuff. */
303 typedef struct lineno_cache_entry
305 unsigned int line_number; /* Linenumber from start of function. */
306 union
308 struct symbol_cache_entry *sym; /* Function name. */
309 bfd_vma offset; /* Offset into section. */
310 } u;
312 alent;
314 /* Object and core file sections. */
316 #define align_power(addr, align) \
317 (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
319 typedef struct sec *sec_ptr;
321 #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
322 #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
323 #define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
324 #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
325 #define bfd_section_name(bfd, ptr) ((ptr)->name)
326 #define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
327 #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
328 #define bfd_section_lma(bfd, ptr) ((ptr)->lma)
329 #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
330 #define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
331 #define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
333 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
335 #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
336 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
337 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
339 typedef struct stat stat_type;
341 typedef enum bfd_print_symbol
343 bfd_print_symbol_name,
344 bfd_print_symbol_more,
345 bfd_print_symbol_all
346 } bfd_print_symbol_type;
348 /* Information about a symbol that nm needs. */
350 typedef struct _symbol_info
352 symvalue value;
353 char type;
354 const char *name; /* Symbol name. */
355 unsigned char stab_type; /* Stab type. */
356 char stab_other; /* Stab other. */
357 short stab_desc; /* Stab desc. */
358 const char *stab_name; /* String for stab type. */
359 } symbol_info;
361 /* Get the name of a stabs type code. */
363 extern const char *bfd_get_stab_name
364 PARAMS ((int));
366 /* Hash table routines. There is no way to free up a hash table. */
368 /* An element in the hash table. Most uses will actually use a larger
369 structure, and an instance of this will be the first field. */
371 struct bfd_hash_entry
373 /* Next entry for this hash code. */
374 struct bfd_hash_entry *next;
375 /* String being hashed. */
376 const char *string;
377 /* Hash code. This is the full hash code, not the index into the
378 table. */
379 unsigned long hash;
382 /* A hash table. */
384 struct bfd_hash_table
386 /* The hash array. */
387 struct bfd_hash_entry **table;
388 /* The number of slots in the hash table. */
389 unsigned int size;
390 /* A function used to create new elements in the hash table. The
391 first entry is itself a pointer to an element. When this
392 function is first invoked, this pointer will be NULL. However,
393 having the pointer permits a hierarchy of method functions to be
394 built each of which calls the function in the superclass. Thus
395 each function should be written to allocate a new block of memory
396 only if the argument is NULL. */
397 struct bfd_hash_entry *(*newfunc)
398 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
399 /* An objalloc for this hash table. This is a struct objalloc *,
400 but we use PTR to avoid requiring the inclusion of objalloc.h. */
401 PTR memory;
404 /* Initialize a hash table. */
405 extern bfd_boolean bfd_hash_table_init
406 PARAMS ((struct bfd_hash_table *,
407 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
408 struct bfd_hash_table *,
409 const char *)));
411 /* Initialize a hash table specifying a size. */
412 extern bfd_boolean bfd_hash_table_init_n
413 PARAMS ((struct bfd_hash_table *,
414 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
415 struct bfd_hash_table *,
416 const char *),
417 unsigned int size));
419 /* Free up a hash table. */
420 extern void bfd_hash_table_free
421 PARAMS ((struct bfd_hash_table *));
423 /* Look up a string in a hash table. If CREATE is TRUE, a new entry
424 will be created for this string if one does not already exist. The
425 COPY argument must be TRUE if this routine should copy the string
426 into newly allocated memory when adding an entry. */
427 extern struct bfd_hash_entry *bfd_hash_lookup
428 PARAMS ((struct bfd_hash_table *, const char *, bfd_boolean create,
429 bfd_boolean copy));
431 /* Replace an entry in a hash table. */
432 extern void bfd_hash_replace
433 PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old,
434 struct bfd_hash_entry *nw));
436 /* Base method for creating a hash table entry. */
437 extern struct bfd_hash_entry *bfd_hash_newfunc
438 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
439 const char *));
441 /* Grab some space for a hash table entry. */
442 extern PTR bfd_hash_allocate
443 PARAMS ((struct bfd_hash_table *, unsigned int));
445 /* Traverse a hash table in a random order, calling a function on each
446 element. If the function returns FALSE, the traversal stops. The
447 INFO argument is passed to the function. */
448 extern void bfd_hash_traverse
449 PARAMS ((struct bfd_hash_table *,
450 bfd_boolean (*) (struct bfd_hash_entry *, PTR),
451 PTR info));
453 #define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
455 /* User program access to BFD facilities. */
457 /* Direct I/O routines, for programs which know more about the object
458 file than BFD does. Use higher level routines if possible. */
460 extern bfd_size_type bfd_bread
461 PARAMS ((PTR, bfd_size_type, bfd *));
462 extern bfd_size_type bfd_bwrite
463 PARAMS ((const PTR, bfd_size_type, bfd *));
464 extern int bfd_seek
465 PARAMS ((bfd *, file_ptr, int));
466 extern ufile_ptr bfd_tell
467 PARAMS ((bfd *));
468 extern int bfd_flush
469 PARAMS ((bfd *));
470 extern int bfd_stat
471 PARAMS ((bfd *, struct stat *));
473 /* Deprecated old routines. */
474 #if __GNUC__
475 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
476 (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
477 bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
478 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
479 (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
480 bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
481 #else
482 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
483 (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
484 bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
485 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
486 (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
487 bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
488 #endif
489 extern void warn_deprecated
490 PARAMS ((const char *, const char *, int, const char *));
492 /* Cast from const char * to char * so that caller can assign to
493 a char * without a warning. */
494 #define bfd_get_filename(abfd) ((char *) (abfd)->filename)
495 #define bfd_get_cacheable(abfd) ((abfd)->cacheable)
496 #define bfd_get_format(abfd) ((abfd)->format)
497 #define bfd_get_target(abfd) ((abfd)->xvec->name)
498 #define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
499 #define bfd_family_coff(abfd) \
500 (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
501 bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
502 #define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
503 #define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
504 #define bfd_header_big_endian(abfd) \
505 ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
506 #define bfd_header_little_endian(abfd) \
507 ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
508 #define bfd_get_file_flags(abfd) ((abfd)->flags)
509 #define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
510 #define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
511 #define bfd_my_archive(abfd) ((abfd)->my_archive)
512 #define bfd_has_map(abfd) ((abfd)->has_armap)
514 #define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
515 #define bfd_usrdata(abfd) ((abfd)->usrdata)
517 #define bfd_get_start_address(abfd) ((abfd)->start_address)
518 #define bfd_get_symcount(abfd) ((abfd)->symcount)
519 #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
520 #define bfd_count_sections(abfd) ((abfd)->section_count)
522 #define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
524 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
526 #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
528 extern bfd_boolean bfd_cache_close
529 PARAMS ((bfd *abfd));
530 /* NB: This declaration should match the autogenerated one in libbfd.h. */
532 extern bfd_boolean bfd_record_phdr
533 PARAMS ((bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
534 bfd_boolean, bfd_boolean, unsigned int, struct sec **));
536 /* Byte swapping routines. */
538 bfd_vma bfd_getb64
539 PARAMS ((const unsigned char *));
540 bfd_vma bfd_getl64
541 PARAMS ((const unsigned char *));
542 bfd_signed_vma bfd_getb_signed_64
543 PARAMS ((const unsigned char *));
544 bfd_signed_vma bfd_getl_signed_64
545 PARAMS ((const unsigned char *));
546 bfd_vma bfd_getb32
547 PARAMS ((const unsigned char *));
548 bfd_vma bfd_getl32
549 PARAMS ((const unsigned char *));
550 bfd_signed_vma bfd_getb_signed_32
551 PARAMS ((const unsigned char *));
552 bfd_signed_vma bfd_getl_signed_32
553 PARAMS ((const unsigned char *));
554 bfd_vma bfd_getb16
555 PARAMS ((const unsigned char *));
556 bfd_vma bfd_getl16
557 PARAMS ((const unsigned char *));
558 bfd_signed_vma bfd_getb_signed_16
559 PARAMS ((const unsigned char *));
560 bfd_signed_vma bfd_getl_signed_16
561 PARAMS ((const unsigned char *));
562 void bfd_putb64
563 PARAMS ((bfd_vma, unsigned char *));
564 void bfd_putl64
565 PARAMS ((bfd_vma, unsigned char *));
566 void bfd_putb32
567 PARAMS ((bfd_vma, unsigned char *));
568 void bfd_putl32
569 PARAMS ((bfd_vma, unsigned char *));
570 void bfd_putb16
571 PARAMS ((bfd_vma, unsigned char *));
572 void bfd_putl16
573 PARAMS ((bfd_vma, unsigned char *));
575 /* Byte swapping routines which take size and endiannes as arguments. */
577 bfd_vma bfd_get_bits
578 PARAMS ((bfd_byte *, int, bfd_boolean));
579 void bfd_put_bits
580 PARAMS ((bfd_vma, bfd_byte *, int, bfd_boolean));
582 /* Externally visible ECOFF routines. */
584 #if defined(__STDC__) || defined(ALMOST_STDC)
585 struct ecoff_debug_info;
586 struct ecoff_debug_swap;
587 struct ecoff_extr;
588 struct symbol_cache_entry;
589 struct bfd_link_info;
590 struct bfd_link_hash_entry;
591 struct bfd_elf_version_tree;
592 #endif
593 extern bfd_vma bfd_ecoff_get_gp_value
594 PARAMS ((bfd * abfd));
595 extern bfd_boolean bfd_ecoff_set_gp_value
596 PARAMS ((bfd *abfd, bfd_vma gp_value));
597 extern bfd_boolean bfd_ecoff_set_regmasks
598 PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
599 unsigned long *cprmask));
600 extern PTR bfd_ecoff_debug_init
601 PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
602 const struct ecoff_debug_swap *output_swap,
603 struct bfd_link_info *));
604 extern void bfd_ecoff_debug_free
605 PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
606 const struct ecoff_debug_swap *output_swap,
607 struct bfd_link_info *));
608 extern bfd_boolean bfd_ecoff_debug_accumulate
609 PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
610 const struct ecoff_debug_swap *output_swap,
611 bfd *input_bfd, struct ecoff_debug_info *input_debug,
612 const struct ecoff_debug_swap *input_swap,
613 struct bfd_link_info *));
614 extern bfd_boolean bfd_ecoff_debug_accumulate_other
615 PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
616 const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
617 struct bfd_link_info *));
618 extern bfd_boolean bfd_ecoff_debug_externals
619 PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
620 const struct ecoff_debug_swap *swap,
621 bfd_boolean relocateable,
622 bfd_boolean (*get_extr) (struct symbol_cache_entry *,
623 struct ecoff_extr *),
624 void (*set_index) (struct symbol_cache_entry *,
625 bfd_size_type)));
626 extern bfd_boolean bfd_ecoff_debug_one_external
627 PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
628 const struct ecoff_debug_swap *swap,
629 const char *name, struct ecoff_extr *esym));
630 extern bfd_size_type bfd_ecoff_debug_size
631 PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
632 const struct ecoff_debug_swap *swap));
633 extern bfd_boolean bfd_ecoff_write_debug
634 PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
635 const struct ecoff_debug_swap *swap, file_ptr where));
636 extern bfd_boolean bfd_ecoff_write_accumulated_debug
637 PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
638 const struct ecoff_debug_swap *swap,
639 struct bfd_link_info *info, file_ptr where));
640 extern bfd_boolean bfd_mips_ecoff_create_embedded_relocs
641 PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
642 char **));
644 /* Externally visible ELF routines. */
646 struct bfd_link_needed_list
648 struct bfd_link_needed_list *next;
649 bfd *by;
650 const char *name;
653 extern bfd_boolean bfd_elf32_record_link_assignment
654 PARAMS ((bfd *, struct bfd_link_info *, const char *, bfd_boolean));
655 extern bfd_boolean bfd_elf64_record_link_assignment
656 PARAMS ((bfd *, struct bfd_link_info *, const char *, bfd_boolean));
657 extern struct bfd_link_needed_list *bfd_elf_get_needed_list
658 PARAMS ((bfd *, struct bfd_link_info *));
659 extern bfd_boolean bfd_elf_get_bfd_needed_list
660 PARAMS ((bfd *, struct bfd_link_needed_list **));
661 extern bfd_boolean bfd_elf32_size_dynamic_sections
662 PARAMS ((bfd *, const char *, const char *, const char *,
663 const char * const *, struct bfd_link_info *, struct sec **,
664 struct bfd_elf_version_tree *));
665 extern bfd_boolean bfd_elf64_size_dynamic_sections
666 PARAMS ((bfd *, const char *, const char *, const char *,
667 const char * const *, struct bfd_link_info *, struct sec **,
668 struct bfd_elf_version_tree *));
669 extern void bfd_elf_set_dt_needed_name
670 PARAMS ((bfd *, const char *));
671 extern void bfd_elf_set_dt_needed_soname
672 PARAMS ((bfd *, const char *));
673 extern const char *bfd_elf_get_dt_soname
674 PARAMS ((bfd *));
675 extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
676 PARAMS ((bfd *, struct bfd_link_info *));
677 extern bfd_boolean bfd_elf32_discard_info
678 PARAMS ((bfd *, struct bfd_link_info *));
679 extern bfd_boolean bfd_elf64_discard_info
680 PARAMS ((bfd *, struct bfd_link_info *));
682 /* Return an upper bound on the number of bytes required to store a
683 copy of ABFD's program header table entries. Return -1 if an error
684 occurs; bfd_get_error will return an appropriate code. */
685 extern long bfd_get_elf_phdr_upper_bound
686 PARAMS ((bfd *abfd));
688 /* Copy ABFD's program header table entries to *PHDRS. The entries
689 will be stored as an array of Elf_Internal_Phdr structures, as
690 defined in include/elf/internal.h. To find out how large the
691 buffer needs to be, call bfd_get_elf_phdr_upper_bound.
693 Return the number of program header table entries read, or -1 if an
694 error occurs; bfd_get_error will return an appropriate code. */
695 extern int bfd_get_elf_phdrs
696 PARAMS ((bfd *abfd, void *phdrs));
698 /* Return the arch_size field of an elf bfd, or -1 if not elf. */
699 extern int bfd_get_arch_size
700 PARAMS ((bfd *));
702 /* Return TRUE if address "naturally" sign extends, or -1 if not elf. */
703 extern int bfd_get_sign_extend_vma
704 PARAMS ((bfd *));
706 extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
707 PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
708 char **));
709 extern bfd_boolean bfd_mips_elf32_create_embedded_relocs
710 PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
711 char **));
713 /* SunOS shared library support routines for the linker. */
715 extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
716 PARAMS ((bfd *, struct bfd_link_info *));
717 extern bfd_boolean bfd_sunos_record_link_assignment
718 PARAMS ((bfd *, struct bfd_link_info *, const char *));
719 extern bfd_boolean bfd_sunos_size_dynamic_sections
720 PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **,
721 struct sec **));
723 /* Linux shared library support routines for the linker. */
725 extern bfd_boolean bfd_i386linux_size_dynamic_sections
726 PARAMS ((bfd *, struct bfd_link_info *));
727 extern bfd_boolean bfd_m68klinux_size_dynamic_sections
728 PARAMS ((bfd *, struct bfd_link_info *));
729 extern bfd_boolean bfd_sparclinux_size_dynamic_sections
730 PARAMS ((bfd *, struct bfd_link_info *));
732 /* mmap hacks */
734 struct _bfd_window_internal;
735 typedef struct _bfd_window_internal bfd_window_internal;
737 typedef struct _bfd_window
739 /* What the user asked for. */
740 PTR data;
741 bfd_size_type size;
742 /* The actual window used by BFD. Small user-requested read-only
743 regions sharing a page may share a single window into the object
744 file. Read-write versions shouldn't until I've fixed things to
745 keep track of which portions have been claimed by the
746 application; don't want to give the same region back when the
747 application wants two writable copies! */
748 struct _bfd_window_internal *i;
750 bfd_window;
752 extern void bfd_init_window
753 PARAMS ((bfd_window *));
754 extern void bfd_free_window
755 PARAMS ((bfd_window *));
756 extern bfd_boolean bfd_get_file_window
757 PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean));
759 /* XCOFF support routines for the linker. */
761 extern bfd_boolean bfd_xcoff_link_record_set
762 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
763 bfd_size_type));
764 extern bfd_boolean bfd_xcoff_import_symbol
765 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
766 bfd_vma, const char *, const char *, const char *, unsigned int));
767 extern bfd_boolean bfd_xcoff_export_symbol
768 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *));
769 extern bfd_boolean bfd_xcoff_link_count_reloc
770 PARAMS ((bfd *, struct bfd_link_info *, const char *));
771 extern bfd_boolean bfd_xcoff_record_link_assignment
772 PARAMS ((bfd *, struct bfd_link_info *, const char *));
773 extern bfd_boolean bfd_xcoff_size_dynamic_sections
774 PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
775 unsigned long, unsigned long, unsigned long, bfd_boolean,
776 int, bfd_boolean, bfd_boolean, struct sec **, bfd_boolean));
777 extern bfd_boolean bfd_xcoff_link_generate_rtinit
778 PARAMS ((bfd *, const char *, const char *, bfd_boolean));
780 /* XCOFF support routines for ar. */
781 extern bfd_boolean bfd_xcoff_ar_archive_set_magic
782 PARAMS ((bfd *, char *));
784 /* Externally visible COFF routines. */
786 #if defined(__STDC__) || defined(ALMOST_STDC)
787 struct internal_syment;
788 union internal_auxent;
789 #endif
791 extern bfd_boolean bfd_coff_get_syment
792 PARAMS ((bfd *, struct symbol_cache_entry *, struct internal_syment *));
794 extern bfd_boolean bfd_coff_get_auxent
795 PARAMS ((bfd *, struct symbol_cache_entry *, int, union internal_auxent *));
797 extern bfd_boolean bfd_coff_set_symbol_class
798 PARAMS ((bfd *, struct symbol_cache_entry *, unsigned int));
800 extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
801 PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
802 char **));
804 /* ARM Interworking support. Called from linker. */
805 extern bfd_boolean bfd_arm_allocate_interworking_sections
806 PARAMS ((struct bfd_link_info *));
808 extern bfd_boolean bfd_arm_process_before_allocation
809 PARAMS ((bfd *, struct bfd_link_info *, int));
811 extern bfd_boolean bfd_arm_get_bfd_for_interworking
812 PARAMS ((bfd *, struct bfd_link_info *));
814 /* PE ARM Interworking support. Called from linker. */
815 extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
816 PARAMS ((struct bfd_link_info *));
818 extern bfd_boolean bfd_arm_pe_process_before_allocation
819 PARAMS ((bfd *, struct bfd_link_info *, int));
821 extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
822 PARAMS ((bfd *, struct bfd_link_info *));
824 /* ELF ARM Interworking support. Called from linker. */
825 extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
826 PARAMS ((struct bfd_link_info *));
828 extern bfd_boolean bfd_elf32_arm_process_before_allocation
829 PARAMS ((bfd *, struct bfd_link_info *, int));
831 extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
832 PARAMS ((bfd *, struct bfd_link_info *));
834 extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
835 PARAMS ((bfd *, struct bfd_link_info *));
837 /* TI COFF load page support. */
838 extern void bfd_ticoff_set_section_load_page
839 PARAMS ((struct sec *, int));
841 extern int bfd_ticoff_get_section_load_page
842 PARAMS ((struct sec *));