The Binary File Descriptor library (BFD) is the
GNU Project
The GNU Project ( ) is a free software, mass collaboration project announced by Richard Stallman on September 27, 1983. Its goal is to give computer users freedom and control in their use of their computers and Computer hardware, computing dev ...
's main mechanism for the
portable manipulation of
object files in a variety of formats. , it supports approximately 50 file formats and 25
instruction set architecture
In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, ...
s.
History
When
David Henkel-Wallace of
Cygnus Support proposed developing the library as a way to open up new business opportunities for the company,
Richard Stallman said that it would be difficult; David's response was that it wasn't such a "Big Fucking Deal". Abbreviated to "BFD", this became the library name. "Binary File Descriptor" was invented later as a
backronym for "BFD".
Design
BFD works by presenting a common abstract view of object files. An object file has a "header" with descriptive info; a variable number of "sections" that each has a name, some attributes, and a block of data; a
symbol table;
relocation entries; and so forth.
Internally, BFD translates the data from the abstract view into the details of the bit/byte layout required by the target
processor and file format. Its key services include handling
byte order differences, such as between a
little-endian host and
big-endian
'' Jonathan_Swift.html" ;"title="Gulliver's Travels'' by Jonathan Swift">Gulliver's Travels'' by Jonathan Swift, the novel from which the term was coined
In computing, endianness is the order in which bytes within a word (data type), word of d ...
target, correct conversion between
32-bit
In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in a maximum of 32- bit units. Compared to smaller bit widths, 32-bit computers can perform la ...
and
64-bit data, and details of
address
An address is a collection of information, presented in a mostly fixed format, used to give the location of a building, apartment, or other structure or a plot of land, generally using border, political boundaries and street names as references, ...
arithmetic specified by relocation entries.
BFD library can be logically divided into two parts. The front-end and the back-end. The front-end gives a common interface independent of underlying object file view. Users will be interacting with the object files with this interface. Even if the layout of the object files are not known to the user, the user would still be able to use the interface. This hiding of the detail is done with the help of the back-end. The back-end implements how the front-end interface interacts with the object files layout. Whenever a new object files type is introduced the back-end needs to register the type and implement it if it needs to be supported by the BFD application.
Although BFD was originally designed to be a generic library usable by a wide variety of tools, the frequent need to tinker with the API to accommodate new systems' capabilities has tended to limit its use; BFD's main clients are the
GNU Assembler
The GNU Assembler, commonly known as gas or as, is the assembler developed by the GNU Project. It is the default back-end of GCC. It is used to assemble the GNU operating system and the Linux kernel, and various other software. It is a part o ...
(GAS),
GNU Linker (GLD),
[ See also: ] and other
GNU Binary Utilities ("binutils") tools, and the
GNU Debugger (GDB). As a result, BFD is not distributed separately, but is always included with releases of binutils and GDB. Nevertheless, BFD is a critical component in the use of GNU tools for
embedded systems development.
The BFD library can be used to read the structured data out of a
core dump
In computing, a core dump, memory dump, crash dump, storage dump, system dump, or ABEND dump consists of the recorded state of the working Computer storage, memory of a computer program at a specific time, generally when the program has crash (com ...
.
BFD library usage
Eg: Print object file size using bfd library APIs.
#include "bfd.h"
#include
int main()
Build command:
gcc main.c -lbfd -o output
./output # prints the size
References
External links
Binutils page, with access to current BFD sourcesobjdump implementation, uses many BFD apis
{{DEFAULTSORT:Binary File Descriptor Library
C (programming language) libraries
Executable file formats
Free computer libraries
GNU Project software