bfd-in2.h 228 KB
Newer Older
1 2 3 4
/* DO NOT EDIT!  -*- buffer-read-only: t -*-  This file is automatically 
   generated from "bfd-in.h", "init.c", "opncls.c", "libbfd.c", 
   "bfdio.c", "bfdwin.c", "section.c", "archures.c", "reloc.c", 
   "syms.c", "bfd.c", "archive.c", "corefile.c", "targets.c", "format.c", 
Craig Silverstein's avatar
bfd/  
Craig Silverstein committed
5
   "linker.c", "simple.c" and "compress.c".
Alan Modra's avatar
bfd/  
Alan Modra committed
6 7
   Run "make headers" in your build bfd/ to regenerate.  */

Richard Henderson's avatar
Richard Henderson committed
8
/* Main header file for the bfd library -- portable access to object files.
9

Roland McGrath's avatar
bfd/  
Roland McGrath committed
10
   Copyright 1990-2013 Free Software Foundation, Inc.
11

Richard Henderson's avatar
Richard Henderson committed
12 13
   Contributed by Cygnus Support.

14
   This file is part of BFD, the Binary File Descriptor library.
Richard Henderson's avatar
Richard Henderson committed
15

16 17
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
18
   the Free Software Foundation; either version 3 of the License, or
19
   (at your option) any later version.
Richard Henderson's avatar
Richard Henderson committed
20

21 22 23 24
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
Richard Henderson's avatar
Richard Henderson committed
25

26 27
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
28
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
Richard Henderson's avatar
Richard Henderson committed
29 30 31 32

#ifndef __BFD_H_SEEN__
#define __BFD_H_SEEN__

Nick Clifton's avatar
Nick Clifton committed
33 34
/* PR 14072: Ensure that config.h is included first.  */
#if !defined PACKAGE && !defined PACKAGE_VERSION
Nick Clifton's avatar
Nick Clifton committed
35 36 37
#error config.h must be included before this header
#endif

Richard Henderson's avatar
Richard Henderson committed
38 39 40 41 42
#ifdef __cplusplus
extern "C" {
#endif

#include "ansidecl.h"
Alan Modra's avatar
Alan Modra committed
43
#include "symcat.h"
Nick Clifton's avatar
Nick Clifton committed
44 45
#include <sys/stat.h>

Alan Modra's avatar
Alan Modra committed
46 47 48 49 50 51 52 53 54 55 56
#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
#ifndef SABER
/* This hack is to avoid a problem with some strict ANSI C preprocessors.
   The problem is, "32_" is not a valid preprocessing token, and we don't
   want extra underscores (e.g., "nlm_32_").  The XCONCAT2 macro will
   cause the inner CONCAT2 macros to be evaluated first, producing
   still-valid pp-tokens.  Then the final concatenation can be done.  */
#undef CONCAT4
#define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
#endif
#endif
Richard Henderson's avatar
Richard Henderson committed
57

58 59 60
/* This is a utility macro to handle the situation where the code
   wants to place a constant string into the code, followed by a
   comma and then the length of the string.  Doing this by hand
Pedro Alves's avatar
Pedro Alves committed
61 62
   is error prone, so using this macro is safer.  */
#define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
63 64 65 66 67 68 69
/* Unfortunately it is not possible to use the STRING_COMMA_LEN macro
   to create the arguments to another macro, since the preprocessor
   will mis-count the number of arguments to the outer macro (by not
   evaluating STRING_COMMA_LEN and so missing the comma).  This is a
   problem for example when trying to use STRING_COMMA_LEN to build
   the arguments to the strncmp() macro.  Hence this alternative
   definition of strncmp is provided here.
70

71 72
   Note - these macros do NOT work if STR2 is not a constant string.  */
#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
73 74 75 76 77 78
  /* strcpy() can have a similar problem, but since we know we are
     copying a constant string, we can use memcpy which will be faster
     since there is no need to check for a NUL byte inside STR.  We
     can also save time if we do not need to copy the terminating NUL.  */
#define LITMEMCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2) - 1)
#define LITSTRCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2))
79 80


81 82
#define BFD_SUPPORTS_PLUGINS @supports_plugins@

83 84 85
/* The word size used by BFD on the host.  This may be 64 with a 32
   bit target if the host is 64 bit, or if other 64 bit targets have
   been selected with --enable-targets, or if --enable-64-bit-bfd.  */
Richard Henderson's avatar
Richard Henderson committed
86
#define BFD_ARCH_SIZE @wordsize@
87 88 89 90

/* The word size of the default bfd target.  */
#define BFD_DEFAULT_TARGET_SIZE @bfd_default_target_size@

Richard Henderson's avatar
Richard Henderson committed
91
#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
92
#define BFD_HOST_64BIT_LONG_LONG @BFD_HOST_64BIT_LONG_LONG@
Richard Henderson's avatar
Richard Henderson committed
93 94 95
#if @BFD_HOST_64_BIT_DEFINED@
#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
96 97
typedef BFD_HOST_64_BIT bfd_int64_t;
typedef BFD_HOST_U_64_BIT bfd_uint64_t;
Richard Henderson's avatar
Richard Henderson committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111
#endif

#if BFD_ARCH_SIZE >= 64
#define BFD64
#endif

#ifndef INLINE
#if __GNUC__ >= 2
#define INLINE __inline__
#else
#define INLINE
#endif
#endif

112 113 114 115
/* Declaring a type wide enough to hold a host long and a host pointer.  */
#define BFD_HOSTPTR_T	@BFD_HOSTPTR_T@
typedef BFD_HOSTPTR_T bfd_hostptr_t;

116
/* Forward declaration.  */
117
typedef struct bfd bfd;
Richard Henderson's avatar
Richard Henderson committed
118

119 120
/* Boolean type used in bfd.  Too many systems define their own
   versions of "boolean" for us to safely typedef a "boolean" of
121
   our own.  Using an enum for "bfd_boolean" has its own set of
122 123 124
   problems, with strange looking casts required to avoid warnings
   on some older compilers.  Thus we just use an int.

125
   General rule: Functions which are bfd_boolean return TRUE on
126 127 128 129 130 131 132 133
   success and FALSE on failure (unless they're a predicate).  */

typedef int bfd_boolean;
#undef FALSE
#undef TRUE
#define FALSE 0
#define TRUE 1

Richard Henderson's avatar
Richard Henderson committed
134 135 136 137 138 139 140 141 142 143 144 145
#ifdef BFD64

#ifndef BFD_HOST_64_BIT
 #error No 64 bit integer type available
#endif /* ! defined (BFD_HOST_64_BIT) */

typedef BFD_HOST_U_64_BIT bfd_vma;
typedef BFD_HOST_64_BIT bfd_signed_vma;
typedef BFD_HOST_U_64_BIT bfd_size_type;
typedef BFD_HOST_U_64_BIT symvalue;

#if BFD_HOST_64BIT_LONG
Alan Modra's avatar
bfd/  
Alan Modra committed
146 147 148
#define BFD_VMA_FMT "l"
#elif defined (__MSVCRT__)
#define BFD_VMA_FMT "I64"
149
#else
Alan Modra's avatar
bfd/  
Alan Modra committed
150
#define BFD_VMA_FMT "ll"
Richard Henderson's avatar
Richard Henderson committed
151
#endif
Alan Modra's avatar
bfd/  
Alan Modra committed
152 153 154 155

#ifndef fprintf_vma
#define sprintf_vma(s,x) sprintf (s, "%016" BFD_VMA_FMT "x", x)
#define fprintf_vma(f,x) fprintf (f, "%016" BFD_VMA_FMT "x", x)
Richard Henderson's avatar
Richard Henderson committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
#endif

#else /* not BFD64  */

/* Represent a target address.  Also used as a generic unsigned type
   which is guaranteed to be big enough to hold any arithmetic types
   we need to deal with.  */
typedef unsigned long bfd_vma;

/* A generic signed type which is guaranteed to be big enough to hold any
   arithmetic types we need to deal with.  Can be assumed to be compatible
   with bfd_vma in the same way that signed and unsigned ints are compatible
   (as parameters, in assignment, etc).  */
typedef long bfd_signed_vma;

typedef unsigned long symvalue;
typedef unsigned long bfd_size_type;

/* Print a bfd_vma x on stream s.  */
Alan Modra's avatar
bfd/  
Alan Modra committed
175 176 177
#define BFD_VMA_FMT "l"
#define fprintf_vma(s,x) fprintf (s, "%08" BFD_VMA_FMT "x", x)
#define sprintf_vma(s,x) sprintf (s, "%08" BFD_VMA_FMT "x", x)
Richard Henderson's avatar
Richard Henderson committed
178 179 180

#endif /* not BFD64  */

181 182 183
#define HALF_BFD_SIZE_TYPE \
  (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2))

