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