Oops, revert unintended commit. Next patch will do this properly.
[deliverable/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
c58b9523
AM
175extern void bfd_sprintf_vma (bfd *, char *, bfd_vma);
176extern void bfd_fprintf_vma (bfd *, void *, bfd_vma);
ae4221d7 177
252b5132 178#define printf_vma(x) fprintf_vma(stdout,x)
ae4221d7 179#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
252b5132
RH
180
181typedef unsigned int flagword; /* 32 bits of flags */
182typedef unsigned char bfd_byte;
183\f
b5f79c76 184/* File formats. */
252b5132 185
b5f79c76
NC
186typedef enum bfd_format
187{
188 bfd_unknown = 0, /* File format is unknown. */
189 bfd_object, /* Linker/assember/compiler output. */
190 bfd_archive, /* Object archive file. */
191 bfd_core, /* Core dump. */
192 bfd_type_end /* Marks the end; don't use it! */
193}
194bfd_format;
252b5132
RH
195
196/* Values that may appear in the flags field of a BFD. These also
197 appear in the object_flags field of the bfd_target structure, where
198 they indicate the set of flags used by that backend (not all flags
199 are meaningful for all object file formats) (FIXME: at the moment,
200 the object_flags values have mostly just been copied from backend
201 to another, and are not necessarily correct). */
202
203/* No flags. */
204#define BFD_NO_FLAGS 0x00
205
206/* BFD contains relocation entries. */
207#define HAS_RELOC 0x01
208
209/* BFD is directly executable. */
210#define EXEC_P 0x02
211
212/* BFD has line number information (basically used for F_LNNO in a
213 COFF header). */
214#define HAS_LINENO 0x04
215
216/* BFD has debugging information. */
217#define HAS_DEBUG 0x08
218
219/* BFD has symbols. */
220#define HAS_SYMS 0x10
221
222/* BFD has local symbols (basically used for F_LSYMS in a COFF
223 header). */
224#define HAS_LOCALS 0x20
225
226/* BFD is a dynamic object. */
227#define DYNAMIC 0x40
228
229/* Text section is write protected (if D_PAGED is not set, this is
230 like an a.out NMAGIC file) (the linker sets this by default, but
231 clears it for -r or -N). */
232#define WP_TEXT 0x80
233
234/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
235 linker sets this by default, but clears it for -r or -n or -N). */
236#define D_PAGED 0x100
237
238/* BFD is relaxable (this means that bfd_relax_section may be able to
239 do something) (sometimes bfd_relax_section can do something even if
240 this is not set). */
241#define BFD_IS_RELAXABLE 0x200
242
243/* This may be set before writing out a BFD to request using a
244 traditional format. For example, this is used to request that when
245 writing out an a.out object the symbols not be hashed to eliminate
246 duplicates. */
247#define BFD_TRADITIONAL_FORMAT 0x400
248
249/* This flag indicates that the BFD contents are actually cached in
250 memory. If this is set, iostream points to a bfd_in_memory struct. */
251#define BFD_IN_MEMORY 0x800
b34976b6 252
026df7c5
NC
253/* The sections in this BFD specify a memory page. */
254#define HAS_LOAD_PAGE 0x1000
252b5132 255\f
b5f79c76 256/* Symbols and relocation. */
252b5132
RH
257
258/* A count of carsyms (canonical archive symbols). */
259typedef unsigned long symindex;
260
261/* How to perform a relocation. */
262typedef const struct reloc_howto_struct reloc_howto_type;
263
264#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
265
266/* General purpose part of a symbol X;
267 target specific parts are in libcoff.h, libaout.h, etc. */
268
269#define bfd_get_section(x) ((x)->section)
270#define bfd_get_output_section(x) ((x)->section->output_section)
271#define bfd_set_section(x,y) ((x)->section) = (y)
272#define bfd_asymbol_base(x) ((x)->section->vma)
273#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
274#define bfd_asymbol_name(x) ((x)->name)
275/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
276#define bfd_asymbol_bfd(x) ((x)->the_bfd)
277#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
278
279/* A canonical archive symbol. */
b5f79c76
NC
280/* This is a type pun with struct ranlib on purpose! */
281typedef struct carsym
282{
252b5132 283 char *name;
b5f79c76
NC
284 file_ptr file_offset; /* Look here to find the file. */
285}
286carsym; /* To make these you call a carsymogen. */
252b5132 287
252b5132 288/* Used in generating armaps (archive tables of contents).
b5f79c76
NC
289 Perhaps just a forward definition would do? */
290struct orl /* Output ranlib. */
291{
292 char **name; /* Symbol name. */
293 union
294 {
dc810e39
AM
295 file_ptr pos;
296 bfd *abfd;
b5f79c76
NC
297 } u; /* bfd* or file position. */
298 int namidx; /* Index into string table. */
252b5132
RH
299};
300\f
b5f79c76
NC
301/* Linenumber stuff. */
302typedef struct lineno_cache_entry
303{
304 unsigned int line_number; /* Linenumber from start of function. */
305 union
306 {
307 struct symbol_cache_entry *sym; /* Function name. */
308 bfd_vma offset; /* Offset into section. */
252b5132 309 } u;
b5f79c76
NC
310}
311alent;
252b5132 312\f
b5f79c76 313/* Object and core file sections. */
252b5132
RH
314
315#define align_power(addr, align) \
e5b45b83 316 (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
252b5132
RH
317
318typedef struct sec *sec_ptr;
319
320#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
321#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
0c04d169 322#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
252b5132
RH
323#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
324#define bfd_section_name(bfd, ptr) ((ptr)->name)
325#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
326#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
327#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
328#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
329#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
330#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
331
332#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
333
b34976b6
AM
334#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
335#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
336#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
252b5132 337
60bcf0fa 338typedef struct stat stat_type;
252b5132
RH
339\f
340typedef enum bfd_print_symbol
60bcf0fa 341{
252b5132
RH
342 bfd_print_symbol_name,
343 bfd_print_symbol_more,
344 bfd_print_symbol_all
345} bfd_print_symbol_type;
60bcf0fa 346
252b5132
RH
347/* Information about a symbol that nm needs. */
348
349typedef struct _symbol_info
350{
351 symvalue value;
352 char type;
dc810e39 353 const char *name; /* Symbol name. */
252b5132 354 unsigned char stab_type; /* Stab type. */
8546af74 355 char stab_other; /* Stab other. */
252b5132 356 short stab_desc; /* Stab desc. */
dc810e39 357 const char *stab_name; /* String for stab type. */
252b5132
RH
358} symbol_info;
359
360/* Get the name of a stabs type code. */
361
c58b9523 362extern const char *bfd_get_stab_name (int);
252b5132
RH
363\f
364/* Hash table routines. There is no way to free up a hash table. */
365
366/* An element in the hash table. Most uses will actually use a larger
367 structure, and an instance of this will be the first field. */
368
369struct bfd_hash_entry
370{
371 /* Next entry for this hash code. */
372 struct bfd_hash_entry *next;
373 /* String being hashed. */
374 const char *string;
375 /* Hash code. This is the full hash code, not the index into the
376 table. */
377 unsigned long hash;
378};
379
380/* A hash table. */
381
382struct bfd_hash_table
383{
384 /* The hash array. */
385 struct bfd_hash_entry **table;
386 /* The number of slots in the hash table. */
387 unsigned int size;
388 /* A function used to create new elements in the hash table. The
389 first entry is itself a pointer to an element. When this
390 function is first invoked, this pointer will be NULL. However,
391 having the pointer permits a hierarchy of method functions to be
392 built each of which calls the function in the superclass. Thus
393 each function should be written to allocate a new block of memory
394 only if the argument is NULL. */
b34976b6 395 struct bfd_hash_entry *(*newfunc)
c58b9523 396 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
252b5132 397 /* An objalloc for this hash table. This is a struct objalloc *,
c58b9523
AM
398 but we use void * to avoid requiring the inclusion of objalloc.h. */
399 void *memory;
252b5132
RH
400};
401
402/* Initialize a hash table. */
b34976b6 403extern bfd_boolean bfd_hash_table_init
c58b9523
AM
404 (struct bfd_hash_table *,
405 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
406 struct bfd_hash_table *,
407 const char *));
252b5132
RH
408
409/* Initialize a hash table specifying a size. */
b34976b6 410extern bfd_boolean bfd_hash_table_init_n
c58b9523
AM
411 (struct bfd_hash_table *,
412 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
413 struct bfd_hash_table *,
414 const char *),
415 unsigned int size);
252b5132
RH
416
417/* Free up a hash table. */
b34976b6 418extern void bfd_hash_table_free
c58b9523 419 (struct bfd_hash_table *);
252b5132 420
b34976b6 421/* Look up a string in a hash table. If CREATE is TRUE, a new entry
252b5132 422 will be created for this string if one does not already exist. The
b34976b6 423 COPY argument must be TRUE if this routine should copy the string
252b5132
RH
424 into newly allocated memory when adding an entry. */
425extern struct bfd_hash_entry *bfd_hash_lookup
c58b9523
AM
426 (struct bfd_hash_table *, const char *, bfd_boolean create,
427 bfd_boolean copy);
252b5132
RH
428
429/* Replace an entry in a hash table. */
430extern void bfd_hash_replace
c58b9523
AM
431 (struct bfd_hash_table *, struct bfd_hash_entry *old,
432 struct bfd_hash_entry *nw);
252b5132
RH
433
434/* Base method for creating a hash table entry. */
435extern struct bfd_hash_entry *bfd_hash_newfunc
c58b9523 436 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
252b5132
RH
437
438/* Grab some space for a hash table entry. */
c58b9523
AM
439extern void *bfd_hash_allocate
440 (struct bfd_hash_table *, unsigned int);
252b5132
RH
441
442/* Traverse a hash table in a random order, calling a function on each
b34976b6 443 element. If the function returns FALSE, the traversal stops. The
252b5132 444 INFO argument is passed to the function. */
b34976b6 445extern void bfd_hash_traverse
c58b9523
AM
446 (struct bfd_hash_table *,
447 bfd_boolean (*) (struct bfd_hash_entry *, void *),
448 void *info);
252b5132 449
c58b9523 450#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
e43d48cc 451
b5f79c76 452/* User program access to BFD facilities. */
252b5132
RH
453
454/* Direct I/O routines, for programs which know more about the object
455 file than BFD does. Use higher level routines if possible. */
456
c58b9523
AM
457extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
458extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
459extern int bfd_seek (bfd *, file_ptr, int);
460extern ufile_ptr bfd_tell (bfd *);
461extern int bfd_flush (bfd *);
462extern int bfd_stat (bfd *, struct stat *);
dc810e39
AM
463
464/* Deprecated old routines. */
465#if __GNUC__
466#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
467 (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
468 bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
469#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
470 (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
471 bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
472#else
473#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
474 (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
475 bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
476#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
477 (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
478 bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
479#endif
c58b9523 480extern void warn_deprecated (const char *, const char *, int, const char *);
252b5132 481
252b5132
RH
482/* Cast from const char * to char * so that caller can assign to
483 a char * without a warning. */
484#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
485#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
486#define bfd_get_format(abfd) ((abfd)->format)
487#define bfd_get_target(abfd) ((abfd)->xvec->name)
488#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
9bd09e22
ND
489#define bfd_family_coff(abfd) \
490 (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
491 bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
252b5132
RH
492#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
493#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
494#define bfd_header_big_endian(abfd) \
495 ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
496#define bfd_header_little_endian(abfd) \
497 ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
498#define bfd_get_file_flags(abfd) ((abfd)->flags)
499#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
500#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
501#define bfd_my_archive(abfd) ((abfd)->my_archive)
502#define bfd_has_map(abfd) ((abfd)->has_armap)
503
504#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
505#define bfd_usrdata(abfd) ((abfd)->usrdata)
506
507#define bfd_get_start_address(abfd) ((abfd)->start_address)
508#define bfd_get_symcount(abfd) ((abfd)->symcount)
509#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
510#define bfd_count_sections(abfd) ((abfd)->section_count)
511
1f70368c
DJ
512#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
513
252b5132
RH
514#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
515
b34976b6 516#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
252b5132 517
b34976b6 518extern bfd_boolean bfd_cache_close
c58b9523 519 (bfd *abfd);
d436a9b3
FCE
520/* NB: This declaration should match the autogenerated one in libbfd.h. */
521
b34976b6 522extern bfd_boolean bfd_record_phdr
c58b9523
AM
523 (bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
524 bfd_boolean, bfd_boolean, unsigned int, struct sec **);
252b5132
RH
525
526/* Byte swapping routines. */
527
c58b9523
AM
528bfd_vma bfd_getb64 (const unsigned char *);
529bfd_vma bfd_getl64 (const unsigned char *);
530bfd_signed_vma bfd_getb_signed_64 (const unsigned char *);
531bfd_signed_vma bfd_getl_signed_64 (const unsigned char *);
532bfd_vma bfd_getb32 (const unsigned char *);
533bfd_vma bfd_getl32 (const unsigned char *);
534bfd_signed_vma bfd_getb_signed_32 (const unsigned char *);
535bfd_signed_vma bfd_getl_signed_32 (const unsigned char *);
536bfd_vma bfd_getb16 (const unsigned char *);
537bfd_vma bfd_getl16 (const unsigned char *);
538bfd_signed_vma bfd_getb_signed_16 (const unsigned char *);
539bfd_signed_vma bfd_getl_signed_16 (const unsigned char *);
540void bfd_putb64 (bfd_vma, unsigned char *);
541void bfd_putl64 (bfd_vma, unsigned char *);
542void bfd_putb32 (bfd_vma, unsigned char *);
543void bfd_putl32 (bfd_vma, unsigned char *);
544void bfd_putb16 (bfd_vma, unsigned char *);
545void bfd_putl16 (bfd_vma, unsigned char *);
8c603c85
NC
546
547/* Byte swapping routines which take size and endiannes as arguments. */
548
c58b9523
AM
549bfd_vma bfd_get_bits (bfd_byte *, int, bfd_boolean);
550void bfd_put_bits (bfd_vma, bfd_byte *, int, bfd_boolean);
252b5132
RH
551\f
552/* Externally visible ECOFF routines. */
553
554#if defined(__STDC__) || defined(ALMOST_STDC)
555struct ecoff_debug_info;
556struct ecoff_debug_swap;
557struct ecoff_extr;
558struct symbol_cache_entry;
559struct bfd_link_info;
560struct bfd_link_hash_entry;
561struct bfd_elf_version_tree;
562#endif
b34976b6 563extern bfd_vma bfd_ecoff_get_gp_value
c58b9523 564 (bfd * abfd);
b34976b6 565extern bfd_boolean bfd_ecoff_set_gp_value
c58b9523 566 (bfd *abfd, bfd_vma gp_value);
b34976b6 567extern bfd_boolean bfd_ecoff_set_regmasks
c58b9523
AM
568 (bfd *abfd, unsigned long gprmask, unsigned long fprmask,
569 unsigned long *cprmask);
570extern void *bfd_ecoff_debug_init
571 (bfd *output_bfd, struct ecoff_debug_info *output_debug,
572 const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
252b5132 573extern void bfd_ecoff_debug_free
c58b9523
AM
574 (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
575 const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
b34976b6 576extern bfd_boolean bfd_ecoff_debug_accumulate
c58b9523
AM
577 (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
578 const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
579 struct ecoff_debug_info *input_debug,
580 const struct ecoff_debug_swap *input_swap, struct bfd_link_info *);
b34976b6 581extern bfd_boolean bfd_ecoff_debug_accumulate_other
c58b9523
AM
582 (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
583 const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
584 struct bfd_link_info *);
b34976b6 585extern bfd_boolean bfd_ecoff_debug_externals
c58b9523
AM
586 (bfd *abfd, struct ecoff_debug_info *debug,
587 const struct ecoff_debug_swap *swap, bfd_boolean relocatable,
588 bfd_boolean (*get_extr) (struct symbol_cache_entry *, struct ecoff_extr *),
589 void (*set_index) (struct symbol_cache_entry *, bfd_size_type));
b34976b6 590extern bfd_boolean bfd_ecoff_debug_one_external
c58b9523
AM
591 (bfd *abfd, struct ecoff_debug_info *debug,
592 const struct ecoff_debug_swap *swap, const char *name,
593 struct ecoff_extr *esym);
252b5132 594extern bfd_size_type bfd_ecoff_debug_size
c58b9523
AM
595 (bfd *abfd, struct ecoff_debug_info *debug,
596 const struct ecoff_debug_swap *swap);
b34976b6 597extern bfd_boolean bfd_ecoff_write_debug
c58b9523
AM
598 (bfd *abfd, struct ecoff_debug_info *debug,
599 const struct ecoff_debug_swap *swap, file_ptr where);
b34976b6 600extern bfd_boolean bfd_ecoff_write_accumulated_debug
c58b9523
AM
601 (void *handle, bfd *abfd, struct ecoff_debug_info *debug,
602 const struct ecoff_debug_swap *swap,
603 struct bfd_link_info *info, file_ptr where);
b34976b6 604extern bfd_boolean bfd_mips_ecoff_create_embedded_relocs
c58b9523 605 (bfd *, struct bfd_link_info *, struct sec *, struct sec *, char **);
252b5132
RH
606
607/* Externally visible ELF routines. */
608
609struct bfd_link_needed_list
610{
611 struct bfd_link_needed_list *next;
612 bfd *by;
613 const char *name;
614};
615
45d6a902 616extern bfd_boolean bfd_elf_record_link_assignment
c58b9523 617 (bfd *, struct bfd_link_info *, const char *, bfd_boolean);
252b5132 618extern struct bfd_link_needed_list *bfd_elf_get_needed_list
c58b9523 619 (bfd *, struct bfd_link_info *);
b34976b6 620extern bfd_boolean bfd_elf_get_bfd_needed_list
c58b9523 621 (bfd *, struct bfd_link_needed_list **);
b34976b6 622extern bfd_boolean bfd_elf32_size_dynamic_sections
c58b9523
AM
623 (bfd *, const char *, const char *, const char *, const char * const *,
624 struct bfd_link_info *, struct sec **, struct bfd_elf_version_tree *);
b34976b6 625extern bfd_boolean bfd_elf64_size_dynamic_sections
c58b9523
AM
626 (bfd *, const char *, const char *, const char *, const char * const *,
627 struct bfd_link_info *, struct sec **, struct bfd_elf_version_tree *);
b34976b6 628extern void bfd_elf_set_dt_needed_name
c58b9523 629 (bfd *, const char *);
b34976b6 630extern void bfd_elf_set_dt_needed_soname
c58b9523 631 (bfd *, const char *);
b34976b6 632extern const char *bfd_elf_get_dt_soname
c58b9523 633 (bfd *);
a963dc6a 634extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
c58b9523 635 (bfd *, struct bfd_link_info *);
b34976b6 636extern bfd_boolean bfd_elf32_discard_info
c58b9523 637 (bfd *, struct bfd_link_info *);
b34976b6 638extern bfd_boolean bfd_elf64_discard_info
c58b9523 639 (bfd *, struct bfd_link_info *);
252b5132 640
7f8d5fc9
ILT
641/* Return an upper bound on the number of bytes required to store a
642 copy of ABFD's program header table entries. Return -1 if an error
643 occurs; bfd_get_error will return an appropriate code. */
b34976b6 644extern long bfd_get_elf_phdr_upper_bound
c58b9523 645 (bfd *abfd);
7f8d5fc9
ILT
646
647/* Copy ABFD's program header table entries to *PHDRS. The entries
648 will be stored as an array of Elf_Internal_Phdr structures, as
649 defined in include/elf/internal.h. To find out how large the
650 buffer needs to be, call bfd_get_elf_phdr_upper_bound.
651
652 Return the number of program header table entries read, or -1 if an
653 error occurs; bfd_get_error will return an appropriate code. */
b34976b6 654extern int bfd_get_elf_phdrs
c58b9523 655 (bfd *abfd, void *phdrs);
7f8d5fc9 656
8d6337fe
RM
657/* Create a new BFD as if by bfd_openr. Rather than opening a file,
658 reconstruct an ELF file by reading the segments out of remote memory
659 based on the ELF file header at EHDR_VMA and the ELF program headers it
660 points to. If not null, *LOADBASEP is filled in with the difference
661 between the VMAs from which the segments were read, and the VMAs the
662 file headers (and hence BFD's idea of each section's VMA) put them at.
663
664 The function TARGET_READ_MEMORY is called to copy LEN bytes from the
665 remote memory at target address VMA into the local buffer at MYADDR; it
666 should return zero on success or an `errno' code on failure. TEMPL must
667 be a BFD for an ELF target with the word size and byte order found in
668 the remote memory. */
669extern bfd *bfd_elf_bfd_from_remote_memory
c58b9523
AM
670 (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
671 int (*target_read_memory) (bfd_vma vma, char *myaddr, int len));
8d6337fe 672
3425c182 673/* Return the arch_size field of an elf bfd, or -1 if not elf. */
b34976b6 674extern int bfd_get_arch_size
c58b9523 675 (bfd *);
3425c182 676
b34976b6
AM
677/* Return TRUE if address "naturally" sign extends, or -1 if not elf. */
678extern int bfd_get_sign_extend_vma
c58b9523 679 (bfd *);
6d9019e4 680
b34976b6 681extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
c58b9523 682 (bfd *, struct bfd_link_info *, struct sec *, struct sec *, char **);
b34976b6 683extern bfd_boolean bfd_mips_elf32_create_embedded_relocs
c58b9523 684 (bfd *, struct bfd_link_info *, struct sec *, struct sec *, char **);
0752970e 685
252b5132
RH
686/* SunOS shared library support routines for the linker. */
687
688extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
c58b9523 689 (bfd *, struct bfd_link_info *);
b34976b6 690extern bfd_boolean bfd_sunos_record_link_assignment
c58b9523 691 (bfd *, struct bfd_link_info *, const char *);
b34976b6 692extern bfd_boolean bfd_sunos_size_dynamic_sections
c58b9523 693 (bfd *, struct bfd_link_info *, struct sec **, struct sec **, struct sec **);
252b5132
RH
694
695/* Linux shared library support routines for the linker. */
696
b34976b6 697extern bfd_boolean bfd_i386linux_size_dynamic_sections
c58b9523 698 (bfd *, struct bfd_link_info *);
b34976b6 699extern bfd_boolean bfd_m68klinux_size_dynamic_sections
c58b9523 700 (bfd *, struct bfd_link_info *);
b34976b6 701extern bfd_boolean bfd_sparclinux_size_dynamic_sections
c58b9523 702 (bfd *, struct bfd_link_info *);
252b5132
RH
703
704/* mmap hacks */
705
706struct _bfd_window_internal;
707typedef struct _bfd_window_internal bfd_window_internal;
708
b5f79c76
NC
709typedef struct _bfd_window
710{
252b5132 711 /* What the user asked for. */
c58b9523 712 void *data;
252b5132
RH
713 bfd_size_type size;
714 /* The actual window used by BFD. Small user-requested read-only
715 regions sharing a page may share a single window into the object
716 file. Read-write versions shouldn't until I've fixed things to
717 keep track of which portions have been claimed by the
718 application; don't want to give the same region back when the
719 application wants two writable copies! */
720 struct _bfd_window_internal *i;
b5f79c76
NC
721}
722bfd_window;
252b5132 723
b34976b6 724extern void bfd_init_window
c58b9523 725 (bfd_window *);
b34976b6 726extern void bfd_free_window
c58b9523 727 (bfd_window *);
b34976b6 728extern bfd_boolean bfd_get_file_window
c58b9523 729 (bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean);
252b5132
RH
730
731/* XCOFF support routines for the linker. */
732
b34976b6 733extern bfd_boolean bfd_xcoff_link_record_set
c58b9523 734 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type);
b34976b6 735extern bfd_boolean bfd_xcoff_import_symbol
c58b9523
AM
736 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma,
737 const char *, const char *, const char *, unsigned int);
b34976b6 738extern bfd_boolean bfd_xcoff_export_symbol
c58b9523 739 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
b34976b6 740extern bfd_boolean bfd_xcoff_link_count_reloc
c58b9523 741 (bfd *, struct bfd_link_info *, const char *);
b34976b6 742extern bfd_boolean bfd_xcoff_record_link_assignment
c58b9523 743 (bfd *, struct bfd_link_info *, const char *);
b34976b6 744extern bfd_boolean bfd_xcoff_size_dynamic_sections
c58b9523
AM
745 (bfd *, struct bfd_link_info *, const char *, const char *,
746 unsigned long, unsigned long, unsigned long, bfd_boolean,
747 int, bfd_boolean, bfd_boolean, struct sec **, bfd_boolean);
b34976b6 748extern bfd_boolean bfd_xcoff_link_generate_rtinit
c58b9523 749 (bfd *, const char *, const char *, bfd_boolean);
252b5132 750
eb1e0e80 751/* XCOFF support routines for ar. */
b34976b6 752extern bfd_boolean bfd_xcoff_ar_archive_set_magic
c58b9523 753 (bfd *, char *);
eb1e0e80 754
252b5132
RH
755/* Externally visible COFF routines. */
756
757#if defined(__STDC__) || defined(ALMOST_STDC)
758struct internal_syment;
759union internal_auxent;
760#endif
761
b34976b6 762extern bfd_boolean bfd_coff_get_syment
c58b9523 763 (bfd *, struct symbol_cache_entry *, struct internal_syment *);
252b5132 764
b34976b6 765extern bfd_boolean bfd_coff_get_auxent
c58b9523 766 (bfd *, struct symbol_cache_entry *, int, union internal_auxent *);
252b5132 767
b34976b6 768extern bfd_boolean bfd_coff_set_symbol_class
c58b9523 769 (bfd *, struct symbol_cache_entry *, unsigned int);
252b5132 770
b34976b6 771extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
c58b9523 772 (bfd *, struct bfd_link_info *, struct sec *, struct sec *, char **);
e702a51c 773
252b5132 774/* ARM Interworking support. Called from linker. */
b34976b6 775extern bfd_boolean bfd_arm_allocate_interworking_sections
c58b9523 776 (struct bfd_link_info *);
252b5132 777
b34976b6 778extern bfd_boolean bfd_arm_process_before_allocation
c58b9523 779 (bfd *, struct bfd_link_info *, int);
252b5132 780
b34976b6 781extern bfd_boolean bfd_arm_get_bfd_for_interworking
c58b9523 782 (bfd *, struct bfd_link_info *);
252b5132 783
86033394 784/* PE ARM Interworking support. Called from linker. */
b34976b6 785extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
c58b9523 786 (struct bfd_link_info *);
86033394 787
b34976b6 788extern bfd_boolean bfd_arm_pe_process_before_allocation
c58b9523 789 (bfd *, struct bfd_link_info *, int);
86033394 790
b34976b6 791extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
c58b9523 792 (bfd *, struct bfd_link_info *);
86033394 793
252b5132 794/* ELF ARM Interworking support. Called from linker. */
b34976b6 795extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
c58b9523 796 (struct bfd_link_info *);
67e5d3d6 797
b34976b6 798extern bfd_boolean bfd_elf32_arm_process_before_allocation
c58b9523 799 (bfd *, struct bfd_link_info *, int);
67e5d3d6 800
b34976b6 801extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
c58b9523 802 (bfd *, struct bfd_link_info *);
252b5132 803
b34976b6 804extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
c58b9523 805 (bfd *, struct bfd_link_info *);
8afb0e02 806
5a6c6817
NC
807/* ARM Note section processing. */
808extern bfd_boolean bfd_arm_merge_machines
c58b9523 809 (bfd *, bfd *);
5a6c6817
NC
810
811extern bfd_boolean bfd_arm_update_notes
c58b9523 812 (bfd *, const char *);
5a6c6817
NC
813
814extern unsigned int bfd_arm_get_mach_from_notes
c58b9523 815 (bfd *, const char *);
5a6c6817 816
8546af74 817/* TI COFF load page support. */
b9af77f5 818extern void bfd_ticoff_set_section_load_page
c58b9523 819 (struct sec *, int);
b9af77f5
TW
820
821extern int bfd_ticoff_get_section_load_page
c58b9523 822 (struct sec *);
a05758dd 823
This page took 0.238397 seconds and 4 git commands to generate.