1 |
38 |
julius |
@section @code{typedef bfd}
|
2 |
|
|
A BFD has type @code{bfd}; objects of this type are the
|
3 |
|
|
cornerstone of any application using BFD. Using BFD
|
4 |
|
|
consists of making references though the BFD and to data in the BFD.
|
5 |
|
|
|
6 |
|
|
Here is the structure that defines the type @code{bfd}. It
|
7 |
|
|
contains the major data about the file and pointers
|
8 |
|
|
to the rest of the data.
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
@example
|
12 |
|
|
|
13 |
|
|
struct bfd
|
14 |
|
|
@{
|
15 |
|
|
/* A unique identifier of the BFD */
|
16 |
|
|
unsigned int id;
|
17 |
|
|
|
18 |
|
|
/* The filename the application opened the BFD with. */
|
19 |
|
|
const char *filename;
|
20 |
|
|
|
21 |
|
|
/* A pointer to the target jump table. */
|
22 |
|
|
const struct bfd_target *xvec;
|
23 |
|
|
|
24 |
|
|
/* The IOSTREAM, and corresponding IO vector that provide access
|
25 |
|
|
to the file backing the BFD. */
|
26 |
|
|
void *iostream;
|
27 |
|
|
const struct bfd_iovec *iovec;
|
28 |
|
|
|
29 |
|
|
/* The caching routines use these to maintain a
|
30 |
|
|
least-recently-used list of BFDs. */
|
31 |
|
|
struct bfd *lru_prev, *lru_next;
|
32 |
|
|
|
33 |
|
|
/* When a file is closed by the caching routines, BFD retains
|
34 |
|
|
state information on the file here... */
|
35 |
|
|
ufile_ptr where;
|
36 |
|
|
|
37 |
|
|
/* File modified time, if mtime_set is TRUE. */
|
38 |
|
|
long mtime;
|
39 |
|
|
|
40 |
|
|
/* Reserved for an unimplemented file locking extension. */
|
41 |
|
|
int ifd;
|
42 |
|
|
|
43 |
|
|
/* The format which belongs to the BFD. (object, core, etc.) */
|
44 |
|
|
bfd_format format;
|
45 |
|
|
|
46 |
|
|
/* The direction with which the BFD was opened. */
|
47 |
|
|
enum bfd_direction
|
48 |
|
|
@{
|
49 |
|
|
no_direction = 0,
|
50 |
|
|
read_direction = 1,
|
51 |
|
|
write_direction = 2,
|
52 |
|
|
both_direction = 3
|
53 |
|
|
@}
|
54 |
|
|
direction;
|
55 |
|
|
|
56 |
|
|
/* Format_specific flags. */
|
57 |
|
|
flagword flags;
|
58 |
|
|
|
59 |
|
|
/* Values that may appear in the flags field of a BFD. These also
|
60 |
|
|
appear in the object_flags field of the bfd_target structure, where
|
61 |
|
|
they indicate the set of flags used by that backend (not all flags
|
62 |
|
|
are meaningful for all object file formats) (FIXME: at the moment,
|
63 |
|
|
the object_flags values have mostly just been copied from backend
|
64 |
|
|
to another, and are not necessarily correct). */
|
65 |
|
|
|
66 |
|
|
#define BFD_NO_FLAGS 0x00
|
67 |
|
|
|
68 |
|
|
/* BFD contains relocation entries. */
|
69 |
|
|
#define HAS_RELOC 0x01
|
70 |
|
|
|
71 |
|
|
/* BFD is directly executable. */
|
72 |
|
|
#define EXEC_P 0x02
|
73 |
|
|
|
74 |
|
|
/* BFD has line number information (basically used for F_LNNO in a
|
75 |
|
|
COFF header). */
|
76 |
|
|
#define HAS_LINENO 0x04
|
77 |
|
|
|
78 |
|
|
/* BFD has debugging information. */
|
79 |
|
|
#define HAS_DEBUG 0x08
|
80 |
|
|
|
81 |
|
|
/* BFD has symbols. */
|
82 |
|
|
#define HAS_SYMS 0x10
|
83 |
|
|
|
84 |
|
|
/* BFD has local symbols (basically used for F_LSYMS in a COFF
|
85 |
|
|
header). */
|
86 |
|
|
#define HAS_LOCALS 0x20
|
87 |
|
|
|
88 |
|
|
/* BFD is a dynamic object. */
|
89 |
|
|
#define DYNAMIC 0x40
|
90 |
|
|
|
91 |
|
|
/* Text section is write protected (if D_PAGED is not set, this is
|
92 |
|
|
like an a.out NMAGIC file) (the linker sets this by default, but
|
93 |
|
|
clears it for -r or -N). */
|
94 |
|
|
#define WP_TEXT 0x80
|
95 |
|
|
|
96 |
|
|
/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
|
97 |
|
|
linker sets this by default, but clears it for -r or -n or -N). */
|
98 |
|
|
#define D_PAGED 0x100
|
99 |
|
|
|
100 |
|
|
/* BFD is relaxable (this means that bfd_relax_section may be able to
|
101 |
|
|
do something) (sometimes bfd_relax_section can do something even if
|
102 |
|
|
this is not set). */
|
103 |
|
|
#define BFD_IS_RELAXABLE 0x200
|
104 |
|
|
|
105 |
|
|
/* This may be set before writing out a BFD to request using a
|
106 |
|
|
traditional format. For example, this is used to request that when
|
107 |
|
|
writing out an a.out object the symbols not be hashed to eliminate
|
108 |
|
|
duplicates. */
|
109 |
|
|
#define BFD_TRADITIONAL_FORMAT 0x400
|
110 |
|
|
|
111 |
|
|
/* This flag indicates that the BFD contents are actually cached
|
112 |
|
|
in memory. If this is set, iostream points to a bfd_in_memory
|
113 |
|
|
struct. */
|
114 |
|
|
#define BFD_IN_MEMORY 0x800
|
115 |
|
|
|
116 |
|
|
/* The sections in this BFD specify a memory page. */
|
117 |
|
|
#define HAS_LOAD_PAGE 0x1000
|
118 |
|
|
|
119 |
|
|
/* This BFD has been created by the linker and doesn't correspond
|
120 |
|
|
to any input file. */
|
121 |
|
|
#define BFD_LINKER_CREATED 0x2000
|
122 |
|
|
|
123 |
|
|
/* Currently my_archive is tested before adding origin to
|
124 |
|
|
anything. I believe that this can become always an add of
|
125 |
|
|
origin, with origin set to 0 for non archive files. */
|
126 |
|
|
ufile_ptr origin;
|
127 |
|
|
|
128 |
|
|
/* The origin in the archive of the proxy entry. This will
|
129 |
|
|
normally be the same as origin, except for thin archives,
|
130 |
|
|
when it will contain the current offset of the proxy in the
|
131 |
|
|
thin archive rather than the offset of the bfd in its actual
|
132 |
|
|
container. */
|
133 |
|
|
ufile_ptr proxy_origin;
|
134 |
|
|
|
135 |
|
|
/* A hash table for section names. */
|
136 |
|
|
struct bfd_hash_table section_htab;
|
137 |
|
|
|
138 |
|
|
/* Pointer to linked list of sections. */
|
139 |
|
|
struct bfd_section *sections;
|
140 |
|
|
|
141 |
|
|
/* The last section on the section list. */
|
142 |
|
|
struct bfd_section *section_last;
|
143 |
|
|
|
144 |
|
|
/* The number of sections. */
|
145 |
|
|
unsigned int section_count;
|
146 |
|
|
|
147 |
|
|
/* Stuff only useful for object files:
|
148 |
|
|
The start address. */
|
149 |
|
|
bfd_vma start_address;
|
150 |
|
|
|
151 |
|
|
/* Used for input and output. */
|
152 |
|
|
unsigned int symcount;
|
153 |
|
|
|
154 |
|
|
/* Symbol table for output BFD (with symcount entries). */
|
155 |
|
|
struct bfd_symbol **outsymbols;
|
156 |
|
|
|
157 |
|
|
/* Used for slurped dynamic symbol tables. */
|
158 |
|
|
unsigned int dynsymcount;
|
159 |
|
|
|
160 |
|
|
/* Pointer to structure which contains architecture information. */
|
161 |
|
|
const struct bfd_arch_info *arch_info;
|
162 |
|
|
|
163 |
|
|
/* Stuff only useful for archives. */
|
164 |
|
|
void *arelt_data;
|
165 |
|
|
struct bfd *my_archive; /* The containing archive BFD. */
|
166 |
|
|
struct bfd *archive_next; /* The next BFD in the archive. */
|
167 |
|
|
struct bfd *archive_head; /* The first BFD in the archive. */
|
168 |
|
|
struct bfd *nested_archives; /* List of nested archive in a flattened
|
169 |
|
|
thin archive. */
|
170 |
|
|
|
171 |
|
|
/* A chain of BFD structures involved in a link. */
|
172 |
|
|
struct bfd *link_next;
|
173 |
|
|
|
174 |
|
|
/* A field used by _bfd_generic_link_add_archive_symbols. This will
|
175 |
|
|
be used only for archive elements. */
|
176 |
|
|
int archive_pass;
|
177 |
|
|
|
178 |
|
|
/* Used by the back end to hold private data. */
|
179 |
|
|
union
|
180 |
|
|
@{
|
181 |
|
|
struct aout_data_struct *aout_data;
|
182 |
|
|
struct artdata *aout_ar_data;
|
183 |
|
|
struct _oasys_data *oasys_obj_data;
|
184 |
|
|
struct _oasys_ar_data *oasys_ar_data;
|
185 |
|
|
struct coff_tdata *coff_obj_data;
|
186 |
|
|
struct pe_tdata *pe_obj_data;
|
187 |
|
|
struct xcoff_tdata *xcoff_obj_data;
|
188 |
|
|
struct ecoff_tdata *ecoff_obj_data;
|
189 |
|
|
struct ieee_data_struct *ieee_data;
|
190 |
|
|
struct ieee_ar_data_struct *ieee_ar_data;
|
191 |
|
|
struct srec_data_struct *srec_data;
|
192 |
|
|
struct ihex_data_struct *ihex_data;
|
193 |
|
|
struct tekhex_data_struct *tekhex_data;
|
194 |
|
|
struct elf_obj_tdata *elf_obj_data;
|
195 |
|
|
struct nlm_obj_tdata *nlm_obj_data;
|
196 |
|
|
struct bout_data_struct *bout_data;
|
197 |
|
|
struct mmo_data_struct *mmo_data;
|
198 |
|
|
struct sun_core_struct *sun_core_data;
|
199 |
|
|
struct sco5_core_struct *sco5_core_data;
|
200 |
|
|
struct trad_core_struct *trad_core_data;
|
201 |
|
|
struct som_data_struct *som_data;
|
202 |
|
|
struct hpux_core_struct *hpux_core_data;
|
203 |
|
|
struct hppabsd_core_struct *hppabsd_core_data;
|
204 |
|
|
struct sgi_core_struct *sgi_core_data;
|
205 |
|
|
struct lynx_core_struct *lynx_core_data;
|
206 |
|
|
struct osf_core_struct *osf_core_data;
|
207 |
|
|
struct cisco_core_struct *cisco_core_data;
|
208 |
|
|
struct versados_data_struct *versados_data;
|
209 |
|
|
struct netbsd_core_struct *netbsd_core_data;
|
210 |
|
|
struct mach_o_data_struct *mach_o_data;
|
211 |
|
|
struct mach_o_fat_data_struct *mach_o_fat_data;
|
212 |
|
|
struct bfd_pef_data_struct *pef_data;
|
213 |
|
|
struct bfd_pef_xlib_data_struct *pef_xlib_data;
|
214 |
|
|
struct bfd_sym_data_struct *sym_data;
|
215 |
|
|
void *any;
|
216 |
|
|
@}
|
217 |
|
|
tdata;
|
218 |
|
|
|
219 |
|
|
/* Used by the application to hold private data. */
|
220 |
|
|
void *usrdata;
|
221 |
|
|
|
222 |
|
|
/* Where all the allocated stuff under this BFD goes. This is a
|
223 |
|
|
struct objalloc *, but we use void * to avoid requiring the inclusion
|
224 |
|
|
of objalloc.h. */
|
225 |
|
|
void *memory;
|
226 |
|
|
|
227 |
|
|
/* Is the file descriptor being cached? That is, can it be closed as
|
228 |
|
|
needed, and re-opened when accessed later? */
|
229 |
|
|
unsigned int cacheable : 1;
|
230 |
|
|
|
231 |
|
|
/* Marks whether there was a default target specified when the
|
232 |
|
|
BFD was opened. This is used to select which matching algorithm
|
233 |
|
|
to use to choose the back end. */
|
234 |
|
|
unsigned int target_defaulted : 1;
|
235 |
|
|
|
236 |
|
|
/* ... and here: (``once'' means at least once). */
|
237 |
|
|
unsigned int opened_once : 1;
|
238 |
|
|
|
239 |
|
|
/* Set if we have a locally maintained mtime value, rather than
|
240 |
|
|
getting it from the file each time. */
|
241 |
|
|
unsigned int mtime_set : 1;
|
242 |
|
|
|
243 |
|
|
/* Flag set if symbols from this BFD should not be exported. */
|
244 |
|
|
unsigned int no_export : 1;
|
245 |
|
|
|
246 |
|
|
/* Remember when output has begun, to stop strange things
|
247 |
|
|
from happening. */
|
248 |
|
|
unsigned int output_has_begun : 1;
|
249 |
|
|
|
250 |
|
|
/* Have archive map. */
|
251 |
|
|
unsigned int has_armap : 1;
|
252 |
|
|
|
253 |
|
|
/* Set if this is a thin archive. */
|
254 |
|
|
unsigned int is_thin_archive : 1;
|
255 |
|
|
@};
|
256 |
|
|
|
257 |
|
|
@end example
|
258 |
|
|
@section Error reporting
|
259 |
|
|
Most BFD functions return nonzero on success (check their
|
260 |
|
|
individual documentation for precise semantics). On an error,
|
261 |
|
|
they call @code{bfd_set_error} to set an error condition that callers
|
262 |
|
|
can check by calling @code{bfd_get_error}.
|
263 |
|
|
If that returns @code{bfd_error_system_call}, then check
|
264 |
|
|
@code{errno}.
|
265 |
|
|
|
266 |
|
|
The easiest way to report a BFD error to the user is to
|
267 |
|
|
use @code{bfd_perror}.
|
268 |
|
|
|
269 |
|
|
@subsection Type @code{bfd_error_type}
|
270 |
|
|
The values returned by @code{bfd_get_error} are defined by the
|
271 |
|
|
enumerated type @code{bfd_error_type}.
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
@example
|
275 |
|
|
|
276 |
|
|
typedef enum bfd_error
|
277 |
|
|
@{
|
278 |
|
|
bfd_error_no_error = 0,
|
279 |
|
|
bfd_error_system_call,
|
280 |
|
|
bfd_error_invalid_target,
|
281 |
|
|
bfd_error_wrong_format,
|
282 |
|
|
bfd_error_wrong_object_format,
|
283 |
|
|
bfd_error_invalid_operation,
|
284 |
|
|
bfd_error_no_memory,
|
285 |
|
|
bfd_error_no_symbols,
|
286 |
|
|
bfd_error_no_armap,
|
287 |
|
|
bfd_error_no_more_archived_files,
|
288 |
|
|
bfd_error_malformed_archive,
|
289 |
|
|
bfd_error_file_not_recognized,
|
290 |
|
|
bfd_error_file_ambiguously_recognized,
|
291 |
|
|
bfd_error_no_contents,
|
292 |
|
|
bfd_error_nonrepresentable_section,
|
293 |
|
|
bfd_error_no_debug_section,
|
294 |
|
|
bfd_error_bad_value,
|
295 |
|
|
bfd_error_file_truncated,
|
296 |
|
|
bfd_error_file_too_big,
|
297 |
|
|
bfd_error_on_input,
|
298 |
|
|
bfd_error_invalid_error_code
|
299 |
|
|
@}
|
300 |
|
|
bfd_error_type;
|
301 |
|
|
|
302 |
|
|
@end example
|
303 |
|
|
@findex bfd_get_error
|
304 |
|
|
@subsubsection @code{bfd_get_error}
|
305 |
|
|
@strong{Synopsis}
|
306 |
|
|
@example
|
307 |
|
|
bfd_error_type bfd_get_error (void);
|
308 |
|
|
@end example
|
309 |
|
|
@strong{Description}@*
|
310 |
|
|
Return the current BFD error condition.
|
311 |
|
|
|
312 |
|
|
@findex bfd_set_error
|
313 |
|
|
@subsubsection @code{bfd_set_error}
|
314 |
|
|
@strong{Synopsis}
|
315 |
|
|
@example
|
316 |
|
|
void bfd_set_error (bfd_error_type error_tag, ...);
|
317 |
|
|
@end example
|
318 |
|
|
@strong{Description}@*
|
319 |
|
|
Set the BFD error condition to be @var{error_tag}.
|
320 |
|
|
If @var{error_tag} is bfd_error_on_input, then this function
|
321 |
|
|
takes two more parameters, the input bfd where the error
|
322 |
|
|
occurred, and the bfd_error_type error.
|
323 |
|
|
|
324 |
|
|
@findex bfd_errmsg
|
325 |
|
|
@subsubsection @code{bfd_errmsg}
|
326 |
|
|
@strong{Synopsis}
|
327 |
|
|
@example
|
328 |
|
|
const char *bfd_errmsg (bfd_error_type error_tag);
|
329 |
|
|
@end example
|
330 |
|
|
@strong{Description}@*
|
331 |
|
|
Return a string describing the error @var{error_tag}, or
|
332 |
|
|
the system error if @var{error_tag} is @code{bfd_error_system_call}.
|
333 |
|
|
|
334 |
|
|
@findex bfd_perror
|
335 |
|
|
@subsubsection @code{bfd_perror}
|
336 |
|
|
@strong{Synopsis}
|
337 |
|
|
@example
|
338 |
|
|
void bfd_perror (const char *message);
|
339 |
|
|
@end example
|
340 |
|
|
@strong{Description}@*
|
341 |
|
|
Print to the standard error stream a string describing the
|
342 |
|
|
last BFD error that occurred, or the last system error if
|
343 |
|
|
the last BFD error was a system call failure. If @var{message}
|
344 |
|
|
is non-NULL and non-empty, the error string printed is preceded
|
345 |
|
|
by @var{message}, a colon, and a space. It is followed by a newline.
|
346 |
|
|
|
347 |
|
|
@subsection BFD error handler
|
348 |
|
|
Some BFD functions want to print messages describing the
|
349 |
|
|
problem. They call a BFD error handler function. This
|
350 |
|
|
function may be overridden by the program.
|
351 |
|
|
|
352 |
|
|
The BFD error handler acts like printf.
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
@example
|
356 |
|
|
|
357 |
|
|
typedef void (*bfd_error_handler_type) (const char *, ...);
|
358 |
|
|
|
359 |
|
|
@end example
|
360 |
|
|
@findex bfd_set_error_handler
|
361 |
|
|
@subsubsection @code{bfd_set_error_handler}
|
362 |
|
|
@strong{Synopsis}
|
363 |
|
|
@example
|
364 |
|
|
bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type);
|
365 |
|
|
@end example
|
366 |
|
|
@strong{Description}@*
|
367 |
|
|
Set the BFD error handler function. Returns the previous
|
368 |
|
|
function.
|
369 |
|
|
|
370 |
|
|
@findex bfd_set_error_program_name
|
371 |
|
|
@subsubsection @code{bfd_set_error_program_name}
|
372 |
|
|
@strong{Synopsis}
|
373 |
|
|
@example
|
374 |
|
|
void bfd_set_error_program_name (const char *);
|
375 |
|
|
@end example
|
376 |
|
|
@strong{Description}@*
|
377 |
|
|
Set the program name to use when printing a BFD error. This
|
378 |
|
|
is printed before the error message followed by a colon and
|
379 |
|
|
space. The string must not be changed after it is passed to
|
380 |
|
|
this function.
|
381 |
|
|
|
382 |
|
|
@findex bfd_get_error_handler
|
383 |
|
|
@subsubsection @code{bfd_get_error_handler}
|
384 |
|
|
@strong{Synopsis}
|
385 |
|
|
@example
|
386 |
|
|
bfd_error_handler_type bfd_get_error_handler (void);
|
387 |
|
|
@end example
|
388 |
|
|
@strong{Description}@*
|
389 |
|
|
Return the BFD error handler function.
|
390 |
|
|
|
391 |
|
|
@section Miscellaneous
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
@subsection Miscellaneous functions
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
@findex bfd_get_reloc_upper_bound
|
398 |
|
|
@subsubsection @code{bfd_get_reloc_upper_bound}
|
399 |
|
|
@strong{Synopsis}
|
400 |
|
|
@example
|
401 |
|
|
long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect);
|
402 |
|
|
@end example
|
403 |
|
|
@strong{Description}@*
|
404 |
|
|
Return the number of bytes required to store the
|
405 |
|
|
relocation information associated with section @var{sect}
|
406 |
|
|
attached to bfd @var{abfd}. If an error occurs, return -1.
|
407 |
|
|
|
408 |
|
|
@findex bfd_canonicalize_reloc
|
409 |
|
|
@subsubsection @code{bfd_canonicalize_reloc}
|
410 |
|
|
@strong{Synopsis}
|
411 |
|
|
@example
|
412 |
|
|
long bfd_canonicalize_reloc
|
413 |
|
|
(bfd *abfd, asection *sec, arelent **loc, asymbol **syms);
|
414 |
|
|
@end example
|
415 |
|
|
@strong{Description}@*
|
416 |
|
|
Call the back end associated with the open BFD
|
417 |
|
|
@var{abfd} and translate the external form of the relocation
|
418 |
|
|
information attached to @var{sec} into the internal canonical
|
419 |
|
|
form. Place the table into memory at @var{loc}, which has
|
420 |
|
|
been preallocated, usually by a call to
|
421 |
|
|
@code{bfd_get_reloc_upper_bound}. Returns the number of relocs, or
|
422 |
|
|
-1 on error.
|
423 |
|
|
|
424 |
|
|
The @var{syms} table is also needed for horrible internal magic
|
425 |
|
|
reasons.
|
426 |
|
|
|
427 |
|
|
@findex bfd_set_reloc
|
428 |
|
|
@subsubsection @code{bfd_set_reloc}
|
429 |
|
|
@strong{Synopsis}
|
430 |
|
|
@example
|
431 |
|
|
void bfd_set_reloc
|
432 |
|
|
(bfd *abfd, asection *sec, arelent **rel, unsigned int count);
|
433 |
|
|
@end example
|
434 |
|
|
@strong{Description}@*
|
435 |
|
|
Set the relocation pointer and count within
|
436 |
|
|
section @var{sec} to the values @var{rel} and @var{count}.
|
437 |
|
|
The argument @var{abfd} is ignored.
|
438 |
|
|
|
439 |
|
|
@findex bfd_set_file_flags
|
440 |
|
|
@subsubsection @code{bfd_set_file_flags}
|
441 |
|
|
@strong{Synopsis}
|
442 |
|
|
@example
|
443 |
|
|
bfd_boolean bfd_set_file_flags (bfd *abfd, flagword flags);
|
444 |
|
|
@end example
|
445 |
|
|
@strong{Description}@*
|
446 |
|
|
Set the flag word in the BFD @var{abfd} to the value @var{flags}.
|
447 |
|
|
|
448 |
|
|
Possible errors are:
|
449 |
|
|
@itemize @bullet
|
450 |
|
|
|
451 |
|
|
@item
|
452 |
|
|
@code{bfd_error_wrong_format} - The target bfd was not of object format.
|
453 |
|
|
@item
|
454 |
|
|
@code{bfd_error_invalid_operation} - The target bfd was open for reading.
|
455 |
|
|
@item
|
456 |
|
|
@code{bfd_error_invalid_operation} -
|
457 |
|
|
The flag word contained a bit which was not applicable to the
|
458 |
|
|
type of file. E.g., an attempt was made to set the @code{D_PAGED} bit
|
459 |
|
|
on a BFD format which does not support demand paging.
|
460 |
|
|
@end itemize
|
461 |
|
|
|
462 |
|
|
@findex bfd_get_arch_size
|
463 |
|
|
@subsubsection @code{bfd_get_arch_size}
|
464 |
|
|
@strong{Synopsis}
|
465 |
|
|
@example
|
466 |
|
|
int bfd_get_arch_size (bfd *abfd);
|
467 |
|
|
@end example
|
468 |
|
|
@strong{Description}@*
|
469 |
|
|
Returns the architecture address size, in bits, as determined
|
470 |
|
|
by the object file's format. For ELF, this information is
|
471 |
|
|
included in the header.
|
472 |
|
|
|
473 |
|
|
@strong{Returns}@*
|
474 |
|
|
Returns the arch size in bits if known, @code{-1} otherwise.
|
475 |
|
|
|
476 |
|
|
@findex bfd_get_sign_extend_vma
|
477 |
|
|
@subsubsection @code{bfd_get_sign_extend_vma}
|
478 |
|
|
@strong{Synopsis}
|
479 |
|
|
@example
|
480 |
|
|
int bfd_get_sign_extend_vma (bfd *abfd);
|
481 |
|
|
@end example
|
482 |
|
|
@strong{Description}@*
|
483 |
|
|
Indicates if the target architecture "naturally" sign extends
|
484 |
|
|
an address. Some architectures implicitly sign extend address
|
485 |
|
|
values when they are converted to types larger than the size
|
486 |
|
|
of an address. For instance, bfd_get_start_address() will
|
487 |
|
|
return an address sign extended to fill a bfd_vma when this is
|
488 |
|
|
the case.
|
489 |
|
|
|
490 |
|
|
@strong{Returns}@*
|
491 |
|
|
Returns @code{1} if the target architecture is known to sign
|
492 |
|
|
extend addresses, @code{0} if the target architecture is known to
|
493 |
|
|
not sign extend addresses, and @code{-1} otherwise.
|
494 |
|
|
|
495 |
|
|
@findex bfd_set_start_address
|
496 |
|
|
@subsubsection @code{bfd_set_start_address}
|
497 |
|
|
@strong{Synopsis}
|
498 |
|
|
@example
|
499 |
|
|
bfd_boolean bfd_set_start_address (bfd *abfd, bfd_vma vma);
|
500 |
|
|
@end example
|
501 |
|
|
@strong{Description}@*
|
502 |
|
|
Make @var{vma} the entry point of output BFD @var{abfd}.
|
503 |
|
|
|
504 |
|
|
@strong{Returns}@*
|
505 |
|
|
Returns @code{TRUE} on success, @code{FALSE} otherwise.
|
506 |
|
|
|
507 |
|
|
@findex bfd_get_gp_size
|
508 |
|
|
@subsubsection @code{bfd_get_gp_size}
|
509 |
|
|
@strong{Synopsis}
|
510 |
|
|
@example
|
511 |
|
|
unsigned int bfd_get_gp_size (bfd *abfd);
|
512 |
|
|
@end example
|
513 |
|
|
@strong{Description}@*
|
514 |
|
|
Return the maximum size of objects to be optimized using the GP
|
515 |
|
|
register under MIPS ECOFF. This is typically set by the @code{-G}
|
516 |
|
|
argument to the compiler, assembler or linker.
|
517 |
|
|
|
518 |
|
|
@findex bfd_set_gp_size
|
519 |
|
|
@subsubsection @code{bfd_set_gp_size}
|
520 |
|
|
@strong{Synopsis}
|
521 |
|
|
@example
|
522 |
|
|
void bfd_set_gp_size (bfd *abfd, unsigned int i);
|
523 |
|
|
@end example
|
524 |
|
|
@strong{Description}@*
|
525 |
|
|
Set the maximum size of objects to be optimized using the GP
|
526 |
|
|
register under ECOFF or MIPS ELF. This is typically set by
|
527 |
|
|
the @code{-G} argument to the compiler, assembler or linker.
|
528 |
|
|
|
529 |
|
|
@findex bfd_scan_vma
|
530 |
|
|
@subsubsection @code{bfd_scan_vma}
|
531 |
|
|
@strong{Synopsis}
|
532 |
|
|
@example
|
533 |
|
|
bfd_vma bfd_scan_vma (const char *string, const char **end, int base);
|
534 |
|
|
@end example
|
535 |
|
|
@strong{Description}@*
|
536 |
|
|
Convert, like @code{strtoul}, a numerical expression
|
537 |
|
|
@var{string} into a @code{bfd_vma} integer, and return that integer.
|
538 |
|
|
(Though without as many bells and whistles as @code{strtoul}.)
|
539 |
|
|
The expression is assumed to be unsigned (i.e., positive).
|
540 |
|
|
If given a @var{base}, it is used as the base for conversion.
|
541 |
|
|
A base of 0 causes the function to interpret the string
|
542 |
|
|
in hex if a leading "0x" or "0X" is found, otherwise
|
543 |
|
|
in octal if a leading zero is found, otherwise in decimal.
|
544 |
|
|
|
545 |
|
|
If the value would overflow, the maximum @code{bfd_vma} value is
|
546 |
|
|
returned.
|
547 |
|
|
|
548 |
|
|
@findex bfd_copy_private_header_data
|
549 |
|
|
@subsubsection @code{bfd_copy_private_header_data}
|
550 |
|
|
@strong{Synopsis}
|
551 |
|
|
@example
|
552 |
|
|
bfd_boolean bfd_copy_private_header_data (bfd *ibfd, bfd *obfd);
|
553 |
|
|
@end example
|
554 |
|
|
@strong{Description}@*
|
555 |
|
|
Copy private BFD header information from the BFD @var{ibfd} to the
|
556 |
|
|
the BFD @var{obfd}. This copies information that may require
|
557 |
|
|
sections to exist, but does not require symbol tables. Return
|
558 |
|
|
@code{true} on success, @code{false} on error.
|
559 |
|
|
Possible error returns are:
|
560 |
|
|
|
561 |
|
|
@itemize @bullet
|
562 |
|
|
|
563 |
|
|
@item
|
564 |
|
|
@code{bfd_error_no_memory} -
|
565 |
|
|
Not enough memory exists to create private data for @var{obfd}.
|
566 |
|
|
@end itemize
|
567 |
|
|
@example
|
568 |
|
|
#define bfd_copy_private_header_data(ibfd, obfd) \
|
569 |
|
|
BFD_SEND (obfd, _bfd_copy_private_header_data, \
|
570 |
|
|
(ibfd, obfd))
|
571 |
|
|
@end example
|
572 |
|
|
|
573 |
|
|
@findex bfd_copy_private_bfd_data
|
574 |
|
|
@subsubsection @code{bfd_copy_private_bfd_data}
|
575 |
|
|
@strong{Synopsis}
|
576 |
|
|
@example
|
577 |
|
|
bfd_boolean bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd);
|
578 |
|
|
@end example
|
579 |
|
|
@strong{Description}@*
|
580 |
|
|
Copy private BFD information from the BFD @var{ibfd} to the
|
581 |
|
|
the BFD @var{obfd}. Return @code{TRUE} on success, @code{FALSE} on error.
|
582 |
|
|
Possible error returns are:
|
583 |
|
|
|
584 |
|
|
@itemize @bullet
|
585 |
|
|
|
586 |
|
|
@item
|
587 |
|
|
@code{bfd_error_no_memory} -
|
588 |
|
|
Not enough memory exists to create private data for @var{obfd}.
|
589 |
|
|
@end itemize
|
590 |
|
|
@example
|
591 |
|
|
#define bfd_copy_private_bfd_data(ibfd, obfd) \
|
592 |
|
|
BFD_SEND (obfd, _bfd_copy_private_bfd_data, \
|
593 |
|
|
(ibfd, obfd))
|
594 |
|
|
@end example
|
595 |
|
|
|
596 |
|
|
@findex bfd_merge_private_bfd_data
|
597 |
|
|
@subsubsection @code{bfd_merge_private_bfd_data}
|
598 |
|
|
@strong{Synopsis}
|
599 |
|
|
@example
|
600 |
|
|
bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
|
601 |
|
|
@end example
|
602 |
|
|
@strong{Description}@*
|
603 |
|
|
Merge private BFD information from the BFD @var{ibfd} to the
|
604 |
|
|
the output file BFD @var{obfd} when linking. Return @code{TRUE}
|
605 |
|
|
on success, @code{FALSE} on error. Possible error returns are:
|
606 |
|
|
|
607 |
|
|
@itemize @bullet
|
608 |
|
|
|
609 |
|
|
@item
|
610 |
|
|
@code{bfd_error_no_memory} -
|
611 |
|
|
Not enough memory exists to create private data for @var{obfd}.
|
612 |
|
|
@end itemize
|
613 |
|
|
@example
|
614 |
|
|
#define bfd_merge_private_bfd_data(ibfd, obfd) \
|
615 |
|
|
BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
|
616 |
|
|
(ibfd, obfd))
|
617 |
|
|
@end example
|
618 |
|
|
|
619 |
|
|
@findex bfd_set_private_flags
|
620 |
|
|
@subsubsection @code{bfd_set_private_flags}
|
621 |
|
|
@strong{Synopsis}
|
622 |
|
|
@example
|
623 |
|
|
bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags);
|
624 |
|
|
@end example
|
625 |
|
|
@strong{Description}@*
|
626 |
|
|
Set private BFD flag information in the BFD @var{abfd}.
|
627 |
|
|
Return @code{TRUE} on success, @code{FALSE} on error. Possible error
|
628 |
|
|
returns are:
|
629 |
|
|
|
630 |
|
|
@itemize @bullet
|
631 |
|
|
|
632 |
|
|
@item
|
633 |
|
|
@code{bfd_error_no_memory} -
|
634 |
|
|
Not enough memory exists to create private data for @var{obfd}.
|
635 |
|
|
@end itemize
|
636 |
|
|
@example
|
637 |
|
|
#define bfd_set_private_flags(abfd, flags) \
|
638 |
|
|
BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags))
|
639 |
|
|
@end example
|
640 |
|
|
|
641 |
|
|
@findex Other functions
|
642 |
|
|
@subsubsection @code{Other functions}
|
643 |
|
|
@strong{Description}@*
|
644 |
|
|
The following functions exist but have not yet been documented.
|
645 |
|
|
@example
|
646 |
|
|
#define bfd_sizeof_headers(abfd, info) \
|
647 |
|
|
BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, info))
|
648 |
|
|
|
649 |
|
|
#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
|
650 |
|
|
BFD_SEND (abfd, _bfd_find_nearest_line, \
|
651 |
|
|
(abfd, sec, syms, off, file, func, line))
|
652 |
|
|
|
653 |
|
|
#define bfd_find_line(abfd, syms, sym, file, line) \
|
654 |
|
|
BFD_SEND (abfd, _bfd_find_line, \
|
655 |
|
|
(abfd, syms, sym, file, line))
|
656 |
|
|
|
657 |
|
|
#define bfd_find_inliner_info(abfd, file, func, line) \
|
658 |
|
|
BFD_SEND (abfd, _bfd_find_inliner_info, \
|
659 |
|
|
(abfd, file, func, line))
|
660 |
|
|
|
661 |
|
|
#define bfd_debug_info_start(abfd) \
|
662 |
|
|
BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
|
663 |
|
|
|
664 |
|
|
#define bfd_debug_info_end(abfd) \
|
665 |
|
|
BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
|
666 |
|
|
|
667 |
|
|
#define bfd_debug_info_accumulate(abfd, section) \
|
668 |
|
|
BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
|
669 |
|
|
|
670 |
|
|
#define bfd_stat_arch_elt(abfd, stat) \
|
671 |
|
|
BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
|
672 |
|
|
|
673 |
|
|
#define bfd_update_armap_timestamp(abfd) \
|
674 |
|
|
BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
|
675 |
|
|
|
676 |
|
|
#define bfd_set_arch_mach(abfd, arch, mach)\
|
677 |
|
|
BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
|
678 |
|
|
|
679 |
|
|
#define bfd_relax_section(abfd, section, link_info, again) \
|
680 |
|
|
BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
|
681 |
|
|
|
682 |
|
|
#define bfd_gc_sections(abfd, link_info) \
|
683 |
|
|
BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
|
684 |
|
|
|
685 |
|
|
#define bfd_merge_sections(abfd, link_info) \
|
686 |
|
|
BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
|
687 |
|
|
|
688 |
|
|
#define bfd_is_group_section(abfd, sec) \
|
689 |
|
|
BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec))
|
690 |
|
|
|
691 |
|
|
#define bfd_discard_group(abfd, sec) \
|
692 |
|
|
BFD_SEND (abfd, _bfd_discard_group, (abfd, sec))
|
693 |
|
|
|
694 |
|
|
#define bfd_link_hash_table_create(abfd) \
|
695 |
|
|
BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
|
696 |
|
|
|
697 |
|
|
#define bfd_link_hash_table_free(abfd, hash) \
|
698 |
|
|
BFD_SEND (abfd, _bfd_link_hash_table_free, (hash))
|
699 |
|
|
|
700 |
|
|
#define bfd_link_add_symbols(abfd, info) \
|
701 |
|
|
BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
|
702 |
|
|
|
703 |
|
|
#define bfd_link_just_syms(abfd, sec, info) \
|
704 |
|
|
BFD_SEND (abfd, _bfd_link_just_syms, (sec, info))
|
705 |
|
|
|
706 |
|
|
#define bfd_final_link(abfd, info) \
|
707 |
|
|
BFD_SEND (abfd, _bfd_final_link, (abfd, info))
|
708 |
|
|
|
709 |
|
|
#define bfd_free_cached_info(abfd) \
|
710 |
|
|
BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
|
711 |
|
|
|
712 |
|
|
#define bfd_get_dynamic_symtab_upper_bound(abfd) \
|
713 |
|
|
BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
|
714 |
|
|
|
715 |
|
|
#define bfd_print_private_bfd_data(abfd, file)\
|
716 |
|
|
BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
|
717 |
|
|
|
718 |
|
|
#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
|
719 |
|
|
BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
|
720 |
|
|
|
721 |
|
|
#define bfd_get_synthetic_symtab(abfd, count, syms, dyncount, dynsyms, ret) \
|
722 |
|
|
BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, count, syms, \
|
723 |
|
|
dyncount, dynsyms, ret))
|
724 |
|
|
|
725 |
|
|
#define bfd_get_dynamic_reloc_upper_bound(abfd) \
|
726 |
|
|
BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
|
727 |
|
|
|
728 |
|
|
#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
|
729 |
|
|
BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
|
730 |
|
|
|
731 |
|
|
extern bfd_byte *bfd_get_relocated_section_contents
|
732 |
|
|
(bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *,
|
733 |
|
|
bfd_boolean, asymbol **);
|
734 |
|
|
|
735 |
|
|
@end example
|
736 |
|
|
|
737 |
|
|
@findex bfd_alt_mach_code
|
738 |
|
|
@subsubsection @code{bfd_alt_mach_code}
|
739 |
|
|
@strong{Synopsis}
|
740 |
|
|
@example
|
741 |
|
|
bfd_boolean bfd_alt_mach_code (bfd *abfd, int alternative);
|
742 |
|
|
@end example
|
743 |
|
|
@strong{Description}@*
|
744 |
|
|
When more than one machine code number is available for the
|
745 |
|
|
same machine type, this function can be used to switch between
|
746 |
|
|
the preferred one (alternative == 0) and any others. Currently,
|
747 |
|
|
only ELF supports this feature, with up to two alternate
|
748 |
|
|
machine codes.
|
749 |
|
|
|
750 |
|
|
|
751 |
|
|
@example
|
752 |
|
|
struct bfd_preserve
|
753 |
|
|
@{
|
754 |
|
|
void *marker;
|
755 |
|
|
void *tdata;
|
756 |
|
|
flagword flags;
|
757 |
|
|
const struct bfd_arch_info *arch_info;
|
758 |
|
|
struct bfd_section *sections;
|
759 |
|
|
struct bfd_section *section_last;
|
760 |
|
|
unsigned int section_count;
|
761 |
|
|
struct bfd_hash_table section_htab;
|
762 |
|
|
@};
|
763 |
|
|
|
764 |
|
|
@end example
|
765 |
|
|
@findex bfd_preserve_save
|
766 |
|
|
@subsubsection @code{bfd_preserve_save}
|
767 |
|
|
@strong{Synopsis}
|
768 |
|
|
@example
|
769 |
|
|
bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
|
770 |
|
|
@end example
|
771 |
|
|
@strong{Description}@*
|
772 |
|
|
When testing an object for compatibility with a particular
|
773 |
|
|
target back-end, the back-end object_p function needs to set
|
774 |
|
|
up certain fields in the bfd on successfully recognizing the
|
775 |
|
|
object. This typically happens in a piecemeal fashion, with
|
776 |
|
|
failures possible at many points. On failure, the bfd is
|
777 |
|
|
supposed to be restored to its initial state, which is
|
778 |
|
|
virtually impossible. However, restoring a subset of the bfd
|
779 |
|
|
state works in practice. This function stores the subset and
|
780 |
|
|
reinitializes the bfd.
|
781 |
|
|
|
782 |
|
|
@findex bfd_preserve_restore
|
783 |
|
|
@subsubsection @code{bfd_preserve_restore}
|
784 |
|
|
@strong{Synopsis}
|
785 |
|
|
@example
|
786 |
|
|
void bfd_preserve_restore (bfd *, struct bfd_preserve *);
|
787 |
|
|
@end example
|
788 |
|
|
@strong{Description}@*
|
789 |
|
|
This function restores bfd state saved by bfd_preserve_save.
|
790 |
|
|
If MARKER is non-NULL in struct bfd_preserve then that block
|
791 |
|
|
and all subsequently bfd_alloc'd memory is freed.
|
792 |
|
|
|
793 |
|
|
@findex bfd_preserve_finish
|
794 |
|
|
@subsubsection @code{bfd_preserve_finish}
|
795 |
|
|
@strong{Synopsis}
|
796 |
|
|
@example
|
797 |
|
|
void bfd_preserve_finish (bfd *, struct bfd_preserve *);
|
798 |
|
|
@end example
|
799 |
|
|
@strong{Description}@*
|
800 |
|
|
This function should be called when the bfd state saved by
|
801 |
|
|
bfd_preserve_save is no longer needed. ie. when the back-end
|
802 |
|
|
object_p function returns with success.
|
803 |
|
|
|
804 |
|
|
@findex bfd_emul_get_maxpagesize
|
805 |
|
|
@subsubsection @code{bfd_emul_get_maxpagesize}
|
806 |
|
|
@strong{Synopsis}
|
807 |
|
|
@example
|
808 |
|
|
bfd_vma bfd_emul_get_maxpagesize (const char *);
|
809 |
|
|
@end example
|
810 |
|
|
@strong{Description}@*
|
811 |
|
|
Returns the maximum page size, in bytes, as determined by
|
812 |
|
|
emulation.
|
813 |
|
|
|
814 |
|
|
@strong{Returns}@*
|
815 |
|
|
Returns the maximum page size in bytes for ELF, abort
|
816 |
|
|
otherwise.
|
817 |
|
|
|
818 |
|
|
@findex bfd_emul_set_maxpagesize
|
819 |
|
|
@subsubsection @code{bfd_emul_set_maxpagesize}
|
820 |
|
|
@strong{Synopsis}
|
821 |
|
|
@example
|
822 |
|
|
void bfd_emul_set_maxpagesize (const char *, bfd_vma);
|
823 |
|
|
@end example
|
824 |
|
|
@strong{Description}@*
|
825 |
|
|
For ELF, set the maximum page size for the emulation. It is
|
826 |
|
|
a no-op for other formats.
|
827 |
|
|
|
828 |
|
|
@findex bfd_emul_get_commonpagesize
|
829 |
|
|
@subsubsection @code{bfd_emul_get_commonpagesize}
|
830 |
|
|
@strong{Synopsis}
|
831 |
|
|
@example
|
832 |
|
|
bfd_vma bfd_emul_get_commonpagesize (const char *);
|
833 |
|
|
@end example
|
834 |
|
|
@strong{Description}@*
|
835 |
|
|
Returns the common page size, in bytes, as determined by
|
836 |
|
|
emulation.
|
837 |
|
|
|
838 |
|
|
@strong{Returns}@*
|
839 |
|
|
Returns the common page size in bytes for ELF, abort otherwise.
|
840 |
|
|
|
841 |
|
|
@findex bfd_emul_set_commonpagesize
|
842 |
|
|
@subsubsection @code{bfd_emul_set_commonpagesize}
|
843 |
|
|
@strong{Synopsis}
|
844 |
|
|
@example
|
845 |
|
|
void bfd_emul_set_commonpagesize (const char *, bfd_vma);
|
846 |
|
|
@end example
|
847 |
|
|
@strong{Description}@*
|
848 |
|
|
For ELF, set the common page size for the emulation. It is
|
849 |
|
|
a no-op for other formats.
|
850 |
|
|
|
851 |
|
|
@findex bfd_demangle
|
852 |
|
|
@subsubsection @code{bfd_demangle}
|
853 |
|
|
@strong{Synopsis}
|
854 |
|
|
@example
|
855 |
|
|
char *bfd_demangle (bfd *, const char *, int);
|
856 |
|
|
@end example
|
857 |
|
|
@strong{Description}@*
|
858 |
|
|
Wrapper around cplus_demangle. Strips leading underscores and
|
859 |
|
|
other such chars that would otherwise confuse the demangler.
|
860 |
|
|
If passed a g++ v3 ABI mangled name, returns a buffer allocated
|
861 |
|
|
with malloc holding the demangled name. Returns NULL otherwise
|
862 |
|
|
and on memory alloc failure.
|
863 |
|
|
|