]> Git Repo - binutils.git/blame - bfd/bfd.texinfo
* all files: update copyright notices for GPL version 2.
[binutils.git] / bfd / bfd.texinfo
CommitLineData
2013f9b4
SC
1\input cyginfo
2@c\input texinfo
3@setfilename bfdinfo
4@c $Id$
5@synindex ky cp
6@ifinfo
7This file documents the BFD library.
8
9Copyright (C) 1991 Cygnus Support.
10
11Permission is granted to make and distribute verbatim copies of
12this manual provided the copyright notice and this permission notice
13are preserved on all copies.
14
15@ignore
16Permission is granted to process this file through Tex and print the
17results, provided the printed document carries copying permission
18notice identical to this one except for the removal of this paragraph
19(this paragraph not being relevant to the printed manual).
20
21@end ignore
22Permission is granted to copy and distribute modified versions of this
23manual under the conditions for verbatim copying, provided also that the
24section entitled ``GNU General Public License'' is included exactly as
25in the original, and provided that the entire resulting derived work is
26distributed under the terms of a permission notice identical to this
27one.
28
29Permission is granted to copy and distribute translations of this manual
30into another language, under the above conditions for modified versions,
31except that the section entitled ``GNU General Public License'' may be
32included in a translation approved by the author instead of in the
33original English.
34@end ifinfo
35@iftex
36@c this removes the gaps around @examples
37
38@c@finalout
39@c@setchapternewpage odd
990778ee 40@settitle LIB BFD, the Binary File Descriptor Library
2013f9b4
SC
41@titlepage
42@title{libbfd}
990778ee 43@subtitle{The Binary File Descriptor Library}
2013f9b4
SC
44@sp 1
45@subtitle First Edition---@code{bfd} version < 2.0
46@subtitle April 1991
47@author {Steve Chamberlain}
48@author {Cygnus Support}
49@page
50
51@tex
52\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
53\xdef\manvers{\$Revision$} % For use in headers, footers too
54{\parskip=0pt
55\hfill Cygnus Support\par
56\hfill steve\@cygnus.com\par
57\hfill {\it BFD}, \manvers\par
58\hfill \TeX{}info \texinfoversion\par
59}
60\global\parindent=0pt % Steve likes it this way
61@end tex
62
63@vskip 0pt plus 1filll
64Copyright @copyright{} 1991 Cygnus Support.
65
66Permission is granted to make and distribute verbatim copies of
67this manual provided the copyright notice and this permission notice
68are preserved on all copies.
69
70Permission is granted to copy and distribute modified versions of this
71manual under the conditions for verbatim copying, provided also that
72the entire resulting derived work is distributed under the terms of a
73permission notice identical to this one.
74
75Permission is granted to copy and distribute translations of this manual
76into another language, under the above conditions for modified versions.
77@end titlepage
78@end iftex
79@c FIXME: Talk about importance of *order* of args, cmds to linker!
80
81@node Top, Overview, (dir), (dir)
82@ifinfo
83This file documents the binary file descriptor library libbfd.
84@end ifinfo
85
86@menu
87* Overview:: Overview of bfd
88* History:: History of bfd
89* Backends:: Backends
90* Porting:: Porting
91* Future:: Future
92* Index:: Index
93
94BFD body:
95* Sections::
96* Symbols::
97* Archives::
98* Formats::
99* Relocations::
100* Core Files::
101* Targets::
102* Architecturs::
103* Opening and Closing::
104* Internal::
105* File Caching::
106
107Bfd backends:
108* a.out backends::
109* coff backends::
110@end menu
111
112@node Overview, History, Top, Top
113@chapter Introduction
114@cindex BFD
115@cindex what is it?
116Simply put, @code{bfd} is a package which allow applications to use the
117same routines to operate on object files whatever the object file
118format. A different object file format can be supported simply by
119creating a new BFD back end and adding it to the library.
120
121BFD is split into two parts; the front end and the many back ends.
122@itemize @bullet
123@item The front end of bfd provides the interface to the user. It manages
124memory, and various canonical data structures. The front end also
125decides which back end to use, and when to call back end routines.
126@item The back ends provide bfd its view of the real world. Each back
127end provides a set of calls which the bfd front end can use to maintain
128its canonical form. The back ends also may keep around information for
129their own use, for greater efficiency.
130@end itemize
131@node History, How It Works, Overview,Top
132@section History
133
2013f9b4
SC
134One spur behind @code{bfd} was the Intel Oregon's GNU 960 team desire for
135interoperability of applications on their COFF and b.out file formats.
136Cygnus was providing GNU support for the team, and Cygnus were
137contracted to provid the required functionality.
138
139The name came from a conversation Gumby Wallace was
140having with Richard Stallman about the library, RMS said that it
141would be quite hard, Gumby said BFD. (Stallman was right, but the name
142stuck).
143
144At the same time, Ready Systems wanted much the same thing, but for
145different object file formats, IEEE-695, Oasys, Srecords, a.out and 68k coff.
146
147BFD was first implemented by Steve Chamberlain (steve@@cygnus.com),
148John Gilmore (gnu@@cygnus.com), K. Richard Pixley (rich@@cygnus.com) and
990778ee
JG
149Gumby Wallace (gumby@@cygnus.com) at Cygnus Support in Palo Alto,
150California.
2013f9b4
SC
151
152@node How It Works, History, Porting, Top
153@section How It Works
154@code{bfd} provides a common interface to the parts of an object file
155to a calling application.
156
157When an application sucessfully opens a
158target file (object, archive or whatever) a pointer to an internal
159structure is returned. This pointer points to structure described in
160@code{include/bfd.h}, called @code{bfd}. Conventionally this pointer is
161called a @code{bfd}, and instances of it within code are called
162@code{abfd}. All operations on the target object file are applied as
163methods to the @code{bfd}, the mapping is defined within @code{bfd.h} in
164a set of macros, all beginning @code{bfd}_something.
165
166For example, this sequence would do what you expect:
167@tex
168\globaldefs=1
169\def\example{\begingroup\inENV %This group ends at the end of the @lisp body
170\hfuzz=12truept % Don't be fussy
171% Make spaces be word-separators rather than space tokens.
172\sepspaces %
173% Single space lines
174\singlespace %
175% The following causes blank lines not to be ignored
176% by adding a space to the end of each line.
177\let\par=\lisppar
178\def\Eexample{\endgroup}%
179\parskip=0pt
180\advance \leftskip by \lispnarrowing
181\parindent=0pt
182\let\exdent=\internalexdent
183\obeyspaces \obeylines \tt \rawbackslash
184\def\next##1{}\next}
185\globaldefs=0
186@end tex
187
188@lisp
189@w{
190#include "bfd.h"
191
192unsigned int number_of_sections(abfd)
193bfd *abfd;
194@{
195 return bfd_count_sections(abfd);
196@}
197}
198@end lisp
199
200The metaphor used within @code{bfd} is that an object file has a header,
201a numbber of sections containing raw data, a set of relocations and some
202symbol information. Also, @code{bfd}s opened upon archives have the
203additional attribute of an index and contained sub bfds. This approach is
204find for a.out and coff, but looses efficiency when applied to formats
205such as S-records and IEEE-695.
206
207@section What BFD Version 1 Can't Do
208As different information from the the object files is required,
209BFD reads from different sections of the file and processes them.
210For example a very common operation for the linker is processing symbol
211tables. Each BFD back end provides a routine for converting
212between the object file's representation of symbols and an internal
213canonical format. When the linker asks for the symbol table of an object
214file, it calls through the memory pointer to the relevant BFD
215back end routine which reads and converts the table into a canonical
216form. The linker then operates upon the common form. When the link is
217finished and the linker writes the symbol table of the output file,
218another BFD back end routine is called which takes the newly
219created symbol table and converts it into the chosen output format.
220
221@node BFD information loss, Mechanism, BFD outline, BFD
222@subsection Information Loss
223@emph{Some information is lost due to the nature of the file format.} The output targets
224supported by BFD do not provide identical facilities, and
225information which may be described in one form has nowhere to go in
226another format. One example of this is alignment information in
227@code{b.out}. There is nowhere in an @code{a.out} format file to store
228alignment information on the contained data, so when a file is linked
229from @code{b.out} and an @code{a.out} image is produced, alignment
230information will not propagate to the output file. (The linker will
231still use the alignment information internally, so the link is performed
232correctly).
233
234Another example is COFF section names. COFF files may contain an
235unlimited number of sections, each one with a textual section name. If
236the target of the link is a format which does not have many sections (eg
237@code{a.out}) or has sections without names (eg the Oasys format) the
238link cannot be done simply. You can circumvent this problem by
239describing the desired input-to-output section mapping with the linker command
240language.
241
242@emph{Information can be lost during canonicalization.} The BFD
243internal canonical form of the external formats is not exhaustive; there
244are structures in input formats for which there is no direct
245representation internally. This means that the BFD back ends
246cannot maintain all possible data richness through the transformation
247between external to internal and back to external formats.
248
249This limitation is only a problem when using the linker to read one
250 format and write another. Each BFD back end is responsible for
251maintaining as much data as possible, and the internal BFD
252canonical form has structures which are opaque to the BFD core,
253and exported only to the back ends. When a file is read in one format,
254the canonical form is generated for BFD and the linker. At the
255same time, the back end saves away any information which may otherwise
256be lost. If the data is then written back in the same format, the back
257end routine will be able to use the canonical form provided by the
258BFD core as well as the information it prepared earlier. Since
259there is a great deal of commonality between back ends, this mechanism
260is very useful. There is no information lost for this reason when
261linking big endian COFF to little endian COFF, or from @code{a.out} to
262@code{b.out}. When a mixture of formats is linked, the information is
263only lost from the files whose format differs from the destination.
264
265@node Mechanism, , BFD information loss, BFD
266@subsection Mechanism
267The greatest potential for loss of information is when there is least
268overlap between the information provided by the source format, that
269stored by the canonical format, and the information needed by the
270destination format. A brief description of the canonical form may help
271you appreciate what kinds of data you can count on preserving across
272conversions.
273@cindex BFD canonical format
274@cindex internal object-file format
275
276@table @emph
277@item files
278Information on target machine architecture, particular implementation
279and format type are stored on a per-file basis. Other information
280includes a demand pageable bit and a write protected bit. Note that
281information like Unix magic numbers is not stored here---only the magic
282numbers' meaning, so a @code{ZMAGIC} file would have both the demand pageable
283bit and the write protected text bit set.
284
285The byte order of the target is stored on a per-file basis, so that big-
286and little-endian object files may be linked with one another.
287
288@item sections
289Each section in the input file contains the name of the section, the
290original address in the object file, various flags, size and alignment
291information and pointers into other BFD data structures.
292
293@item symbols
294Each symbol contains a pointer to the object file which originally
295defined it, its name, its value, and various flag bits. When a
296BFD back end reads in a symbol table, the back end relocates all
297symbols to make them relative to the base of the section where they were
298defined. This ensures that each symbol points to its containing
299section. Each symbol also has a varying amount of hidden data to contain
300private data for the BFD back end. Since the symbol points to the
301original file, the private data format for that symbol is accessible.
302@code{gld} can operate on a collection of symbols of wildly different
303formats without problems.
304
305Normal global and simple local symbols are maintained on output, so an
306output file (no matter its format) will retain symbols pointing to
307functions and to global, static, and common variables. Some symbol
308information is not worth retaining; in @code{a.out} type information is
309stored in the symbol table as long symbol names. This information would
310be useless to most COFF debuggers and may be thrown away with
311appropriate command line switches. (The GNU debugger @code{gdb} does
312support @code{a.out} style debugging information in COFF).
313
314There is one word of type information within the symbol, so if the
315format supports symbol type information within symbols (for example COFF,
316IEEE, Oasys) and the type is simple enough to fit within one word
317(nearly everything but aggregates) the information will be preserved.
318
319@item relocation level
320Each canonical BFD relocation record contains a pointer to the symbol to
321relocate to, the offset of the data to relocate, the section the data
322is in and a pointer to a relocation type descriptor. Relocation is
323performed effectively by message passing through the relocation type
324descriptor and symbol pointer. It allows relocations to be performed
325on output data using a relocation method only available in one of the
326input formats. For instance, Oasys provides a byte relocation format.
327A relocation record requesting this relocation type would point
328indirectly to a routine to perform this, so the relocation may be
329performed on a byte being written to a COFF file, even though 68k COFF
330has no such relocation type.
331
332@item line numbers
333Object formats can contain, for debugging purposes, some form of mapping
334between symbols, source line numbers, and addresses in the output file.
335These addresses have to be relocated along with the symbol information.
336Each symbol with an associated list of line number records points to the
337first record of the list. The head of a line number list consists of a
338pointer to the symbol, which allows divination of the address of the
339function whose line number is being described. The rest of the list is
340made up of pairs: offsets into the section and line numbers. Any format
341which can simply derive this information can pass it successfully
342between formats (COFF, IEEE and Oasys).
343@end table
344
345
346What is a backend
347@node BFD front end, BFD back end, Mechanism, Top
348@page
349@chapter BFD front end
350@include doc/bfd.doc
351@page
352@node Sections, Symbols , bfd, Top
353@include doc/section.doc
354@page
355@node Symbols, Archives ,Sections, To
356@include doc/syms.doc
357@page
358@node Archives, Formats, Symbols, Top
359@include doc/archive.doc
360@page
361@node Formats, Relocations, Archives, Top
362@include doc/format.doc
363@page
364@node Relocations, Core Files,Formats, Top
365@include doc/reloc.doc
366@page
367@node Core Files, Targets, Relocations, Top
368@include doc/core.doc
369@page
370@node Targets, Architectures, Core Files, Top
371@include doc/targets.doc
372@page
373@node Architectures, Opening and Closing, Targets, Top
374@include doc/archures.doc
375@page
376@node Opening and Closing, Internal, Architectures, Top
377@include doc/opncls.doc
378@page
379@node Internal, File Caching, Opening and Closing, Top
380@include doc/libbfd.doc
381@page
382@node File Caching, Top, Internal, Top
383@include doc/cache.doc
384@page
385@chapter BFD back end
386@node BFD back end, ,BFD front end, Top
387@menu
388* What to put where
389* a.out backends::
390* coff backends::
391* oasys backend::
392* ieee backend::
393* srecord backend::
394@end menu
395@node What to Put Where, aout backends, BFD back end, BFD back end
396All of bfd lives in one directory.
397@page
398@node aout backends, coff backends, What to Put Where, BFD back end
399@include doc/aoutx.doc
400@page
401@node coff backends, oasys backends, aout backends, BFD back end
402@include doc/coffcode.doc
403@page
404@node Index, , BFD, Top
405@unnumbered Function Index
406@printindex fn
407@setchapternewpage on
408@unnumbered Index
409@printindex cp
410
411@tex
412% I think something like @colophon should be in texinfo. In the
413% meantime:
414\long\def\colophon{\hbox to0pt{}\vfill
415\centerline{The body of this manual is set in}
416\centerline{\fontname\tenrm,}
417\centerline{with headings in {\bf\fontname\tenbf}}
418\centerline{and examples in {\tt\fontname\tentt}.}
419\centerline{{\it\fontname\tenit\/} and}
420\centerline{{\sl\fontname\tensl\/}}
421\centerline{are used for emphasis.}\vfill}
422\page\colophon
423% Blame: [email protected], 28mar91.
424@end tex
425
426
427@contents
428@bye
429
430
This page took 0.06588 seconds and 4 git commands to generate.