3 @c Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1997, 2000,
4 @c 2001, 2002, 2003, 2006, 2007, 2008, 2009
5 @c Free Software Foundation, Inc.
10 @dircategory Software development
12 * Bfd: (bfd). The Binary File Descriptor library.
17 This file documents the BFD library.
19 Copyright @copyright{} 1991, 2000, 2001, 2003, 2006, 2007, 2008 Free Software Foundation, Inc.
21 Permission is granted to copy, distribute and/or modify this document
22 under the terms of the GNU Free Documentation License, Version 1.3 or
23 any later version published by the Free Software Foundation; with the
24 Invariant Sections being ``GNU General Public License'' and ``Funding
25 Free Software'', the Front-Cover texts being (a) (see below), and with
26 the Back-Cover Texts being (b) (see below). A copy of the license is
27 included in the section entitled ``GNU Free Documentation License''.
29 (a) The FSF's Front-Cover Text is:
33 (b) The FSF's Back-Cover Text is:
35 You have freedom to copy and modify this GNU Manual, like GNU
36 software. Copies published by the Free Software Foundation raise
37 funds for GNU development.
42 @c@setchapternewpage odd
43 @settitle LIB BFD, the Binary File Descriptor Library
46 @subtitle{The Binary File Descriptor Library}
48 @subtitle First Edition---BFD version < 3.0 % Since no product is stable before version 3.0 :-)
49 @subtitle Original Document Created: April 1991
50 @author {Steve Chamberlain}
51 @author {Cygnus Support}
55 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
56 \xdef\manvers{1.5} % For use in headers, footers too
58 \hfill Free Software Foundation\par
59 \hfill sac\@www.gnu.org\par
60 \hfill {\it BFD}, \manvers\par
61 \hfill \TeX{}info \texinfoversion\par
63 \global\parindent=0pt % Steve likes it this way
66 @vskip 0pt plus 1filll
67 Copyright @copyright{} 1991, 2001, 2003, 2006, 2008 Free Software Foundation, Inc.
69 Permission is granted to copy, distribute and/or modify this document
70 under the terms of the GNU Free Documentation License, Version 1.3
71 or any later version published by the Free Software Foundation;
72 with no Invariant Sections, with no Front-Cover Texts, and with no
73 Back-Cover Texts. A copy of the license is included in the
74 section entitled ``GNU Free Documentation License''.
80 @node Top, Overview, (dir), (dir)
82 This file documents the binary file descriptor library libbfd.
86 * Overview:: Overview of BFD
87 * BFD front end:: BFD front end
88 * BFD back ends:: BFD back ends
89 * GNU Free Documentation License:: GNU Free Documentation License
90 * BFD Index:: BFD Index
93 @node Overview, BFD front end, Top, Top
97 BFD is a package which allows applications to use the
98 same routines to operate on object files whatever the object file
99 format. A new object file format can be supported simply by
100 creating a new BFD back end and adding it to the library.
102 BFD is split into two parts: the front end, and the back ends (one for
103 each object file format).
105 @item The front end of BFD provides the interface to the user. It manages
106 memory and various canonical data structures. The front end also
107 decides which back end to use and when to call back end routines.
108 @item The back ends provide BFD its view of the real world. Each back
109 end provides a set of calls which the BFD front end can use to maintain
110 its canonical form. The back ends also may keep around information for
111 their own use, for greater efficiency.
115 * How It Works:: How It Works
116 * What BFD Version 2 Can Do:: What BFD Version 2 Can Do
119 @node History, How It Works, Overview, Overview
122 One spur behind BFD was the desire, on the part of the GNU 960 team at
123 Intel Oregon, for interoperability of applications on their COFF and
124 b.out file formats. Cygnus was providing GNU support for the team, and
125 was contracted to provide the required functionality.
127 The name came from a conversation David Wallace was having with Richard
128 Stallman about the library: RMS said that it would be quite hard---David
129 said ``BFD''. Stallman was right, but the name stuck.
131 At the same time, Ready Systems wanted much the same thing, but for
132 different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k
135 BFD was first implemented by members of Cygnus Support; Steve
136 Chamberlain (@code{sac@@cygnus.com}), John Gilmore
137 (@code{gnu@@cygnus.com}), K. Richard Pixley (@code{rich@@cygnus.com})
138 and David Henkel-Wallace (@code{gumby@@cygnus.com}).
142 @node How It Works, What BFD Version 2 Can Do, History, Overview
143 @section How To Use BFD
145 To use the library, include @file{bfd.h} and link with @file{libbfd.a}.
147 BFD provides a common interface to the parts of an object file
148 for a calling application.
150 When an application successfully opens a target file (object, archive, or
151 whatever), a pointer to an internal structure is returned. This pointer
152 points to a structure called @code{bfd}, described in
153 @file{bfd.h}. Our convention is to call this pointer a BFD, and
154 instances of it within code @code{abfd}. All operations on
155 the target object file are applied as methods to the BFD. The mapping is
156 defined within @code{bfd.h} in a set of macros, all beginning
157 with @samp{bfd_} to reduce namespace pollution.
159 For example, this sequence does what you would probably expect:
160 return the number of sections in an object file attached to a BFD
167 unsigned int number_of_sections (abfd)
170 return bfd_count_sections (abfd);
175 The abstraction used within BFD is that an object file has:
181 a number of sections containing raw data (@pxref{Sections}),
183 a set of relocations (@pxref{Relocations}), and
185 some symbol information (@pxref{Symbols}).
188 Also, BFDs opened for archives have the additional attribute of an index
189 and contain subordinate BFDs. This approach is fine for a.out and coff,
190 but loses efficiency when applied to formats such as S-records and
193 @node What BFD Version 2 Can Do, , How It Works, Overview
194 @section What BFD Version 2 Can Do
195 @include bfdsumm.texi
197 @node BFD front end, BFD back ends, Overview, Top
198 @chapter BFD Front End
213 * Opening and Closing::
220 @node Memory Usage, Initialization, BFD front end, BFD front end
221 @section Memory Usage
222 BFD keeps all of its internal structures in obstacks. There is one obstack
223 per open BFD file, into which the current state is stored. When a BFD is
224 closed, the obstack is deleted, and so everything which has been
225 allocated by BFD for the closing file is thrown away.
227 BFD does not free anything created by an application, but pointers into
228 @code{bfd} structures become invalid on a @code{bfd_close}; for example,
229 after a @code{bfd_close} the vector passed to
230 @code{bfd_canonicalize_symtab} is still around, since it has been
231 allocated by the application, but the data that it pointed to are
234 The general rule is to not close a BFD until all operations dependent
235 upon data from the BFD have been completed, or all the data from within
236 the file has been copied. To help with the management of memory, there
237 is a function (@code{bfd_alloc_size}) which returns the number of bytes
238 in obstacks associated with the supplied BFD. This could be used to
239 select the greediest open BFD, close it to reclaim the memory, perform
240 some operation and reopen the BFD again, to get a fresh copy of the data
243 @node Initialization, Sections, Memory Usage, BFD front end
246 @node Sections, Symbols, Initialization, BFD front end
247 @include section.texi
249 @node Symbols, Archives, Sections, BFD front end
252 @node Archives, Formats, Symbols, BFD front end
253 @include archive.texi
255 @node Formats, Relocations, Archives, BFD front end
258 @node Relocations, Core Files, Formats, BFD front end
261 @node Core Files, Targets, Relocations, BFD front end
264 @node Targets, Architectures, Core Files, BFD front end
265 @include targets.texi
267 @node Architectures, Opening and Closing, Targets, BFD front end
268 @include archures.texi
270 @node Opening and Closing, Internal, Architectures, BFD front end
273 @node Internal, File Caching, Opening and Closing, BFD front end
276 @node File Caching, Linker Functions, Internal, BFD front end
279 @node Linker Functions, Hash Tables, File Caching, BFD front end
282 @node Hash Tables, , Linker Functions, BFD front end
285 @node BFD back ends, GNU Free Documentation License, BFD front end, Top
286 @chapter BFD back ends
288 * What to Put Where::
289 * aout :: a.out backends
290 * coff :: coff backends
291 * elf :: elf backends
294 * oasys :: oasys backends
295 * ieee :: ieee backend
296 * srecord :: s-record backend
299 @node What to Put Where, aout, BFD back ends, BFD back ends
300 @section What to Put Where
301 All of BFD lives in one directory.
303 @node aout, coff, What to Put Where, BFD back ends
306 @node coff, elf, aout, BFD back ends
307 @include coffcode.texi
309 @node elf, mmo, coff, BFD back ends
311 @c Leave this out until the file has some actual contents...
312 @c @include elfcode.texi
314 @node mmo, , elf, BFD back ends
317 @node GNU Free Documentation License, BFD Index, BFD back ends, Top
320 @node BFD Index, , GNU Free Documentation License, Top
321 @unnumbered BFD Index
325 % I think something like @colophon should be in texinfo. In the
327 \long\def\colophon{\hbox to0pt{}\vfill
328 \centerline{The body of this manual is set in}
329 \centerline{\fontname\tenrm,}
330 \centerline{with headings in {\bf\fontname\tenbf}}
331 \centerline{and examples in {\tt\fontname\tentt}.}
332 \centerline{{\it\fontname\tenit\/} and}
333 \centerline{{\sl\fontname\tensl\/}}
334 \centerline{are used for emphasis.}\vfill}
336 % Blame: doc@cygnus.com, 28mar91.