bfd/
[deliverable/binutils-gdb.git] / bfd / bfd-in.h
1 /* Main header file for the bfd library -- portable access to object files.
2
3 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5
6 Contributed by Cygnus Support.
7
8 This file is part of BFD, the Binary File Descriptor library.
9
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.
14
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.
19
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. */
23
24 #ifndef __BFD_H_SEEN__
25 #define __BFD_H_SEEN__
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #include "ansidecl.h"
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
44
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. */
48 #define BFD_ARCH_SIZE @wordsize@
49
50 /* The word size of the default bfd target. */
51 #define BFD_DEFAULT_TARGET_SIZE @bfd_default_target_size@
52
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
71 /* Forward declaration. */
72 typedef struct bfd bfd;
73
74 /* Boolean type used in bfd. Too many systems define their own
75 versions of "boolean" for us to safely typedef a "boolean" of
76 our own. Using an enum for "bfd_boolean" has its own set of
77 problems, with strange looking casts required to avoid warnings
78 on some older compilers. Thus we just use an int.
79
80 General rule: Functions which are bfd_boolean return TRUE on
81 success and FALSE on failure (unless they're a predicate). */
82
83 typedef 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
95 #endif
96
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
123 typedef BFD_HOST_U_64_BIT bfd_vma;
124 typedef BFD_HOST_64_BIT bfd_signed_vma;
125 typedef BFD_HOST_U_64_BIT bfd_size_type;
126 typedef 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. */
147 typedef 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). */
153 typedef long bfd_signed_vma;
154
155 typedef unsigned long symvalue;
156 typedef unsigned long bfd_size_type;
157
158 /* Print a bfd_vma x on stream s. */
159 #define fprintf_vma(s,x) fprintf (s, "%08lx", x)
160 #define sprintf_vma(s,x) sprintf (s, "%08lx", x)
161
162 #endif /* not BFD64 */
163
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; */
172 typedef bfd_signed_vma file_ptr;
173 typedef bfd_vma ufile_ptr;
174
175 extern void bfd_sprintf_vma (bfd *, char *, bfd_vma);
176 extern void bfd_fprintf_vma (bfd *, void *, bfd_vma);
177
178 #define printf_vma(x) fprintf_vma(stdout,x)
179 #define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
180
181 typedef unsigned int flagword; /* 32 bits of flags */
182 typedef unsigned char bfd_byte;
183 \f
184 /* File formats. */
185
186 typedef 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 }
194 bfd_format;
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
252
253 /* The sections in this BFD specify a memory page. */
254 #define HAS_LOAD_PAGE 0x1000
255 \f
256 /* Symbols and relocation. */
257
258 /* A count of carsyms (canonical archive symbols). */
259 typedef unsigned long symindex;
260
261 /* How to perform a relocation. */
262 typedef 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. */
280 /* This is a type pun with struct ranlib on purpose! */
281 typedef struct carsym
282 {
283 char *name;
284 file_ptr file_offset; /* Look here to find the file. */
285 }
286 carsym; /* To make these you call a carsymogen. */
287
288 /* Used in generating armaps (archive tables of contents).
289 Perhaps just a forward definition would do? */
290 struct orl /* Output ranlib. */
291 {
292 char **name; /* Symbol name. */
293 union
294 {
295 file_ptr pos;
296 bfd *abfd;
297 } u; /* bfd* or file position. */
298 int namidx; /* Index into string table. */
299 };
300 \f
301 /* Linenumber stuff. */
302 typedef 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. */
309 } u;
310 }
311 alent;
312 \f
313 /* Object and core file sections. */
314
315 #define align_power(addr, align) \
316 (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
317
318 typedef 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)
322 #define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
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
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)
337
338 typedef struct stat stat_type;
339 \f
340 typedef enum bfd_print_symbol
341 {
342 bfd_print_symbol_name,
343 bfd_print_symbol_more,
344 bfd_print_symbol_all
345 } bfd_print_symbol_type;
346
347 /* Information about a symbol that nm needs. */
348
349 typedef struct _symbol_info
350 {
351 symvalue value;
352 char type;
353 const char *name; /* Symbol name. */
354 unsigned char stab_type; /* Stab type. */
355 char stab_other; /* Stab other. */
356 short stab_desc; /* Stab desc. */
357 const char *stab_name; /* String for stab type. */
358 } symbol_info;
359
360 /* Get the name of a stabs type code. */
361
362 extern const char *bfd_get_stab_name (int);
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
369 struct 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
382 struct 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. */
395 struct bfd_hash_entry *(*newfunc)
396 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
397 /* An objalloc for this hash table. This is a struct objalloc *,
398 but we use void * to avoid requiring the inclusion of objalloc.h. */
399 void *memory;
400 };
401
402 /* Initialize a hash table. */
403 extern bfd_boolean bfd_hash_table_init
404 (struct bfd_hash_table *,
405 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
406 struct bfd_hash_table *,
407 const char *));
408
409 /* Initialize a hash table specifying a size. */
410 extern bfd_boolean bfd_hash_table_init_n
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);
416
417 /* Free up a hash table. */
418 extern void bfd_hash_table_free
419 (struct bfd_hash_table *);
420
421 /* Look up a string in a hash table. If CREATE is TRUE, a new entry
422 will be created for this string if one does not already exist. The
423 COPY argument must be TRUE if this routine should copy the string
424 into newly allocated memory when adding an entry. */
425 extern struct bfd_hash_entry *bfd_hash_lookup
426 (struct bfd_hash_table *, const char *, bfd_boolean create,
427 bfd_boolean copy);
428
429 /* Replace an entry in a hash table. */
430 extern void bfd_hash_replace
431 (struct bfd_hash_table *, struct bfd_hash_entry *old,
432 struct bfd_hash_entry *nw);
433
434 /* Base method for creating a hash table entry. */
435 extern struct bfd_hash_entry *bfd_hash_newfunc
436 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
437
438 /* Grab some space for a hash table entry. */
439 extern void *bfd_hash_allocate
440 (struct bfd_hash_table *, unsigned int);
441
442 /* Traverse a hash table in a random order, calling a function on each
443 element. If the function returns FALSE, the traversal stops. The
444 INFO argument is passed to the function. */
445 extern void bfd_hash_traverse
446 (struct bfd_hash_table *,
447 bfd_boolean (*) (struct bfd_hash_entry *, void *),
448 void *info);
449
450 #define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
451
452 /* User program access to BFD facilities. */
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
457 extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
458 extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
459 extern int bfd_seek (bfd *, file_ptr, int);
460 extern ufile_ptr bfd_tell (bfd *);
461 extern int bfd_flush (bfd *);
462 extern int bfd_stat (bfd *, struct stat *);
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
480 extern void warn_deprecated (const char *, const char *, int, const char *);
481
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)
489 #define bfd_family_coff(abfd) \
490 (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
491 bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
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
512 #define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
513
514 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
515
516 #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
517
518 extern bfd_boolean bfd_cache_close
519 (bfd *abfd);
520 /* NB: This declaration should match the autogenerated one in libbfd.h. */
521
522 extern bfd_boolean bfd_record_phdr
523 (bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
524 bfd_boolean, bfd_boolean, unsigned int, struct sec **);
525
526 /* Byte swapping routines. */
527
528 bfd_vma bfd_getb64 (const unsigned char *);
529 bfd_vma bfd_getl64 (const unsigned char *);
530 bfd_signed_vma bfd_getb_signed_64 (const unsigned char *);
531 bfd_signed_vma bfd_getl_signed_64 (const unsigned char *);
532 bfd_vma bfd_getb32 (const unsigned char *);
533 bfd_vma bfd_getl32 (const unsigned char *);
534 bfd_signed_vma bfd_getb_signed_32 (const unsigned char *);
535 bfd_signed_vma bfd_getl_signed_32 (const unsigned char *);
536 bfd_vma bfd_getb16 (const unsigned char *);
537 bfd_vma bfd_getl16 (const unsigned char *);
538 bfd_signed_vma bfd_getb_signed_16 (const unsigned char *);
539 bfd_signed_vma bfd_getl_signed_16 (const unsigned char *);
540 void bfd_putb64 (bfd_vma, unsigned char *);
541 void bfd_putl64 (bfd_vma, unsigned char *);
542 void bfd_putb32 (bfd_vma, unsigned char *);
543 void bfd_putl32 (bfd_vma, unsigned char *);
544 void bfd_putb16 (bfd_vma, unsigned char *);
545 void bfd_putl16 (bfd_vma, unsigned char *);
546
547 /* Byte swapping routines which take size and endiannes as arguments. */
548
549 bfd_vma bfd_get_bits (bfd_byte *, int, bfd_boolean);
550 void bfd_put_bits (bfd_vma, bfd_byte *, int, bfd_boolean);
551 \f
552 /* Externally visible ECOFF routines. */
553
554 #if defined(__STDC__) || defined(ALMOST_STDC)
555 struct ecoff_debug_info;
556 struct ecoff_debug_swap;
557 struct ecoff_extr;
558 struct symbol_cache_entry;
559 struct bfd_link_info;
560 struct bfd_link_hash_entry;
561 struct bfd_elf_version_tree;
562 #endif
563 extern bfd_vma bfd_ecoff_get_gp_value
564 (bfd * abfd);
565 extern bfd_boolean bfd_ecoff_set_gp_value
566 (bfd *abfd, bfd_vma gp_value);
567 extern bfd_boolean bfd_ecoff_set_regmasks
568 (bfd *abfd, unsigned long gprmask, unsigned long fprmask,
569 unsigned long *cprmask);
570 extern 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 *);
573 extern void bfd_ecoff_debug_free
574 (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
575 const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
576 extern bfd_boolean bfd_ecoff_debug_accumulate
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 *);
581 extern bfd_boolean bfd_ecoff_debug_accumulate_other
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 *);
585 extern bfd_boolean bfd_ecoff_debug_externals
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));
590 extern bfd_boolean bfd_ecoff_debug_one_external
591 (bfd *abfd, struct ecoff_debug_info *debug,
592 const struct ecoff_debug_swap *swap, const char *name,
593 struct ecoff_extr *esym);
594 extern bfd_size_type bfd_ecoff_debug_size
595 (bfd *abfd, struct ecoff_debug_info *debug,
596 const struct ecoff_debug_swap *swap);
597 extern bfd_boolean bfd_ecoff_write_debug
598 (bfd *abfd, struct ecoff_debug_info *debug,
599 const struct ecoff_debug_swap *swap, file_ptr where);
600 extern bfd_boolean bfd_ecoff_write_accumulated_debug
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);
604 extern bfd_boolean bfd_mips_ecoff_create_embedded_relocs
605 (bfd *, struct bfd_link_info *, struct sec *, struct sec *, char **);
606
607 /* Externally visible ELF routines. */
608
609 struct bfd_link_needed_list
610 {
611 struct bfd_link_needed_list *next;
612 bfd *by;
613 const char *name;
614 };
615
616 extern bfd_boolean bfd_elf_record_link_assignment
617 (bfd *, struct bfd_link_info *, const char *, bfd_boolean);
618 extern struct bfd_link_needed_list *bfd_elf_get_needed_list
619 (bfd *, struct bfd_link_info *);
620 extern bfd_boolean bfd_elf_get_bfd_needed_list
621 (bfd *, struct bfd_link_needed_list **);
622 extern bfd_boolean bfd_elf32_size_dynamic_sections
623 (bfd *, const char *, const char *, const char *, const char * const *,
624 struct bfd_link_info *, struct sec **, struct bfd_elf_version_tree *);
625 extern bfd_boolean bfd_elf64_size_dynamic_sections
626 (bfd *, const char *, const char *, const char *, const char * const *,
627 struct bfd_link_info *, struct sec **, struct bfd_elf_version_tree *);
628 extern void bfd_elf_set_dt_needed_name
629 (bfd *, const char *);
630 extern void bfd_elf_set_dt_needed_soname
631 (bfd *, const char *);
632 extern const char *bfd_elf_get_dt_soname
633 (bfd *);
634 extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
635 (bfd *, struct bfd_link_info *);
636 extern bfd_boolean bfd_elf32_discard_info
637 (bfd *, struct bfd_link_info *);
638 extern bfd_boolean bfd_elf64_discard_info
639 (bfd *, struct bfd_link_info *);
640
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. */
644 extern long bfd_get_elf_phdr_upper_bound
645 (bfd *abfd);
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. */
654 extern int bfd_get_elf_phdrs
655 (bfd *abfd, void *phdrs);
656
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. */
669 extern bfd *bfd_elf_bfd_from_remote_memory
670 (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
671 int (*target_read_memory) (bfd_vma vma, char *myaddr, int len));
672
673 /* Return the arch_size field of an elf bfd, or -1 if not elf. */
674 extern int bfd_get_arch_size
675 (bfd *);
676
677 /* Return TRUE if address "naturally" sign extends, or -1 if not elf. */
678 extern int bfd_get_sign_extend_vma
679 (bfd *);
680
681 extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
682 (bfd *, struct bfd_link_info *, struct sec *, struct sec *, char **);
683 extern bfd_boolean bfd_mips_elf32_create_embedded_relocs
684 (bfd *, struct bfd_link_info *, struct sec *, struct sec *, char **);
685
686 /* SunOS shared library support routines for the linker. */
687
688 extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
689 (bfd *, struct bfd_link_info *);
690 extern bfd_boolean bfd_sunos_record_link_assignment
691 (bfd *, struct bfd_link_info *, const char *);
692 extern bfd_boolean bfd_sunos_size_dynamic_sections
693 (bfd *, struct bfd_link_info *, struct sec **, struct sec **, struct sec **);
694
695 /* Linux shared library support routines for the linker. */
696
697 extern bfd_boolean bfd_i386linux_size_dynamic_sections
698 (bfd *, struct bfd_link_info *);
699 extern bfd_boolean bfd_m68klinux_size_dynamic_sections
700 (bfd *, struct bfd_link_info *);
701 extern bfd_boolean bfd_sparclinux_size_dynamic_sections
702 (bfd *, struct bfd_link_info *);
703
704 /* mmap hacks */
705
706 struct _bfd_window_internal;
707 typedef struct _bfd_window_internal bfd_window_internal;
708
709 typedef struct _bfd_window
710 {
711 /* What the user asked for. */
712 void *data;
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;
721 }
722 bfd_window;
723
724 extern void bfd_init_window
725 (bfd_window *);
726 extern void bfd_free_window
727 (bfd_window *);
728 extern bfd_boolean bfd_get_file_window
729 (bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean);
730
731 /* XCOFF support routines for the linker. */
732
733 extern bfd_boolean bfd_xcoff_link_record_set
734 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type);
735 extern bfd_boolean bfd_xcoff_import_symbol
736 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma,
737 const char *, const char *, const char *, unsigned int);
738 extern bfd_boolean bfd_xcoff_export_symbol
739 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
740 extern bfd_boolean bfd_xcoff_link_count_reloc
741 (bfd *, struct bfd_link_info *, const char *);
742 extern bfd_boolean bfd_xcoff_record_link_assignment
743 (bfd *, struct bfd_link_info *, const char *);
744 extern bfd_boolean bfd_xcoff_size_dynamic_sections
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);
748 extern bfd_boolean bfd_xcoff_link_generate_rtinit
749 (bfd *, const char *, const char *, bfd_boolean);
750
751 /* XCOFF support routines for ar. */
752 extern bfd_boolean bfd_xcoff_ar_archive_set_magic
753 (bfd *, char *);
754
755 /* Externally visible COFF routines. */
756
757 #if defined(__STDC__) || defined(ALMOST_STDC)
758 struct internal_syment;
759 union internal_auxent;
760 #endif
761
762 extern bfd_boolean bfd_coff_get_syment
763 (bfd *, struct symbol_cache_entry *, struct internal_syment *);
764
765 extern bfd_boolean bfd_coff_get_auxent
766 (bfd *, struct symbol_cache_entry *, int, union internal_auxent *);
767
768 extern bfd_boolean bfd_coff_set_symbol_class
769 (bfd *, struct symbol_cache_entry *, unsigned int);
770
771 extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
772 (bfd *, struct bfd_link_info *, struct sec *, struct sec *, char **);
773
774 /* ARM Interworking support. Called from linker. */
775 extern bfd_boolean bfd_arm_allocate_interworking_sections
776 (struct bfd_link_info *);
777
778 extern bfd_boolean bfd_arm_process_before_allocation
779 (bfd *, struct bfd_link_info *, int);
780
781 extern bfd_boolean bfd_arm_get_bfd_for_interworking
782 (bfd *, struct bfd_link_info *);
783
784 /* PE ARM Interworking support. Called from linker. */
785 extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
786 (struct bfd_link_info *);
787
788 extern bfd_boolean bfd_arm_pe_process_before_allocation
789 (bfd *, struct bfd_link_info *, int);
790
791 extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
792 (bfd *, struct bfd_link_info *);
793
794 /* ELF ARM Interworking support. Called from linker. */
795 extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
796 (struct bfd_link_info *);
797
798 extern bfd_boolean bfd_elf32_arm_process_before_allocation
799 (bfd *, struct bfd_link_info *, int);
800
801 extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
802 (bfd *, struct bfd_link_info *);
803
804 extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
805 (bfd *, struct bfd_link_info *);
806
807 /* ARM Note section processing. */
808 extern bfd_boolean bfd_arm_merge_machines
809 (bfd *, bfd *);
810
811 extern bfd_boolean bfd_arm_update_notes
812 (bfd *, const char *);
813
814 extern unsigned int bfd_arm_get_mach_from_notes
815 (bfd *, const char *);
816
817 /* TI COFF load page support. */
818 extern void bfd_ticoff_set_section_load_page
819 (struct sec *, int);
820
821 extern int bfd_ticoff_get_section_load_page
822 (struct sec *);
823
824 /* H8/300 functions. */
825 extern bfd_vma bfd_h8300_pad_address
826 (bfd *, bfd_vma);
827
This page took 0.047672 seconds and 5 git commands to generate.