184 185 186 187 188 189 190 191 192
#ifndef BFD_HOST_64_BIT
/* Fall back on a 32 bit type.  The idea is to make these types always
   available for function return types, but in the case that
   BFD_HOST_64_BIT is undefined such a function should abort or
   otherwise signal an error.  */
typedef bfd_signed_vma bfd_int64_t;
typedef bfd_vma bfd_uint64_t;
#endif

193 194 195 196
/* An offset into a file.  BFD always uses the largest possible offset
   based on the build time availability of fseek, fseeko, or fseeko64.  */
typedef @bfd_file_ptr@ file_ptr;
typedef unsigned @bfd_file_ptr@ ufile_ptr;
197

198 199
extern void bfd_sprintf_vma (bfd *, char *, bfd_vma);
extern void bfd_fprintf_vma (bfd *, void *, bfd_vma);
H.J. Lu's avatar
H.J. Lu committed
200

Richard Henderson's avatar
Richard Henderson committed
201
#define printf_vma(x) fprintf_vma(stdout,x)
H.J. Lu's avatar
H.J. Lu committed
202
#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
Richard Henderson's avatar
Richard Henderson committed
203 204 205 206

typedef unsigned int flagword;	/* 32 bits of flags */
typedef unsigned char bfd_byte;

207
/* File formats.  */
Richard Henderson's avatar
Richard Henderson committed
208

209 210 211
typedef enum bfd_format
{
  bfd_unknown = 0,	/* File format is unknown.  */
212
  bfd_object,		/* Linker/assembler/compiler output.  */
213 214 215 216 217
  bfd_archive,		/* Object archive file.  */
  bfd_core,		/* Core dump.  */
  bfd_type_end		/* Marks the end; don't use it!  */
}
bfd_format;
Richard Henderson's avatar
Richard Henderson committed
218

219
/* Symbols and relocation.  */
Richard Henderson's avatar
Richard Henderson committed
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239

/* A count of carsyms (canonical archive symbols).  */
typedef unsigned long symindex;

/* How to perform a relocation.  */
typedef const struct reloc_howto_struct reloc_howto_type;

#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)

/* General purpose part of a symbol X;
   target specific parts are in libcoff.h, libaout.h, etc.  */

#define bfd_get_section(x) ((x)->section)
#define bfd_get_output_section(x) ((x)->section->output_section)
#define bfd_set_section(x,y) ((x)->section) = (y)
#define bfd_asymbol_base(x) ((x)->section->vma)
#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
#define bfd_asymbol_name(x) ((x)->name)
/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
#define bfd_asymbol_bfd(x) ((x)->the_bfd)
Richard Sandiford's avatar
bfd/  
Richard Sandiford committed
240 241 242 243
#define bfd_asymbol_flavour(x)			\
  (((x)->flags & BSF_SYNTHETIC) != 0		\
   ? bfd_target_unknown_flavour			\
   : bfd_asymbol_bfd (x)->xvec->flavour)
Richard Henderson's avatar
Richard Henderson committed
244 245

/* A canonical archive symbol.  */
246 247 248
/* This is a type pun with struct ranlib on purpose!  */
typedef struct carsym
{
Richard Henderson's avatar
Richard Henderson committed
249
  char *name;
250 251 252
  file_ptr file_offset;	/* Look here to find the file.  */
}
carsym;			/* To make these you call a carsymogen.  */
Richard Henderson's avatar
Richard Henderson committed
253 254

/* Used in generating armaps (archive tables of contents).
255 256 257 258 259 260
   Perhaps just a forward definition would do?  */
struct orl 			/* Output ranlib.  */
{
  char **name;		/* Symbol name.  */
  union
  {
261 262
    file_ptr pos;
    bfd *abfd;
263 264
  } u;			/* bfd* or file position.  */
  int namidx;		/* Index into string table.  */
Richard Henderson's avatar
Richard Henderson committed
265 266
};

267 268 269 270 271 272
/* Linenumber stuff.  */
typedef struct lineno_cache_entry
{
  unsigned int line_number;	/* Linenumber from start of function.  */
  union
  {
Andrew Cagney's avatar
Andrew Cagney committed
273
    struct bfd_symbol *sym;	/* Function name.  */
274
    bfd_vma offset;	    		/* Offset into section.  */
Richard Henderson's avatar
Richard Henderson committed
275
  } u;
276 277
}
alent;
Richard Henderson's avatar
Richard Henderson committed
278

279
/* Object and core file sections.  */
Richard Henderson's avatar
Richard Henderson committed
280 281

#define	align_power(addr, align)	\
282
  (((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align))))
Richard Henderson's avatar
Richard Henderson committed
283

284
typedef struct bfd_section *sec_ptr;
Richard Henderson's avatar
Richard Henderson committed
285

286 287 288 289 290
#define bfd_get_section_name(bfd, ptr) ((void) bfd, (ptr)->name)
#define bfd_get_section_vma(bfd, ptr) ((void) bfd, (ptr)->vma)
#define bfd_get_section_lma(bfd, ptr) ((void) bfd, (ptr)->lma)
#define bfd_get_section_alignment(bfd, ptr) ((void) bfd, \
					     (ptr)->alignment_power)
