bfd-in.h revision 38889
141502Swpaul/* Main header file for the bfd library -- portable access to object files. 241502Swpaul Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 341502Swpaul Free Software Foundation, Inc. 441502Swpaul Contributed by Cygnus Support. 541502Swpaul 641502Swpaul** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them; 741502Swpaul** instead, change bfd-in.h or the other BFD source files processed to 841502Swpaul** generate these files. 941502Swpaul 1041502SwpaulThis file is part of BFD, the Binary File Descriptor library. 1141502Swpaul 1241502SwpaulThis program is free software; you can redistribute it and/or modify 1341502Swpaulit under the terms of the GNU General Public License as published by 1441502Swpaulthe Free Software Foundation; either version 2 of the License, or 1541502Swpaul(at your option) any later version. 1641502Swpaul 1741502SwpaulThis program is distributed in the hope that it will be useful, 1841502Swpaulbut WITHOUT ANY WARRANTY; without even the implied warranty of 1941502SwpaulMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2041502SwpaulGNU General Public License for more details. 2141502Swpaul 2241502SwpaulYou should have received a copy of the GNU General Public License 2341502Swpaulalong with this program; if not, write to the Free Software 2441502SwpaulFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2541502Swpaul 2641502Swpaul/* bfd.h -- The only header file required by users of the bfd library 2741502Swpaul 2841502SwpaulThe bfd.h file is generated from bfd-in.h and various .c files; if you 2941502Swpaulchange it, your changes will probably be lost. 3041502Swpaul 3141502SwpaulAll the prototypes and definitions following the comment "THE FOLLOWING 3241502SwpaulIS EXTRACTED FROM THE SOURCE" are extracted from the source files for 33122678SobrienBFD. If you change it, someone oneday will extract it from the source 34122678Sobrienagain, and your changes will be lost. To save yourself from this bind, 35122678Sobrienchange the definitions in the source in the bfd directory. Type "make 3641502Swpauldocs" and then "make headers" in that directory, and magically this file 3741502Swpaulwill change to reflect your changes. 3841502Swpaul 3941502SwpaulIf you don't have the tools to perform the extraction, then you are 4041502Swpaulsafe from someone on your system trampling over your header files. 4141502SwpaulYou should still maintain the equivalence between the source and this 4241502Swpaulfile though; every change you make to the .c file should be reflected 4341502Swpaulhere. */ 4441502Swpaul 4541502Swpaul#ifndef __BFD_H_SEEN__ 4641502Swpaul#define __BFD_H_SEEN__ 4741502Swpaul 4841502Swpaul#ifdef __cplusplus 4941502Swpaulextern "C" { 5041502Swpaul#endif 5141502Swpaul 5241502Swpaul#include "ansidecl.h" 5341502Swpaul 5441502Swpaul/* These two lines get substitutions done by commands in Makefile.in. */ 5541502Swpaul#define BFD_VERSION "@VERSION@" 5641502Swpaul#define BFD_ARCH_SIZE @wordsize@ 5741502Swpaul#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@ 5841502Swpaul#if @BFD_HOST_64_BIT_DEFINED@ 5941502Swpaul#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@ 6041502Swpaul#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@ 6141502Swpaul#endif 6241502Swpaul 6341502Swpaul#if BFD_ARCH_SIZE >= 64 6441502Swpaul#define BFD64 6541502Swpaul#endif 6641502Swpaul 6741502Swpaul#ifndef INLINE 68129878Sphk#if __GNUC__ >= 2 6941502Swpaul#define INLINE __inline__ 7041502Swpaul#else 7141502Swpaul#define INLINE 7241502Swpaul#endif 7341502Swpaul#endif 7441502Swpaul 7541502Swpaul/* forward declaration */ 7641502Swpaultypedef struct _bfd bfd; 7741502Swpaul 7841502Swpaul/* To squelch erroneous compiler warnings ("illegal pointer 7941502Swpaul combination") from the SVR3 compiler, we would like to typedef 8041502Swpaul boolean to int (it doesn't like functions which return boolean. 8141502Swpaul Making sure they are never implicitly declared to return int 8241502Swpaul doesn't seem to help). But this file is not configured based on 8341502Swpaul the host. */ 8449610Swpaul/* General rules: functions which are boolean return true on success 8549610Swpaul and false on failure (unless they're a predicate). -- bfd.doc */ 8649610Swpaul/* I'm sure this is going to break something and someone is going to 8741502Swpaul force me to change it. */ 8851432Swpaul/* typedef enum boolean {false, true} boolean; */ 8951432Swpaul/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */ 9051432Swpaul/* It gets worse if the host also defines a true/false enum... -sts */ 91119288Simp/* And even worse if your compiler has built-in boolean types... -law */ 92119288Simp#if defined (__GNUG__) && (__GNUC_MINOR__ > 5) 9341502Swpaul#define TRUE_FALSE_ALREADY_DEFINED 9441502Swpaul#endif 9541502Swpaul#ifdef MPW 9641502Swpaul/* Pre-emptive strike - get the file with the enum. */ 9741502Swpaul#include <Types.h> 98113506Smdodd#define TRUE_FALSE_ALREADY_DEFINED 99113506Smdodd#endif /* MPW */ 10059758Speter#ifndef TRUE_FALSE_ALREADY_DEFINED 10159758Spetertypedef enum bfd_boolean {false, true} boolean; 10251432Swpaul#define BFD_TRUE_FALSE 10351432Swpaul#else 10451432Swpaul/* Use enum names that will appear nowhere else. */ 105110168Ssilbytypedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean; 106110168Ssilby#endif 10741502Swpaul 10841502Swpaul/* A pointer to a position in a file. */ 10941502Swpaul/* FIXME: This should be using off_t from <sys/types.h>. 11041502Swpaul For now, try to avoid breaking stuff by not including <sys/types.h> here. 11141502Swpaul This will break on systems with 64-bit file offsets (e.g. 4.4BSD). 11241502Swpaul Probably the best long-term answer is to avoid using file_ptr AND off_t 11341502Swpaul in this header file, and to handle this in the BFD implementation 11441502Swpaul rather than in its interface. */ 11562653Swpaul/* typedef off_t file_ptr; */ 11662653Swpaultypedef long int file_ptr; 117110170Ssilby 118110170Ssilby/* Support for different sizes of target format ints and addresses. 119110170Ssilby If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be 120110170Ssilby set to 1 above. Otherwise, if gcc is being used, this code will 12144238Swpaul use gcc's "long long" type. Otherwise, BFD_HOST_64_BIT must be 12244238Swpaul defined above. */ 12344238Swpaul 12444238Swpaul#ifdef BFD64 12541502Swpaul 12641502Swpaul#ifndef BFD_HOST_64_BIT 12741502Swpaul#if BFD_HOST_64BIT_LONG 12892739Salfred#define BFD_HOST_64_BIT long 12992739Salfred#define BFD_HOST_U_64_BIT unsigned long 13092739Salfred#else 13141502Swpaul#ifdef __GNUC__ 13292739Salfred#define BFD_HOST_64_BIT long long 13349610Swpaul#define BFD_HOST_U_64_BIT unsigned long long 13492739Salfred#else /* ! defined (__GNUC__) */ 13592739Salfred #error No 64 bit integer type available 13692739Salfred#endif /* ! defined (__GNUC__) */ 13741502Swpaul#endif /* ! BFD_HOST_64BIT_LONG */ 13892739Salfred#endif /* ! defined (BFD_HOST_64_BIT) */ 13992739Salfred 14092739Salfredtypedef BFD_HOST_U_64_BIT bfd_vma; 14192739Salfredtypedef BFD_HOST_64_BIT bfd_signed_vma; 14292739Salfredtypedef BFD_HOST_U_64_BIT bfd_size_type; 14392739Salfredtypedef BFD_HOST_U_64_BIT symvalue; 14492739Salfred 14592739Salfred#ifndef fprintf_vma 14692739Salfred#if BFD_HOST_64BIT_LONG 14792739Salfred#define sprintf_vma(s,x) sprintf (s, "%016lx", x) 14892739Salfred#define fprintf_vma(f,x) fprintf (f, "%016lx", x) 14992739Salfred#else 15092739Salfred#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff))) 15141502Swpaul#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff)) 152110168Ssilby#define fprintf_vma(s,x) \ 15392739Salfred fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x)) 15492739Salfred#define sprintf_vma(s,x) \ 155110168Ssilby sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x)) 15692739Salfred#endif 15792739Salfred#endif 15892739Salfred 15992739Salfred#else /* not BFD64 */ 16092739Salfred 16141502Swpaul/* Represent a target address. Also used as a generic unsigned type 16292739Salfred which is guaranteed to be big enough to hold any arithmetic types 16392739Salfred we need to deal with. */ 16492739Salfredtypedef unsigned long bfd_vma; 16592739Salfred 16692739Salfred/* A generic signed type which is guaranteed to be big enough to hold any 16741502Swpaul arithmetic types we need to deal with. Can be assumed to be compatible 16849610Swpaul with bfd_vma in the same way that signed and unsigned ints are compatible 16949610Swpaul (as parameters, in assignment, etc). */ 17049610Swpaultypedef long bfd_signed_vma; 17149610Swpaul 17249610Swpaultypedef unsigned long symvalue; 17349610Swpaultypedef unsigned long bfd_size_type; 17449610Swpaul 17549610Swpaul/* Print a bfd_vma x on stream s. */ 17649610Swpaul#define fprintf_vma(s,x) fprintf(s, "%08lx", x) 17749610Swpaul#define sprintf_vma(s,x) sprintf(s, "%08lx", x) 17849610Swpaul#endif /* not BFD64 */ 17949610Swpaul#define printf_vma(x) fprintf_vma(stdout,x) 18049610Swpaul 18149610Swpaultypedef unsigned int flagword; /* 32 bits of flags */ 18251432Swpaultypedef unsigned char bfd_byte; 18351432Swpaul 18451432Swpaul/** File formats */ 18551432Swpaul 18651432Swpaultypedef enum bfd_format { 18751432Swpaul bfd_unknown = 0, /* file format is unknown */ 18851432Swpaul bfd_object, /* linker/assember/compiler output */ 18951432Swpaul bfd_archive, /* object archive file */ 19051432Swpaul bfd_core, /* core dump */ 19151432Swpaul bfd_type_end} /* marks the end; don't use it! */ 19249610Swpaul bfd_format; 19349610Swpaul 19449610Swpaul/* Values that may appear in the flags field of a BFD. These also 19549610Swpaul appear in the object_flags field of the bfd_target structure, where 19651455Swpaul they indicate the set of flags used by that backend (not all flags 19749610Swpaul are meaningful for all object file formats) (FIXME: at the moment, 19849610Swpaul the object_flags values have mostly just been copied from backend 19949610Swpaul to another, and are not necessarily correct). */ 20049610Swpaul 20149610Swpaul/* No flags. */ 20249610Swpaul#define BFD_NO_FLAGS 0x00 203113506Smdodd 20451473Swpaul/* BFD contains relocation entries. */ 20549610Swpaul#define HAS_RELOC 0x01 20641502Swpaul 20741502Swpaul/* BFD is directly executable. */ 208105221Sphk#define EXEC_P 0x02 20941502Swpaul 21041502Swpaul/* BFD has line number information (basically used for F_LNNO in a 21141502Swpaul COFF header). */ 212105221Sphk#define HAS_LINENO 0x04 21341502Swpaul 21441502Swpaul/* BFD has debugging information. */ 21541502Swpaul#define HAS_DEBUG 0x08 216105221Sphk 21741502Swpaul/* BFD has symbols. */ 21841502Swpaul#define HAS_SYMS 0x10 21941502Swpaul 220105221Sphk/* BFD has local symbols (basically used for F_LSYMS in a COFF 22141502Swpaul header). */ 22241502Swpaul#define HAS_LOCALS 0x20 22341502Swpaul 224105221Sphk/* BFD is a dynamic object. */ 22541502Swpaul#define DYNAMIC 0x40 22641502Swpaul 22741502Swpaul/* Text section is write protected (if D_PAGED is not set, this is 228105221Sphk like an a.out NMAGIC file) (the linker sets this by default, but 22941502Swpaul clears it for -r or -N). */ 23041502Swpaul#define WP_TEXT 0x80 23141502Swpaul 232105221Sphk/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the 23341502Swpaul linker sets this by default, but clears it for -r or -n or -N). */ 23441502Swpaul#define D_PAGED 0x100 23541502Swpaul 236105221Sphk/* BFD is relaxable (this means that bfd_relax_section may be able to 23741502Swpaul do something) (sometimes bfd_relax_section can do something even if 238110168Ssilby this is not set). */ 23941502Swpaul#define BFD_IS_RELAXABLE 0x200 24041502Swpaul 24141502Swpaul/* This may be set before writing out a BFD to request using a 242102336Salfred traditional format. For example, this is used to request that when 243102336Salfred writing out an a.out object the symbols not be hashed to eliminate 24441502Swpaul duplicates. */ 24541502Swpaul#define BFD_TRADITIONAL_FORMAT 0x400 24641502Swpaul 24741502Swpaul/* This flag indicates that the BFD contents are actually cached in 24841502Swpaul memory. If this is set, iostream points to a bfd_in_memory struct. */ 24941502Swpaul#define BFD_IN_MEMORY 0x800 25041502Swpaul 25141502Swpaul/* symbols and relocation */ 25241502Swpaul 25341502Swpaul/* A count of carsyms (canonical archive symbols). */ 25441502Swpaultypedef unsigned long symindex; 25541502Swpaul 25641502Swpaul/* How to perform a relocation. */ 25741502Swpaultypedef const struct reloc_howto_struct reloc_howto_type; 25841502Swpaul 25941502Swpaul#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) 26041502Swpaul 26141502Swpaul/* General purpose part of a symbol X; 26241502Swpaul target specific parts are in libcoff.h, libaout.h, etc. */ 263102336Salfred 264102336Salfred#define bfd_get_section(x) ((x)->section) 26541502Swpaul#define bfd_get_output_section(x) ((x)->section->output_section) 26641502Swpaul#define bfd_set_section(x,y) ((x)->section) = (y) 26741502Swpaul#define bfd_asymbol_base(x) ((x)->section->vma) 26841502Swpaul#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value) 26941502Swpaul#define bfd_asymbol_name(x) ((x)->name) 27041502Swpaul/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/ 27141502Swpaul#define bfd_asymbol_bfd(x) ((x)->the_bfd) 27241502Swpaul#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour) 27341502Swpaul 27441502Swpaul/* A canonical archive symbol. */ 27541502Swpaul/* This is a type pun with struct ranlib on purpose! */ 27641502Swpaultypedef struct carsym { 27741502Swpaul char *name; 27841502Swpaul file_ptr file_offset; /* look here to find the file */ 27941502Swpaul} carsym; /* to make these you call a carsymogen */ 28041502Swpaul 28141502Swpaul 28241502Swpaul/* Used in generating armaps (archive tables of contents). 28341502Swpaul Perhaps just a forward definition would do? */ 28441502Swpaulstruct orl { /* output ranlib */ 285110168Ssilby char **name; /* symbol name */ 28641502Swpaul file_ptr pos; /* bfd* or file position */ 28741502Swpaul int namidx; /* index into string table */ 28841502Swpaul}; 28941502Swpaul 290102336Salfred 291102336Salfred/* Linenumber stuff */ 29241502Swpaultypedef struct lineno_cache_entry { 29341502Swpaul unsigned int line_number; /* Linenumber from start of function*/ 29441502Swpaul union { 295110168Ssilby struct symbol_cache_entry *sym; /* Function name */ 29641502Swpaul unsigned long offset; /* Offset into section */ 29767087Swpaul } u; 29841502Swpaul} alent; 29967087Swpaul 30041502Swpaul/* object and core file sections */ 30141502Swpaul 30241502Swpaul#define align_power(addr, align) \ 30341502Swpaul ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) 30441502Swpaul 30541502Swpaultypedef struct sec *sec_ptr; 30641502Swpaul 30741502Swpaul#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0) 30841502Swpaul#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0) 30941502Swpaul#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) 31041502Swpaul#define bfd_section_name(bfd, ptr) ((ptr)->name) 31141502Swpaul#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr)) 31241502Swpaul#define bfd_section_vma(bfd, ptr) ((ptr)->vma) 31341502Swpaul#define bfd_section_lma(bfd, ptr) ((ptr)->lma) 31441502Swpaul#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) 31541502Swpaul#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0) 31641502Swpaul#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) 31741502Swpaul 31841502Swpaul#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) 31941502Swpaul 32041502Swpaul#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true) 32141502Swpaul#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true) 32241502Swpaul#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true) 32341502Swpaul 32441502Swpaultypedef struct stat stat_type; 32541502Swpaul 32641502Swpaultypedef enum bfd_print_symbol 32741502Swpaul{ 32841502Swpaul bfd_print_symbol_name, 32941502Swpaul bfd_print_symbol_more, 33041502Swpaul bfd_print_symbol_all 33141502Swpaul} bfd_print_symbol_type; 33241502Swpaul 33341502Swpaul/* Information about a symbol that nm needs. */ 33441502Swpaul 33541502Swpaultypedef struct _symbol_info 33641502Swpaul{ 33741502Swpaul symvalue value; 33841502Swpaul char type; 339109058Smbr CONST char *name; /* Symbol name. */ 34041502Swpaul unsigned char stab_type; /* Stab type. */ 34141502Swpaul char stab_other; /* Stab other. */ 34241502Swpaul short stab_desc; /* Stab desc. */ 34341502Swpaul CONST char *stab_name; /* String for stab type. */ 34441502Swpaul} symbol_info; 34541502Swpaul 34641502Swpaul/* Get the name of a stabs type code. */ 34741502Swpaul 34841502Swpaulextern const char *bfd_get_stab_name PARAMS ((int)); 34941502Swpaul 35041502Swpaul/* Hash table routines. There is no way to free up a hash table. */ 35141502Swpaul 35241502Swpaul/* An element in the hash table. Most uses will actually use a larger 35341502Swpaul structure, and an instance of this will be the first field. */ 35441502Swpaul 35541502Swpaulstruct bfd_hash_entry 35641502Swpaul{ 35741502Swpaul /* Next entry for this hash code. */ 35841502Swpaul struct bfd_hash_entry *next; 35941502Swpaul /* String being hashed. */ 36041502Swpaul const char *string; 36141502Swpaul /* Hash code. This is the full hash code, not the index into the 36241502Swpaul table. */ 36341502Swpaul unsigned long hash; 36441502Swpaul}; 36541502Swpaul 36641502Swpaul/* A hash table. */ 36741502Swpaul 36841502Swpaulstruct bfd_hash_table 36941502Swpaul{ 37041502Swpaul /* The hash array. */ 37141502Swpaul struct bfd_hash_entry **table; 37241502Swpaul /* The number of slots in the hash table. */ 37341502Swpaul unsigned int size; 37441502Swpaul /* A function used to create new elements in the hash table. The 37541502Swpaul first entry is itself a pointer to an element. When this 37667087Swpaul function is first invoked, this pointer will be NULL. However, 37741502Swpaul having the pointer permits a hierarchy of method functions to be 37841502Swpaul built each of which calls the function in the superclass. Thus 37941502Swpaul each function should be written to allocate a new block of memory 38041502Swpaul only if the argument is NULL. */ 38141502Swpaul struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, 382110168Ssilby struct bfd_hash_table *, 383110168Ssilby const char *)); 384110168Ssilby /* An objalloc for this hash table. This is a struct objalloc *, 38541502Swpaul but we use PTR to avoid requiring the inclusion of objalloc.h. */ 386110168Ssilby PTR memory; 387110168Ssilby}; 388110168Ssilby 389110168Ssilby/* Initialize a hash table. */ 390110168Ssilbyextern boolean bfd_hash_table_init 391110168Ssilby PARAMS ((struct bfd_hash_table *, 392110168Ssilby struct bfd_hash_entry *(*) (struct bfd_hash_entry *, 393110168Ssilby struct bfd_hash_table *, 394110168Ssilby const char *))); 395110168Ssilby 396110168Ssilby/* Initialize a hash table specifying a size. */ 397110168Ssilbyextern boolean bfd_hash_table_init_n 398110168Ssilby PARAMS ((struct bfd_hash_table *, 399110168Ssilby struct bfd_hash_entry *(*) (struct bfd_hash_entry *, 400110168Ssilby struct bfd_hash_table *, 401110168Ssilby const char *), 402110168Ssilby unsigned int size)); 403110168Ssilby 404110168Ssilby/* Free up a hash table. */ 405110168Ssilbyextern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *)); 406110168Ssilby 407110168Ssilby/* Look up a string in a hash table. If CREATE is true, a new entry 408110168Ssilby will be created for this string if one does not already exist. The 409110168Ssilby COPY argument must be true if this routine should copy the string 410110168Ssilby into newly allocated memory when adding an entry. */ 41141502Swpaulextern struct bfd_hash_entry *bfd_hash_lookup 41241502Swpaul PARAMS ((struct bfd_hash_table *, const char *, boolean create, 41341502Swpaul boolean copy)); 414102336Salfred 415102336Salfred/* Replace an entry in a hash table. */ 41641502Swpaulextern void bfd_hash_replace 41741502Swpaul PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old, 41841502Swpaul struct bfd_hash_entry *nw)); 419110168Ssilby 42041502Swpaul/* Base method for creating a hash table entry. */ 42167087Swpaulextern struct bfd_hash_entry *bfd_hash_newfunc 42241502Swpaul PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, 42341502Swpaul const char *)); 42441502Swpaul 42541502Swpaul/* Grab some space for a hash table entry. */ 42641502Swpaulextern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *, 42741502Swpaul unsigned int)); 42841502Swpaul 42941502Swpaul/* Traverse a hash table in a random order, calling a function on each 43041502Swpaul element. If the function returns false, the traversal stops. The 43141502Swpaul INFO argument is passed to the function. */ 43241502Swpaulextern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *, 43341502Swpaul boolean (*) (struct bfd_hash_entry *, 43441502Swpaul PTR), 43541502Swpaul PTR info)); 43641502Swpaul 43741502Swpaul/* Semi-portable string concatenation in cpp. 43841502Swpaul The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors. 43941502Swpaul The problem is, "32_" is not a valid preprocessing token, and we don't 44041502Swpaul want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the 44141502Swpaul inner CAT macros to be evaluated first, producing still-valid pp-tokens. 44241502Swpaul Then the final concatenation can be done. (Sigh.) */ 44341502Swpaul#ifndef CAT 44441502Swpaul#ifdef SABER 44541502Swpaul#define CAT(a,b) a##b 44641502Swpaul#define CAT3(a,b,c) a##b##c 44741502Swpaul#define CAT4(a,b,c,d) a##b##c##d 44841502Swpaul#else 44941502Swpaul#if defined(__STDC__) || defined(ALMOST_STDC) 45041502Swpaul#define CAT(a,b) a##b 45141502Swpaul#define CAT3(a,b,c) a##b##c 45241502Swpaul#define XCAT2(a,b) CAT(a,b) 45341502Swpaul#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d)) 45441502Swpaul#else 45541502Swpaul#define CAT(a,b) a/**/b 45641502Swpaul#define CAT3(a,b,c) a/**/b/**/c 45741502Swpaul#define CAT4(a,b,c,d) a/**/b/**/c/**/d 45841502Swpaul#endif 45967087Swpaul#endif 46041502Swpaul#endif 46141502Swpaul 46241502Swpaul#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table 463110168Ssilby 464110168Ssilby/* User program access to BFD facilities */ 465110168Ssilby 46641502Swpaul/* Direct I/O routines, for programs which know more about the object 467110168Ssilby file than BFD does. Use higher level routines if possible. */ 468110168Ssilby 469110168Ssilbyextern bfd_size_type bfd_read 470110168Ssilby PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd)); 471110168Ssilbyextern bfd_size_type bfd_write 472110168Ssilby PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd)); 473110168Ssilbyextern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction)); 474110168Ssilbyextern long bfd_tell PARAMS ((bfd *abfd)); 475110168Ssilbyextern int bfd_flush PARAMS ((bfd *abfd)); 476110168Ssilbyextern int bfd_stat PARAMS ((bfd *abfd, struct stat *)); 477110168Ssilby 478110168Ssilby 479110168Ssilby/* Cast from const char * to char * so that caller can assign to 480110168Ssilby a char * without a warning. */ 481110168Ssilby#define bfd_get_filename(abfd) ((char *) (abfd)->filename) 482110168Ssilby#define bfd_get_cacheable(abfd) ((abfd)->cacheable) 483110168Ssilby#define bfd_get_format(abfd) ((abfd)->format) 484110168Ssilby#define bfd_get_target(abfd) ((abfd)->xvec->name) 485110168Ssilby#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour) 486110168Ssilby#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG) 487110168Ssilby#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE) 488110168Ssilby#define bfd_header_big_endian(abfd) \ 489110168Ssilby ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG) 490110168Ssilby#define bfd_header_little_endian(abfd) \ 491102336Salfred ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE) 492102336Salfred#define bfd_get_file_flags(abfd) ((abfd)->flags) 49351432Swpaul#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags) 49451432Swpaul#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags) 49551432Swpaul#define bfd_my_archive(abfd) ((abfd)->my_archive) 49641502Swpaul#define bfd_has_map(abfd) ((abfd)->has_armap) 49741502Swpaul 49841502Swpaul#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) 49951432Swpaul#define bfd_usrdata(abfd) ((abfd)->usrdata) 500110168Ssilby 501110168Ssilby#define bfd_get_start_address(abfd) ((abfd)->start_address) 502110168Ssilby#define bfd_get_symcount(abfd) ((abfd)->symcount) 503110168Ssilby#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) 504110168Ssilby#define bfd_count_sections(abfd) ((abfd)->section_count) 505110168Ssilby 506110168Ssilby#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) 507110168Ssilby 508110168Ssilby#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true) 50941502Swpaul 51041502Swpaulextern boolean bfd_record_phdr 51151432Swpaul PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma, 51241502Swpaul boolean, boolean, unsigned int, struct sec **)); 51341502Swpaul 51441502Swpaul/* Byte swapping routines. */ 51541502Swpaul 51641502Swpaulbfd_vma bfd_getb64 PARAMS ((const unsigned char *)); 51741502Swpaulbfd_vma bfd_getl64 PARAMS ((const unsigned char *)); 518102336Salfredbfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *)); 519102336Salfredbfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *)); 52051432Swpaulbfd_vma bfd_getb32 PARAMS ((const unsigned char *)); 52151432Swpaulbfd_vma bfd_getl32 PARAMS ((const unsigned char *)); 52251432Swpaulbfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *)); 52341502Swpaulbfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *)); 52441502Swpaulbfd_vma bfd_getb16 PARAMS ((const unsigned char *)); 52541502Swpaulbfd_vma bfd_getl16 PARAMS ((const unsigned char *)); 52651432Swpaulbfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *)); 527110168Ssilbybfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *)); 528110168Ssilbyvoid bfd_putb64 PARAMS ((bfd_vma, unsigned char *)); 529110168Ssilbyvoid bfd_putl64 PARAMS ((bfd_vma, unsigned char *)); 530110168Ssilbyvoid bfd_putb32 PARAMS ((bfd_vma, unsigned char *)); 531110168Ssilbyvoid bfd_putl32 PARAMS ((bfd_vma, unsigned char *)); 532110168Ssilbyvoid bfd_putb16 PARAMS ((bfd_vma, unsigned char *)); 533110168Ssilbyvoid bfd_putl16 PARAMS ((bfd_vma, unsigned char *)); 534110168Ssilby 535110168Ssilby/* Externally visible ECOFF routines. */ 53641502Swpaul 53741502Swpaul#if defined(__STDC__) || defined(ALMOST_STDC) 53851432Swpaulstruct ecoff_debug_info; 53941502Swpaulstruct ecoff_debug_swap; 54041502Swpaulstruct ecoff_extr; 54141502Swpaulstruct symbol_cache_entry; 54241502Swpaulstruct bfd_link_info; 54341502Swpaulstruct bfd_link_hash_entry; 54451432Swpaulstruct bfd_elf_version_tree; 54551432Swpaul#endif 54651432Swpaulextern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd)); 547102336Salfredextern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value)); 548102336Salfredextern boolean bfd_ecoff_set_regmasks 54951432Swpaul PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask, 55051432Swpaul unsigned long *cprmask)); 55151432Swpaulextern PTR bfd_ecoff_debug_init 55251432Swpaul PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug, 55351432Swpaul const struct ecoff_debug_swap *output_swap, 55451432Swpaul struct bfd_link_info *)); 55567087Swpaulextern void bfd_ecoff_debug_free 55651432Swpaul PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, 55751432Swpaul const struct ecoff_debug_swap *output_swap, 55867087Swpaul struct bfd_link_info *)); 55951432Swpaulextern boolean bfd_ecoff_debug_accumulate 56041502Swpaul PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, 56141502Swpaul const struct ecoff_debug_swap *output_swap, 56241502Swpaul bfd *input_bfd, struct ecoff_debug_info *input_debug, 56341502Swpaul const struct ecoff_debug_swap *input_swap, 56441502Swpaul struct bfd_link_info *)); 56541502Swpaulextern boolean bfd_ecoff_debug_accumulate_other 566102336Salfred PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, 567102336Salfred const struct ecoff_debug_swap *output_swap, bfd *input_bfd, 56841502Swpaul struct bfd_link_info *)); 56941502Swpaulextern boolean bfd_ecoff_debug_externals 57041502Swpaul PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, 57141502Swpaul const struct ecoff_debug_swap *swap, 57241502Swpaul boolean relocateable, 57341502Swpaul boolean (*get_extr) (struct symbol_cache_entry *, 57441502Swpaul struct ecoff_extr *), 57541502Swpaul void (*set_index) (struct symbol_cache_entry *, 57641502Swpaul bfd_size_type))); 57741502Swpaulextern boolean bfd_ecoff_debug_one_external 57841502Swpaul PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, 57941502Swpaul const struct ecoff_debug_swap *swap, 58041502Swpaul const char *name, struct ecoff_extr *esym)); 58141502Swpaulextern bfd_size_type bfd_ecoff_debug_size 58241502Swpaul PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, 58341502Swpaul const struct ecoff_debug_swap *swap)); 58441502Swpaulextern boolean bfd_ecoff_write_debug 58541502Swpaul PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, 58641502Swpaul const struct ecoff_debug_swap *swap, file_ptr where)); 58741502Swpaulextern boolean bfd_ecoff_write_accumulated_debug 58841502Swpaul PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug, 58941502Swpaul const struct ecoff_debug_swap *swap, 59041502Swpaul struct bfd_link_info *info, file_ptr where)); 59141502Swpaulextern boolean bfd_mips_ecoff_create_embedded_relocs 59241502Swpaul PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *, 59341502Swpaul char **)); 59472084Sphk 59541502Swpaul/* Externally visible ELF routines. */ 59641502Swpaul 597130270Snaddystruct bfd_link_needed_list 598130270Snaddy{ 59941502Swpaul struct bfd_link_needed_list *next; 60041502Swpaul bfd *by; 60141502Swpaul const char *name; 60241502Swpaul}; 60341502Swpaul 60441502Swpaulextern boolean bfd_elf32_record_link_assignment 60541502Swpaul PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean)); 60641502Swpaulextern boolean bfd_elf64_record_link_assignment 60741502Swpaul PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean)); 60841502Swpaulextern struct bfd_link_needed_list *bfd_elf_get_needed_list 60941502Swpaul PARAMS ((bfd *, struct bfd_link_info *)); 61041502Swpaulextern boolean bfd_elf_get_bfd_needed_list 61141502Swpaul PARAMS ((bfd *, struct bfd_link_needed_list **)); 61241502Swpaulextern boolean bfd_elf32_size_dynamic_sections 61341502Swpaul PARAMS ((bfd *, const char *, const char *, boolean, const char *, 61441502Swpaul const char * const *, struct bfd_link_info *, struct sec **, 61541502Swpaul struct bfd_elf_version_tree *)); 61641502Swpaulextern boolean bfd_elf64_size_dynamic_sections 61741502Swpaul PARAMS ((bfd *, const char *, const char *, boolean, const char *, 61841502Swpaul const char * const *, struct bfd_link_info *, struct sec **, 61941502Swpaul struct bfd_elf_version_tree *)); 62041502Swpaulextern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *)); 62141502Swpaulextern const char *bfd_elf_get_dt_soname PARAMS ((bfd *)); 62241502Swpaul 623102336Salfred/* SunOS shared library support routines for the linker. */ 624102336Salfred 62541502Swpaulextern struct bfd_link_needed_list *bfd_sunos_get_needed_list 62651432Swpaul PARAMS ((bfd *, struct bfd_link_info *)); 62741502Swpaulextern boolean bfd_sunos_record_link_assignment 62841502Swpaul PARAMS ((bfd *, struct bfd_link_info *, const char *)); 62941502Swpaulextern boolean bfd_sunos_size_dynamic_sections 63041502Swpaul PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **, 63141502Swpaul struct sec **)); 63241502Swpaul 63341502Swpaul/* Linux shared library support routines for the linker. */ 63441502Swpaul 63551432Swpaulextern boolean bfd_i386linux_size_dynamic_sections 63641502Swpaul PARAMS ((bfd *, struct bfd_link_info *)); 63741502Swpaulextern boolean bfd_m68klinux_size_dynamic_sections 63841502Swpaul PARAMS ((bfd *, struct bfd_link_info *)); 63941502Swpaulextern boolean bfd_sparclinux_size_dynamic_sections 64041502Swpaul PARAMS ((bfd *, struct bfd_link_info *)); 64141502Swpaul 64241502Swpaul/* mmap hacks */ 64341502Swpaul 64441502Swpaulstruct _bfd_window_internal; 64541502Swpaultypedef struct _bfd_window_internal bfd_window_internal; 646102336Salfred 647102336Salfredtypedef struct _bfd_window { 64841502Swpaul /* What the user asked for. */ 64941502Swpaul PTR data; 65041502Swpaul bfd_size_type size; 65141502Swpaul /* The actual window used by BFD. Small user-requested read-only 65241502Swpaul regions sharing a page may share a single window into the object 65341502Swpaul file. Read-write versions shouldn't until I've fixed things to 65441502Swpaul keep track of which portions have been claimed by the 65541502Swpaul application; don't want to give the same region back when the 65641502Swpaul application wants two writable copies! */ 65741502Swpaul struct _bfd_window_internal *i; 65841502Swpaul} bfd_window; 659107220Ssilby 660107220Ssilbyextern void bfd_init_window PARAMS ((bfd_window *)); 661107220Ssilbyextern void bfd_free_window PARAMS ((bfd_window *)); 662107220Ssilbyextern boolean bfd_get_file_window 663107220Ssilby PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, boolean)); 664107220Ssilby 665107220Ssilby/* XCOFF support routines for the linker. */ 666107220Ssilby 667107220Ssilbyextern boolean bfd_xcoff_link_record_set 66841502Swpaul PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, 66941502Swpaul bfd_size_type)); 67041502Swpaulextern boolean bfd_xcoff_import_symbol 67141502Swpaul PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, 67241502Swpaul bfd_vma, const char *, const char *, const char *)); 67341502Swpaulextern boolean bfd_xcoff_export_symbol 67441502Swpaul PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, 67541502Swpaul boolean)); 67641502Swpaulextern boolean bfd_xcoff_link_count_reloc 67741502Swpaul PARAMS ((bfd *, struct bfd_link_info *, const char *)); 67841502Swpaulextern boolean bfd_xcoff_record_link_assignment 679102336Salfred PARAMS ((bfd *, struct bfd_link_info *, const char *)); 680102336Salfredextern boolean bfd_xcoff_size_dynamic_sections 68149610Swpaul PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *, 68241502Swpaul unsigned long, unsigned long, unsigned long, boolean, 68341502Swpaul int, boolean, boolean, struct sec **)); 68441502Swpaul 68541502Swpaul/* Externally visible COFF routines. */ 68641502Swpaul 68741502Swpaul#if defined(__STDC__) || defined(ALMOST_STDC) 68849610Swpaulstruct internal_syment; 68949610Swpaulunion internal_auxent; 69049610Swpaul#endif 69149610Swpaul 69241502Swpaulextern boolean bfd_coff_get_syment 69341502Swpaul PARAMS ((bfd *, struct symbol_cache_entry *, struct internal_syment *)); 69441502Swpaulextern boolean bfd_coff_get_auxent 69541502Swpaul PARAMS ((bfd *, struct symbol_cache_entry *, int, union internal_auxent *)); 69649610Swpaul 69741502Swpaul/* And more from the source. */ 69841502Swpaul