1 /* Main header file for the bfd library -- portable access to object files.
3 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
5 Free Software Foundation, Inc.
7 Contributed by Cygnus Support.
9 This file is part of BFD, the Binary File Descriptor library.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
25 #ifndef __BFD_H_SEEN__
26 #define __BFD_H_SEEN__
34 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
36 /* This hack is to avoid a problem with some strict ANSI C preprocessors.
37 The problem is, "32_" is not a valid preprocessing token, and we don't
38 want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will
39 cause the inner CONCAT2 macros to be evaluated first, producing
40 still-valid pp-tokens. Then the final concatenation can be done. */
42 #define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
46 /* This is a utility macro to handle the situation where the code
47 wants to place a constant string into the code, followed by a
48 comma and then the length of the string. Doing this by hand
49 is error prone, so using this macro is safer. */
50 #define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
51 /* Unfortunately it is not possible to use the STRING_COMMA_LEN macro
52 to create the arguments to another macro, since the preprocessor
53 will mis-count the number of arguments to the outer macro (by not
54 evaluating STRING_COMMA_LEN and so missing the comma). This is a
55 problem for example when trying to use STRING_COMMA_LEN to build
56 the arguments to the strncmp() macro. Hence this alternative
57 definition of strncmp is provided here.
59 Note - these macros do NOT work if STR2 is not a constant string. */
60 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
61 /* strcpy() can have a similar problem, but since we know we are
62 copying a constant string, we can use memcpy which will be faster
63 since there is no need to check for a NUL byte inside STR. We
64 can also save time if we do not need to copy the terminating NUL. */
65 #define LITMEMCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2) - 1)
66 #define LITSTRCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2))
69 /* The word size used by BFD on the host. This may be 64 with a 32
70 bit target if the host is 64 bit, or if other 64 bit targets have
71 been selected with --enable-targets, or if --enable-64-bit-bfd. */
72 #define BFD_ARCH_SIZE @wordsize@
74 /* The word size of the default bfd target. */
75 #define BFD_DEFAULT_TARGET_SIZE @bfd_default_target_size@
77 #define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
78 #define BFD_HOST_64BIT_LONG_LONG @BFD_HOST_64BIT_LONG_LONG@
79 #if @BFD_HOST_64_BIT_DEFINED@
80 #define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
81 #define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
82 typedef BFD_HOST_64_BIT bfd_int64_t
;
83 typedef BFD_HOST_U_64_BIT bfd_uint64_t
;
86 #if BFD_ARCH_SIZE >= 64
92 #define INLINE __inline__
98 /* Declaring a type wide enough to hold a host long and a host pointer. */
99 #define BFD_HOSTPTR_T @BFD_HOSTPTR_T@
100 typedef BFD_HOSTPTR_T bfd_hostptr_t
;
102 /* Forward declaration. */
103 typedef struct bfd bfd
;
105 /* Boolean type used in bfd. Too many systems define their own
106 versions of "boolean" for us to safely typedef a "boolean" of
107 our own. Using an enum for "bfd_boolean" has its own set of
108 problems, with strange looking casts required to avoid warnings
109 on some older compilers. Thus we just use an int.
111 General rule: Functions which are bfd_boolean return TRUE on
112 success and FALSE on failure (unless they're a predicate). */
114 typedef int bfd_boolean
;
122 #ifndef BFD_HOST_64_BIT
123 #error No 64 bit integer type available
124 #endif /* ! defined (BFD_HOST_64_BIT) */
126 typedef BFD_HOST_U_64_BIT bfd_vma
;
127 typedef BFD_HOST_64_BIT bfd_signed_vma
;
128 typedef BFD_HOST_U_64_BIT bfd_size_type
;
129 typedef BFD_HOST_U_64_BIT symvalue
;
132 #if BFD_HOST_64BIT_LONG
133 #define sprintf_vma(s,x) sprintf (s, "%016lx", x)
134 #define fprintf_vma(f,x) fprintf (f, "%016lx", x)
135 #elif BFD_HOST_64BIT_LONG_LONG
136 #define sprintf_vma(s,x) sprintf (s, "%016llx", x)
137 #define fprintf_vma(f,x) fprintf (f, "%016llx", x)
139 #define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
140 #define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
141 #define fprintf_vma(s,x) \
142 fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
143 #define sprintf_vma(s,x) \
144 sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
148 #else /* not BFD64 */
150 /* Represent a target address. Also used as a generic unsigned type
151 which is guaranteed to be big enough to hold any arithmetic types
152 we need to deal with. */
153 typedef unsigned long bfd_vma
;
155 /* A generic signed type which is guaranteed to be big enough to hold any
156 arithmetic types we need to deal with. Can be assumed to be compatible
157 with bfd_vma in the same way that signed and unsigned ints are compatible
158 (as parameters, in assignment, etc). */
159 typedef long bfd_signed_vma
;
161 typedef unsigned long symvalue
;
162 typedef unsigned long bfd_size_type
;
164 /* Print a bfd_vma x on stream s. */
165 #define fprintf_vma(s,x) fprintf (s, "%08lx", x)
166 #define sprintf_vma(s,x) sprintf (s, "%08lx", x)
168 #endif /* not BFD64 */
170 #define HALF_BFD_SIZE_TYPE \
171 (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2))
173 #ifndef BFD_HOST_64_BIT
174 /* Fall back on a 32 bit type. The idea is to make these types always
175 available for function return types, but in the case that
176 BFD_HOST_64_BIT is undefined such a function should abort or
177 otherwise signal an error. */
178 typedef bfd_signed_vma bfd_int64_t
;
179 typedef bfd_vma bfd_uint64_t
;
182 /* An offset into a file. BFD always uses the largest possible offset
183 based on the build time availability of fseek, fseeko, or fseeko64. */
184 typedef @bfd_file_ptr@ file_ptr
;
185 typedef unsigned @bfd_file_ptr@ ufile_ptr
;
187 extern void bfd_sprintf_vma (bfd
*, char *, bfd_vma
);
188 extern void bfd_fprintf_vma (bfd
*, void *, bfd_vma
);
190 #define printf_vma(x) fprintf_vma(stdout,x)
191 #define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
193 typedef unsigned int flagword
; /* 32 bits of flags */
194 typedef unsigned char bfd_byte
;
198 typedef enum bfd_format
200 bfd_unknown
= 0, /* File format is unknown. */
201 bfd_object
, /* Linker/assembler/compiler output. */
202 bfd_archive
, /* Object archive file. */
203 bfd_core
, /* Core dump. */
204 bfd_type_end
/* Marks the end; don't use it! */
208 /* Values that may appear in the flags field of a BFD. These also
209 appear in the object_flags field of the bfd_target structure, where
210 they indicate the set of flags used by that backend (not all flags
211 are meaningful for all object file formats) (FIXME: at the moment,
212 the object_flags values have mostly just been copied from backend
213 to another, and are not necessarily correct). */
216 #define BFD_NO_FLAGS 0x00
218 /* BFD contains relocation entries. */
219 #define HAS_RELOC 0x01
221 /* BFD is directly executable. */
224 /* BFD has line number information (basically used for F_LNNO in a
226 #define HAS_LINENO 0x04
228 /* BFD has debugging information. */
229 #define HAS_DEBUG 0x08
231 /* BFD has symbols. */
232 #define HAS_SYMS 0x10
234 /* BFD has local symbols (basically used for F_LSYMS in a COFF
236 #define HAS_LOCALS 0x20
238 /* BFD is a dynamic object. */
241 /* Text section is write protected (if D_PAGED is not set, this is
242 like an a.out NMAGIC file) (the linker sets this by default, but
243 clears it for -r or -N). */
246 /* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
247 linker sets this by default, but clears it for -r or -n or -N). */
248 #define D_PAGED 0x100
250 /* BFD is relaxable (this means that bfd_relax_section may be able to
251 do something) (sometimes bfd_relax_section can do something even if
253 #define BFD_IS_RELAXABLE 0x200
255 /* This may be set before writing out a BFD to request using a
256 traditional format. For example, this is used to request that when
257 writing out an a.out object the symbols not be hashed to eliminate
259 #define BFD_TRADITIONAL_FORMAT 0x400
261 /* This flag indicates that the BFD contents are actually cached in
262 memory. If this is set, iostream points to a bfd_in_memory struct. */
263 #define BFD_IN_MEMORY 0x800
265 /* The sections in this BFD specify a memory page. */
266 #define HAS_LOAD_PAGE 0x1000
268 /* This BFD has been created by the linker and doesn't correspond
269 to any input file. */
270 #define BFD_LINKER_CREATED 0x2000
272 /* Symbols and relocation. */
274 /* A count of carsyms (canonical archive symbols). */
275 typedef unsigned long symindex
;
277 /* How to perform a relocation. */
278 typedef const struct reloc_howto_struct reloc_howto_type
;
280 #define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
282 /* General purpose part of a symbol X;
283 target specific parts are in libcoff.h, libaout.h, etc. */
285 #define bfd_get_section(x) ((x)->section)
286 #define bfd_get_output_section(x) ((x)->section->output_section)
287 #define bfd_set_section(x,y) ((x)->section) = (y)
288 #define bfd_asymbol_base(x) ((x)->section->vma)
289 #define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
290 #define bfd_asymbol_name(x) ((x)->name)
291 /*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
292 #define bfd_asymbol_bfd(x) ((x)->the_bfd)
293 #define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
295 /* A canonical archive symbol. */
296 /* This is a type pun with struct ranlib on purpose! */
297 typedef struct carsym
300 file_ptr file_offset
; /* Look here to find the file. */
302 carsym
; /* To make these you call a carsymogen. */
304 /* Used in generating armaps (archive tables of contents).
305 Perhaps just a forward definition would do? */
306 struct orl
/* Output ranlib. */
308 char **name
; /* Symbol name. */
313 } u
; /* bfd* or file position. */
314 int namidx
; /* Index into string table. */
317 /* Linenumber stuff. */
318 typedef struct lineno_cache_entry
320 unsigned int line_number
; /* Linenumber from start of function. */
323 struct bfd_symbol
*sym
; /* Function name. */
324 bfd_vma offset
; /* Offset into section. */
329 /* Object and core file sections. */
331 #define align_power(addr, align) \
332 (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
334 typedef struct bfd_section
*sec_ptr
;
336 #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
337 #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
338 #define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
339 #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
340 #define bfd_section_name(bfd, ptr) ((ptr)->name)
341 #define bfd_section_size(bfd, ptr) ((ptr)->size)
342 #define bfd_get_section_size(ptr) ((ptr)->size)
343 #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
344 #define bfd_section_lma(bfd, ptr) ((ptr)->lma)
345 #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
346 #define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
347 #define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
349 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
351 #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
352 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
353 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
354 /* Find the address one past the end of SEC. */
355 #define bfd_get_section_limit(bfd, sec) \
356 (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
357 / bfd_octets_per_byte (bfd))
359 /* Return TRUE if section has been discarded. */
360 #define elf_discarded_section(sec) \
361 (!bfd_is_abs_section (sec) \
362 && bfd_is_abs_section ((sec)->output_section) \
363 && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE \
364 && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
366 /* Forward define. */
369 typedef enum bfd_print_symbol
371 bfd_print_symbol_name
,
372 bfd_print_symbol_more
,
374 } bfd_print_symbol_type
;
376 /* Information about a symbol that nm needs. */
378 typedef struct _symbol_info
382 const char *name
; /* Symbol name. */
383 unsigned char stab_type
; /* Stab type. */
384 char stab_other
; /* Stab other. */
385 short stab_desc
; /* Stab desc. */
386 const char *stab_name
; /* String for stab type. */
389 /* Get the name of a stabs type code. */
391 extern const char *bfd_get_stab_name (int);
393 /* Hash table routines. There is no way to free up a hash table. */
395 /* An element in the hash table. Most uses will actually use a larger
396 structure, and an instance of this will be the first field. */
398 struct bfd_hash_entry
400 /* Next entry for this hash code. */
401 struct bfd_hash_entry
*next
;
402 /* String being hashed. */
404 /* Hash code. This is the full hash code, not the index into the
411 struct bfd_hash_table
413 /* The hash array. */
414 struct bfd_hash_entry
**table
;
415 /* A function used to create new elements in the hash table. The
416 first entry is itself a pointer to an element. When this
417 function is first invoked, this pointer will be NULL. However,
418 having the pointer permits a hierarchy of method functions to be
419 built each of which calls the function in the superclass. Thus
420 each function should be written to allocate a new block of memory
421 only if the argument is NULL. */
422 struct bfd_hash_entry
*(*newfunc
)
423 (struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *);
424 /* An objalloc for this hash table. This is a struct objalloc *,
425 but we use void * to avoid requiring the inclusion of objalloc.h. */
427 /* The number of slots in the hash table. */
429 /* The number of entries in the hash table. */
431 /* The size of elements. */
432 unsigned int entsize
;
433 /* If non-zero, don't grow the hash table. */
434 unsigned int frozen
:1;
437 /* Initialize a hash table. */
438 extern bfd_boolean bfd_hash_table_init
439 (struct bfd_hash_table
*,
440 struct bfd_hash_entry
*(*) (struct bfd_hash_entry
*,
441 struct bfd_hash_table
*,
445 /* Initialize a hash table specifying a size. */
446 extern bfd_boolean bfd_hash_table_init_n
447 (struct bfd_hash_table
*,
448 struct bfd_hash_entry
*(*) (struct bfd_hash_entry
*,
449 struct bfd_hash_table
*,
451 unsigned int, unsigned int);
453 /* Free up a hash table. */
454 extern void bfd_hash_table_free
455 (struct bfd_hash_table
*);
457 /* Look up a string in a hash table. If CREATE is TRUE, a new entry
458 will be created for this string if one does not already exist. The
459 COPY argument must be TRUE if this routine should copy the string
460 into newly allocated memory when adding an entry. */
461 extern struct bfd_hash_entry
*bfd_hash_lookup
462 (struct bfd_hash_table
*, const char *, bfd_boolean create
,
465 /* Insert an entry in a hash table. */
466 extern struct bfd_hash_entry
*bfd_hash_insert
467 (struct bfd_hash_table
*, const char *, unsigned long);
469 /* Replace an entry in a hash table. */
470 extern void bfd_hash_replace
471 (struct bfd_hash_table
*, struct bfd_hash_entry
*old
,
472 struct bfd_hash_entry
*nw
);
474 /* Base method for creating a hash table entry. */
475 extern struct bfd_hash_entry
*bfd_hash_newfunc
476 (struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *);
478 /* Grab some space for a hash table entry. */
479 extern void *bfd_hash_allocate
480 (struct bfd_hash_table
*, unsigned int);
482 /* Traverse a hash table in a random order, calling a function on each
483 element. If the function returns FALSE, the traversal stops. The
484 INFO argument is passed to the function. */
485 extern void bfd_hash_traverse
486 (struct bfd_hash_table
*,
487 bfd_boolean (*) (struct bfd_hash_entry
*, void *),
490 /* Allows the default size of a hash table to be configured. New hash
491 tables allocated using bfd_hash_table_init will be created with
493 extern void bfd_hash_set_default_size (bfd_size_type
);
495 /* This structure is used to keep track of stabs in sections
496 information while linking. */
500 /* A hash table used to hold stabs strings. */
501 struct bfd_strtab_hash
*strings
;
502 /* The header file hash table. */
503 struct bfd_hash_table includes
;
504 /* The first .stabstr section. */
505 struct bfd_section
*stabstr
;
508 #define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
510 /* User program access to BFD facilities. */
512 /* Direct I/O routines, for programs which know more about the object
513 file than BFD does. Use higher level routines if possible. */
515 extern bfd_size_type
bfd_bread (void *, bfd_size_type
, bfd
*);
516 extern bfd_size_type
bfd_bwrite (const void *, bfd_size_type
, bfd
*);
517 extern int bfd_seek (bfd
*, file_ptr
, int);
518 extern file_ptr
bfd_tell (bfd
*);
519 extern int bfd_flush (bfd
*);
520 extern int bfd_stat (bfd
*, struct stat
*);
522 /* Deprecated old routines. */
524 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
525 (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
526 bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
527 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
528 (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
529 bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
531 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
532 (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
533 bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
534 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
535 (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
536 bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
538 extern void warn_deprecated (const char *, const char *, int, const char *);
540 /* Cast from const char * to char * so that caller can assign to
541 a char * without a warning. */
542 #define bfd_get_filename(abfd) ((char *) (abfd)->filename)
543 #define bfd_get_cacheable(abfd) ((abfd)->cacheable)
544 #define bfd_get_format(abfd) ((abfd)->format)
545 #define bfd_get_target(abfd) ((abfd)->xvec->name)
546 #define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
547 #define bfd_family_coff(abfd) \
548 (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
549 bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
550 #define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
551 #define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
552 #define bfd_header_big_endian(abfd) \
553 ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
554 #define bfd_header_little_endian(abfd) \
555 ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
556 #define bfd_get_file_flags(abfd) ((abfd)->flags)
557 #define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
558 #define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
559 #define bfd_my_archive(abfd) ((abfd)->my_archive)
560 #define bfd_has_map(abfd) ((abfd)->has_armap)
562 #define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
563 #define bfd_usrdata(abfd) ((abfd)->usrdata)
565 #define bfd_get_start_address(abfd) ((abfd)->start_address)
566 #define bfd_get_symcount(abfd) ((abfd)->symcount)
567 #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
568 #define bfd_count_sections(abfd) ((abfd)->section_count)
570 #define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
572 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
574 #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
576 extern bfd_boolean bfd_cache_close
578 /* NB: This declaration should match the autogenerated one in libbfd.h. */
580 extern bfd_boolean
bfd_cache_close_all (void);
582 extern bfd_boolean bfd_record_phdr
583 (bfd
*, unsigned long, bfd_boolean
, flagword
, bfd_boolean
, bfd_vma
,
584 bfd_boolean
, bfd_boolean
, unsigned int, struct bfd_section
**);
586 /* Byte swapping routines. */
588 bfd_uint64_t
bfd_getb64 (const void *);
589 bfd_uint64_t
bfd_getl64 (const void *);
590 bfd_int64_t
bfd_getb_signed_64 (const void *);
591 bfd_int64_t
bfd_getl_signed_64 (const void *);
592 bfd_vma
bfd_getb32 (const void *);
593 bfd_vma
bfd_getl32 (const void *);
594 bfd_signed_vma
bfd_getb_signed_32 (const void *);
595 bfd_signed_vma
bfd_getl_signed_32 (const void *);
596 bfd_vma
bfd_getb16 (const void *);
597 bfd_vma
bfd_getl16 (const void *);
598 bfd_signed_vma
bfd_getb_signed_16 (const void *);
599 bfd_signed_vma
bfd_getl_signed_16 (const void *);
600 void bfd_putb64 (bfd_uint64_t
, void *);
601 void bfd_putl64 (bfd_uint64_t
, void *);
602 void bfd_putb32 (bfd_vma
, void *);
603 void bfd_putl32 (bfd_vma
, void *);
604 void bfd_putb16 (bfd_vma
, void *);
605 void bfd_putl16 (bfd_vma
, void *);
607 /* Byte swapping routines which take size and endiannes as arguments. */
609 bfd_uint64_t
bfd_get_bits (const void *, int, bfd_boolean
);
610 void bfd_put_bits (bfd_uint64_t
, void *, int, bfd_boolean
);
612 extern bfd_boolean
bfd_section_already_linked_table_init (void);
613 extern void bfd_section_already_linked_table_free (void);
615 /* Externally visible ECOFF routines. */
617 #if defined(__STDC__) || defined(ALMOST_STDC)
618 struct ecoff_debug_info
;
619 struct ecoff_debug_swap
;
622 struct bfd_link_info
;
623 struct bfd_link_hash_entry
;
624 struct bfd_elf_version_tree
;
626 extern bfd_vma bfd_ecoff_get_gp_value
628 extern bfd_boolean bfd_ecoff_set_gp_value
629 (bfd
*abfd
, bfd_vma gp_value
);
630 extern bfd_boolean bfd_ecoff_set_regmasks
631 (bfd
*abfd
, unsigned long gprmask
, unsigned long fprmask
,
632 unsigned long *cprmask
);
633 extern void *bfd_ecoff_debug_init
634 (bfd
*output_bfd
, struct ecoff_debug_info
*output_debug
,
635 const struct ecoff_debug_swap
*output_swap
, struct bfd_link_info
*);
636 extern void bfd_ecoff_debug_free
637 (void *handle
, bfd
*output_bfd
, struct ecoff_debug_info
*output_debug
,
638 const struct ecoff_debug_swap
*output_swap
, struct bfd_link_info
*);
639 extern bfd_boolean bfd_ecoff_debug_accumulate
640 (void *handle
, bfd
*output_bfd
, struct ecoff_debug_info
*output_debug
,
641 const struct ecoff_debug_swap
*output_swap
, bfd
*input_bfd
,
642 struct ecoff_debug_info
*input_debug
,
643 const struct ecoff_debug_swap
*input_swap
, struct bfd_link_info
*);
644 extern bfd_boolean bfd_ecoff_debug_accumulate_other
645 (void *handle
, bfd
*output_bfd
, struct ecoff_debug_info
*output_debug
,
646 const struct ecoff_debug_swap
*output_swap
, bfd
*input_bfd
,
647 struct bfd_link_info
*);
648 extern bfd_boolean bfd_ecoff_debug_externals
649 (bfd
*abfd
, struct ecoff_debug_info
*debug
,
650 const struct ecoff_debug_swap
*swap
, bfd_boolean relocatable
,
651 bfd_boolean (*get_extr
) (struct bfd_symbol
*, struct ecoff_extr
*),
652 void (*set_index
) (struct bfd_symbol
*, bfd_size_type
));
653 extern bfd_boolean bfd_ecoff_debug_one_external
654 (bfd
*abfd
, struct ecoff_debug_info
*debug
,
655 const struct ecoff_debug_swap
*swap
, const char *name
,
656 struct ecoff_extr
*esym
);
657 extern bfd_size_type bfd_ecoff_debug_size
658 (bfd
*abfd
, struct ecoff_debug_info
*debug
,
659 const struct ecoff_debug_swap
*swap
);
660 extern bfd_boolean bfd_ecoff_write_debug
661 (bfd
*abfd
, struct ecoff_debug_info
*debug
,
662 const struct ecoff_debug_swap
*swap
, file_ptr where
);
663 extern bfd_boolean bfd_ecoff_write_accumulated_debug
664 (void *handle
, bfd
*abfd
, struct ecoff_debug_info
*debug
,
665 const struct ecoff_debug_swap
*swap
,
666 struct bfd_link_info
*info
, file_ptr where
);
668 /* Externally visible ELF routines. */
670 struct bfd_link_needed_list
672 struct bfd_link_needed_list
*next
;
677 enum dynamic_lib_link_class
{
681 DYN_NO_ADD_NEEDED
= 4,
685 enum notice_asneeded_action
{
691 extern bfd_boolean bfd_elf_record_link_assignment
692 (bfd
*, struct bfd_link_info
*, const char *, bfd_boolean
,
694 extern struct bfd_link_needed_list
*bfd_elf_get_needed_list
695 (bfd
*, struct bfd_link_info
*);
696 extern bfd_boolean bfd_elf_get_bfd_needed_list
697 (bfd
*, struct bfd_link_needed_list
**);
698 extern bfd_boolean bfd_elf_size_dynamic_sections
699 (bfd
*, const char *, const char *, const char *, const char * const *,
700 struct bfd_link_info
*, struct bfd_section
**,
701 struct bfd_elf_version_tree
*);
702 extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr
703 (bfd
*, struct bfd_link_info
*);
704 extern void bfd_elf_set_dt_needed_name
705 (bfd
*, const char *);
706 extern const char *bfd_elf_get_dt_soname
708 extern void bfd_elf_set_dyn_lib_class
709 (bfd
*, enum dynamic_lib_link_class
);
710 extern int bfd_elf_get_dyn_lib_class
712 extern struct bfd_link_needed_list
*bfd_elf_get_runpath_list
713 (bfd
*, struct bfd_link_info
*);
714 extern bfd_boolean bfd_elf_discard_info
715 (bfd
*, struct bfd_link_info
*);
716 extern unsigned int _bfd_elf_default_action_discarded
717 (struct bfd_section
*);
719 /* Return an upper bound on the number of bytes required to store a
720 copy of ABFD's program header table entries. Return -1 if an error
721 occurs; bfd_get_error will return an appropriate code. */
722 extern long bfd_get_elf_phdr_upper_bound
725 /* Copy ABFD's program header table entries to *PHDRS. The entries
726 will be stored as an array of Elf_Internal_Phdr structures, as
727 defined in include/elf/internal.h. To find out how large the
728 buffer needs to be, call bfd_get_elf_phdr_upper_bound.
730 Return the number of program header table entries read, or -1 if an
731 error occurs; bfd_get_error will return an appropriate code. */
732 extern int bfd_get_elf_phdrs
733 (bfd
*abfd
, void *phdrs
);
735 /* Create a new BFD as if by bfd_openr. Rather than opening a file,
736 reconstruct an ELF file by reading the segments out of remote memory
737 based on the ELF file header at EHDR_VMA and the ELF program headers it
738 points to. If not null, *LOADBASEP is filled in with the difference
739 between the VMAs from which the segments were read, and the VMAs the
740 file headers (and hence BFD's idea of each section's VMA) put them at.
742 The function TARGET_READ_MEMORY is called to copy LEN bytes from the
743 remote memory at target address VMA into the local buffer at MYADDR; it
744 should return zero on success or an `errno' code on failure. TEMPL must
745 be a BFD for an ELF target with the word size and byte order found in
746 the remote memory. */
747 extern bfd
*bfd_elf_bfd_from_remote_memory
748 (bfd
*templ
, bfd_vma ehdr_vma
, bfd_vma
*loadbasep
,
749 int (*target_read_memory
) (bfd_vma vma
, bfd_byte
*myaddr
, int len
));
751 /* Return the arch_size field of an elf bfd, or -1 if not elf. */
752 extern int bfd_get_arch_size
755 /* Return TRUE if address "naturally" sign extends, or -1 if not elf. */
756 extern int bfd_get_sign_extend_vma
759 extern struct bfd_section
*_bfd_elf_tls_setup
760 (bfd
*, struct bfd_link_info
*);
762 extern void _bfd_fix_excluded_sec_syms
763 (bfd
*, struct bfd_link_info
*);
765 extern unsigned bfd_m68k_mach_to_features (int);
767 extern int bfd_m68k_features_to_mach (unsigned);
769 extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
770 (bfd
*, struct bfd_link_info
*, struct bfd_section
*, struct bfd_section
*,
773 extern bfd_boolean bfd_bfin_elf32_create_embedded_relocs
774 (bfd
*, struct bfd_link_info
*, struct bfd_section
*, struct bfd_section
*,
777 /* SunOS shared library support routines for the linker. */
779 extern struct bfd_link_needed_list
*bfd_sunos_get_needed_list
780 (bfd
*, struct bfd_link_info
*);
781 extern bfd_boolean bfd_sunos_record_link_assignment
782 (bfd
*, struct bfd_link_info
*, const char *);
783 extern bfd_boolean bfd_sunos_size_dynamic_sections
784 (bfd
*, struct bfd_link_info
*, struct bfd_section
**,
785 struct bfd_section
**, struct bfd_section
**);
787 /* Linux shared library support routines for the linker. */
789 extern bfd_boolean bfd_i386linux_size_dynamic_sections
790 (bfd
*, struct bfd_link_info
*);
791 extern bfd_boolean bfd_m68klinux_size_dynamic_sections
792 (bfd
*, struct bfd_link_info
*);
793 extern bfd_boolean bfd_sparclinux_size_dynamic_sections
794 (bfd
*, struct bfd_link_info
*);
798 struct _bfd_window_internal
;
799 typedef struct _bfd_window_internal bfd_window_internal
;
801 typedef struct _bfd_window
803 /* What the user asked for. */
806 /* The actual window used by BFD. Small user-requested read-only
807 regions sharing a page may share a single window into the object
808 file. Read-write versions shouldn't until I've fixed things to
809 keep track of which portions have been claimed by the
810 application; don't want to give the same region back when the
811 application wants two writable copies! */
812 struct _bfd_window_internal
*i
;
816 extern void bfd_init_window
818 extern void bfd_free_window
820 extern bfd_boolean bfd_get_file_window
821 (bfd
*, file_ptr
, bfd_size_type
, bfd_window
*, bfd_boolean
);
823 /* XCOFF support routines for the linker. */
825 extern bfd_boolean bfd_xcoff_link_record_set
826 (bfd
*, struct bfd_link_info
*, struct bfd_link_hash_entry
*, bfd_size_type
);
827 extern bfd_boolean bfd_xcoff_import_symbol
828 (bfd
*, struct bfd_link_info
*, struct bfd_link_hash_entry
*, bfd_vma
,
829 const char *, const char *, const char *, unsigned int);
830 extern bfd_boolean bfd_xcoff_export_symbol
831 (bfd
*, struct bfd_link_info
*, struct bfd_link_hash_entry
*);
832 extern bfd_boolean bfd_xcoff_link_count_reloc
833 (bfd
*, struct bfd_link_info
*, const char *);
834 extern bfd_boolean bfd_xcoff_record_link_assignment
835 (bfd
*, struct bfd_link_info
*, const char *);
836 extern bfd_boolean bfd_xcoff_size_dynamic_sections
837 (bfd
*, struct bfd_link_info
*, const char *, const char *,
838 unsigned long, unsigned long, unsigned long, bfd_boolean
,
839 int, bfd_boolean
, bfd_boolean
, struct bfd_section
**, bfd_boolean
);
840 extern bfd_boolean bfd_xcoff_link_generate_rtinit
841 (bfd
*, const char *, const char *, bfd_boolean
);
843 /* XCOFF support routines for ar. */
844 extern bfd_boolean bfd_xcoff_ar_archive_set_magic
847 /* Externally visible COFF routines. */
849 #if defined(__STDC__) || defined(ALMOST_STDC)
850 struct internal_syment
;
851 union internal_auxent
;
854 extern bfd_boolean bfd_coff_get_syment
855 (bfd
*, struct bfd_symbol
*, struct internal_syment
*);
857 extern bfd_boolean bfd_coff_get_auxent
858 (bfd
*, struct bfd_symbol
*, int, union internal_auxent
*);
860 extern bfd_boolean bfd_coff_set_symbol_class
861 (bfd
*, struct bfd_symbol
*, unsigned int);
863 extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
864 (bfd
*, struct bfd_link_info
*, struct bfd_section
*, struct bfd_section
*, char **);
866 /* ARM VFP11 erratum workaround support. */
869 BFD_ARM_VFP11_FIX_DEFAULT
,
870 BFD_ARM_VFP11_FIX_NONE
,
871 BFD_ARM_VFP11_FIX_SCALAR
,
872 BFD_ARM_VFP11_FIX_VECTOR
875 extern void bfd_elf32_arm_init_maps
878 extern void bfd_elf32_arm_set_vfp11_fix
879 (bfd
*, struct bfd_link_info
*);
881 extern bfd_boolean bfd_elf32_arm_vfp11_erratum_scan
882 (bfd
*, struct bfd_link_info
*);
884 extern void bfd_elf32_arm_vfp11_fix_veneer_locations
885 (bfd
*, struct bfd_link_info
*);
887 /* ARM Interworking support. Called from linker. */
888 extern bfd_boolean bfd_arm_allocate_interworking_sections
889 (struct bfd_link_info
*);
891 extern bfd_boolean bfd_arm_process_before_allocation
892 (bfd
*, struct bfd_link_info
*, int);
894 extern bfd_boolean bfd_arm_get_bfd_for_interworking
895 (bfd
*, struct bfd_link_info
*);
897 /* PE ARM Interworking support. Called from linker. */
898 extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
899 (struct bfd_link_info
*);
901 extern bfd_boolean bfd_arm_pe_process_before_allocation
902 (bfd
*, struct bfd_link_info
*, int);
904 extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
905 (bfd
*, struct bfd_link_info
*);
907 /* ELF ARM Interworking support. Called from linker. */
908 extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
909 (struct bfd_link_info
*);
911 extern bfd_boolean bfd_elf32_arm_process_before_allocation
912 (bfd
*, struct bfd_link_info
*);
914 void bfd_elf32_arm_set_target_relocs
915 (bfd
*, struct bfd_link_info
*, int, char *, int, int, bfd_arm_vfp11_fix
,
918 extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
919 (bfd
*, struct bfd_link_info
*);
921 extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
922 (bfd
*, struct bfd_link_info
*);
924 /* ELF ARM mapping symbol support */
925 #define BFD_ARM_SPECIAL_SYM_TYPE_MAP (1 << 0)
926 #define BFD_ARM_SPECIAL_SYM_TYPE_TAG (1 << 1)
927 #define BFD_ARM_SPECIAL_SYM_TYPE_OTHER (1 << 2)
928 #define BFD_ARM_SPECIAL_SYM_TYPE_ANY (~0)
929 extern bfd_boolean bfd_is_arm_special_symbol_name
930 (const char * name
, int type
);
932 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info
*, int);
934 /* ARM Note section processing. */
935 extern bfd_boolean bfd_arm_merge_machines
938 extern bfd_boolean bfd_arm_update_notes
939 (bfd
*, const char *);
941 extern unsigned int bfd_arm_get_mach_from_notes
942 (bfd
*, const char *);
944 /* TI COFF load page support. */
945 extern void bfd_ticoff_set_section_load_page
946 (struct bfd_section
*, int);
948 extern int bfd_ticoff_get_section_load_page
949 (struct bfd_section
*);
951 /* H8/300 functions. */
952 extern bfd_vma bfd_h8300_pad_address
955 /* IA64 Itanium code generation. Called from linker. */
956 extern void bfd_elf32_ia64_after_parse
959 extern void bfd_elf64_ia64_after_parse
962 /* This structure is used for a comdat section, as in PE. A comdat
963 section is associated with a particular symbol. When the linker
964 sees a comdat section, it keeps only one of the sections with a
965 given name and associated with a given symbol. */
967 struct coff_comdat_info
969 /* The name of the symbol associated with a comdat section. */
972 /* The local symbol table index of the symbol associated with a
973 comdat section. This is only meaningful to the object file format
974 specific code; it is not an index into the list returned by
975 bfd_canonicalize_symtab. */
979 extern struct coff_comdat_info
*bfd_coff_get_comdat_section
980 (bfd
*, struct bfd_section
*);