Richard Henderson's avatar
Richard Henderson committed
291
#define bfd_section_name(bfd, ptr) ((ptr)->name)
Alan Modra's avatar
bfd/  
Alan Modra committed
292 293
#define bfd_section_size(bfd, ptr) ((ptr)->size)
#define bfd_get_section_size(ptr) ((ptr)->size)
Richard Henderson's avatar
Richard Henderson committed
294 295 296
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
297 298
#define bfd_get_section_flags(bfd, ptr) ((void) bfd, (ptr)->flags)
#define bfd_get_section_userdata(bfd, ptr) ((void) bfd, (ptr)->userdata)
Richard Henderson's avatar
Richard Henderson committed
299 300 301

#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)

302 303
/* Find the address one past the end of SEC.  */
#define bfd_get_section_limit(bfd, sec) \
304 305
  (((bfd)->direction != write_direction && (sec)->rawsize != 0	\
    ? (sec)->rawsize : (sec)->size) / bfd_octets_per_byte (bfd))
Richard Henderson's avatar
Richard Henderson committed
306

307
/* Return TRUE if input section SEC has been discarded.  */
Alan Modra's avatar
Alan Modra committed
308
#define discarded_section(sec)				\
Alan Modra's avatar
Alan Modra committed
309 310
  (!bfd_is_abs_section (sec)					\
   && bfd_is_abs_section ((sec)->output_section)		\
Alan Modra's avatar
Alan Modra committed
311 312
   && (sec)->sec_info_type != SEC_INFO_TYPE_MERGE		\
   && (sec)->sec_info_type != SEC_INFO_TYPE_JUST_SYMS)
Richard Henderson's avatar
Richard Henderson committed
313 314

typedef enum bfd_print_symbol
315
{
Richard Henderson's avatar
Richard Henderson committed
316 317 318 319
  bfd_print_symbol_name,
  bfd_print_symbol_more,
  bfd_print_symbol_all
} bfd_print_symbol_type;
320

Richard Henderson's avatar
Richard Henderson committed
321 322 323 324 325 326
/* Information about a symbol that nm needs.  */

typedef struct _symbol_info
{
  symvalue value;
  char type;
327
  const char *name;            /* Symbol name.  */
Richard Henderson's avatar
Richard Henderson committed
328
  unsigned char stab_type;     /* Stab type.  */
329
  char stab_other;             /* Stab other.  */
Richard Henderson's avatar
Richard Henderson committed
330
  short stab_desc;             /* Stab desc.  */
331
  const char *stab_name;       /* String for stab type.  */
Richard Henderson's avatar
Richard Henderson committed
332 333 334 335
} symbol_info;

/* Get the name of a stabs type code.  */

336
extern const char *bfd_get_stab_name (int);
Richard Henderson's avatar
Richard Henderson committed
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366

/* Hash table routines.  There is no way to free up a hash table.  */

/* An element in the hash table.  Most uses will actually use a larger
   structure, and an instance of this will be the first field.  */

struct bfd_hash_entry
{
  /* Next entry for this hash code.  */
  struct bfd_hash_entry *next;
  /* String being hashed.  */
  const char *string;
  /* Hash code.  This is the full hash code, not the index into the
     table.  */
  unsigned long hash;
};

/* A hash table.  */

struct bfd_hash_table
{
  /* The hash array.  */
  struct bfd_hash_entry **table;
  /* A function used to create new elements in the hash table.  The
     first entry is itself a pointer to an element.  When this
     function is first invoked, this pointer will be NULL.  However,
     having the pointer permits a hierarchy of method functions to be
     built each of which calls the function in the superclass.  Thus
     each function should be written to allocate a new block of memory
     only if the argument is NULL.  */
367
  struct bfd_hash_entry *(*newfunc)
368
    (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
Richard Henderson's avatar
Richard Henderson committed
369
   /* An objalloc for this hash table.  This is a struct objalloc *,
370 371
     but we use void * to avoid requiring the inclusion of objalloc.h.  */
  void *memory;
Alan Modra's avatar
Alan Modra committed
372 373 374 375 376 377 378 379
  /* The number of slots in the hash table.  */
  unsigned int size;
  /* The number of entries in the hash table.  */
  unsigned int count;
  /* The size of elements.  */
  unsigned int entsize;
  /* If non-zero, don't grow the hash table.  */
  unsigned int frozen:1;
Richard Henderson's avatar
Richard Henderson committed
380 381 382
};

/* Initialize a hash table.  */
383
extern bfd_boolean bfd_hash_table_init
384 385 386
  (struct bfd_hash_table *,
   struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
			       struct bfd_hash_table *,
Alan Modra's avatar
Alan Modra committed
387 388
			       const char *),
   unsigned int);
Richard Henderson's avatar
Richard Henderson committed
389 390

/* Initialize a hash table specifying a size.  */
391
extern bfd_boolean bfd_hash_table_init_n
392 393 394 395
  (struct bfd_hash_table *,
   struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
			       struct bfd_hash_table *,
			       const char *),
Alan Modra's avatar
Alan Modra committed
396
   unsigned int, unsigned int);
Richard Henderson's avatar
Richard Henderson committed
397 398

/* Free up a hash table.  */
399
extern void bfd_hash_table_free
400
  (struct bfd_hash_table *);
Richard Henderson's avatar
Richard Henderson committed
401

402
/* Look up a string in a hash table.  If CREATE is TRUE, a new entry
Richard Henderson's avatar
Richard Henderson committed
403
   will be created for this string if one does not already exist.  The
404
   COPY argument must be TRUE if this routine should copy the string
Richard Henderson's avatar
Richard Henderson committed
405 406
   into newly allocated memory when adding an entry.  */
extern struct bfd_hash_entry *bfd_hash_lookup
407 408
  (struct bfd_hash_table *, const char *, bfd_boolean create,
   bfd_boolean copy);
Richard Henderson's avatar
Richard Henderson committed
409

410 411 412 413
/* Insert an entry in a hash table.  */
extern struct bfd_hash_entry *bfd_hash_insert
  (struct bfd_hash_table *, const char *, unsigned long);

Alan Modra's avatar
bfd/  
Alan Modra committed
414 415 416 417
/* Rename an entry in a hash table.  */
extern void bfd_hash_rename
  (struct bfd_hash_table *, const char *, struct bfd_hash_entry *);

Richard Henderson's avatar
Richard Henderson committed
418 419
/* Replace an entry in a hash table.  */
extern void bfd_hash_replace
420 421
  (struct bfd_hash_table *, struct bfd_hash_entry *old,
   struct bfd_hash_entry *nw);
Richard Henderson's avatar
Richard Henderson committed
422 423 424

