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: