1 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
3 This file is part of BFD, the Binary File Diddler.
5 BFD is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 1, or (at your option)
10 BFD is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with BFD; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /*** libbfd.h -- Declarations used by bfd library implementation.
22 This include file is not for users of the library */
28 /* If you want to read and write large blocks, you might want to do it
29 in quanta of this amount */
30 #define DEFAULT_BUFFERSIZE 8192
32 /* tdata for an archive. For an input archive cache
33 needs to be free()'d. For an output archive, symdefs do.
37 file_ptr first_file_filepos
;
38 /* Speed up searching the armap */
39 struct ar_cache
*cache
;
40 bfd
*archive_head
; /* Only interesting in output routines */
41 carsym
*symdefs
; /* the symdef entries */
42 symindex symdef_count
; /* how many there are */
43 char *extended_names
; /* clever intel extension */
46 #define bfd_ardata(bfd) ((struct artdata *) ((bfd)->tdata))
47 #define bfd_set_ardata(bfd, v) ((bfd)->tdata = (void *) (v))
49 /* Goes in bfd's arelt_data slot */
51 char * arch_header
; /* it's actually a string */
52 unsigned int parsed_size
; /* octets of filesize not including ar_hdr */
53 char *filename
; /* null-terminated */
56 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
58 /* FIXME -- a lot of my code allocates a large block and subdivides it.
59 This can't always work, because of alignment restrictions. We should change
60 it before it becomes a problem -- Gumby */
62 PROTO (char *, zalloc
, (size_t size
));
63 PROTO (char *, realloc
, (char * ptr
, size_t size
));
64 PROTO (bfd_target
*, bfd_find_target
, (char *target_name
));
65 PROTO (size_t, bfd_read
, (void *ptr
, size_t size
, size_t nitems
, bfd
*abfd
));
66 PROTO (size_t, bfd_write
, (void *ptr
, size_t size
, size_t nitems
, bfd
*abfd
));
70 PROTO (FILE *, bfd_cache_lookup
, (bfd
*));
71 PROTO (void, bfd_cache_close
, (bfd
*));
72 PROTO (int, bfd_seek
,(bfd
*, file_ptr
, int direction
));
73 PROTO (long, bfd_tell
, (bfd
*abfd
));
74 PROTO (bfd
*, _bfd_create_empty_archive_element_shell
, (bfd
*obfd
));
75 PROTO (bfd
*, look_for_bfd_in_cache
, (bfd
*arch_bfd
, file_ptr index
));
76 PROTO (boolean
, _bfd_generic_mkarchive
, (bfd
*abfd
));
77 PROTO (struct areltdata
*, snarf_ar_hdr
, (bfd
*abfd
));
78 PROTO (bfd_target
*, bfd_generic_archive_p
, (bfd
*abfd
));
79 PROTO (boolean
, bfd_slurp_bsd_armap
, (bfd
*abfd
));
80 PROTO (boolean
, bfd_slurp_coff_armap
, (bfd
*abfd
));
81 PROTO (boolean
, _bfd_slurp_extended_name_table
, (bfd
*abfd
));
82 PROTO (boolean
, _bfd_write_archive_contents
, (bfd
*abfd
));
83 PROTO (bfd
*, new_bfd
, ());
85 #define DEFAULT_STRING_SPACE_SIZE 0x2000
86 PROTO (boolean
, bfd_add_to_string_table
, (char **table
, char *new_string
,
87 unsigned int *table_length
,
90 PROTO (long, _do_getblong
, (unsigned char *addr
));
91 PROTO (long, _do_getllong
, (unsigned char *addr
));
92 PROTO (short, _do_getbshort
, (unsigned char *addr
));
93 PROTO (short, _do_getlshort
, (unsigned char *addr
));
94 PROTO (void, _do_putblong
, (unsigned long data
, unsigned char *addr
));
95 PROTO (void, _do_putllong
, (unsigned long data
, unsigned char *addr
));
96 PROTO (void, _do_putbshort
, (int data
, unsigned char *addr
));
97 PROTO (void, _do_putlshort
, (int data
, unsigned char *addr
));
99 PROTO (boolean
, bfd_false
, (bfd
*ignore
));
100 PROTO (boolean
, bfd_true
, (bfd
*ignore
));
101 PROTO (void *, bfd_nullvoidptr
, (bfd
*ignore
));
102 PROTO (int, bfd_0
, (bfd
*ignore
));
103 PROTO (unsigned int, bfd_0u
, (bfd
*ignore
));
104 PROTO (void, bfd_void
, (bfd
*ignore
));
107 PROTO (bfd
*,new_bfd_contained_in
,(bfd
*));
108 PROTO (boolean
, _bfd_dummy_new_section_hook
, (bfd
*ignore
, asection
*newsect
));
109 PROTO (char *, _bfd_dummy_core_file_failing_command
, (bfd
*abfd
));
110 PROTO (int, _bfd_dummy_core_file_failing_signal
, (bfd
*abfd
));
111 PROTO (boolean
, _bfd_dummy_core_file_matches_executable_p
, (bfd
*core_bfd
,
113 PROTO (bfd_target
*, _bfd_dummy_target
, (bfd
*abfd
));
115 PROTO (void, bfd_dont_truncate_arname
, (bfd
*abfd
, char *filename
, char *hdr
));
116 PROTO (void, bfd_bsd_truncate_arname
, (bfd
*abfd
, char *filename
, char *hdr
));
117 PROTO (void, bfd_gnu_truncate_arname
, (bfd
*abfd
, char *filename
, char *hdr
));
119 PROTO (boolean
, bsd_write_armap
, (bfd
*arch
, unsigned int elength
,
120 struct orl
*map
, int orl_count
, int stridx
));
122 PROTO (boolean
, coff_write_armap
, (bfd
*arch
, unsigned int elength
,
123 struct orl
*map
, int orl_count
, int stridx
));
125 PROTO ( bfd
*,bfd_generic_openr_next_archived_file
, (bfd
*archive
, bfd
*last_file
));
127 PROTO(int, bfd_generic_stat_arch_elt
, (bfd
*, struct stat
*));
128 /* Macros to tell if bfds are read or write enabled.
130 Note that bfds open for read may be scribbled into if the fd passed
131 to bfd_fdopenr is actually open both for read and write
132 simultaneously. However an output bfd will never be open for
133 read. Therefore sometimes you want to check bfd_read_p or
134 !bfd_read_p, and only sometimes bfd_write_p.
137 #define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
138 #define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
140 PROTO (void, bfd_assert
,(char*,int));
141 #define BFD_ASSERT(x) \
142 { if (!(x)) bfd_assert(__FILE__,__LINE__); }
145 { bfd_assert(__FILE__,__LINE__); }
147 PROTO (FILE *, bfd_cache_lookup_worker
, (bfd
*));
149 extern bfd
*bfd_last_cache
;
150 #define bfd_cache_lookup(x) \
151 (x==bfd_last_cache?(FILE*)(bfd_last_cache->iostream):bfd_cache_lookup_worker(x))
153 /* Now Steve, what's the story here? */
158 #define itos(x) ((char*)(x))
159 #define stoi(x) ((int)(x))