/* Base method for creating a hash table entry.  */
extern struct bfd_hash_entry *bfd_hash_newfunc
425
  (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
Richard Henderson's avatar
Richard Henderson committed
426 427

/* Grab some space for a hash table entry.  */
428 429
extern void *bfd_hash_allocate
  (struct bfd_hash_table *, unsigned int);
Richard Henderson's avatar
Richard Henderson committed
430 431

/* Traverse a hash table in a random order, calling a function on each
432
   element.  If the function returns FALSE, the traversal stops.  The
Richard Henderson's avatar
Richard Henderson committed
433
   INFO argument is passed to the function.  */
434
extern void bfd_hash_traverse
435 436 437
  (struct bfd_hash_table *,
   bfd_boolean (*) (struct bfd_hash_entry *, void *),
   void *info);
Richard Henderson's avatar
Richard Henderson committed
438

439 440 441
/* Allows the default size of a hash table to be configured. New hash
   tables allocated using bfd_hash_table_init will be created with
   this size.  */
Alan Modra's avatar
bfd/  
Alan Modra committed
442
extern unsigned long bfd_hash_set_default_size (unsigned long);
443

444 445 446 447 448 449 450 451 452 453 454 455 456
/* This structure is used to keep track of stabs in sections
   information while linking.  */

struct stab_info
{
  /* A hash table used to hold stabs strings.  */
  struct bfd_strtab_hash *strings;
  /* The header file hash table.  */
  struct bfd_hash_table includes;
  /* The first .stabstr section.  */
  struct bfd_section *stabstr;
};

457
#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
Alan Modra's avatar
Alan Modra committed
458

459
/* User program access to BFD facilities.  */
Richard Henderson's avatar
Richard Henderson committed
460 461 462 463

/* Direct I/O routines, for programs which know more about the object
   file than BFD does.  Use higher level routines if possible.  */

464 465 466
extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
extern int bfd_seek (bfd *, file_ptr, int);
467
extern file_ptr bfd_tell (bfd *);
468 469
extern int bfd_flush (bfd *);
extern int bfd_stat (bfd *, struct stat *);
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486

/* Deprecated old routines.  */
#if __GNUC__
#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD)				\
  (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__),	\
   bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD)				\
  (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__),	\
   bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
