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