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