#else
#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD)				\
  (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
   bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD)				\
  (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
   bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
#endif
487
extern void warn_deprecated (const char *, const char *, int, const char *);
Richard Henderson's avatar
Richard Henderson committed
488 489 490 491 492 493 494 495

/* Cast from const char * to char * so that caller can assign to
   a char * without a warning.  */
#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
#define bfd_get_format(abfd) ((abfd)->format)
#define bfd_get_target(abfd) ((abfd)->xvec->name)
#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
496 497 498
#define bfd_family_coff(abfd) \
  (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
   bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
Richard Henderson's avatar
Richard Henderson committed
499 500 501 502 503 504 505 506 507 508 509
#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
#define bfd_header_big_endian(abfd) \
  ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
#define bfd_header_little_endian(abfd) \
  ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
#define bfd_get_file_flags(abfd) ((abfd)->flags)
#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
#define bfd_my_archive(abfd) ((abfd)->my_archive)
#define bfd_has_map(abfd) ((abfd)->has_armap)
510
#define bfd_is_thin_archive(abfd) ((abfd)->is_thin_archive)
Richard Henderson's avatar
Richard Henderson committed
511 512 513 514 515 516 517 518 519

#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
#define bfd_usrdata(abfd) ((abfd)->usrdata)

#define bfd_get_start_address(abfd) ((abfd)->start_address)
#define bfd_get_symcount(abfd) ((abfd)->symcount)
#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
#define bfd_count_sections(abfd) ((abfd)->section_count)

520 521
#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)

Richard Henderson's avatar
Richard Henderson committed
522 523
#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)

524
#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
Richard Henderson's avatar
Richard Henderson committed
525

526
extern bfd_boolean bfd_cache_close
527
  (bfd *abfd);
Frank Ch. Eigler's avatar
Frank Ch. Eigler committed
528 529
/* NB: This declaration should match the autogenerated one in libbfd.h.  */

530 531
extern bfd_boolean bfd_cache_close_all (void);

532
extern bfd_boolean bfd_record_phdr
533
  (bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
534
   bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
Richard Henderson's avatar
Richard Henderson committed
535 536 537

/* Byte swapping routines.  */

538 539 540 541
bfd_uint64_t bfd_getb64 (const void *);
bfd_uint64_t bfd_getl64 (const void *);
bfd_int64_t bfd_getb_signed_64 (const void *);
bfd_int64_t bfd_getl_signed_64 (const void *);
542 543 544 545 546 547 548 549
bfd_vma bfd_getb32 (const void *);
bfd_vma bfd_getl32 (const void *);
bfd_signed_vma bfd_getb_signed_32 (const void *);
bfd_signed_vma bfd_getl_signed_32 (const void *);
bfd_vma bfd_getb16 (const void *);
bfd_vma bfd_getl16 (const void *);
bfd_signed_vma bfd_getb_signed_16 (const void *);
bfd_signed_vma bfd_getl_signed_16 (const void *);
550 551
void bfd_putb64 (bfd_uint64_t, void *);
void bfd_putl64 (bfd_uint64_t, void *);
552 553 554 555
void bfd_putb32 (bfd_vma, void *);
void bfd_putl32 (bfd_vma, void *);
void bfd_putb16 (bfd_vma, void *);
void bfd_putl16 (bfd_vma, void *);
556 557 558

/* Byte swapping routines which take size and endiannes as arguments.  */

559 560
bfd_uint64_t bfd_get_bits (const void *, int, bfd_boolean);
void bfd_put_bits (bfd_uint64_t, void *, int, bfd_boolean);
H.J. Lu's avatar
bfd/  
H.J. Lu committed
561

Richard Henderson's avatar
Richard Henderson committed
562 563 564 565
#if defined(__STDC__) || defined(ALMOST_STDC)
struct ecoff_debug_info;
struct ecoff_debug_swap;
struct ecoff_extr;
Andrew Cagney's avatar
Andrew Cagney committed
566
struct bfd_symbol;
Richard Henderson's avatar
Richard Henderson committed
567 568
struct bfd_link_info;
struct bfd_link_hash_entry;
Alan Modra's avatar
Alan Modra committed
569
struct bfd_section_already_linked;
Richard Henderson's avatar
Richard Henderson committed
570 571
struct bfd_elf_version_tree;
#endif
Alan Modra's avatar
Alan Modra committed
572 573 574 575 576 577 578 579 580

extern bfd_boolean bfd_section_already_linked_table_init (void);
extern void bfd_section_already_linked_table_free (void);
extern bfd_boolean _bfd_handle_already_linked
  (struct bfd_section *, struct bfd_section_already_linked *,
   struct bfd_link_info *);

/* Externally visible ECOFF routines.  */

581
extern bfd_vma bfd_ecoff_get_gp_value
582
  (bfd * abfd);
583
extern bfd_boolean bfd_ecoff_set_gp_value
584
  (bfd *abfd, bfd_vma gp_value);
585
extern bfd_boolean bfd_ecoff_set_regmasks
586 587 588 589 590
  (bfd *abfd, unsigned long gprmask, unsigned long fprmask,
   unsigned long *cprmask);
extern void *bfd_ecoff_debug_init
  (bfd *output_bfd, struct ecoff_debug_info *output_debug,
   const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
Richard Henderson's avatar
Richard Henderson committed
591
extern void bfd_ecoff_debug_free
592 593
  (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
   const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
594
extern bfd_boolean bfd_ecoff_debug_accumulate
595 596 597 598
  (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
   const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
   struct ecoff_debug_info *input_debug,
   const struct ecoff_debug_swap *input_swap, struct bfd_link_info *);
599
extern bfd_boolean bfd_ecoff_debug_accumulate_other
600 601 602
  (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
   const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
   struct bfd_link_info *);
603
extern bfd_boolean bfd_ecoff_debug_externals
604 605
  (bfd *abfd, struct ecoff_debug_info *debug,
   const struct ecoff_debug_swap *swap, bfd_boolean relocatable,
Andrew Cagney's avatar
Andrew Cagney committed
606 607
   bfd_boolean (*get_extr) (struct bfd_symbol *, struct ecoff_extr *),
   void (*set_index) (struct bfd_symbol *, bfd_size_type));
608
extern bfd_boolean bfd_ecoff_debug_one_external
609 610 611
  (bfd *abfd, struct ecoff_debug_info *debug,
   const struct ecoff_debug_swap *swap, const char *name,
   struct ecoff_extr *esym);
Richard Henderson's avatar
Richard Henderson committed
612
extern bfd_size_type bfd_ecoff_debug_size
613 614
  (bfd *abfd, struct ecoff_debug_info *debug,
   const struct ecoff_debug_swap *swap);
615
extern bfd_boolean bfd_ecoff_write_debug
616 617
  (bfd *abfd, struct ecoff_debug_info *debug,
   const struct ecoff_debug_swap *swap, file_ptr where);
618
extern bfd_boolean bfd_ecoff_write_accumulated_debug
619 620 621
  (void *handle, bfd *abfd, struct ecoff_debug_info *debug,
   const struct ecoff_debug_swap *swap,
   struct bfd_link_info *info, file_ptr where);
Richard Henderson's avatar
Richard Henderson committed
622 623 624 625 626 627 628 629 630 631

/* Externally visible ELF routines.  */

struct bfd_link_needed_list
{
  struct bfd_link_needed_list *next;
  bfd *by;
  const char *name;
};

Alan Modra's avatar
bfd/  
Alan Modra committed
632 633 634
enum dynamic_lib_link_class {
  DYN_NORMAL = 0,
  DYN_AS_NEEDED = 1,
H.J. Lu's avatar
bfd/  
H.J. Lu committed
635 636 637
  DYN_DT_NEEDED = 2,
  DYN_NO_ADD_NEEDED = 4,
  DYN_NO_NEEDED = 8
Alan Modra's avatar
bfd/  
Alan Modra committed
638 639
};

Alan Modra's avatar
bfd/  
Alan Modra committed
640 641 642 643 644 645
enum notice_asneeded_action {
  notice_as_needed,
  notice_not_needed,
  notice_needed
};

646
extern bfd_boolean bfd_elf_record_link_assignment
H.J. Lu's avatar
bfd/  
H.J. Lu committed
647 648
  (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
   bfd_boolean);
Richard Henderson's avatar
Richard Henderson committed
649
extern struct bfd_link_needed_list *bfd_elf_get_needed_list
650
  (bfd *, struct bfd_link_info *);
651
extern bfd_boolean bfd_elf_get_bfd_needed_list
652
  (bfd *, struct bfd_link_needed_list **);
Nathan Sidwell's avatar
Nathan Sidwell committed
653 654
extern bfd_boolean bfd_elf_stack_segment_size (bfd *, struct bfd_link_info *,
					       const char *, bfd_vma);
Alan Modra's avatar
Alan Modra committed
655
extern bfd_boolean bfd_elf_size_dynamic_sections
Alan Modra's avatar
bfd/  
Alan Modra committed
656
  (bfd *, const char *, const char *, const char *, const char *, const char *,
657
   const char * const *, struct bfd_link_info *, struct bfd_section **);
Alan Modra's avatar
bfd/  
Alan Modra committed
658 659
extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr
  (bfd *, struct bfd_link_info *);
660
extern void bfd_elf_set_dt_needed_name
661
  (bfd *, const char *);
662
extern const char *bfd_elf_get_dt_soname
663
  (bfd *);
Alan Modra's avatar
bfd/  
Alan Modra committed
664
extern void bfd_elf_set_dyn_lib_class
665
  (bfd *, enum dynamic_lib_link_class);
H.J. Lu's avatar
bfd/  
H.J. Lu committed
666 667
extern int bfd_elf_get_dyn_lib_class
  (bfd *);
H.J. Lu's avatar
H.J. Lu committed
668
extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
669
  (bfd *, struct bfd_link_info *);
670
extern bfd_boolean bfd_elf_discard_info
671
  (bfd *, struct bfd_link_info *);
672 673
extern unsigned int _bfd_elf_default_action_discarded
  (struct bfd_section *);
Richard Henderson's avatar
Richard Henderson committed
674

675 676 677
/* Return an upper bound on the number of bytes required to store a
   copy of ABFD's program header table entries.  Return -1 if an error
   occurs; bfd_get_error will return an appropriate code.  */
678
extern long bfd_get_elf_phdr_upper_bound
679
  (bfd *abfd);
680 681 682 683 684 685 686 687

/* Copy ABFD's program header table entries to *PHDRS.  The entries
   will be stored as an array of Elf_Internal_Phdr structures, as
   defined in include/elf/internal.h.  To find out how large the
   buffer needs to be, call bfd_get_elf_phdr_upper_bound.

   Return the number of program header table entries read, or -1 if an
   error occurs; bfd_get_error will return an appropriate code.  */
688
extern int bfd_get_elf_phdrs
689
  (bfd *abfd, void *phdrs);
690

691 692 693 694 695 696 697 698 699 700 701 702 703
/* Create a new BFD as if by bfd_openr.  Rather than opening a file,
   reconstruct an ELF file by reading the segments out of remote memory
   based on the ELF file header at EHDR_VMA and the ELF program headers it
   points to.  If not null, *LOADBASEP is filled in with the difference
   between the VMAs from which the segments were read, and the VMAs the
   file headers (and hence BFD's idea of each section's VMA) put them at.

   The function TARGET_READ_MEMORY is called to copy LEN bytes from the
   remote memory at target address VMA into the local buffer at MYADDR; it
   should return zero on success or an `errno' code on failure.  TEMPL must
   be a BFD for an ELF target with the word size and byte order found in
   the remote memory.  */
extern bfd *bfd_elf_bfd_from_remote_memory
704
  (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
Jan Kratochvil's avatar
bfd/  
Jan Kratochvil committed
705 706
   int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
			      bfd_size_type len));
707

708 709 710
extern struct bfd_section *_bfd_elf_tls_setup
  (bfd *, struct bfd_link_info *);

711 712 713
extern struct bfd_section *
_bfd_nearby_section (bfd *, struct bfd_section *, bfd_vma);

Alan Modra's avatar
bfd/  
Alan Modra committed
714
extern void _bfd_fix_excluded_sec_syms
Alan Modra's avatar
bfd/  
Alan Modra committed
715
  (bfd *, struct bfd_link_info *);
H.J. Lu's avatar
bfd/  
H.J. Lu committed
716

717 718 719 720
extern unsigned bfd_m68k_mach_to_features (int);

extern int bfd_m68k_features_to_mach (unsigned);

721
extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
Alan Modra's avatar
bfd/  
Alan Modra committed
722 723
  (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
   char **);
724

725 726
extern void bfd_elf_m68k_set_target_options (struct bfd_link_info *, int);

727 728 729 730
extern bfd_boolean bfd_bfin_elf32_create_embedded_relocs
  (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
   char **);

M R Swami Reddy's avatar
 
M R Swami Reddy committed
731 732 733 734
extern bfd_boolean bfd_cr16_elf32_create_embedded_relocs
  (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
   char **);

Richard Henderson's avatar
Richard Henderson committed
735 736 737
/* SunOS shared library support routines for the linker.  */

extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
738
  (bfd *, struct bfd_link_info *);
739
extern bfd_boolean bfd_sunos_record_link_assignment
740
  (bfd *, struct bfd_link_info *, const char *);
741
extern bfd_boolean bfd_sunos_size_dynamic_sections
Alan Modra's avatar
bfd/  
Alan Modra committed
742 743
  (bfd *, struct bfd_link_info *, struct bfd_section **,
   struct bfd_section **, struct bfd_section **);
Richard Henderson's avatar
Richard Henderson committed
744 745 746

/* Linux shared library support routines for the linker.  */

747
extern bfd_boolean bfd_i386linux_size_dynamic_sections
748
  (bfd *, struct bfd_link_info *);
749
extern bfd_boolean bfd_m68klinux_size_dynamic_sections
750
  (bfd *, struct bfd_link_info *);
751
extern bfd_boolean bfd_sparclinux_size_dynamic_sections
752
  (bfd *, struct bfd_link_info *);
Richard Henderson's avatar
Richard Henderson committed
753 754 755 756 757 758

/* mmap hacks */

struct _bfd_window_internal;
typedef struct _bfd_window_internal bfd_window_internal;

759 760
typedef struct _bfd_window
{
Richard Henderson's avatar
Richard Henderson committed
761
  /* What the user asked for.  */
762
  void *data;
Richard Henderson's avatar
Richard Henderson committed
763 764 765 766 767 768 769 770
  bfd_size_type size;
  /* The actual window used by BFD.  Small user-requested read-only
     regions sharing a page may share a single window into the object
     file.  Read-write versions shouldn't until I've fixed things to
     keep track of which portions have been claimed by the
     application; don't want to give the same region back when the
     application wants two writable copies!  */
  struct _bfd_window_internal *i;
771 772
}
bfd_window;
Richard Henderson's avatar
Richard Henderson committed
773

774
extern void bfd_init_window
775
  (bfd_window *);
776
extern void bfd_free_window
777
  (bfd_window *);
778
extern bfd_boolean bfd_get_file_window
779
  (bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean);
Richard Henderson's avatar
Richard Henderson committed
780 781 782

/* XCOFF support routines for the linker.  */

Richard Sandiford's avatar
bfd/  
Richard Sandiford committed
783 784 785 786
extern bfd_boolean bfd_xcoff_split_import_path
  (bfd *, const char *, const char **, const char **);
extern bfd_boolean bfd_xcoff_set_archive_import_path
  (struct bfd_link_info *, bfd *, const char *);
787
extern bfd_boolean bfd_xcoff_link_record_set
788
  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type);
789
extern bfd_boolean bfd_xcoff_import_symbol
790 791
  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma,
   const char *, const char *, const char *, unsigned int);
792
extern bfd_boolean bfd_xcoff_export_symbol
793
  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
794
extern bfd_boolean bfd_xcoff_link_count_reloc
795
  (bfd *, struct bfd_link_info *, const char *);
796
extern bfd_boolean bfd_xcoff_record_link_assignment
797
  (bfd *, struct bfd_link_info *, const char *);
798
extern bfd_boolean bfd_xcoff_size_dynamic_sections
799 800
  (bfd *, struct bfd_link_info *, const char *, const char *,
   unsigned long, unsigned long, unsigned long, bfd_boolean,
Richard Sandiford's avatar
Richard Sandiford committed
801
   int, bfd_boolean, unsigned int, struct bfd_section **, bfd_boolean);
802
extern bfd_boolean bfd_xcoff_link_generate_rtinit
803
  (bfd *, const char *, const char *, bfd_boolean);
Richard Henderson's avatar
Richard Henderson committed
804

805
/* XCOFF support routines for ar.  */
806
extern bfd_boolean bfd_xcoff_ar_archive_set_magic
807
  (bfd *, char *);
808

Richard Henderson's avatar
Richard Henderson committed
809 810 811 812 813 814 815
/* Externally visible COFF routines.  */

#if defined(__STDC__) || defined(ALMOST_STDC)
struct internal_syment;
union internal_auxent;
#endif

816
extern bfd_boolean bfd_coff_get_syment
Andrew Cagney's avatar
Andrew Cagney committed
817
  (bfd *, struct bfd_symbol *, struct internal_syment *);
Richard Henderson's avatar
Richard Henderson committed
818

819
extern bfd_boolean bfd_coff_get_auxent
Andrew Cagney's avatar
Andrew Cagney committed
820
  (bfd *, struct bfd_symbol *, int, union internal_auxent *);
Richard Henderson's avatar
Richard Henderson committed
821

822
extern bfd_boolean bfd_coff_set_symbol_class
Andrew Cagney's avatar
Andrew Cagney committed
823
  (bfd *, struct bfd_symbol *, unsigned int);
Richard Henderson's avatar
Richard Henderson committed
824

825
extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
826
  (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
827

Julian Brown's avatar
Julian Brown committed
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842
/* ARM VFP11 erratum workaround support.  */
typedef enum
{
  BFD_ARM_VFP11_FIX_DEFAULT,
  BFD_ARM_VFP11_FIX_NONE,
  BFD_ARM_VFP11_FIX_SCALAR,
  BFD_ARM_VFP11_FIX_VECTOR
} bfd_arm_vfp11_fix;

extern void bfd_elf32_arm_init_maps
  (bfd *);

extern void bfd_elf32_arm_set_vfp11_fix
  (bfd *, struct bfd_link_info *);

Julian Brown's avatar
Julian Brown committed
843 844 845
extern void bfd_elf32_arm_set_cortex_a8_fix
  (bfd *, struct bfd_link_info *);

Julian Brown's avatar
Julian Brown committed
846 847 848 849 850 851
extern bfd_boolean bfd_elf32_arm_vfp11_erratum_scan
  (bfd *, struct bfd_link_info *);

extern void bfd_elf32_arm_vfp11_fix_veneer_locations
  (bfd *, struct bfd_link_info *);

Richard Henderson's avatar
Richard Henderson committed
852
/* ARM Interworking support.  Called from linker.  */
853
extern bfd_boolean bfd_arm_allocate_interworking_sections
854
  (struct bfd_link_info *);
Richard Henderson's avatar
Richard Henderson committed
855

856
extern bfd_boolean bfd_arm_process_before_allocation
857
  (bfd *, struct bfd_link_info *, int);
Richard Henderson's avatar
Richard Henderson committed
858

859
extern bfd_boolean bfd_arm_get_bfd_for_interworking
860
  (bfd *, struct bfd_link_info *);
Richard Henderson's avatar
Richard Henderson committed
861

862
/* PE ARM Interworking support.  Called from linker.  */
863
extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
864
  (struct bfd_link_info *);
865

866
extern bfd_boolean bfd_arm_pe_process_before_allocation
867
  (bfd *, struct bfd_link_info *, int);
868

869
extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
870
  (bfd *, struct bfd_link_info *);
871

Richard Henderson's avatar
Richard Henderson committed
872
/* ELF ARM Interworking support.  Called from linker.  */
873
extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
874
  (struct bfd_link_info *);
875

876
extern bfd_boolean bfd_elf32_arm_process_before_allocation
Daniel Jacobowitz's avatar
bfd/  
Daniel Jacobowitz committed
877
  (bfd *, struct bfd_link_info *);
Paul Brook's avatar
bfd/  
Paul Brook committed
878 879

void bfd_elf32_arm_set_target_relocs
Mark Shinwell's avatar
Mark Shinwell committed
880
  (bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix,
881
   int, int, int, int, int);
882

883
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
884
  (bfd *, struct bfd_link_info *);
Richard Henderson's avatar
Richard Henderson committed
885

886
extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
887
  (bfd *, struct bfd_link_info *);
888

889
/* ELF ARM mapping symbol support */
890 891 892 893 894 895
#define BFD_ARM_SPECIAL_SYM_TYPE_MAP	(1 << 0)
#define BFD_ARM_SPECIAL_SYM_TYPE_TAG	(1 << 1)
#define BFD_ARM_SPECIAL_SYM_TYPE_OTHER  (1 << 2)
#define BFD_ARM_SPECIAL_SYM_TYPE_ANY	(~0)
extern bfd_boolean bfd_is_arm_special_symbol_name
  (const char * name, int type);
896

Daniel Jacobowitz's avatar
bfd/  
Daniel Jacobowitz committed
897 898
extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);

899 900
/* ARM Note section processing.  */
extern bfd_boolean bfd_arm_merge_machines
901
  (bfd *, bfd *);
902 903

extern bfd_boolean bfd_arm_update_notes
904
  (bfd *, const char *);
905 906

extern unsigned int bfd_arm_get_mach_from_notes
907
  (bfd *, const char *);
908

Nick Clifton's avatar
Nick Clifton committed
909 910 911 912 913 914 915
/* ARM stub generation support.  Called from the linker.  */
extern int elf32_arm_setup_section_lists
  (bfd *, struct bfd_link_info *);
extern void elf32_arm_next_input_section
  (struct bfd_link_info *, struct bfd_section *);
extern bfd_boolean elf32_arm_size_stubs
  (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
916 917
   struct bfd_section * (*) (const char *, struct bfd_section *, unsigned int),
   void (*) (void));
Nick Clifton's avatar
Nick Clifton committed
918 919
extern bfd_boolean elf32_arm_build_stubs
  (struct bfd_link_info *);
920 921 922

/* ARM unwind section editing support.  */
extern bfd_boolean elf32_arm_fix_exidx_coverage
Nick Clifton's avatar
Nick Clifton committed
923
(struct bfd_section **, unsigned int, struct bfd_link_info *, bfd_boolean);
924

925 926 927 928
/* C6x unwind section editing support.  */
extern bfd_boolean elf32_tic6x_fix_exidx_coverage
(struct bfd_section **, unsigned int, struct bfd_link_info *, bfd_boolean);

Alan Modra's avatar
bfd/  
Alan Modra committed
929 930 931
/* PowerPC @tls opcode transform/validate.  */
extern unsigned int _bfd_elf_ppc_at_tls_transform
  (unsigned int, unsigned int);
Alan Modra's avatar
Alan Modra committed
932 933 934
/* PowerPC @tprel opcode transform/validate.  */
extern unsigned int _bfd_elf_ppc_at_tprel_transform
  (unsigned int, unsigned int);
Alan Modra's avatar
bfd/  
Alan Modra committed
935

936 937 938
extern void bfd_elf64_aarch64_init_maps
  (bfd *);

939 940 941
extern void bfd_elf32_aarch64_init_maps
  (bfd *);

Yufeng Zhang's avatar
bfd/  
Yufeng Zhang committed
942
extern void bfd_elf64_aarch64_set_options
943 944
  (bfd *, struct bfd_link_info *, int, int, int);

945 946 947
extern void bfd_elf32_aarch64_set_options
  (bfd *, struct bfd_link_info *, int, int, int);

948 949 950 951 952 953 954 955
/* ELF AArch64 mapping symbol support.  */
#define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP	(1 << 0)
#define BFD_AARCH64_SPECIAL_SYM_TYPE_TAG	(1 << 1)
#define BFD_AARCH64_SPECIAL_SYM_TYPE_OTHER	(1 << 2)
#define BFD_AARCH64_SPECIAL_SYM_TYPE_ANY	(~0)
extern bfd_boolean bfd_is_aarch64_special_symbol_name
  (const char * name, int type);

956
/* AArch64 stub generation support for ELF64.  Called from the linker.  */
957 958 959 960 961 962 963 964 965 966
extern int elf64_aarch64_setup_section_lists
  (bfd *, struct bfd_link_info *);
extern void elf64_aarch64_next_input_section
  (struct bfd_link_info *, struct bfd_section *);
extern bfd_boolean elf64_aarch64_size_stubs
  (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
   struct bfd_section * (*) (const char *, struct bfd_section *),
   void (*) (void));
extern bfd_boolean elf64_aarch64_build_stubs
  (struct bfd_link_info *);
967 968 969 970 971 972 973 974 975 976 977 978
/* AArch64 stub generation support for ELF32.  Called from the linker.  */
extern int elf32_aarch64_setup_section_lists
  (bfd *, struct bfd_link_info *);
extern void elf32_aarch64_next_input_section
  (struct bfd_link_info *, struct bfd_section *);
extern bfd_boolean elf32_aarch64_size_stubs
  (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
   struct bfd_section * (*) (const char *, struct bfd_section *),
   void (*) (void));
extern bfd_boolean elf32_aarch64_build_stubs
  (struct bfd_link_info *);

979

980
/* TI COFF load page support.  */
981
extern void bfd_ticoff_set_section_load_page
982
  (struct bfd_section *, int);
983 984

extern int bfd_ticoff_get_section_load_page
985
  (struct bfd_section *);
986

Richard Sandiford's avatar
bfd/  
Richard Sandiford committed
987 988 989 990
/* H8/300 functions.  */
extern bfd_vma bfd_h8300_pad_address
  (bfd *, bfd_vma);

H.J. Lu's avatar
bfd/  
H.J. Lu committed
991 992 993 994 995 996 997
/* IA64 Itanium code generation.  Called from linker.  */
extern void bfd_elf32_ia64_after_parse
  (int);

extern void bfd_elf64_ia64_after_parse
  (int);

H.J. Lu's avatar
bfd/  
H.J. Lu committed
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
/* This structure is used for a comdat section, as in PE.  A comdat
   section is associated with a particular symbol.  When the linker
   sees a comdat section, it keeps only one of the sections with a
   given name and associated with a given symbol.  */

struct coff_comdat_info
{
  /* The name of the symbol associated with a comdat section.  */
  const char *name;

  /* The local symbol table index of the symbol associated with a
     comdat section.  This is only meaningful to the object file format
     specific code; it is not an index into the list returned by
     bfd_canonicalize_symtab.  */
  long symbol;
};

1015
extern struct coff_comdat_info * bfd_coff_get_comdat_section
H.J. Lu's avatar
bfd/  
H.J. Lu committed
1016
  (bfd *, struct bfd_section *);
1017
/* Extracted from init.c.  */
1018
void bfd_init (void);
Richard Henderson's avatar
Richard Henderson committed
1019

1020
/* Extracted from opncls.c.  */
1021
extern unsigned int bfd_use_reserved_id;
1022 1023 1024
bfd *bfd_fopen (const char *filename, const char *target,
    const char *mode, int fd);

1025
bfd *bfd_openr (const char *filename, const char *target);
Richard Henderson's avatar
Richard Henderson committed
1026

1027
bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
Richard Henderson's avatar
Richard Henderson committed
1028

1029
bfd *bfd_openstreamr (const char *, const char *, void *);
Richard Henderson's avatar
Richard Henderson committed
1030

1031
bfd *bfd_openr_iovec (const char *filename, const char *target,
1032
    void *(*open_func) (struct bfd *nbfd,
1033 1034
    void *open_closure),
    void *open_closure,
1035
    file_ptr (*pread_func) (struct bfd *nbfd,
1036 1037 1038 1039
    void *stream,
    void *buf,
    file_ptr nbytes,
    file_ptr offset),
1040
    int (*close_func) (struct bfd *nbfd,
Alan Modra's avatar
bfd/  
Alan Modra committed
1041
    void *stream),
1042
    int (*stat_func) (struct bfd *abfd,
Alan Modra's avatar
bfd/  
Alan Modra committed
1043 1044
    void *stream,
    struct stat *sb));
1045

1046
bfd *bfd_openw (const char *filename, const char *target);
Richard Henderson's avatar
Richard Henderson committed
1047

1048
bfd_boolean bfd_close (bfd *abfd);
Richard Henderson's avatar
Richard Henderson committed
1049

1050
bfd_boolean bfd_close_all_done (bfd *);
Richard Henderson's avatar
Richard Henderson committed
1051

1052
bfd *bfd_create (const char *filename, bfd *templ);
Richard Henderson's avatar
Richard Henderson committed
1053

1054
bfd_boolean bfd_make_writable (bfd *abfd);
Richard Henderson's avatar
Richard Henderson committed
1055

1056
bfd_boolean bfd_make_readable (bfd *abfd);
Richard Henderson's avatar
Richard Henderson committed
1057

1058 1059 1060 1061
void *bfd_alloc (bfd *abfd, bfd_size_type wanted);

void *bfd_zalloc (bfd *abfd, bfd_size_type wanted);

1062 1063
unsigned long bfd_calc_gnu_debuglink_crc32
   (unsigned long crc, const unsigned char *buf, bfd_size_type len);
1064

Tom Tromey's avatar
gdb  
Tom Tromey committed
1065 1066
char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out);

1067 1068
char *bfd_get_alt_debug_link_info (bfd *abfd, unsigned long *crc32_out);

1069
char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir);
1070

