Personal checkpoint.
[deliverable/binutils-gdb.git] / bfd / libbfd.h
CommitLineData
4a81b561
DHW
1/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
2
3This file is part of BFD, the Binary File Diddler.
4
5BFD is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation; either version 1, or (at your option)
8any later version.
9
10BFD is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BFD; see the file COPYING. If not, write to
17the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
18
19/* $Id$ */
20
21/*** libbfd.h -- Declarations used by bfd library implementation.
22 This include file is not for users of the library */
23
24
25
26
27
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
31
32/* tdata for an archive. For an input archive cache
33 needs to be free()'d. For an output archive, symdefs do.
34*/
35
36struct artdata {
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 */
44};
45
46#define bfd_ardata(bfd) ((struct artdata *) ((bfd)->tdata))
47#define bfd_set_ardata(bfd, v) ((bfd)->tdata = (void *) (v))
48
49/* Goes in bfd's arelt_data slot */
50struct areltdata {
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 */
54};
55
56#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
57
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 */
61
62PROTO (char *, zalloc, (size_t size));
63PROTO (char *, realloc, (char * ptr, size_t size));
64PROTO (bfd_target *, bfd_find_target, (char *target_name));
65PROTO (size_t, bfd_read, (void *ptr, size_t size, size_t nitems, bfd *abfd));
66PROTO (size_t, bfd_write, (void *ptr, size_t size, size_t nitems, bfd *abfd));
67
68
69
70PROTO (FILE *, bfd_cache_lookup, (bfd *));
71PROTO (void, bfd_cache_close, (bfd *));
72PROTO (int, bfd_seek,(bfd*, file_ptr, int direction));
73PROTO (long, bfd_tell, (bfd *abfd));
74PROTO (bfd *, _bfd_create_empty_archive_element_shell, (bfd *obfd));
75PROTO (bfd *, look_for_bfd_in_cache, (bfd *arch_bfd, file_ptr index));
76PROTO (boolean, _bfd_generic_mkarchive, (bfd *abfd));
77PROTO (struct areltdata *, snarf_ar_hdr, (bfd *abfd));
78PROTO (bfd_target *, bfd_generic_archive_p, (bfd *abfd));
79PROTO (boolean, bfd_slurp_bsd_armap, (bfd *abfd));
80PROTO (boolean, bfd_slurp_coff_armap, (bfd *abfd));
81PROTO (boolean, _bfd_slurp_extended_name_table, (bfd *abfd));
82PROTO (boolean, _bfd_write_archive_contents, (bfd *abfd));
83PROTO (bfd *, new_bfd, ());
84
85#define DEFAULT_STRING_SPACE_SIZE 0x2000
86PROTO (boolean, bfd_add_to_string_table, (char **table, char *new_string,
87 unsigned int *table_length,
88 char **free_ptr));
89
90PROTO (long, _do_getblong, (unsigned char *addr));
91PROTO (long, _do_getllong, (unsigned char *addr));
92PROTO (short, _do_getbshort, (unsigned char *addr));
93PROTO (short, _do_getlshort, (unsigned char *addr));
94PROTO (void, _do_putblong, (unsigned long data, unsigned char *addr));
95PROTO (void, _do_putllong, (unsigned long data, unsigned char *addr));
96PROTO (void, _do_putbshort, (int data, unsigned char *addr));
97PROTO (void, _do_putlshort, (int data, unsigned char *addr));
98
99PROTO (boolean, bfd_false, (bfd *ignore));
100PROTO (boolean, bfd_true, (bfd *ignore));
101PROTO (void *, bfd_nullvoidptr, (bfd *ignore));
102PROTO (int, bfd_0, (bfd *ignore));
103PROTO (unsigned int, bfd_0u, (bfd *ignore));
104PROTO (void, bfd_void, (bfd *ignore));
105
106
107PROTO (bfd *,new_bfd_contained_in,(bfd *));
108PROTO (boolean, _bfd_dummy_new_section_hook, (bfd *ignore, asection *newsect));
109PROTO (char *, _bfd_dummy_core_file_failing_command, (bfd *abfd));
110PROTO (int, _bfd_dummy_core_file_failing_signal, (bfd *abfd));
111PROTO (boolean, _bfd_dummy_core_file_matches_executable_p, (bfd *core_bfd,
112 bfd *exec_bfd));
113PROTO (bfd_target *, _bfd_dummy_target, (bfd *abfd));
114
115PROTO (void, bfd_dont_truncate_arname, (bfd *abfd, char *filename, char *hdr));
116PROTO (void, bfd_bsd_truncate_arname, (bfd *abfd, char *filename, char *hdr));
117PROTO (void, bfd_gnu_truncate_arname, (bfd *abfd, char *filename, char *hdr));
118
119PROTO (boolean, bsd_write_armap, (bfd *arch, unsigned int elength,
120 struct orl *map, int orl_count, int stridx));
121
122PROTO (boolean, coff_write_armap, (bfd *arch, unsigned int elength,
123 struct orl *map, int orl_count, int stridx));
124
125PROTO ( bfd *,bfd_generic_openr_next_archived_file, (bfd *archive, bfd *last_file));
126
127PROTO(int, bfd_generic_stat_arch_elt, (bfd *, struct stat *));
128/* Macros to tell if bfds are read or write enabled.
129
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.
135*/
136
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)
139
140PROTO (void, bfd_assert,(char*,int));
141#define BFD_ASSERT(x) \
142{ if (!(x)) bfd_assert(__FILE__,__LINE__); }
143
144#define BFD_FAIL() \
145{ bfd_assert(__FILE__,__LINE__); }
146
147PROTO (FILE *, bfd_cache_lookup_worker, (bfd *));
148
149extern 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))
152
153/* Now Steve, what's the story here? */
154#ifdef lint
155#define itos(x) "l"
156#define stoi(x) 1
157#else
158#define itos(x) ((char*)(x))
159#define stoi(x) ((int)(x))
160#endif
This page took 0.027678 seconds and 4 git commands to generate.