Next: What BFD Version 2 Can Do, Previous: History, Up: Overview [Contents][Index]
To use the library, include bfd.h and link with libbfd.a.
BFD provides a common interface to the parts of an object file for a calling application.
When an application successfully opens a target file (object, archive, or
whatever), a pointer to an internal structure is returned. This pointer
points to a structure called bfd
, described in
bfd.h. Our convention is to call this pointer a BFD, and
instances of it within code abfd
. All operations on
the target object file are applied as methods to the BFD. The mapping is
defined within bfd.h
in a set of macros, all beginning
with ‘bfd_’ to reduce namespace pollution.
For example, this sequence does what you would probably expect:
return the number of sections in an object file attached to a BFD
abfd
.
#include "bfd.h" unsigned int number_of_sections (abfd) bfd *abfd; { return bfd_count_sections (abfd); }
The abstraction used within BFD is that an object file has:
Also, BFDs opened for archives have the additional attribute of an index and contain subordinate BFDs. This approach is fine for a.out and coff, but loses efficiency when applied to formats such as S-records and IEEE-695.