* ldmain.c (decode_library_subfile): Patch from
[deliverable/binutils-gdb.git] / include / bfd.h
CommitLineData
18fe0e9f
JG
1/* Main header file for the bfd library -- portable access to object files.
2 ==> The bfd.h file is generated from bfd-in.h and various .c files; if you
3 ==> change it, your changes will probably be lost.
c98d03ea 4 Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
095c7223 5 Contributed by Cygnus Support.
a07cc613 6
2c346475 7This file is part of BFD, the Binary File Descriptor library.
a07cc613 8
095c7223 9This program is free software; you can redistribute it and/or modify
a07cc613 10it under the terms of the GNU General Public License as published by
095c7223
JG
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
a07cc613 13
095c7223 14This program is distributed in the hope that it will be useful,
a07cc613
JG
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
095c7223
JG
20along with this program; if not, write to the Free Software
21Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22
23/* bfd.h -- The only header file required by users of the bfd library
24
18fe0e9f
JG
25The bfd.h file is generated from bfd-in.h and various .c files; if you
26change it, your changes will probably be lost.
095c7223
JG
27
28All the prototypes and definitions following the comment "THE FOLLOWING
29IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
30BFD. If you change it, someone oneday will extract it from the source
31again, and your changes will be lost. To save yourself from this bind,
32change the definitions in the source in the bfd directory. Type "make
33docs" and then "make headers" in that directory, and magically this file
34will change to reflect your changes.
35
36If you don't have the tools to perform the extraction, then you are
37safe from someone on your system trampling over your header files.
38You should still maintain the equivalence between the source and this
39file though; every change you make to the .c file should be reflected
40here. */
a07cc613 41
a07cc613
JG
42#ifndef __BFD_H_SEEN__
43#define __BFD_H_SEEN__
44
45#include "ansidecl.h"
46#include "obstack.h"
47
60289922 48#define BFD_VERSION "2.0"
ec08b077 49
a07cc613 50/* forward declaration */
9c6a9c92 51typedef struct _bfd bfd;
a07cc613 52
ec08b077
JG
53/* General rules: functions which are boolean return true on success
54 and false on failure (unless they're a predicate). -- bfd.doc */
a07cc613
JG
55/* I'm sure this is going to break something and someone is going to
56 force me to change it. */
f7cfc4a6
JG
57/* typedef enum boolean {false, true} boolean; */
58/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */
59typedef enum bfd_boolean {false, true} boolean;
a07cc613 60
c98d03ea
JG
61/* A pointer to a position in a file. */
62/* FIXME: This should be using off_t from <sys/types.h>.
63 For now, try to avoid breaking stuff by not including <sys/types.h> here.
64 This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
65 Probably the best long-term answer is to avoid using file_ptr AND off_t
66 in this header file, and to handle this in the BFD implementation
67 rather than in its interface. */
68/* typedef off_t file_ptr; */
69typedef long int file_ptr;
a07cc613 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 */
01bbba25
SC
109#define NO_FLAGS 0x00
110#define HAS_RELOC 0x01
111#define EXEC_P 0x02
112#define HAS_LINENO 0x04
113#define HAS_DEBUG 0x08
114#define HAS_SYMS 0x10
115#define HAS_LOCALS 0x20
116#define DYNAMIC 0x40
117#define WP_TEXT 0x80
118#define D_PAGED 0x100
119#define BFD_IS_RELAXABLE 0x200
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)
2f5e51f7 146#define bfd_asymbol_base(x) ((x)->section->vma)
a07cc613
JG
147#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + x->value)
148#define bfd_asymbol_name(x) ((x)->name)
2f5e51f7
PB
149/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
150#define bfd_asymbol_bfd(x) ((x)->the_bfd)
151#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
a07cc613 152
a07cc613 153/* This is a type pun with struct ranlib on purpose! */
9c6a9c92 154typedef struct carsym {
a07cc613
JG
155 char *name;
156 file_ptr file_offset; /* look here to find the file */
157} carsym; /* to make these you call a carsymogen */
158
a07cc613
JG
159
160/* Used in generating armaps. Perhaps just a forward definition would do? */
161struct orl { /* output ranlib */
162 char **name; /* symbol name */
c93e2c55 163 file_ptr pos; /* bfd* or file position */
a07cc613
JG
164 int namidx; /* index into string table */
165};
166
167\f
168
169/* Linenumber stuff */
170typedef struct lineno_cache_entry {
171 unsigned int line_number; /* Linenumber from start of function*/
172 union {
7a276b09 173 struct symbol_cache_entry *sym; /* Function name */
a07cc613
JG
174 unsigned long offset; /* Offset into section */
175 } u;
176} alent;
177\f
178/* object and core file sections */
179
a07cc613
JG
180
181#define align_power(addr, align) \
182 ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
183
9c6a9c92 184typedef struct sec *sec_ptr;
a07cc613 185
d5ceae78
KR
186#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
187#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
188#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
a07cc613 189#define bfd_section_name(bfd, ptr) ((ptr)->name)
9a7c5449 190#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
a07cc613
JG
191#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
192#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
d5ceae78 193#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
a07cc613
JG
194#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
195
9a51287f 196#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (val)), ((ptr)->user_set_vma = true), true)
a07cc613
JG
197#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
198#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
4322f04d
SC
199
200typedef struct stat stat_type;
a07cc613
JG
201\f
202/** Error handling */
203
fb3ee1c0
JG
204typedef enum bfd_error {
205 no_error = 0, system_call_error, invalid_target,
a07cc613
JG
206 wrong_format, invalid_operation, no_memory,
207 no_symbols, no_relocation_info,
208 no_more_archived_files, malformed_archive,
209 symbol_not_found, file_not_recognized,
210 file_ambiguously_recognized, no_contents,
6603bf38 211 bfd_error_nonrepresentable_section,
d5ceae78 212 no_debug_section, bad_value,
a07cc613
JG
213 invalid_error_code} bfd_ec;
214
215extern bfd_ec bfd_error;
9a7c5449 216struct reloc_cache_entry;
f6047bbd 217struct bfd_seclet;
9a7c5449 218
a07cc613 219
9c6a9c92 220typedef struct bfd_error_vector {
d4a06831
JG
221 void (* nonrepresentable_section ) PARAMS ((CONST bfd *CONST abfd,
222 CONST char *CONST name));
223 void (* undefined_symbol) PARAMS ((CONST struct reloc_cache_entry *rel,
224 CONST struct bfd_seclet *sec));
225 void (* reloc_value_truncated) PARAMS ((CONST struct
9a7c5449 226 reloc_cache_entry *rel,
f6047bbd 227 struct bfd_seclet *sec));
9a7c5449 228
d4a06831
JG
229 void (* reloc_dangerous) PARAMS ((CONST struct reloc_cache_entry *rel,
230 CONST struct bfd_seclet *sec));
9a7c5449 231
a07cc613
JG
232} bfd_error_vector_type;
233
d4a06831
JG
234CONST char *bfd_errmsg PARAMS ((bfd_ec error_tag));
235void bfd_perror PARAMS ((CONST char *message));
a07cc613
JG
236\f
237
9b9c5c39 238typedef enum bfd_print_symbol
a07cc613 239{
81f8fee9
JG
240 bfd_print_symbol_name,
241 bfd_print_symbol_more,
b941cb35 242 bfd_print_symbol_all,
0aa70210 243 bfd_print_symbol_nm /* Pretty format suitable for nm program. */
81f8fee9 244} bfd_print_symbol_type;
a07cc613
JG
245
246\f
a07cc613
JG
247\f
248/* The code that implements targets can initialize a jump table with this
249 macro. It must name all its routines the same way (a prefix plus
250 the standard routine suffix), or it must #define the routines that
251 are not so named, before calling JUMP_TABLE in the initializer. */
252
253/* Semi-portable string concatenation in cpp */
254#ifndef CAT
255#ifdef __STDC__
256#define CAT(a,b) a##b
257#else
258#define CAT(a,b) a/**/b
259#endif
260#endif
261
262#define JUMP_TABLE(NAME)\
263CAT(NAME,_core_file_failing_command),\
264CAT(NAME,_core_file_failing_signal),\
265CAT(NAME,_core_file_matches_executable_p),\
266CAT(NAME,_slurp_armap),\
267CAT(NAME,_slurp_extended_name_table),\
268CAT(NAME,_truncate_arname),\
269CAT(NAME,_write_armap),\
270CAT(NAME,_close_and_cleanup), \
271CAT(NAME,_set_section_contents),\
272CAT(NAME,_get_section_contents),\
273CAT(NAME,_new_section_hook),\
274CAT(NAME,_get_symtab_upper_bound),\
275CAT(NAME,_get_symtab),\
276CAT(NAME,_get_reloc_upper_bound),\
277CAT(NAME,_canonicalize_reloc),\
278CAT(NAME,_make_empty_symbol),\
279CAT(NAME,_print_symbol),\
280CAT(NAME,_get_lineno),\
281CAT(NAME,_set_arch_mach),\
282CAT(NAME,_openr_next_archived_file),\
283CAT(NAME,_find_nearest_line),\
284CAT(NAME,_generic_stat_arch_elt),\
7a276b09
SC
285CAT(NAME,_sizeof_headers),\
286CAT(NAME,_bfd_debug_info_start),\
287CAT(NAME,_bfd_debug_info_end),\
9a7c5449 288CAT(NAME,_bfd_debug_info_accumulate),\
daa91756
SC
289CAT(NAME,_bfd_get_relocated_section_contents),\
290CAT(NAME,_bfd_relax_section)
2700c3c7 291
355e5a8e 292#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
0c210c9c 293
a07cc613
JG
294\f
295/* User program access to BFD facilities */
296
297extern CONST short _bfd_host_big_endian;
298#define HOST_BYTE_ORDER_BIG_P (*(char *)&_bfd_host_big_endian)
299
300/* The bfd itself */
301
8c01a0ea
JK
302/* Cast from const char * to char * so that caller can assign to
303 a char * without a warning. */
304#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
a07cc613
JG
305#define bfd_get_format(abfd) ((abfd)->format)
306#define bfd_get_target(abfd) ((abfd)->xvec->name)
307#define bfd_get_file_flags(abfd) ((abfd)->flags)
308#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
309#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
22ef104a 310#define bfd_my_archive(abfd) ((abfd)->my_archive)
a07cc613
JG
311#define bfd_has_map(abfd) ((abfd)->has_armap)
312#define bfd_header_twiddle_required(abfd) \
313 ((((abfd)->xvec->header_byteorder_big_p) \
314 != (boolean)HOST_BYTE_ORDER_BIG_P) ? true:false)
315
316#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
317#define bfd_usrdata(abfd) ((abfd)->usrdata)
318
319#define bfd_get_start_address(abfd) ((abfd)->start_address)
320#define bfd_get_symcount(abfd) ((abfd)->symcount)
321#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
322#define bfd_count_sections(abfd) ((abfd)->section_count)
323#define bfd_get_architecture(abfd) ((abfd)->obj_arch)
324#define bfd_get_machine(abfd) ((abfd)->obj_machine)
325
ab414d87 326#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
a07cc613 327
7a276b09
SC
328#define BYTE_SIZE 1
329#define SHORT_SIZE 2
330#define LONG_SIZE 4
331
d5ceae78 332/* And more from the source. */
18fe0e9f
JG
333void
334bfd_init PARAMS ((void));
335
336bfd *
337bfd_openr PARAMS ((CONST char *filename, CONST char*target));
338
339bfd *
340bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd));
341
342bfd *
343bfd_openw PARAMS ((CONST char *filename, CONST char *target));
344
345boolean
346bfd_close PARAMS ((bfd *));
347
348boolean
349bfd_close_all_done PARAMS ((bfd *));
350
351bfd_size_type
352bfd_alloc_size PARAMS ((bfd *abfd));
353
354bfd *
355bfd_create PARAMS ((CONST char *filename, bfd *template));
356
7a276b09
SC
357#define bfd_put_8(abfd, val, ptr) \
358 (*((char *)ptr) = (char)val)
359#define bfd_get_8(abfd, ptr) \
360 (*((char *)ptr))
361#define bfd_put_16(abfd, val, ptr) \
362 BFD_SEND(abfd, bfd_putx16, (val,ptr))
363#define bfd_get_16(abfd, ptr) \
364 BFD_SEND(abfd, bfd_getx16, (ptr))
365#define bfd_put_32(abfd, val, ptr) \
366 BFD_SEND(abfd, bfd_putx32, (val,ptr))
367#define bfd_get_32(abfd, ptr) \
368 BFD_SEND(abfd, bfd_getx32, (ptr))
369#define bfd_put_64(abfd, val, ptr) \
370 BFD_SEND(abfd, bfd_putx64, (val, ptr))
371#define bfd_get_64(abfd, ptr) \
372 BFD_SEND(abfd, bfd_getx64, (ptr))
7a276b09
SC
373#define bfd_h_put_8(abfd, val, ptr) \
374 (*((char *)ptr) = (char)val)
375#define bfd_h_get_8(abfd, ptr) \
376 (*((char *)ptr))
377#define bfd_h_put_16(abfd, val, ptr) \
378 BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
379#define bfd_h_get_16(abfd, ptr) \
380 BFD_SEND(abfd, bfd_h_getx16,(ptr))
381#define bfd_h_put_32(abfd, val, ptr) \
382 BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
383#define bfd_h_get_32(abfd, ptr) \
384 BFD_SEND(abfd, bfd_h_getx32,(ptr))
385#define bfd_h_put_64(abfd, val, ptr) \
386 BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
387#define bfd_h_get_64(abfd, ptr) \
388 BFD_SEND(abfd, bfd_h_getx64,(ptr))
332b6327
SC
389typedef struct sec
390{
391 /* The name of the section, the name isn't a copy, the pointer is
392 the same as that passed to bfd_make_section. */
393
7a276b09 394 CONST char *name;
332b6327 395
9a7c5449
SC
396
397 /* Which section is it 0.nth */
398
399 int index;
400
332b6327
SC
401 /* The next section in the list belonging to the BFD, or NULL. */
402
7a276b09 403 struct sec *next;
332b6327
SC
404
405 /* The field flags contains attributes of the section. Some of
406 flags are read in from the object file, and some are
407 synthesized from other information. */
408
6d56c69a 409 flagword flags;
332b6327 410
7a276b09 411#define SEC_NO_FLAGS 0x000
332b6327
SC
412
413 /* Tells the OS to allocate space for this section when loaded.
414 This would clear for a section containing debug information
415 only. */
416
417
7a276b09 418#define SEC_ALLOC 0x001
332b6327
SC
419 /* Tells the OS to load the section from the file when loading.
420 This would be clear for a .bss section */
421
7a276b09 422#define SEC_LOAD 0x002
332b6327
SC
423 /* The section contains data still to be relocated, so there will
424 be some relocation information too. */
425
7a276b09 426#define SEC_RELOC 0x004
332b6327
SC
427
428 /* Obsolete ? */
429
7a276b09 430#define SEC_BALIGN 0x008
332b6327
SC
431
432 /* A signal to the OS that the section contains read only
433 data. */
7a276b09 434#define SEC_READONLY 0x010
332b6327
SC
435
436 /* The section contains code only. */
437
7a276b09 438#define SEC_CODE 0x020
332b6327
SC
439
440 /* The section contains data only. */
441
7a276b09 442#define SEC_DATA 0x040
332b6327
SC
443
444 /* The section will reside in ROM. */
445
7a276b09 446#define SEC_ROM 0x080
332b6327
SC
447
448 /* The section contains constructor information. This section
449 type is used by the linker to create lists of constructors and
450 destructors used by <<g++>>. When a back end sees a symbol
451 which should be used in a constructor list, it creates a new
452 section for the type of name (eg <<__CTOR_LIST__>>), attaches
453 the symbol to it and builds a relocation. To build the lists
454 of constructors, all the linker has to to is catenate all the
455 sections called <<__CTOR_LIST__>> and relocte the data
456 contained within - exactly the operations it would peform on
457 standard data. */
458
7a276b09 459#define SEC_CONSTRUCTOR 0x100
332b6327
SC
460
461 /* The section is a constuctor, and should be placed at the
462 end of the . */
463
464
1c6c6598 465#define SEC_CONSTRUCTOR_TEXT 0x1100
332b6327 466
1c6c6598 467#define SEC_CONSTRUCTOR_DATA 0x2100
332b6327 468
1c6c6598 469#define SEC_CONSTRUCTOR_BSS 0x3100
332b6327
SC
470
471
472 /* The section has contents - a bss section could be
473 <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>, a debug section could be
474 <<SEC_HAS_CONTENTS>> */
475
7a276b09 476#define SEC_HAS_CONTENTS 0x200
332b6327
SC
477
478 /* An instruction to the linker not to output sections
479 containing this flag even if they have information which
480 would normally be written. */
481
7a276b09 482#define SEC_NEVER_LOAD 0x400
332b6327 483
41d1b02f
ILT
484 /* The section is a shared library section. The linker must leave
485 these completely alone, as the vma and size are used when
486 the executable is loaded. */
487
488#define SEC_SHARED_LIBRARY 0x800
9a7c5449 489
332b6327 490
7a276b09 491 bfd_vma vma;
9a51287f 492 boolean user_set_vma;
332b6327 493
9a7c5449 494 /* The size of the section in bytes, as it will be output.
332b6327 495 contains a value even if the section has no contents (eg, the
9a7c5449 496 size of <<.bss>>). This will be filled in after relocation */
332b6327 497
9a7c5449
SC
498 bfd_size_type _cooked_size;
499
500 /* The size on disk of the section in bytes originally. Normally this
501 value is the same as the size, but if some relaxing has
502 been done, then this value will be bigger. */
503
504 bfd_size_type _raw_size;
332b6327
SC
505
506 /* If this section is going to be output, then this value is the
507 offset into the output section of the first byte in the input
508 section. Eg, if this was going to start at the 100th byte in
509 the output section, this value would be 100. */
510
7a276b09 511 bfd_vma output_offset;
332b6327
SC
512
513 /* The output section through which to map on output. */
514
7a276b09 515 struct sec *output_section;
332b6327
SC
516
517 /* The alignment requirement of the section, as an exponent - eg
518 3 aligns to 2^3 (or 8) */
519
7a276b09 520 unsigned int alignment_power;
332b6327
SC
521
522 /* If an input section, a pointer to a vector of relocation
523 records for the data in this section. */
524
7a276b09 525 struct reloc_cache_entry *relocation;
332b6327
SC
526
527 /* If an output section, a pointer to a vector of pointers to
528 relocation records for the data in this section. */
529
7a276b09 530 struct reloc_cache_entry **orelocation;
332b6327
SC
531
532 /* The number of relocation records in one of the above */
533
7a276b09 534 unsigned reloc_count;
332b6327 535
332b6327
SC
536 /* Information below is back end specific - and not always used
537 or updated
538
539 File position of section data */
540
7a276b09 541 file_ptr filepos;
332b6327
SC
542
543 /* File position of relocation info */
544
7a276b09 545 file_ptr rel_filepos;
332b6327
SC
546
547 /* File position of line data */
548
7a276b09 549 file_ptr line_filepos;
332b6327
SC
550
551 /* Pointer to data for applications */
552
7a276b09 553 PTR userdata;
332b6327 554
7a276b09 555 struct lang_output_section *otheruserdata;
332b6327
SC
556
557 /* Attached line number information */
558
7a276b09 559 alent *lineno;
332b6327
SC
560
561 /* Number of line number records */
562
7a276b09 563 unsigned int lineno_count;
332b6327
SC
564
565 /* When a section is being output, this value changes as more
566 linenumbers are written out */
567
7a276b09 568 file_ptr moving_line_filepos;
332b6327
SC
569
570 /* what the section number is in the target world */
571
9a7c5449 572 int target_index;
332b6327 573
7a276b09 574 PTR used_by_bfd;
332b6327
SC
575
576 /* If this is a constructor section then here is a list of the
577 relocations created to relocate items within it. */
578
7a276b09 579 struct relent_chain *constructor_chain;
332b6327
SC
580
581 /* The BFD which owns the section. */
582
7a276b09 583 bfd *owner;
332b6327 584
9a7c5449
SC
585 boolean reloc_done;
586 /* A symbol which points at this section only */
587 struct symbol_cache_entry *symbol;
588 struct symbol_cache_entry **symbol_ptr_ptr;
f6047bbd
JG
589 struct bfd_seclet *seclets_head;
590 struct bfd_seclet *seclets_tail;
7a276b09 591} asection ;
9a7c5449
SC
592
593
594#define BFD_ABS_SECTION_NAME "*ABS*"
595#define BFD_UND_SECTION_NAME "*UND*"
596#define BFD_COM_SECTION_NAME "*COM*"
597
598 /* the absolute section */
599 extern asection bfd_abs_section;
600 /* Pointer to the undefined section */
601 extern asection bfd_und_section;
602 /* Pointer to the common section */
603 extern asection bfd_com_section;
604
605 extern struct symbol_cache_entry *bfd_abs_symbol;
606 extern struct symbol_cache_entry *bfd_com_symbol;
607 extern struct symbol_cache_entry *bfd_und_symbol;
608#define bfd_get_section_size_before_reloc(section) \
609 (section->reloc_done ? (abort(),1): (section)->_raw_size)
610#define bfd_get_section_size_after_reloc(section) \
611 ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
18fe0e9f
JG
612asection *
613bfd_get_section_by_name PARAMS ((bfd *abfd, CONST char *name));
614
615asection *
616bfd_make_section_old_way PARAMS ((bfd *, CONST char *name));
617
618asection *
619bfd_make_section PARAMS ((bfd *, CONST char *name));
620
621boolean
622bfd_set_section_flags PARAMS ((bfd *, asection *, flagword));
623
624void
625bfd_map_over_sections PARAMS ((bfd *abfd,
f48e5efe
JG
626 void (*func)(bfd *abfd,
627 asection *sect,
628 PTR obj),
629 PTR obj));
18fe0e9f
JG
630
631boolean
632bfd_set_section_size PARAMS ((bfd *, asection *, bfd_size_type val));
633
634boolean
635bfd_set_section_contents
636 PARAMS ((bfd *abfd,
332b6327
SC
637 asection *section,
638 PTR data,
639 file_ptr offset,
640 bfd_size_type count));
18fe0e9f
JG
641
642boolean
643bfd_get_section_contents
644 PARAMS ((bfd *abfd, asection *section, PTR location,
332b6327 645 file_ptr offset, bfd_size_type count));
18fe0e9f 646
b39096a4 647enum bfd_architecture
7a276b09 648{
6d56c69a
SC
649 bfd_arch_unknown, /* File arch not known */
650 bfd_arch_obscure, /* Arch known, not one of these */
651 bfd_arch_m68k, /* Motorola 68xxx */
652 bfd_arch_vax, /* DEC Vax */
653 bfd_arch_i960, /* Intel 960 */
654 /* The order of the following is important.
b39096a4
SC
655 lower number indicates a machine type that
656 only accepts a subset of the instructions
657 available to machines with higher numbers.
658 The exception is the "ca", which is
659 incompatible with all other machines except
660 "core". */
7a276b09 661
b39096a4
SC
662#define bfd_mach_i960_core 1
663#define bfd_mach_i960_ka_sa 2
664#define bfd_mach_i960_kb_sb 3
665#define bfd_mach_i960_mc 4
666#define bfd_mach_i960_xa 5
667#define bfd_mach_i960_ca 6
668
6d56c69a
SC
669 bfd_arch_a29k, /* AMD 29000 */
670 bfd_arch_sparc, /* SPARC */
671 bfd_arch_mips, /* MIPS Rxxxx */
672 bfd_arch_i386, /* Intel 386 */
60289922 673 bfd_arch_we32k, /* AT&T WE32xxx */
6d56c69a
SC
674 bfd_arch_tahoe, /* CCI/Harris Tahoe */
675 bfd_arch_i860, /* Intel 860 */
676 bfd_arch_romp, /* IBM ROMP PC/RT */
677 bfd_arch_alliant, /* Alliant */
678 bfd_arch_convex, /* Convex */
679 bfd_arch_m88k, /* Motorola 88xxx */
680 bfd_arch_pyramid, /* Pyramid Technology */
681 bfd_arch_h8300, /* Hitachi H8/300 */
682 bfd_arch_rs6000, /* IBM RS/6000 */
5e511f6f 683 bfd_arch_hppa, /* HP PA RISC */
3ab9faab
SC
684 bfd_arch_z8k, /* Zilog Z8000 */
685#define bfd_mach_z8001 1
686#define bfd_mach_z8002 2
b39096a4
SC
687 bfd_arch_last
688 };
bded7de2 689
81f8fee9 690typedef struct bfd_arch_info
b39096a4
SC
691{
692 int bits_per_word;
693 int bits_per_address;
694 int bits_per_byte;
695 enum bfd_architecture arch;
696 long mach;
697 char *arch_name;
698 CONST char *printable_name;
9a51287f 699 unsigned int section_align_power;
43857158 700 /* true if this is the default machine for the architecture */
b39096a4 701 boolean the_default;
18fe0e9f
JG
702 CONST struct bfd_arch_info * (*compatible)
703 PARAMS ((CONST struct bfd_arch_info *a,
704 CONST struct bfd_arch_info *b));
b39096a4 705
18fe0e9f 706 boolean (*scan) PARAMS ((CONST struct bfd_arch_info *, CONST char *));
355e5a8e
KR
707 /* How to disassemble an instruction, producing a printable
708 representation on a specified stdio stream. This isn't
709 defined for most processors at present, because of the size
710 of the additional tables it would drag in, and because gdb
711 wants to use a different interface. */
18fe0e9f
JG
712 unsigned int (*disassemble) PARAMS ((bfd_vma addr, CONST char *data,
713 PTR stream));
b39096a4 714
9a51287f 715 struct bfd_arch_info *next;
81f8fee9 716} bfd_arch_info_type;
18fe0e9f
JG
717CONST char *
718bfd_printable_name PARAMS ((bfd *abfd));
719
720bfd_arch_info_type *
721bfd_scan_arch PARAMS ((CONST char *));
722
723CONST bfd_arch_info_type *
724bfd_arch_get_compatible PARAMS ((
332b6327
SC
725 CONST bfd *abfd,
726 CONST bfd *bbfd));
18fe0e9f
JG
727
728void
729bfd_set_arch_info PARAMS ((bfd *, bfd_arch_info_type *));
730
731enum bfd_architecture
732bfd_get_arch PARAMS ((bfd *abfd));
733
734unsigned long
735bfd_get_mach PARAMS ((bfd *abfd));
736
737unsigned int
738bfd_arch_bits_per_byte PARAMS ((bfd *abfd));
739
740unsigned int
741bfd_arch_bits_per_address PARAMS ((bfd *abfd));
742
743bfd_arch_info_type *
744bfd_get_arch_info PARAMS ((bfd *));
745
746bfd_arch_info_type *
747bfd_lookup_arch
748 PARAMS ((enum bfd_architecture
332b6327
SC
749 arch,
750 long machine));
18fe0e9f
JG
751
752CONST char *
753bfd_printable_arch_mach
754 PARAMS ((enum bfd_architecture arch, unsigned long machine));
755
332b6327
SC
756typedef enum bfd_reloc_status
757{
758 /* No errors detected */
b39096a4 759 bfd_reloc_ok,
332b6327
SC
760
761 /* The relocation was performed, but there was an overflow. */
b39096a4 762 bfd_reloc_overflow,
332b6327
SC
763
764 /* The address to relocate was not within the section supplied*/
b39096a4 765 bfd_reloc_outofrange,
332b6327
SC
766
767 /* Used by special functions */
b39096a4 768 bfd_reloc_continue,
332b6327
SC
769
770 /* Unused */
b39096a4 771 bfd_reloc_notsupported,
332b6327
SC
772
773 /* Unsupported relocation size requested. */
b39096a4 774 bfd_reloc_other,
332b6327
SC
775
776 /* The symbol to relocate against was undefined.*/
b39096a4 777 bfd_reloc_undefined,
332b6327
SC
778
779 /* The relocation was performed, but may not be ok - presently
780 generated only when linking i960 coff files with i960 b.out
781 symbols. */
b39096a4 782 bfd_reloc_dangerous
332b6327 783 }
81f8fee9 784 bfd_reloc_status_type;
332b6327
SC
785
786
b39096a4
SC
787typedef struct reloc_cache_entry
788{
332b6327 789 /* A pointer into the canonical table of pointers */
b39096a4 790 struct symbol_cache_entry **sym_ptr_ptr;
332b6327
SC
791
792 /* offset in section */
b39096a4 793 rawdata_offset address;
332b6327
SC
794
795 /* addend for relocation value */
b39096a4 796 bfd_vma addend;
332b6327 797
332b6327 798 /* Pointer to how to perform the required relocation */
b39096a4 799 CONST struct reloc_howto_struct *howto;
332b6327 800
b39096a4 801} arelent;
f48e5efe 802
b39096a4
SC
803typedef CONST struct reloc_howto_struct
804{
332b6327
SC
805 /* The type field has mainly a documetary use - the back end can
806 to what it wants with it, though the normally the back end's
807 external idea of what a reloc number would be would be stored
808 in this field. For example, the a PC relative word relocation
809 in a coff environment would have the type 023 - because that's
810 what the outside world calls a R_PCRWORD reloc. */
b39096a4 811 unsigned int type;
332b6327
SC
812
813 /* The value the final relocation is shifted right by. This drops
814 unwanted data from the relocation. */
b39096a4 815 unsigned int rightshift;
332b6327
SC
816
817 /* The size of the item to be relocated - 0, is one byte, 1 is 2
7917455f
KR
818 bytes, 3 is four bytes. A negative value indicates that the
819 result is to be subtracted from the data. */
2c0e53a4 820 int size;
332b6327 821
7917455f 822 /* Now obsolete? But m68k-coff still uses it... */
b39096a4 823 unsigned int bitsize;
332b6327
SC
824
825 /* Notes that the relocation is relative to the location in the
826 data section of the addend. The relocation function will
827 subtract from the relocation value the address of the location
828 being relocated. */
b39096a4 829 boolean pc_relative;
332b6327 830
b39096a4 831 unsigned int bitpos;
332b6327
SC
832
833 /* Now obsolete */
b39096a4 834 boolean absolute;
332b6327
SC
835
836 /* Causes the relocation routine to return an error if overflow
837 is detected when relocating. */
b39096a4 838 boolean complain_on_overflow;
332b6327
SC
839
840 /* If this field is non null, then the supplied function is
841 called rather than the normal function. This allows really
7917455f 842 strange relocation methods to be accomodated (e.g., i960 callj
332b6327 843 instructions). */
18fe0e9f
JG
844 bfd_reloc_status_type (*special_function)
845 PARAMS ((bfd *abfd,
f48e5efe
JG
846 arelent *reloc_entry,
847 struct symbol_cache_entry *symbol,
848 PTR data,
2d690b0a 849 asection *input_section,
18fe0e9f 850 bfd *output_bfd));
332b6327
SC
851
852 /* The textual name of the relocation type. */
b39096a4 853 char *name;
332b6327
SC
854
855 /* When performing a partial link, some formats must modify the
856 relocations rather than the data - this flag signals this.*/
b39096a4 857 boolean partial_inplace;
332b6327
SC
858
859 /* The src_mask is used to select what parts of the read in data
7917455f 860 are to be used in the relocation sum. E.g., if this was an 8 bit
332b6327
SC
861 bit of data which we read and relocated, this would be
862 0x000000ff. When we have relocs which have an addend, such as
863 sun4 extended relocs, the value in the offset part of a
864 relocating field is garbage so we never use it. In this case
865 the mask would be 0x00000000. */
b39096a4 866 bfd_word src_mask;
332b6327
SC
867
868 /* The dst_mask is what parts of the instruction are replaced
869 into the instruction. In most cases src_mask == dst_mask,
870 except in the above special case, where dst_mask would be
871 0x000000ff, and src_mask would be 0x00000000. */
b39096a4 872 bfd_word dst_mask;
332b6327
SC
873
874 /* When some formats create PC relative instructions, they leave
875 the value of the pc of the place being relocated in the offset
876 slot of the instruction, so that a PC relative relocation can
7917455f 877 be made just by adding in an ordinary offset (e.g., sun3 a.out).
332b6327 878 Some formats leave the displacement part of an instruction
7917455f 879 empty (e.g., m88k bcs), this flag signals the fact.*/
b39096a4 880 boolean pcrel_offset;
332b6327 881
b39096a4 882} reloc_howto_type;
b39096a4
SC
883#define HOWTO(C, R,S,B, P, BI, ABS, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
884 {(unsigned)C,R,S,B, P, BI, ABS,O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
46773090 885#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,false,false,FUNCTION, NAME,false,0,0,IN)
7a276b09 886
332b6327
SC
887#define HOWTO_PREPARE(relocation, symbol) \
888 { \
889 if (symbol != (asymbol *)NULL) { \
9a7c5449 890 if (symbol->section == &bfd_com_section) { \
332b6327
SC
891 relocation = 0; \
892 } \
893 else { \
894 relocation = symbol->value; \
895 } \
896 } \
332b6327 897}
b39096a4 898typedef unsigned char bfd_byte;
bded7de2 899
b39096a4
SC
900typedef struct relent_chain {
901 arelent relent;
902 struct relent_chain *next;
903} arelent_chain;
6d56c69a 904bfd_reloc_status_type
18fe0e9f
JG
905
906bfd_perform_relocation
907 PARAMS ((bfd * abfd,
332b6327
SC
908 arelent *reloc_entry,
909 PTR data,
910 asection *input_section,
911 bfd *output_bfd));
18fe0e9f 912
332b6327 913typedef enum bfd_reloc_code_real
3ab9faab 914
332b6327
SC
915{
916 /* 16 bits wide, simple reloc */
917 BFD_RELOC_16,
918
919 /* 8 bits wide, but used to form an address like 0xffnn */
de7e640d 920 BFD_RELOC_8_FFnn,
332b6327
SC
921
922 /* 8 bits wide, simple */
de7e640d 923 BFD_RELOC_8,
332b6327
SC
924
925 /* 8 bits wide, pc relative */
358c1d4d 926 BFD_RELOC_8_PCREL,
332b6327
SC
927
928 /* The type of reloc used to build a contructor table - at the
929 moment probably a 32 bit wide abs address, but the cpu can
930 choose. */
931
d5ceae78
KR
932 BFD_RELOC_CTOR,
933
934 /* 32 bits wide, simple reloc */
935 BFD_RELOC_32,
936 /* 32 bits, PC-relative */
937 BFD_RELOC_32_PCREL,
938
939 /* High 22 bits of 32-bit value; simple reloc. */
940 BFD_RELOC_HI22,
941 /* Low 10 bits. */
942 BFD_RELOC_LO10,
943
944 /* Reloc types used for i960/b.out. */
945 BFD_RELOC_24_PCREL,
946 BFD_RELOC_I960_CALLJ,
947
948 BFD_RELOC_16_PCREL,
949 /* 32-bit pc-relative, shifted right 2 bits (i.e., 30-bit
950 word displacement, e.g. for SPARC) */
951 BFD_RELOC_32_PCREL_S2,
952
953 /* now for the sparc/elf codes */
954 BFD_RELOC_NONE, /* actually used */
955 BFD_RELOC_SPARC_WDISP22,
956 BFD_RELOC_SPARC22,
957 BFD_RELOC_SPARC13,
958 BFD_RELOC_SPARC_BASE13,
959 BFD_RELOC_SPARC_GOT10,
960 BFD_RELOC_SPARC_GOT13,
961 BFD_RELOC_SPARC_GOT22,
962 BFD_RELOC_SPARC_PC10,
963 BFD_RELOC_SPARC_PC22,
964 BFD_RELOC_SPARC_WPLT30,
965 BFD_RELOC_SPARC_COPY,
966 BFD_RELOC_SPARC_GLOB_DAT,
967 BFD_RELOC_SPARC_JMP_SLOT,
968 BFD_RELOC_SPARC_RELATIVE,
969 BFD_RELOC_SPARC_UA32,
970
971 /* this one is a.out specific? */
972 BFD_RELOC_SPARC_BASE22,
973
974 /* this must be the highest numeric value */
975 BFD_RELOC_UNUSED
81f8fee9 976 } bfd_reloc_code_real_type;
6d56c69a 977CONST struct reloc_howto_struct *
18fe0e9f
JG
978
979bfd_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
980
b39096a4
SC
981typedef struct symbol_cache_entry
982{
332b6327
SC
983 /* A pointer to the BFD which owns the symbol. This information
984 is necessary so that a back end can work out what additional
355e5a8e 985 information (invisible to the application writer) is carried
2f5e51f7 986 with the symbol.
332b6327 987
2f5e51f7
PB
988 This field is *almost* redundant, since you can use section->owner
989 instead, except that some symbols point to the global sections
990 bfd_{abs,com,und}_section. This could be fixed by making
991 these globals be per-bfd (or per-target-flavor). FIXME. */
992
993 struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */
332b6327
SC
994
995 /* The text of the symbol. The name is left alone, and not copied - the
996 application may not alter it. */
997 CONST char *name;
998
999 /* The value of the symbol.*/
1000 symvalue value;
1001
1002 /* Attributes of a symbol: */
1003
b39096a4 1004#define BSF_NO_FLAGS 0x00
332b6327
SC
1005
1006 /* The symbol has local scope; <<static>> in <<C>>. The value
1007 is the offset into the section of the data. */
b39096a4 1008#define BSF_LOCAL 0x01
332b6327
SC
1009
1010 /* The symbol has global scope; initialized data in <<C>>. The
1011 value is the offset into the section of the data. */
b39096a4 1012#define BSF_GLOBAL 0x02
332b6327 1013
355e5a8e 1014 /* Obsolete; should be deleted? */
b39096a4 1015#define BSF_IMPORT 0x04
332b6327
SC
1016
1017 /* The symbol has global scope, and is exported. The value is
1018 the offset into the section of the data. */
b39096a4 1019#define BSF_EXPORT 0x08
332b6327
SC
1020
1021 /* The symbol is undefined. <<extern>> in <<C>>. The value has
355e5a8e 1022 no meaning. Obsolete; should be deleted? */
9a7c5449 1023#define BSF_UNDEFINED_OBS 0x10
332b6327
SC
1024
1025 /* The symbol is common, initialized to zero; default in
1026 <<C>>. The value is the size of the object in bytes. */
9a7c5449 1027#define BSF_FORT_COMM_OBS 0x20
332b6327
SC
1028
1029 /* A normal C symbol would be one of:
1030 <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
1031 <<BSF_EXPORT|BSD_GLOBAL>> */
1032
1033 /* The symbol is a debugging record. The value has an arbitary
1034 meaning. */
b39096a4 1035#define BSF_DEBUGGING 0x40
332b6327 1036
2f5e51f7 1037 /* Used by the linker. */
b39096a4
SC
1038#define BSF_KEEP 0x10000
1039#define BSF_KEEP_G 0x80000
332b6327 1040
355e5a8e 1041 /* Unused; should be deleted? */
b39096a4
SC
1042#define BSF_WEAK 0x100000
1043#define BSF_CTOR 0x200000
9a7c5449 1044
bc718e87
JG
1045 /* This symbol was created to point to a section, e.g. ELF's
1046 STT_SECTION symbols. */
9a7c5449 1047#define BSF_SECTION_SYM 0x400000
332b6327
SC
1048
1049 /* The symbol used to be a common symbol, but now it is
1050 allocated. */
b39096a4 1051#define BSF_OLD_COMMON 0x800000
332b6327
SC
1052
1053 /* The default value for common data. */
b39096a4 1054#define BFD_FORT_COMM_DEFAULT_VALUE 0
332b6327
SC
1055
1056 /* In some files the type of a symbol sometimes alters its
1057 location in an output file - ie in coff a <<ISFCN>> symbol
1058 which is also <<C_EXT>> symbol appears where it was
1059 declared and not at the end of a section. This bit is set
1060 by the target BFD part to convey this information. */
1061
b39096a4 1062#define BSF_NOT_AT_END 0x40000
332b6327
SC
1063
1064 /* Signal that the symbol is the label of constructor section. */
b39096a4 1065#define BSF_CONSTRUCTOR 0x1000000
332b6327
SC
1066
1067 /* Signal that the symbol is a warning symbol. If the symbol
1068 is a warning symbol, then the value field (I know this is
1069 tacky) will point to the asymbol which when referenced will
1070 cause the warning. */
b39096a4 1071#define BSF_WARNING 0x2000000
332b6327
SC
1072
1073 /* Signal that the symbol is indirect. The value of the symbol
1074 is a pointer to an undefined asymbol which contains the
1075 name to use instead. */
bc718e87
JG
1076#define BSF_INDIRECT 0x4000000
1077
1078 /* BSF_FILE marks symbols that contain a file name. This is used
1079 for ELF STT_FILE symbols. */
1080#define BSF_FILE 0x08000000
332b6327 1081
b39096a4 1082 flagword flags;
332b6327 1083
9a7c5449
SC
1084 /* A pointer to the section to which this symbol is
1085 relative. This will always be non NULL, there are special
1086 sections for undefined and absolute symbols */
b39096a4 1087 struct sec *section;
332b6327
SC
1088
1089 /* Back end special data. This is being phased out in favour
1090 of making this a union. */
355e5a8e
KR
1091 PTR udata;
1092
b39096a4 1093} asymbol;
b39096a4
SC
1094#define get_symtab_upper_bound(abfd) \
1095 BFD_SEND (abfd, _get_symtab_upper_bound, (abfd))
b39096a4
SC
1096#define bfd_canonicalize_symtab(abfd, location) \
1097 BFD_SEND (abfd, _bfd_canonicalize_symtab,\
1098 (abfd, location))
18fe0e9f
JG
1099boolean
1100bfd_set_symtab PARAMS ((bfd *, asymbol **, unsigned int ));
1101
1102void
1103bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol));
1104
b39096a4
SC
1105#define bfd_make_empty_symbol(abfd) \
1106 BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
d5ceae78
KR
1107#define bfd_make_debug_symbol(abfd,ptr,size) \
1108 BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
18fe0e9f
JG
1109int
1110bfd_decode_symclass PARAMS ((asymbol *symbol));
1111
b39096a4
SC
1112struct _bfd
1113{
332b6327
SC
1114 /* The filename the application opened the BFD with. */
1115 CONST char *filename;
1116
1117 /* A pointer to the target jump table. */
1118 struct bfd_target *xvec;
1119
1120 /* To avoid dragging too many header files into every file that
0aa70210 1121 includes `<<bfd.h>>', IOSTREAM has been declared as a "char
332b6327
SC
1122 *", and MTIME as a "long". Their correct types, to which they
1123 are cast when used, are "FILE *" and "time_t". The iostream
1124 is the result of an fopen on the filename. */
1125 char *iostream;
1126
1127 /* Is the file being cached */
1128
1129 boolean cacheable;
1130
1131 /* Marks whether there was a default target specified when the
1132 BFD was opened. This is used to select what matching algorithm
1133 to use to chose the back end. */
1134
1135 boolean target_defaulted;
1136
1137 /* The caching routines use these to maintain a
1138 least-recently-used list of BFDs */
1139
1140 struct _bfd *lru_prev, *lru_next;
1141
1142 /* When a file is closed by the caching routines, BFD retains
1143 state information on the file here:
1144 */
1145
1146 file_ptr where;
1147
1148 /* and here:*/
1149
1150 boolean opened_once;
1151
1152 /* Set if we have a locally maintained mtime value, rather than
1153 getting it from the file each time: */
1154
1155 boolean mtime_set;
1156
1157 /* File modified time, if mtime_set is true: */
1158
1159 long mtime;
1160
1161 /* Reserved for an unimplemented file locking extension.*/
1162
1163 int ifd;
1164
1165 /* The format which belongs to the BFD.*/
1166
1167 bfd_format format;
1168
1169 /* The direction the BFD was opened with*/
1170
1171 enum bfd_direction {no_direction = 0,
1172 read_direction = 1,
1173 write_direction = 2,
1174 both_direction = 3} direction;
1175
1176 /* Format_specific flags*/
1177
1178 flagword flags;
1179
1180 /* Currently my_archive is tested before adding origin to
1181 anything. I believe that this can become always an add of
1182 origin, with origin set to 0 for non archive files. */
1183
1184 file_ptr origin;
1185
1186 /* Remember when output has begun, to stop strange things
1187 happening. */
1188 boolean output_has_begun;
1189
1190 /* Pointer to linked list of sections*/
1191 struct sec *sections;
1192
1193 /* The number of sections */
1194 unsigned int section_count;
1195
1196 /* Stuff only useful for object files:
1197 The start address. */
1198 bfd_vma start_address;
1199
1200 /* Used for input and output*/
1201 unsigned int symcount;
1202
1203 /* Symbol table for output BFD*/
1204 struct symbol_cache_entry **outsymbols;
1205
1206 /* Pointer to structure which contains architecture information*/
1207 struct bfd_arch_info *arch_info;
1208
1209 /* Stuff only useful for archives:*/
1210 PTR arelt_data;
1211 struct _bfd *my_archive;
1212 struct _bfd *next;
1213 struct _bfd *archive_head;
1214 boolean has_armap;
1215
1216 /* Used by the back end to hold private data. */
332b6327 1217
9a7c5449
SC
1218 union
1219 {
1220 struct aout_data_struct *aout_data;
1221 struct artdata *aout_ar_data;
1222 struct _oasys_data *oasys_obj_data;
1223 struct _oasys_ar_data *oasys_ar_data;
1224 struct coff_tdata *coff_obj_data;
06c3865a 1225 struct ecoff_tdata *ecoff_obj_data;
9a7c5449
SC
1226 struct ieee_data_struct *ieee_data;
1227 struct ieee_ar_data_struct *ieee_ar_data;
1228 struct srec_data_struct *srec_data;
8cedecca 1229 struct tekhex_data_struct *tekhex_data;
3ce7a824 1230 struct elf_obj_tdata *elf_obj_data;
9a7c5449
SC
1231 struct bout_data_struct *bout_data;
1232 struct sun_core_struct *sun_core_data;
2b74083c 1233 struct trad_core_struct *trad_core_data;
d63a3da9 1234 struct hppa_data_struct *hppa_data;
808566e8 1235 struct hppa_core_struct *hppa_core_data;
9a7c5449
SC
1236 PTR any;
1237 } tdata;
1238
332b6327
SC
1239 /* Used by the application to hold private data*/
1240 PTR usrdata;
1241
1242 /* Where all the allocated stuff under this BFD goes */
1243 struct obstack memory;
9a7c5449 1244
d5ceae78 1245 /* Is this really needed in addition to usrdata? */
9a7c5449 1246 asymbol **ld_symbols;
b39096a4 1247};
332b6327 1248
18fe0e9f
JG
1249unsigned int
1250bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
1251
1252unsigned int
1253bfd_canonicalize_reloc
1254 PARAMS ((bfd *abfd,
332b6327
SC
1255 asection *sec,
1256 arelent **loc,
1257 asymbol **syms));
18fe0e9f
JG
1258
1259boolean
1260bfd_set_file_flags PARAMS ((bfd *abfd, flagword flags));
1261
1262void
1263bfd_set_reloc
1264 PARAMS ((bfd *abfd, asection *sec, arelent **rel, unsigned int count)
332b6327
SC
1265
1266 );
18fe0e9f
JG
1267
1268boolean
1269bfd_set_start_address PARAMS ((bfd *, bfd_vma));
1270
1271long
1272bfd_get_mtime PARAMS ((bfd *));
1273
7917455f 1274long
fa754be2
FF
1275bfd_get_size PARAMS ((bfd *));
1276
b39096a4
SC
1277#define bfd_sizeof_headers(abfd, reloc) \
1278 BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
1279
332b6327
SC
1280#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
1281 BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
b39096a4 1282
d5ceae78 1283 /* Do these three do anything useful at all, for any back end? */
b39096a4
SC
1284#define bfd_debug_info_start(abfd) \
1285 BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
1286
1287#define bfd_debug_info_end(abfd) \
1288 BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
1289
1290#define bfd_debug_info_accumulate(abfd, section) \
1291 BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
1292
d5ceae78 1293
b39096a4
SC
1294#define bfd_stat_arch_elt(abfd, stat) \
1295 BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
1296
b39096a4
SC
1297#define bfd_set_arch_mach(abfd, arch, mach)\
1298 BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
7f3d9f46 1299
2d690b0a
SC
1300#define bfd_get_relocated_section_contents(abfd, seclet, data) \
1301 BFD_SEND (abfd, _bfd_get_relocated_section_contents, (abfd, seclet, data))
1302
daa91756
SC
1303#define bfd_relax_section(abfd, section, symbols) \
1304 BFD_SEND (abfd, _bfd_relax_section, (abfd, section, symbols))
18fe0e9f
JG
1305symindex
1306bfd_get_next_mapent PARAMS ((bfd *, symindex previous, carsym ** sym));
1307
1308boolean
1309bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head));
1310
1311bfd *
1312bfd_get_elt_at_index PARAMS ((bfd * archive, int index));
1313
1314bfd*
1315bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous));
1316
1317CONST char *
1318bfd_core_file_failing_command PARAMS ((bfd *));
1319
1320int
1321bfd_core_file_failing_signal PARAMS ((bfd *));
1322
1323boolean
1324core_file_matches_executable_p
1325 PARAMS ((bfd *core_bfd, bfd *exec_bfd));
1326
7a276b09
SC
1327#define BFD_SEND(bfd, message, arglist) \
1328 ((*((bfd)->xvec->message)) arglist)
7a276b09
SC
1329#define BFD_SEND_FMT(bfd, message, arglist) \
1330 (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
7a276b09
SC
1331typedef struct bfd_target
1332{
7a276b09 1333 char *name;
81f8fee9
JG
1334 enum target_flavour {
1335 bfd_target_unknown_flavour,
1336 bfd_target_aout_flavour,
1337 bfd_target_coff_flavour,
06c3865a 1338 bfd_target_ecoff_flavour,
81f8fee9
JG
1339 bfd_target_elf_flavour,
1340 bfd_target_ieee_flavour,
1341 bfd_target_oasys_flavour,
c3089ec9 1342 bfd_target_tekhex_flavour,
5e511f6f
SG
1343 bfd_target_srec_flavour,
1344 bfd_target_hppa_flavour} flavour;
7a276b09 1345 boolean byteorder_big_p;
7a276b09 1346 boolean header_byteorder_big_p;
7a276b09 1347 flagword object_flags;
7a276b09 1348 flagword section_flags;
ab414d87 1349 char symbol_leading_char;
7a276b09 1350 char ar_pad_char;
a4c22791 1351 unsigned short ar_max_namelen;
7a276b09 1352 unsigned int align_power_min;
a4c22791
JG
1353 bfd_vma (*bfd_getx64) PARAMS ((bfd_byte *));
1354 void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
1355 bfd_vma (*bfd_getx32) PARAMS ((bfd_byte *));
1356 void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
1357 bfd_vma (*bfd_getx16) PARAMS ((bfd_byte *));
1358 void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
1359 bfd_vma (*bfd_h_getx64) PARAMS ((bfd_byte *));
1360 void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
1361 bfd_vma (*bfd_h_getx32) PARAMS ((bfd_byte *));
1362 void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
1363 bfd_vma (*bfd_h_getx16) PARAMS ((bfd_byte *));
1364 void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
1365 struct bfd_target * (*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
1366 boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
1367 boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
1368 char * (*_core_file_failing_command) PARAMS ((bfd *));
1369 int (*_core_file_failing_signal) PARAMS ((bfd *));
1370 boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
1371 boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
1372 boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
1373 void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
1374 boolean (*write_armap) PARAMS ((bfd *arch,
7a276b09
SC
1375 unsigned int elength,
1376 struct orl *map,
a0788ae3 1377 unsigned int orl_count,
7a276b09 1378 int stridx));
a4c22791
JG
1379 boolean (*_close_and_cleanup) PARAMS ((bfd *));
1380 boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
7a276b09 1381 file_ptr, bfd_size_type));
a4c22791 1382 boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
7a276b09 1383 file_ptr, bfd_size_type));
a4c22791
JG
1384 boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
1385 unsigned int (*_get_symtab_upper_bound) PARAMS ((bfd *));
1386 unsigned int (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
1387 struct symbol_cache_entry **));
1388 unsigned int (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
1389 unsigned int (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
1390 struct symbol_cache_entry **));
1391 struct symbol_cache_entry *
1392 (*_bfd_make_empty_symbol) PARAMS ((bfd *));
1393 void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
1394 struct symbol_cache_entry *,
81f8fee9 1395 bfd_print_symbol_type));
7a276b09 1396#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
a4c22791
JG
1397 alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
1398
1399 boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
1400 unsigned long));
1401
1402 bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
1403
1404 boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
1405 struct sec *section, struct symbol_cache_entry **symbols,
1406 bfd_vma offset, CONST char **file, CONST char **func,
1407 unsigned int *line));
1408
1409 int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
1410
1411 int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
1412
1413 void (*_bfd_debug_info_start) PARAMS ((bfd *));
1414 void (*_bfd_debug_info_end) PARAMS ((bfd *));
1415 void (*_bfd_debug_info_accumulate) PARAMS ((bfd *, struct sec *));
1416
1417 bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
1418 struct bfd_seclet *, bfd_byte *data));
1419
1420 boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
1421 struct symbol_cache_entry **));
d5ceae78 1422 /* See documentation on reloc types. */
a4c22791
JG
1423 CONST struct reloc_howto_struct *
1424 (*reloc_type_lookup) PARAMS ((bfd *abfd,
1425 bfd_reloc_code_real_type code));
d5ceae78 1426
a4c22791
JG
1427 /* Back-door to allow format-aware applications to create debug symbols
1428 while using BFD for everything else. Currently used by the assembler
d5ceae78 1429 when creating COFF files. */
a4c22791 1430 asymbol * (*_bfd_make_debug_symbol) PARAMS ((
d5ceae78
KR
1431 bfd *abfd,
1432 void *ptr,
1433 unsigned long size));
9a51287f 1434 PTR backend_data;
7a276b09 1435} bfd_target;
18fe0e9f
JG
1436bfd_target *
1437bfd_find_target PARAMS ((CONST char *, bfd *));
1438
1439CONST char **
1440bfd_target_list PARAMS ((void));
1441
1442boolean
1443bfd_check_format PARAMS ((bfd *abfd, bfd_format format));
1444
1445boolean
1446bfd_set_format PARAMS ((bfd *, bfd_format));
1447
1448CONST char *
1449bfd_format_string PARAMS ((bfd_format));
1450
1484208f 1451#endif
This page took 0.136075 seconds and 4 git commands to generate.