bfd.texi revision 1.1.1.2.2.1 1 1.1 christos \input texinfo.tex
2 1.1 christos @setfilename bfd.info
3 1.1.1.2.2.1 perseant @c Copyright (C) 1988-2022 Free Software Foundation, Inc.
4 1.1 christos @c
5 1.1 christos @synindex fn cp
6 1.1 christos
7 1.1 christos @ifnottex
8 1.1 christos @dircategory Software development
9 1.1 christos @direntry
10 1.1 christos * Bfd: (bfd). The Binary File Descriptor library.
11 1.1 christos @end direntry
12 1.1 christos @end ifnottex
13 1.1 christos
14 1.1 christos @copying
15 1.1 christos This file documents the BFD library.
16 1.1 christos
17 1.1.1.2.2.1 perseant Copyright @copyright{} 1991-2022 Free Software Foundation, Inc.
18 1.1 christos
19 1.1 christos Permission is granted to copy, distribute and/or modify this document
20 1.1 christos under the terms of the GNU Free Documentation License, Version 1.3 or
21 1.1 christos any later version published by the Free Software Foundation; with the
22 1.1 christos Invariant Sections being ``GNU General Public License'' and ``Funding
23 1.1 christos Free Software'', the Front-Cover texts being (a) (see below), and with
24 1.1 christos the Back-Cover Texts being (b) (see below). A copy of the license is
25 1.1 christos included in the section entitled ``GNU Free Documentation License''.
26 1.1 christos
27 1.1 christos (a) The FSF's Front-Cover Text is:
28 1.1 christos
29 1.1 christos A GNU Manual
30 1.1 christos
31 1.1 christos (b) The FSF's Back-Cover Text is:
32 1.1 christos
33 1.1 christos You have freedom to copy and modify this GNU Manual, like GNU
34 1.1 christos software. Copies published by the Free Software Foundation raise
35 1.1 christos funds for GNU development.
36 1.1 christos @end copying
37 1.1 christos @iftex
38 1.1 christos @c@finalout
39 1.1 christos @setchapternewpage on
40 1.1 christos @c@setchapternewpage odd
41 1.1 christos @settitle LIB BFD, the Binary File Descriptor Library
42 1.1 christos @titlepage
43 1.1 christos @title{libbfd}
44 1.1 christos @subtitle{The Binary File Descriptor Library}
45 1.1 christos @sp 1
46 1.1 christos @subtitle First Edition---BFD version < 3.0 % Since no product is stable before version 3.0 :-)
47 1.1 christos @subtitle Original Document Created: April 1991
48 1.1 christos @author {Steve Chamberlain}
49 1.1 christos @author {Cygnus Support}
50 1.1 christos @page
51 1.1 christos
52 1.1 christos @tex
53 1.1 christos \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
54 1.1 christos \xdef\manvers{1.5} % For use in headers, footers too
55 1.1 christos {\parskip=0pt
56 1.1 christos \hfill Free Software Foundation\par
57 1.1 christos \hfill sac\@www.gnu.org\par
58 1.1 christos \hfill {\it BFD}, \manvers\par
59 1.1 christos \hfill \TeX{}info \texinfoversion\par
60 1.1 christos }
61 1.1 christos \global\parindent=0pt % Steve likes it this way
62 1.1 christos @end tex
63 1.1 christos
64 1.1 christos @vskip 0pt plus 1filll
65 1.1.1.2.2.1 perseant Copyright @copyright{} 1991-2022 Free Software Foundation, Inc.
66 1.1 christos
67 1.1 christos Permission is granted to copy, distribute and/or modify this document
68 1.1 christos under the terms of the GNU Free Documentation License, Version 1.3
69 1.1 christos or any later version published by the Free Software Foundation;
70 1.1 christos with no Invariant Sections, with no Front-Cover Texts, and with no
71 1.1 christos Back-Cover Texts. A copy of the license is included in the
72 1.1 christos section entitled ``GNU Free Documentation License''.
73 1.1 christos
74 1.1 christos @end titlepage
75 1.1 christos @end iftex
76 1.1 christos @contents
77 1.1 christos
78 1.1 christos @node Top, Overview, (dir), (dir)
79 1.1 christos @ifinfo
80 1.1 christos This file documents the binary file descriptor library libbfd.
81 1.1 christos @end ifinfo
82 1.1 christos
83 1.1 christos @menu
84 1.1 christos * Overview:: Overview of BFD
85 1.1 christos * BFD front end:: BFD front end
86 1.1 christos * BFD back ends:: BFD back ends
87 1.1 christos * GNU Free Documentation License:: GNU Free Documentation License
88 1.1 christos * BFD Index:: BFD Index
89 1.1 christos @end menu
90 1.1 christos
91 1.1 christos @node Overview, BFD front end, Top, Top
92 1.1 christos @chapter Introduction
93 1.1 christos @cindex BFD
94 1.1 christos @cindex what is it?
95 1.1 christos BFD is a package which allows applications to use the
96 1.1 christos same routines to operate on object files whatever the object file
97 1.1 christos format. A new object file format can be supported simply by
98 1.1 christos creating a new BFD back end and adding it to the library.
99 1.1 christos
100 1.1 christos BFD is split into two parts: the front end, and the back ends (one for
101 1.1 christos each object file format).
102 1.1 christos @itemize @bullet
103 1.1 christos @item The front end of BFD provides the interface to the user. It manages
104 1.1 christos memory and various canonical data structures. The front end also
105 1.1 christos decides which back end to use and when to call back end routines.
106 1.1 christos @item The back ends provide BFD its view of the real world. Each back
107 1.1 christos end provides a set of calls which the BFD front end can use to maintain
108 1.1 christos its canonical form. The back ends also may keep around information for
109 1.1 christos their own use, for greater efficiency.
110 1.1 christos @end itemize
111 1.1 christos @menu
112 1.1 christos * History:: History
113 1.1 christos * How It Works:: How It Works
114 1.1 christos * What BFD Version 2 Can Do:: What BFD Version 2 Can Do
115 1.1 christos @end menu
116 1.1 christos
117 1.1 christos @node History, How It Works, Overview, Overview
118 1.1 christos @section History
119 1.1 christos
120 1.1 christos One spur behind BFD was the desire, on the part of the GNU 960 team at
121 1.1 christos Intel Oregon, for interoperability of applications on their COFF and
122 1.1 christos b.out file formats. Cygnus was providing GNU support for the team, and
123 1.1 christos was contracted to provide the required functionality.
124 1.1 christos
125 1.1 christos The name came from a conversation David Wallace was having with Richard
126 1.1 christos Stallman about the library: RMS said that it would be quite hard---David
127 1.1 christos said ``BFD''. Stallman was right, but the name stuck.
128 1.1 christos
129 1.1 christos At the same time, Ready Systems wanted much the same thing, but for
130 1.1 christos different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k
131 1.1 christos coff.
132 1.1 christos
133 1.1 christos BFD was first implemented by members of Cygnus Support; Steve
134 1.1 christos Chamberlain (@code{sac@@cygnus.com}), John Gilmore
135 1.1 christos (@code{gnu@@cygnus.com}), K. Richard Pixley (@code{rich@@cygnus.com})
136 1.1 christos and David Henkel-Wallace (@code{gumby@@cygnus.com}).
137 1.1 christos
138 1.1 christos
139 1.1 christos
140 1.1 christos @node How It Works, What BFD Version 2 Can Do, History, Overview
141 1.1 christos @section How To Use BFD
142 1.1 christos
143 1.1 christos To use the library, include @file{bfd.h} and link with @file{libbfd.a}.
144 1.1 christos
145 1.1 christos BFD provides a common interface to the parts of an object file
146 1.1 christos for a calling application.
147 1.1 christos
148 1.1 christos When an application successfully opens a target file (object, archive, or
149 1.1 christos whatever), a pointer to an internal structure is returned. This pointer
150 1.1 christos points to a structure called @code{bfd}, described in
151 1.1 christos @file{bfd.h}. Our convention is to call this pointer a BFD, and
152 1.1 christos instances of it within code @code{abfd}. All operations on
153 1.1 christos the target object file are applied as methods to the BFD. The mapping is
154 1.1 christos defined within @code{bfd.h} in a set of macros, all beginning
155 1.1 christos with @samp{bfd_} to reduce namespace pollution.
156 1.1 christos
157 1.1 christos For example, this sequence does what you would probably expect:
158 1.1 christos return the number of sections in an object file attached to a BFD
159 1.1 christos @code{abfd}.
160 1.1 christos
161 1.1 christos @example
162 1.1 christos @c @cartouche
163 1.1 christos #include "bfd.h"
164 1.1 christos
165 1.1 christos unsigned int number_of_sections (abfd)
166 1.1 christos bfd *abfd;
167 1.1 christos @{
168 1.1 christos return bfd_count_sections (abfd);
169 1.1 christos @}
170 1.1 christos @c @end cartouche
171 1.1 christos @end example
172 1.1 christos
173 1.1 christos The abstraction used within BFD is that an object file has:
174 1.1 christos
175 1.1 christos @itemize @bullet
176 1.1 christos @item
177 1.1 christos a header,
178 1.1 christos @item
179 1.1 christos a number of sections containing raw data (@pxref{Sections}),
180 1.1 christos @item
181 1.1 christos a set of relocations (@pxref{Relocations}), and
182 1.1 christos @item
183 1.1 christos some symbol information (@pxref{Symbols}).
184 1.1 christos @end itemize
185 1.1 christos @noindent
186 1.1 christos Also, BFDs opened for archives have the additional attribute of an index
187 1.1 christos and contain subordinate BFDs. This approach is fine for a.out and coff,
188 1.1 christos but loses efficiency when applied to formats such as S-records and
189 1.1 christos IEEE-695.
190 1.1 christos
191 1.1 christos @node What BFD Version 2 Can Do, , How It Works, Overview
192 1.1 christos @section What BFD Version 2 Can Do
193 1.1 christos @include bfdsumm.texi
194 1.1 christos
195 1.1 christos @node BFD front end, BFD back ends, Overview, Top
196 1.1 christos @chapter BFD Front End
197 1.1 christos
198 1.1 christos @menu
199 1.1 christos * typedef bfd::
200 1.1 christos * Error reporting::
201 1.1 christos * Miscellaneous::
202 1.1 christos * Memory Usage::
203 1.1 christos * Initialization::
204 1.1 christos * Sections::
205 1.1 christos * Symbols::
206 1.1 christos * Archives::
207 1.1 christos * Formats::
208 1.1 christos * Relocations::
209 1.1 christos * Core Files::
210 1.1 christos * Targets::
211 1.1 christos * Architectures::
212 1.1 christos * Opening and Closing::
213 1.1 christos * Internal::
214 1.1 christos * File Caching::
215 1.1 christos * Linker Functions::
216 1.1 christos * Hash Tables::
217 1.1 christos @end menu
218 1.1 christos
219 1.1 christos @include bfdt.texi
220 1.1 christos @include bfdio.texi
221 1.1 christos
222 1.1 christos @node Memory Usage, Initialization, Miscellaneous, BFD front end
223 1.1 christos @section Memory Usage
224 1.1 christos BFD keeps all of its internal structures in obstacks. There is one obstack
225 1.1 christos per open BFD file, into which the current state is stored. When a BFD is
226 1.1 christos closed, the obstack is deleted, and so everything which has been
227 1.1 christos allocated by BFD for the closing file is thrown away.
228 1.1 christos
229 1.1 christos BFD does not free anything created by an application, but pointers into
230 1.1 christos @code{bfd} structures become invalid on a @code{bfd_close}; for example,
231 1.1 christos after a @code{bfd_close} the vector passed to
232 1.1 christos @code{bfd_canonicalize_symtab} is still around, since it has been
233 1.1 christos allocated by the application, but the data that it pointed to are
234 1.1 christos lost.
235 1.1 christos
236 1.1 christos The general rule is to not close a BFD until all operations dependent
237 1.1 christos upon data from the BFD have been completed, or all the data from within
238 1.1 christos the file has been copied. To help with the management of memory, there
239 1.1 christos is a function (@code{bfd_alloc_size}) which returns the number of bytes
240 1.1 christos in obstacks associated with the supplied BFD. This could be used to
241 1.1 christos select the greediest open BFD, close it to reclaim the memory, perform
242 1.1 christos some operation and reopen the BFD again, to get a fresh copy of the data
243 1.1 christos structures.
244 1.1 christos
245 1.1 christos @node Initialization, Sections, Memory Usage, BFD front end
246 1.1 christos @include init.texi
247 1.1 christos
248 1.1 christos @node Sections, Symbols, Initialization, BFD front end
249 1.1 christos @include section.texi
250 1.1 christos
251 1.1 christos @node Symbols, Archives, Sections, BFD front end
252 1.1 christos @include syms.texi
253 1.1 christos
254 1.1 christos @node Archives, Formats, Symbols, BFD front end
255 1.1 christos @include archive.texi
256 1.1 christos
257 1.1 christos @node Formats, Relocations, Archives, BFD front end
258 1.1 christos @include format.texi
259 1.1 christos
260 1.1 christos @node Relocations, Core Files, Formats, BFD front end
261 1.1 christos @include reloc.texi
262 1.1 christos
263 1.1 christos @node Core Files, Targets, Relocations, BFD front end
264 1.1.1.2.2.1 perseant @include corefile.texi
265 1.1 christos
266 1.1 christos @node Targets, Architectures, Core Files, BFD front end
267 1.1 christos @include targets.texi
268 1.1 christos
269 1.1 christos @node Architectures, Opening and Closing, Targets, BFD front end
270 1.1 christos @include archures.texi
271 1.1 christos
272 1.1 christos @node Opening and Closing, Internal, Architectures, BFD front end
273 1.1 christos @include opncls.texi
274 1.1 christos
275 1.1 christos @node Internal, File Caching, Opening and Closing, BFD front end
276 1.1 christos @include libbfd.texi
277 1.1 christos
278 1.1 christos @node File Caching, Linker Functions, Internal, BFD front end
279 1.1 christos @include cache.texi
280 1.1 christos
281 1.1 christos @node Linker Functions, Hash Tables, File Caching, BFD front end
282 1.1 christos @include linker.texi
283 1.1 christos
284 1.1 christos @node Hash Tables, , Linker Functions, BFD front end
285 1.1 christos @include hash.texi
286 1.1 christos
287 1.1 christos @node BFD back ends, GNU Free Documentation License, BFD front end, Top
288 1.1 christos @chapter BFD back ends
289 1.1 christos @menu
290 1.1 christos * What to Put Where::
291 1.1 christos * aout :: a.out backends
292 1.1 christos * coff :: coff backends
293 1.1 christos * elf :: elf backends
294 1.1 christos * mmo :: mmo backend
295 1.1 christos @ignore
296 1.1 christos * srecord :: s-record backend
297 1.1 christos @end ignore
298 1.1 christos @end menu
299 1.1 christos @node What to Put Where, aout, BFD back ends, BFD back ends
300 1.1 christos @section What to Put Where
301 1.1 christos All of BFD lives in one directory.
302 1.1 christos
303 1.1 christos @node aout, coff, What to Put Where, BFD back ends
304 1.1 christos @include aoutx.texi
305 1.1 christos
306 1.1 christos @node coff, elf, aout, BFD back ends
307 1.1 christos @include coffcode.texi
308 1.1 christos
309 1.1 christos @node elf, mmo, coff, BFD back ends
310 1.1 christos @include elf.texi
311 1.1 christos @c Leave this out until the file has some actual contents...
312 1.1 christos @c @include elfcode.texi
313 1.1 christos
314 1.1 christos @node mmo, , elf, BFD back ends
315 1.1 christos @include mmo.texi
316 1.1 christos
317 1.1 christos @node GNU Free Documentation License, BFD Index, BFD back ends, Top
318 1.1 christos @include fdl.texi
319 1.1 christos
320 1.1 christos @node BFD Index, , GNU Free Documentation License, Top
321 1.1 christos @unnumbered BFD Index
322 1.1 christos @printindex cp
323 1.1 christos
324 1.1 christos @tex
325 1.1 christos % I think something like @@colophon should be in texinfo. In the
326 1.1 christos % meantime:
327 1.1 christos \long\def\colophon{\hbox to0pt{}\vfill
328 1.1 christos \centerline{The body of this manual is set in}
329 1.1 christos \centerline{\fontname\tenrm,}
330 1.1 christos \centerline{with headings in {\bf\fontname\tenbf}}
331 1.1 christos \centerline{and examples in {\tt\fontname\tentt}.}
332 1.1 christos \centerline{{\it\fontname\tenit\/} and}
333 1.1 christos \centerline{{\sl\fontname\tensl\/}}
334 1.1 christos \centerline{are used for emphasis.}\vfill}
335 1.1 christos \page\colophon
336 1.1 christos % Blame: doc@@cygnus.com, 28mar91.
337 1.1 christos @end tex
338 1.1 christos
339 1.1 christos @bye
340