The topic of this articlemay not meet Wikipedia'snotability guidelines for products and services. Please help to demonstrate the notability of the topic by citingreliable secondary sources that areindependent of the topic and provide significant coverage of it beyond a mere trivial mention. If notability cannot be shown, the article is likely to bemerged,redirected, ordeleted. Find sources: "Binary File Descriptor library" – news ·newspapers ·books ·scholar ·JSTOR(July 2011) (Learn how and when to remove this message) |
| Binary File Descriptor library | |
|---|---|
| Original author | Cygnus Solutions |
| Written in | C |
| Platform | |
| Type | Library |
| License | GNU General Public License |
| Repository | |
TheBinary File Descriptor library (BFD) is theGNU Project's main mechanism for theportable manipulation ofobject files in a variety of formats. As of 2003[update],[needs update] it supports approximately 50 file formats and 25instruction set architectures.
WhenDavid Henkel-Wallace ofCygnus 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.[1] "Binary File Descriptor" was invented later as abackronym for "BFD".
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; asymbol 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 targetprocessor and file format. Its key services include handlingbyte order differences, such as between alittle-endian host andbig-endian target, correct conversion between32-bit and64-bit data, and details ofaddress arithmetic specified by relocation entries.
BFD[2] 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;[3][4][5] BFD's main clients are theGNU Assembler (GAS),GNU Linker (GLD),[6] and otherGNU Binary Utilities ("binutils") tools, and theGNU 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 forembedded systems development.
The BFD library can be used to read the structured data out of acore dump.
Eg: Print object file size using bfd library APIs.
#include"bfd.h"#include<stdio.h>intmain(){bfd*abfd=bfd_openr("a.o",NULL);printf("%llu\n",bfd_get_size(abfd));return0;}
Build command:
gcc main.c -lbfd -o output./output # prints the size
Gumby began designing the library and discussing the design with Stallman. Stallman said that the job was too difficult—it would require a complete rewrite of all the tools, and it would be too difficult to maintain. Gumby told him it wasn't such a "Big F*cking Deal" and hence named this new creation the BFD library. (We explained to our customers that BFD stood for the binary file descriptor library.)