Reflect the new scheme
[deliverable/binutils-gdb.git] / include / bfd.h
CommitLineData
095c7223
JG
1/* A -*- C -*- header file for the bfd library
2 Copyright 1990, 1991 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
a07cc613 4
2c346475 5This file is part of BFD, the Binary File Descriptor library.
a07cc613 6
095c7223 7This program is free software; you can redistribute it and/or modify
a07cc613 8it under the terms of the GNU General Public License as published by
095c7223
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
a07cc613 11
095c7223 12This program is distributed in the hope that it will be useful,
a07cc613
JG
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
095c7223
JG
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21/* bfd.h -- The only header file required by users of the bfd library
22
23This file is generated from various .c files, if you change it, your
24bits may be lost.
25
26All the prototypes and definitions following the comment "THE FOLLOWING
27IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
28BFD. If you change it, someone oneday will extract it from the source
29again, and your changes will be lost. To save yourself from this bind,
30change the definitions in the source in the bfd directory. Type "make
31docs" and then "make headers" in that directory, and magically this file
32will change to reflect your changes.
33
34If you don't have the tools to perform the extraction, then you are
35safe from someone on your system trampling over your header files.
36You should still maintain the equivalence between the source and this
37file though; every change you make to the .c file should be reflected
38here. */
a07cc613 39
a07cc613
JG
40#ifndef __BFD_H_SEEN__
41#define __BFD_H_SEEN__
42
43#include "ansidecl.h"
44#include "obstack.h"
45
46/* Make it easier to declare prototypes (puts conditional here) */
47#ifndef PROTO
48# if __STDC__
49# define PROTO(type, name, arglist) type name arglist
50# else
51# define PROTO(type, name, arglist) type name ()
52# endif
53#endif
54
40a08432 55#define BFD_VERSION "0.18"
ec08b077 56
a07cc613 57/* forward declaration */
9c6a9c92 58typedef struct _bfd bfd;
a07cc613 59
ec08b077
JG
60/* General rules: functions which are boolean return true on success
61 and false on failure (unless they're a predicate). -- bfd.doc */
a07cc613
JG
62/* I'm sure this is going to break something and someone is going to
63 force me to change it. */
f7cfc4a6
JG
64/* typedef enum boolean {false, true} boolean; */
65/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */
66typedef enum bfd_boolean {false, true} boolean;
a07cc613
JG
67
68/* Try to avoid breaking stuff */
69typedef long int file_ptr;
70
9b9c5c39 71/* Support for different sizes of target format ints and addresses */
19b03b7a 72
9b9c5c39 73#ifdef HOST_64_BIT
7ed4093a
SC
74typedef HOST_64_BIT rawdata_offset;
75typedef HOST_64_BIT bfd_vma;
76typedef HOST_64_BIT bfd_word;
77typedef HOST_64_BIT bfd_offset;
78typedef HOST_64_BIT bfd_size_type;
9b9c5c39 79typedef HOST_64_BIT symvalue;
7ed4093a 80typedef HOST_64_BIT bfd_64_type;
9b9c5c39
JG
81#define fprintf_vma(s,x) \
82 fprintf(s,"%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x))
19b03b7a 83#else
9b9c5c39
JG
84typedef struct {int a,b;} bfd_64_type;
85typedef unsigned long rawdata_offset;
a07cc613
JG
86typedef unsigned long bfd_vma;
87typedef unsigned long bfd_offset;
19b03b7a
SC
88typedef unsigned long bfd_word;
89typedef unsigned long bfd_size;
90typedef unsigned long symvalue;
91typedef unsigned long bfd_size_type;
a737c70b 92#define fprintf_vma(s,x) fprintf(s, "%08lx", x)
19b03b7a 93#endif
1d2c5574 94#define printf_vma(x) fprintf_vma(stdout,x)
a07cc613
JG
95
96typedef unsigned int flagword; /* 32 bits of flags */
97\f
98/** File formats */
99
100typedef enum bfd_format {
101 bfd_unknown = 0, /* file format is unknown */
102 bfd_object, /* linker/assember/compiler output */
103 bfd_archive, /* object archive file */
104 bfd_core, /* core dump */
105 bfd_type_end} /* marks the end; don't use it! */
106 bfd_format;
107
108/* Object file flag values */
9b9c5c39 109#define NO_FLAGS 0
a07cc613
JG
110#define HAS_RELOC 001
111#define EXEC_P 002
112#define HAS_LINENO 004
113#define HAS_DEBUG 010
114#define HAS_SYMS 020
115#define HAS_LOCALS 040
116#define DYNAMIC 0100
117#define WP_TEXT 0200
118#define D_PAGED 0400
119
a07cc613
JG
120\f
121/* symbols and relocation */
122
123typedef unsigned long symindex;
124
125#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
126
fb3ee1c0
JG
127typedef enum bfd_symclass {
128 bfd_symclass_unknown = 0,
a07cc613
JG
129 bfd_symclass_fcommon, /* fortran common symbols */
130 bfd_symclass_global, /* global symbol, what a surprise */
131 bfd_symclass_debugger, /* some debugger symbol */
132 bfd_symclass_undefined /* none known */
133 } symclass;
134
19b03b7a 135
a07cc613 136typedef int symtype; /* Who knows, yet? */
19b03b7a 137
a07cc613 138
9b9c5c39
JG
139/* general purpose part of a symbol;
140 target specific parts will be found in libcoff.h, liba.out.h etc */
7a276b09 141
a07cc613
JG
142
143#define bfd_get_section(x) ((x)->section)
144#define bfd_get_output_section(x) ((x)->section->output_section)
145#define bfd_set_section(x,y) ((x)->section) = (y)
146#define bfd_asymbol_base(x) ((x)->section?((x)->section->vma):0)
147#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + x->value)
148#define bfd_asymbol_name(x) ((x)->name)
149
a07cc613 150/* This is a type pun with struct ranlib on purpose! */
9c6a9c92 151typedef struct carsym {
a07cc613
JG
152 char *name;
153 file_ptr file_offset; /* look here to find the file */
154} carsym; /* to make these you call a carsymogen */
155
a07cc613
JG
156
157/* Used in generating armaps. Perhaps just a forward definition would do? */
158struct orl { /* output ranlib */
159 char **name; /* symbol name */
c93e2c55 160 file_ptr pos; /* bfd* or file position */
a07cc613
JG
161 int namidx; /* index into string table */
162};
163
164\f
165
166/* Linenumber stuff */
167typedef struct lineno_cache_entry {
168 unsigned int line_number; /* Linenumber from start of function*/
169 union {
7a276b09 170 struct symbol_cache_entry *sym; /* Function name */
a07cc613
JG
171 unsigned long offset; /* Offset into section */
172 } u;
173} alent;
174\f
175/* object and core file sections */
176
a07cc613
JG
177
178#define align_power(addr, align) \
179 ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
180
9c6a9c92 181typedef struct sec *sec_ptr;
a07cc613
JG
182
183#define bfd_section_name(bfd, ptr) ((ptr)->name)
184#define bfd_section_size(bfd, ptr) ((ptr)->size)
185#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
186#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
187#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags)
188#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
189
190#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (val)), true)
191#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
192#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
4322f04d
SC
193
194typedef struct stat stat_type;
a07cc613
JG
195\f
196/** Error handling */
197
fb3ee1c0
JG
198typedef enum bfd_error {
199 no_error = 0, system_call_error, invalid_target,
a07cc613
JG
200 wrong_format, invalid_operation, no_memory,
201 no_symbols, no_relocation_info,
202 no_more_archived_files, malformed_archive,
203 symbol_not_found, file_not_recognized,
204 file_ambiguously_recognized, no_contents,
6603bf38
JG
205 bfd_error_nonrepresentable_section,
206 no_debug_section,
a07cc613
JG
207 invalid_error_code} bfd_ec;
208
209extern bfd_ec bfd_error;
210
9c6a9c92 211typedef struct bfd_error_vector {
a07cc613
JG
212 PROTO(void,(* nonrepresentable_section ),(CONST bfd *CONST abfd,
213 CONST char *CONST name));
214} bfd_error_vector_type;
215
216PROTO (char *, bfd_errmsg, ());
217PROTO (void, bfd_perror, (CONST char *message));
218\f
219
9b9c5c39 220typedef enum bfd_print_symbol
a07cc613 221{
81f8fee9
JG
222 bfd_print_symbol_name,
223 bfd_print_symbol_more,
b941cb35
PB
224 bfd_print_symbol_all,
225 bfd_print_symbol_nm, /* Pretty format suitable for nm program. */
81f8fee9 226} bfd_print_symbol_type;
a07cc613
JG
227
228\f
a07cc613
JG
229\f
230/* The code that implements targets can initialize a jump table with this
231 macro. It must name all its routines the same way (a prefix plus
232 the standard routine suffix), or it must #define the routines that
233 are not so named, before calling JUMP_TABLE in the initializer. */
234
235/* Semi-portable string concatenation in cpp */
236#ifndef CAT
237#ifdef __STDC__
238#define CAT(a,b) a##b
239#else
240#define CAT(a,b) a/**/b
241#endif
242#endif
243
244#define JUMP_TABLE(NAME)\
245CAT(NAME,_core_file_failing_command),\
246CAT(NAME,_core_file_failing_signal),\
247CAT(NAME,_core_file_matches_executable_p),\
248CAT(NAME,_slurp_armap),\
249CAT(NAME,_slurp_extended_name_table),\
250CAT(NAME,_truncate_arname),\
251CAT(NAME,_write_armap),\
252CAT(NAME,_close_and_cleanup), \
253CAT(NAME,_set_section_contents),\
254CAT(NAME,_get_section_contents),\
255CAT(NAME,_new_section_hook),\
256CAT(NAME,_get_symtab_upper_bound),\
257CAT(NAME,_get_symtab),\
258CAT(NAME,_get_reloc_upper_bound),\
259CAT(NAME,_canonicalize_reloc),\
260CAT(NAME,_make_empty_symbol),\
261CAT(NAME,_print_symbol),\
262CAT(NAME,_get_lineno),\
263CAT(NAME,_set_arch_mach),\
264CAT(NAME,_openr_next_archived_file),\
265CAT(NAME,_find_nearest_line),\
266CAT(NAME,_generic_stat_arch_elt),\
7a276b09
SC
267CAT(NAME,_sizeof_headers),\
268CAT(NAME,_bfd_debug_info_start),\
269CAT(NAME,_bfd_debug_info_end),\
270CAT(NAME,_bfd_debug_info_accumulate)
2700c3c7 271
0c210c9c
SC
272#define COFF_SWAP_TABLE \
273 coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in, \
274 coff_swap_aux_out, coff_swap_sym_out, \
275 coff_swap_lineno_out, coff_swap_reloc_out, \
276 coff_swap_filehdr_out, coff_swap_aouthdr_out, \
277 coff_swap_scnhdr_out
278
279
a07cc613
JG
280\f
281/* User program access to BFD facilities */
282
283extern CONST short _bfd_host_big_endian;
284#define HOST_BYTE_ORDER_BIG_P (*(char *)&_bfd_host_big_endian)
285
286/* The bfd itself */
287
8c01a0ea
JK
288/* Cast from const char * to char * so that caller can assign to
289 a char * without a warning. */
290#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
a07cc613
JG
291#define bfd_get_format(abfd) ((abfd)->format)
292#define bfd_get_target(abfd) ((abfd)->xvec->name)
293#define bfd_get_file_flags(abfd) ((abfd)->flags)
294#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
295#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
22ef104a 296#define bfd_my_archive(abfd) ((abfd)->my_archive)
a07cc613
JG
297#define bfd_has_map(abfd) ((abfd)->has_armap)
298#define bfd_header_twiddle_required(abfd) \
299 ((((abfd)->xvec->header_byteorder_big_p) \
300 != (boolean)HOST_BYTE_ORDER_BIG_P) ? true:false)
301
302#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
303#define bfd_usrdata(abfd) ((abfd)->usrdata)
304
305#define bfd_get_start_address(abfd) ((abfd)->start_address)
306#define bfd_get_symcount(abfd) ((abfd)->symcount)
307#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
308#define bfd_count_sections(abfd) ((abfd)->section_count)
309#define bfd_get_architecture(abfd) ((abfd)->obj_arch)
310#define bfd_get_machine(abfd) ((abfd)->obj_machine)
311
a07cc613 312
a07cc613 313
7a276b09
SC
314#define BYTE_SIZE 1
315#define SHORT_SIZE 2
316#define LONG_SIZE 4
317
318
319
1484208f 320/* ANd more from the source */
7a276b09 321
b39096a4 322
bded7de2 323
bded7de2 324
bded7de2 325
bded7de2 326
7a276b09 327
6d56c69a
SC
328void EXFUN(bfd_init, (void));
329bfd *EXFUN(bfd_openr, (CONST char *filename, CONST char*target));
330bfd *EXFUN(bfd_fdopenr, (CONST char *filename, CONST char *target, int fd));
331bfd *EXFUN(bfd_openw, (CONST char *filename, CONST char *target));
332boolean EXFUN(bfd_close, (bfd *));
333boolean EXFUN(bfd_close_all_done, (bfd *));
334bfd *EXFUN(bfd_create, (CONST char *filename, bfd *template));
335bfd_size_type EXFUN(bfd_alloc_size, (bfd *abfd));
336PTR EXFUN(bfd_xmalloc, ( bfd_size_type size));
337void EXFUN(bfd_write_bigendian_4byte_int, (bfd *abfd, int i));
7a276b09
SC
338#define bfd_put_8(abfd, val, ptr) \
339 (*((char *)ptr) = (char)val)
340#define bfd_get_8(abfd, ptr) \
341 (*((char *)ptr))
342#define bfd_put_16(abfd, val, ptr) \
343 BFD_SEND(abfd, bfd_putx16, (val,ptr))
344#define bfd_get_16(abfd, ptr) \
345 BFD_SEND(abfd, bfd_getx16, (ptr))
346#define bfd_put_32(abfd, val, ptr) \
347 BFD_SEND(abfd, bfd_putx32, (val,ptr))
348#define bfd_get_32(abfd, ptr) \
349 BFD_SEND(abfd, bfd_getx32, (ptr))
350#define bfd_put_64(abfd, val, ptr) \
351 BFD_SEND(abfd, bfd_putx64, (val, ptr))
352#define bfd_get_64(abfd, ptr) \
353 BFD_SEND(abfd, bfd_getx64, (ptr))
7a276b09
SC
354#define bfd_h_put_8(abfd, val, ptr) \
355 (*((char *)ptr) = (char)val)
356#define bfd_h_get_8(abfd, ptr) \
357 (*((char *)ptr))
358#define bfd_h_put_16(abfd, val, ptr) \
359 BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
360#define bfd_h_get_16(abfd, ptr) \
361 BFD_SEND(abfd, bfd_h_getx16,(ptr))
362#define bfd_h_put_32(abfd, val, ptr) \
363 BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
364#define bfd_h_get_32(abfd, ptr) \
365 BFD_SEND(abfd, bfd_h_getx32,(ptr))
366#define bfd_h_put_64(abfd, val, ptr) \
367 BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
368#define bfd_h_get_64(abfd, ptr) \
369 BFD_SEND(abfd, bfd_h_getx64,(ptr))
7a276b09 370typedef struct sec {
7a276b09 371 CONST char *name;
7a276b09 372 struct sec *next;
6d56c69a 373 flagword flags;
7a276b09 374#define SEC_NO_FLAGS 0x000
7a276b09 375#define SEC_ALLOC 0x001
7a276b09 376#define SEC_LOAD 0x002
7a276b09 377#define SEC_RELOC 0x004
7a276b09 378#define SEC_BALIGN 0x008
7a276b09 379#define SEC_READONLY 0x010
7a276b09 380#define SEC_CODE 0x020
7a276b09 381#define SEC_DATA 0x040
7a276b09 382#define SEC_ROM 0x080
7a276b09 383#define SEC_CONSTRUCTOR 0x100
1c6c6598
SC
384#define SEC_CONSTRUCTOR_TEXT 0x1100
385#define SEC_CONSTRUCTOR_DATA 0x2100
386#define SEC_CONSTRUCTOR_BSS 0x3100
7a276b09 387#define SEC_HAS_CONTENTS 0x200
7a276b09 388#define SEC_NEVER_LOAD 0x400
7a276b09 389 bfd_vma vma;
7a276b09 390 bfd_size_type size;
7a276b09 391 bfd_vma output_offset;
7a276b09 392 struct sec *output_section;
7a276b09 393 unsigned int alignment_power;
7a276b09 394 struct reloc_cache_entry *relocation;
7a276b09 395 struct reloc_cache_entry **orelocation;
7a276b09 396 unsigned reloc_count;
7a276b09 397 int index;
7a276b09 398 file_ptr filepos;
7a276b09 399 file_ptr rel_filepos;
7a276b09 400 file_ptr line_filepos;
7a276b09
SC
401 PTR userdata;
402 struct lang_output_section *otheruserdata;
7a276b09 403 alent *lineno;
7a276b09 404 unsigned int lineno_count;
7a276b09 405 file_ptr moving_line_filepos;
7a276b09
SC
406 unsigned int target_index;
407 PTR used_by_bfd;
7a276b09 408 struct relent_chain *constructor_chain;
7a276b09
SC
409 bfd *owner;
410} asection ;
6d56c69a
SC
411asection *EXFUN(bfd_get_section_by_name, (bfd *abfd, CONST char *name));
412asection *EXFUN(bfd_make_section_old_way, (bfd *, CONST char *name));
413asection * EXFUN(bfd_make_section, (bfd *, CONST char *name));
414boolean EXFUN(bfd_set_section_flags, (bfd *, asection *, flagword));
415void EXFUN(bfd_map_over_sections, (bfd *abfd, void (*func)(), PTR obj));
416boolean EXFUN(bfd_set_section_size, (bfd *, asection *, bfd_size_type val));
417boolean EXFUN(bfd_set_section_contents
418, (bfd *abfd,
419asection *section,
420PTR data,
421file_ptr offset,
422bfd_size_type count));
423boolean EXFUN(bfd_get_section_contents
424, (bfd *abfd, asection *section, PTR location,
425file_ptr offset, bfd_size_type count));
b39096a4 426enum bfd_architecture
7a276b09 427{
6d56c69a
SC
428 bfd_arch_unknown, /* File arch not known */
429 bfd_arch_obscure, /* Arch known, not one of these */
430 bfd_arch_m68k, /* Motorola 68xxx */
431 bfd_arch_vax, /* DEC Vax */
432 bfd_arch_i960, /* Intel 960 */
433 /* The order of the following is important.
b39096a4
SC
434 lower number indicates a machine type that
435 only accepts a subset of the instructions
436 available to machines with higher numbers.
437 The exception is the "ca", which is
438 incompatible with all other machines except
439 "core". */
7a276b09 440
b39096a4
SC
441#define bfd_mach_i960_core 1
442#define bfd_mach_i960_ka_sa 2
443#define bfd_mach_i960_kb_sb 3
444#define bfd_mach_i960_mc 4
445#define bfd_mach_i960_xa 5
446#define bfd_mach_i960_ca 6
447
6d56c69a
SC
448 bfd_arch_a29k, /* AMD 29000 */
449 bfd_arch_sparc, /* SPARC */
450 bfd_arch_mips, /* MIPS Rxxxx */
451 bfd_arch_i386, /* Intel 386 */
452 bfd_arch_ns32k, /* National Semiconductor 32xxx */
453 bfd_arch_tahoe, /* CCI/Harris Tahoe */
454 bfd_arch_i860, /* Intel 860 */
455 bfd_arch_romp, /* IBM ROMP PC/RT */
456 bfd_arch_alliant, /* Alliant */
457 bfd_arch_convex, /* Convex */
458 bfd_arch_m88k, /* Motorola 88xxx */
459 bfd_arch_pyramid, /* Pyramid Technology */
460 bfd_arch_h8300, /* Hitachi H8/300 */
461 bfd_arch_rs6000, /* IBM RS/6000 */
b39096a4
SC
462 bfd_arch_last
463 };
81f8fee9 464typedef int bfd_reloc_code_type;
bded7de2 465
81f8fee9 466typedef struct bfd_arch_info
b39096a4
SC
467{
468 int bits_per_word;
469 int bits_per_address;
470 int bits_per_byte;
471 enum bfd_architecture arch;
472 long mach;
473 char *arch_name;
474 CONST char *printable_name;
6d56c69a 475 /* true if this is the default machine for the architecture */
b39096a4 476 boolean the_default;
6d56c69a
SC
477 CONST struct bfd_arch_info * EXFUN((*compatible),
478 (CONST struct bfd_arch_info *a,
479 CONST struct bfd_arch_info *b));
b39096a4 480
81f8fee9 481 boolean EXFUN((*scan),(CONST struct bfd_arch_info *,CONST char *));
b39096a4
SC
482 unsigned int EXFUN((*disassemble),(bfd_vma addr, CONST char *data,
483 PTR stream));
6d56c69a
SC
484 CONST struct reloc_howto_struct *EXFUN((*reloc_type_lookup),
485 (CONST struct bfd_arch_info *,
486 bfd_reloc_code_type code));
b39096a4 487
81f8fee9 488 struct bfd_arch_info *next;
b39096a4 489
81f8fee9 490} bfd_arch_info_type;
6d56c69a
SC
491CONST char *EXFUN(bfd_printable_name, (bfd *abfd));
492bfd_arch_info_type *EXFUN(bfd_scan_arch, (CONST char *));
493CONST bfd_arch_info_type *EXFUN(bfd_arch_get_compatible, (
494CONST bfd *abfd,
495CONST bfd *bbfd));
496extern bfd_arch_info_type bfd_default_arch_struct;
497void EXFUN(bfd_set_arch_info, (bfd *, bfd_arch_info_type *));
498enum bfd_architecture EXFUN(bfd_get_arch, (bfd *abfd));
499unsigned long EXFUN(bfd_get_mach, (bfd *abfd));
500unsigned int EXFUN(bfd_arch_bits_per_byte, (bfd *abfd));
501unsigned int EXFUN(bfd_arch_bits_per_address, (bfd *abfd));
502bfd_arch_info_type * EXFUN(bfd_get_arch_info, (bfd *));
503bfd_arch_info_type *EXFUN(bfd_lookup_arch
504, (enum bfd_architecture
505arch,
506long machine));
507CONST char * EXFUN(bfd_printable_arch_mach
508, (enum bfd_architecture arch, unsigned long machine));
b39096a4 509typedef enum bfd_reloc_status {
b39096a4 510 bfd_reloc_ok,
b39096a4 511 bfd_reloc_overflow,
b39096a4 512 bfd_reloc_outofrange,
b39096a4 513 bfd_reloc_continue,
b39096a4 514 bfd_reloc_notsupported,
b39096a4 515 bfd_reloc_other,
b39096a4 516 bfd_reloc_undefined,
b39096a4
SC
517 bfd_reloc_dangerous
518 }
81f8fee9 519 bfd_reloc_status_type;
b39096a4
SC
520typedef struct reloc_cache_entry
521{
b39096a4 522 struct symbol_cache_entry **sym_ptr_ptr;
b39096a4 523 rawdata_offset address;
b39096a4 524 bfd_vma addend;
b39096a4 525 struct sec *section;
b39096a4
SC
526 CONST struct reloc_howto_struct *howto;
527} arelent;
b39096a4
SC
528typedef CONST struct reloc_howto_struct
529{
b39096a4 530 unsigned int type;
b39096a4 531 unsigned int rightshift;
b39096a4 532 unsigned int size;
b39096a4 533 unsigned int bitsize;
b39096a4 534 boolean pc_relative;
b39096a4 535 unsigned int bitpos;
b39096a4 536 boolean absolute;
b39096a4 537 boolean complain_on_overflow;
81f8fee9 538 bfd_reloc_status_type (*special_function)();
b39096a4 539 char *name;
b39096a4 540 boolean partial_inplace;
b39096a4 541 bfd_word src_mask;
b39096a4 542 bfd_word dst_mask;
b39096a4
SC
543 boolean pcrel_offset;
544} reloc_howto_type;
b39096a4
SC
545#define HOWTO(C, R,S,B, P, BI, ABS, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
546 {(unsigned)C,R,S,B, P, BI, ABS,O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
46773090 547#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,false,false,FUNCTION, NAME,false,0,0,IN)
7a276b09 548
b39096a4
SC
549#define HOWTO_PREPARE(relocation, symbol) \
550 { \
551 if (symbol != (asymbol *)NULL) { \
552 if (symbol->flags & BSF_FORT_COMM) { \
553 relocation = 0; \
554 } \
555 else { \
556 relocation = symbol->value; \
557 } \
558 } \
559 if (symbol->section != (asection *)NULL) { \
560 relocation += symbol->section->output_section->vma + \
561 symbol->section->output_offset; \
562 } \
563}
b39096a4 564typedef unsigned char bfd_byte;
bded7de2 565
b39096a4
SC
566typedef struct relent_chain {
567 arelent relent;
568 struct relent_chain *next;
569} arelent_chain;
6d56c69a
SC
570bfd_reloc_status_type
571EXFUN(bfd_perform_relocation
572, (bfd * abfd,
573arelent *reloc_entry,
574PTR data,
575asection *input_section,
576bfd *output_bfd));
81f8fee9 577typedef enum bfd_reloc_code_real {
de7e640d 578 BFD_RELOC_16,
de7e640d 579 BFD_RELOC_8_FFnn,
de7e640d 580 BFD_RELOC_8,
358c1d4d 581 BFD_RELOC_8_PCREL,
358c1d4d 582 BFD_RELOC_CTOR
81f8fee9 583 } bfd_reloc_code_real_type;
6d56c69a
SC
584CONST struct reloc_howto_struct *
585EXFUN(bfd_reloc_type_lookup
586, (CONST bfd_arch_info_type *arch, bfd_reloc_code_type code));
b39096a4
SC
587typedef struct symbol_cache_entry
588{
b39096a4 589 struct _bfd *the_bfd;
b39096a4 590 CONST char *name;
b39096a4 591 symvalue value;
b39096a4 592#define BSF_NO_FLAGS 0x00
b39096a4 593#define BSF_LOCAL 0x01
b39096a4 594#define BSF_GLOBAL 0x02
b39096a4 595#define BSF_IMPORT 0x04
b39096a4 596#define BSF_EXPORT 0x08
b39096a4 597#define BSF_UNDEFINED 0x10
b39096a4 598#define BSF_FORT_COMM 0x20
b39096a4 599#define BSF_DEBUGGING 0x40
b39096a4 600#define BSF_ABSOLUTE 0x80
b39096a4
SC
601#define BSF_KEEP 0x10000
602#define BSF_KEEP_G 0x80000
b39096a4
SC
603#define BSF_WEAK 0x100000
604#define BSF_CTOR 0x200000
605#define BSF_FAKE 0x400000
b39096a4 606#define BSF_OLD_COMMON 0x800000
b39096a4 607#define BFD_FORT_COMM_DEFAULT_VALUE 0
b39096a4 608#define BSF_NOT_AT_END 0x40000
b39096a4 609#define BSF_CONSTRUCTOR 0x1000000
b39096a4 610#define BSF_WARNING 0x2000000
b39096a4 611#define BSF_INDIRECT 0x4000000
b39096a4 612 flagword flags;
b39096a4 613 struct sec *section;
b39096a4
SC
614 PTR udata;
615} asymbol;
b39096a4
SC
616#define get_symtab_upper_bound(abfd) \
617 BFD_SEND (abfd, _get_symtab_upper_bound, (abfd))
b39096a4
SC
618#define bfd_canonicalize_symtab(abfd, location) \
619 BFD_SEND (abfd, _bfd_canonicalize_symtab,\
620 (abfd, location))
6d56c69a
SC
621boolean EXFUN(bfd_set_symtab , (bfd *, asymbol **, unsigned int ));
622void EXFUN(bfd_print_symbol_vandf, (PTR file, asymbol *symbol));
b39096a4
SC
623#define bfd_make_empty_symbol(abfd) \
624 BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
6d56c69a 625int EXFUN(bfd_decode_symclass, (asymbol *symbol));
b39096a4
SC
626struct _bfd
627{
b39096a4 628 CONST char *filename;
b39096a4 629 struct bfd_target *xvec;
b39096a4 630 char *iostream;
b39096a4 631 boolean cacheable;
b39096a4 632 boolean target_defaulted;
b39096a4 633 struct _bfd *lru_prev, *lru_next;
b39096a4 634 file_ptr where;
b39096a4 635 boolean opened_once;
b39096a4 636 boolean mtime_set;
b39096a4 637 long mtime;
6d56c69a 638 int ifd;
b39096a4 639 bfd_format format;
b39096a4
SC
640 enum bfd_direction {no_direction = 0,
641 read_direction = 1,
642 write_direction = 2,
643 both_direction = 3} direction;
b39096a4 644 flagword flags;
b39096a4 645 file_ptr origin;
b39096a4 646 boolean output_has_begun;
b39096a4 647 struct sec *sections;
b39096a4 648 unsigned int section_count;
b39096a4 649 bfd_vma start_address;
b39096a4 650 unsigned int symcount;
b39096a4 651 struct symbol_cache_entry **outsymbols;
81f8fee9 652 struct bfd_arch_info *arch_info;
b39096a4
SC
653 PTR arelt_data;
654 struct _bfd *my_archive;
655 struct _bfd *next;
656 struct _bfd *archive_head;
657 boolean has_armap;
b39096a4 658 PTR tdata;
b39096a4 659 PTR usrdata;
b39096a4
SC
660 struct obstack memory;
661};
6d56c69a
SC
662boolean EXFUN(bfd_set_start_address, (bfd *, bfd_vma));
663long EXFUN(bfd_get_mtime, (bfd *));
b39096a4
SC
664#define bfd_sizeof_headers(abfd, reloc) \
665 BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
666
667#define bfd_find_nearest_line(abfd, section, symbols, offset, filename_ptr, func, line_ptr) \
668 BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, section, symbols, offset, filename_ptr, func, line_ptr))
669
670#define bfd_debug_info_start(abfd) \
671 BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
672
673#define bfd_debug_info_end(abfd) \
674 BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
675
676#define bfd_debug_info_accumulate(abfd, section) \
677 BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
678
679#define bfd_stat_arch_elt(abfd, stat) \
680 BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
681
682#define bfd_coff_swap_aux_in(a,e,t,c,i) \
683 BFD_SEND (a, _bfd_coff_swap_aux_in, (a,e,t,c,i))
684
685#define bfd_coff_swap_sym_in(a,e,i) \
686 BFD_SEND (a, _bfd_coff_swap_sym_in, (a,e,i))
687
688#define bfd_coff_swap_lineno_in(a,e,i) \
689 BFD_SEND ( a, _bfd_coff_swap_lineno_in, (a,e,i))
690
691#define bfd_set_arch_mach(abfd, arch, mach)\
692 BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
7f3d9f46 693
0c210c9c
SC
694#define bfd_coff_swap_reloc_out(abfd, i, o) \
695 BFD_SEND (abfd, _bfd_coff_swap_reloc_out, (abfd, i, o))
696
697#define bfd_coff_swap_lineno_out(abfd, i, o) \
698 BFD_SEND (abfd, _bfd_coff_swap_lineno_out, (abfd, i, o))
699
700#define bfd_coff_swap_aux_out(abfd, i, t,c,o) \
701 BFD_SEND (abfd, _bfd_coff_swap_aux_out, (abfd, i,t,c, o))
702
703#define bfd_coff_swap_sym_out(abfd, i,o) \
704 BFD_SEND (abfd, _bfd_coff_swap_sym_out, (abfd, i, o))
705
706#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
707 BFD_SEND (abfd, _bfd_coff_swap_scnhdr_out, (abfd, i, o))
708
709#define bfd_coff_swap_filehdr_out(abfd, i,o) \
710 BFD_SEND (abfd, _bfd_coff_swap_filehdr_out, (abfd, i, o))
711
712#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
713 BFD_SEND (abfd, _bfd_coff_swap_aouthdr_out, (abfd, i, o))
714
6d56c69a
SC
715symindex EXFUN(bfd_get_next_mapent, (bfd *, symindex, carsym **));
716boolean EXFUN(bfd_set_archive_head, (bfd *output, bfd *new_head));
717bfd *EXFUN(bfd_get_elt_at_index, (bfd *, int));
718bfd* EXFUN(bfd_openr_next_archived_file, (bfd *archive, bfd *previous));
719CONST char *EXFUN(bfd_core_file_failing_command, (bfd *));
720int EXFUN(bfd_core_file_failing_signal, (bfd *));
721boolean EXFUN(core_file_matches_executable_p
722, (bfd *core_bfd, bfd *exec_bfd));
7a276b09
SC
723#define SDEF(ret, name, arglist) \
724 PROTO(ret,(*name),arglist)
725#define SDEF_FMT(ret, name, arglist) \
726 PROTO(ret,(*name[bfd_type_end]),arglist)
7a276b09
SC
727#define BFD_SEND(bfd, message, arglist) \
728 ((*((bfd)->xvec->message)) arglist)
7a276b09
SC
729#define BFD_SEND_FMT(bfd, message, arglist) \
730 (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
7a276b09
SC
731typedef struct bfd_target
732{
7a276b09 733 char *name;
81f8fee9
JG
734 enum target_flavour {
735 bfd_target_unknown_flavour,
736 bfd_target_aout_flavour,
737 bfd_target_coff_flavour,
738 bfd_target_elf_flavour,
739 bfd_target_ieee_flavour,
740 bfd_target_oasys_flavour,
741 bfd_target_srec_flavour} flavour;
7a276b09 742 boolean byteorder_big_p;
7a276b09 743 boolean header_byteorder_big_p;
7a276b09 744 flagword object_flags;
7a276b09 745 flagword section_flags;
7a276b09 746 char ar_pad_char;
7a276b09 747 unsigned short ar_max_namelen;
7a276b09 748 unsigned int align_power_min;
fcc654cb
SC
749 SDEF (bfd_vma, bfd_getx64, (bfd_byte *));
750 SDEF (void, bfd_putx64, (bfd_vma, bfd_byte *));
751 SDEF (bfd_vma, bfd_getx32, (bfd_byte *));
752 SDEF (void, bfd_putx32, (bfd_vma, bfd_byte *));
753 SDEF (bfd_vma, bfd_getx16, (bfd_byte *));
754 SDEF (void, bfd_putx16, (bfd_vma, bfd_byte *));
fcc654cb
SC
755 SDEF (bfd_vma, bfd_h_getx64, (bfd_byte *));
756 SDEF (void, bfd_h_putx64, (bfd_vma, bfd_byte *));
757 SDEF (bfd_vma, bfd_h_getx32, (bfd_byte *));
758 SDEF (void, bfd_h_putx32, (bfd_vma, bfd_byte *));
759 SDEF (bfd_vma, bfd_h_getx16, (bfd_byte *));
760 SDEF (void, bfd_h_putx16, (bfd_vma, bfd_byte *));
7a276b09 761 SDEF_FMT (struct bfd_target *, _bfd_check_format, (bfd *));
7a276b09 762 SDEF_FMT (boolean, _bfd_set_format, (bfd *));
7a276b09 763 SDEF_FMT (boolean, _bfd_write_contents, (bfd *));
7a276b09
SC
764 SDEF (char *, _core_file_failing_command, (bfd *));
765 SDEF (int, _core_file_failing_signal, (bfd *));
766 SDEF (boolean, _core_file_matches_executable_p, (bfd *, bfd *));
7a276b09
SC
767 SDEF (boolean, _bfd_slurp_armap, (bfd *));
768 SDEF (boolean, _bfd_slurp_extended_name_table, (bfd *));
769 SDEF (void, _bfd_truncate_arname, (bfd *, CONST char *, char *));
770 SDEF (boolean, write_armap, (bfd *arch,
771 unsigned int elength,
772 struct orl *map,
a0788ae3 773 unsigned int orl_count,
7a276b09 774 int stridx));
7a276b09
SC
775 SDEF (boolean, _close_and_cleanup, (bfd *));
776 SDEF (boolean, _bfd_set_section_contents, (bfd *, sec_ptr, PTR,
777 file_ptr, bfd_size_type));
778 SDEF (boolean, _bfd_get_section_contents, (bfd *, sec_ptr, PTR,
779 file_ptr, bfd_size_type));
780 SDEF (boolean, _new_section_hook, (bfd *, sec_ptr));
6d56c69a 781 SDEF (unsigned int, _get_symtab_upper_bound, (bfd *));
7a276b09
SC
782 SDEF (unsigned int, _bfd_canonicalize_symtab,
783 (bfd *, struct symbol_cache_entry **));
784 SDEF (unsigned int, _get_reloc_upper_bound, (bfd *, sec_ptr));
785 SDEF (unsigned int, _bfd_canonicalize_reloc, (bfd *, sec_ptr, arelent **,
786 struct symbol_cache_entry**));
787 SDEF (struct symbol_cache_entry *, _bfd_make_empty_symbol, (bfd *));
788 SDEF (void, _bfd_print_symbol, (bfd *, PTR, struct symbol_cache_entry *,
81f8fee9 789 bfd_print_symbol_type));
7a276b09
SC
790#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
791 SDEF (alent *, _get_lineno, (bfd *, struct symbol_cache_entry *));
792
793 SDEF (boolean, _bfd_set_arch_mach, (bfd *, enum bfd_architecture,
794 unsigned long));
795
796 SDEF (bfd *, openr_next_archived_file, (bfd *arch, bfd *prev));
797 SDEF (boolean, _bfd_find_nearest_line,
798 (bfd *abfd, struct sec *section,
799 struct symbol_cache_entry **symbols,bfd_vma offset,
800 CONST char **file, CONST char **func, unsigned int *line));
801 SDEF (int, _bfd_stat_arch_elt, (bfd *, struct stat *));
802
803 SDEF (int, _bfd_sizeof_headers, (bfd *, boolean));
804
805 SDEF (void, _bfd_debug_info_start, (bfd *));
806 SDEF (void, _bfd_debug_info_end, (bfd *));
807 SDEF (void, _bfd_debug_info_accumulate, (bfd *, struct sec *));
7a276b09
SC
808 SDEF(void, _bfd_coff_swap_aux_in,(
809 bfd *abfd ,
810 PTR ext,
811 int type,
812 int class ,
813 PTR in));
814
815 SDEF(void, _bfd_coff_swap_sym_in,(
816 bfd *abfd ,
817 PTR ext,
818 PTR in));
819
820 SDEF(void, _bfd_coff_swap_lineno_in, (
821 bfd *abfd,
822 PTR ext,
823 PTR in));
824
0c210c9c
SC
825 SDEF(unsigned int, _bfd_coff_swap_aux_out,(
826 bfd *abfd,
827 PTR in,
828 int type,
829 int class,
830 PTR ext));
831
832 SDEF(unsigned int, _bfd_coff_swap_sym_out,(
833 bfd *abfd,
834 PTR in,
835 PTR ext));
836
837 SDEF(unsigned int, _bfd_coff_swap_lineno_out,(
838 bfd *abfd,
839 PTR in,
840 PTR ext));
841
842 SDEF(unsigned int, _bfd_coff_swap_reloc_out,(
843 bfd *abfd,
844 PTR src,
845 PTR dst));
846
847 SDEF(unsigned int, _bfd_coff_swap_filehdr_out,(
848 bfd *abfd,
849 PTR in,
850 PTR out));
851
852 SDEF(unsigned int, _bfd_coff_swap_aouthdr_out,(
853 bfd *abfd,
854 PTR in,
855 PTR out));
856
857 SDEF(unsigned int, _bfd_coff_swap_scnhdr_out,(
858 bfd *abfd,
859 PTR in,
860 PTR out));
861
7a276b09 862} bfd_target;
6d56c69a
SC
863bfd_target *EXFUN(bfd_find_target, (CONST char *, bfd *));
864CONST char **EXFUN(bfd_target_list, ());
865boolean EXFUN(bfd_check_format, (bfd *abfd, bfd_format format));
866boolean EXFUN(bfd_set_format, (bfd *, bfd_format));
867CONST char *EXFUN(bfd_format_string, (bfd_format));
1484208f 868#endif
This page took 0.083744 seconds and 4 git commands to generate.