1071 1072
char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir);

1073
struct bfd_section *bfd_create_gnu_debuglink_section
1074
   (bfd *abfd, const char *filename);
Nick Clifton's avatar
Nick Clifton committed
1075

1076
bfd_boolean bfd_fill_in_gnu_debuglink_section
1077
   (bfd *abfd, struct bfd_section *sect, const char *filename);
1078

1079
/* Extracted from libbfd.c.  */
H.J. Lu's avatar
H.J. Lu committed
1080

1081
/* Byte swapping macros for user section data.  */
Richard Henderson's avatar
Richard Henderson committed
1082 1083

#define bfd_put_8(abfd, val, ptr) \
1084
  ((void) (*((unsigned char *) (ptr)) = (val) & 0xff))
Richard Henderson's avatar
Richard Henderson committed
1085
#define bfd_put_signed_8 \
1086
  bfd_put_8
Richard Henderson's avatar
Richard Henderson committed
1087
#define bfd_get_8(abfd, ptr) \
Alan Modra's avatar
Alan Modra committed
1088
  (*(const unsigned char *) (ptr) & 0xff)
Richard Henderson's avatar
Richard Henderson committed
1089
#define bfd_get_signed_8(abfd, ptr) \
Alan Modra's avatar
Alan Modra committed
1090
  (((*(const unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
Richard Henderson's avatar
Richard Henderson committed
1091 1092

#define bfd_put_16(abfd, val, ptr) \
1093
  BFD_SEND (abfd, bfd_putx16, ((val),(ptr)))
Richard Henderson's avatar
Richard Henderson committed
1094
#define bfd_put_signed_16 \
1095
  bfd_put_16
Richard Henderson's avatar
Richard Henderson committed
1096
#define bfd_get_16(abfd, ptr) \
1097
  BFD_SEND (abfd, bfd_getx16, (ptr))
Richard Henderson's avatar
Richard Henderson committed
1098
#define bfd_get_signed_16(abfd, ptr) \
1099
  BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
Richard Henderson's avatar
Richard Henderson committed
1100 1101

#define bfd_put_32(abfd, val, ptr) \
1102
  BFD_SEND (abfd, bfd_putx32, ((val),(ptr)))
Richard Henderson's avatar
Richard Henderson committed
1103
#define bfd_put_signed_32 \
1104
  bfd_put_32
Richard Henderson's avatar
Richard Henderson committed
1105
#define bfd_get_32(abfd, ptr) \
1106
  BFD_SEND (abfd, bfd_getx32, (ptr))
Richard Henderson's avatar
Richard Henderson committed
1107
#define bfd_get_signed_32(abfd, ptr) \
1108
  BFD_SEND (abfd, bfd_getx_signed_32, (ptr))
Richard Henderson's avatar
Richard Henderson committed
1109 1110

#define bfd_put_64(abfd, val, ptr) \
1111
  BFD_SEND (abfd, bfd_putx64, ((val), (ptr)))
Richard Henderson's avatar
Richard Henderson committed
1112
#define bfd_put_signed_64 \
1113
  bfd_put_64
Richard Henderson's avatar
1