binutils-gdb/bfd/doc/bfd.texinfo

344 lines
10 KiB
Plaintext
Raw Normal View History

1993-04-29 05:45:24 +02:00
\input texinfo.tex
1991-11-14 00:06:07 +01:00
@setfilename bfd.info
1991-08-22 21:56:14 +02:00
@c $Id$
1993-04-29 05:45:24 +02:00
@tex
% NOTE LOCAL KLUGE TO AVOID TOO MUCH WHITESPACE
\global\long\def\example{%
\begingroup
\let\aboveenvbreak=\par
\let\afterenvbreak=\par
\parskip=0pt
\lisp}
\global\long\def\Eexample{%
\Elisp
\endgroup
\vskip -\parskip% to cancel out effect of following \par
}
@end tex
1991-11-14 00:06:07 +01:00
@synindex fn cp
1991-11-27 20:28:39 +01:00
@ifinfo
@format
START-INFO-DIR-ENTRY
1993-08-09 22:31:30 +02:00
* Bfd:: The Binary File Descriptor library.
1991-11-27 20:28:39 +01:00
END-INFO-DIR-ENTRY
@end format
@end ifinfo
1991-08-22 21:56:14 +02:00
@ifinfo
This file documents the BFD library.
Copyright (C) 1991 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
@ignore
Permission is granted to process this file through Tex and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, subject to the terms
of the GNU General Public License, which includes the provision that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
@end ifinfo
@iftex
@c@finalout
@setchapternewpage on
@c@setchapternewpage odd
@settitle LIB BFD, the Binary File Descriptor Library
@titlepage
@title{libbfd}
@subtitle{The Binary File Descriptor Library}
@sp 1
1993-04-29 05:45:24 +02:00
@subtitle First Edition---BFD version < 3.0
1991-08-22 21:56:14 +02:00
@subtitle April 1991
@author {Steve Chamberlain}
@author {Cygnus Support}
@page
@tex
\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
\xdef\manvers{\$Revision$} % For use in headers, footers too
{\parskip=0pt
\hfill Cygnus Support\par
1993-04-29 05:45:24 +02:00
\hfill sac\@cygnus.com\par
1991-08-22 21:56:14 +02:00
\hfill {\it BFD}, \manvers\par
\hfill \TeX{}info \texinfoversion\par
}
\global\parindent=0pt % Steve likes it this way
@end tex
@vskip 0pt plus 1filll
Copyright @copyright{} 1991 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, subject to the terms
of the GNU General Public License, which includes the provision that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
@end titlepage
@end iftex
@node Top, Overview, (dir), (dir)
@ifinfo
This file documents the binary file descriptor library libbfd.
@end ifinfo
@menu
* Overview:: Overview of BFD
1991-11-14 00:06:07 +01:00
* BFD front end:: BFD front end
* BFD back end:: BFD back end
1991-08-22 21:56:14 +02:00
* Index:: Index
@end menu
1991-11-14 00:06:07 +01:00
@node Overview, BFD front end, Top, Top
1991-08-22 21:56:14 +02:00
@chapter Introduction
@cindex BFD
@cindex what is it?
1993-04-29 05:45:24 +02:00
BFD is a package which allows applications to use the
1991-08-22 21:56:14 +02:00
same routines to operate on object files whatever the object file
1993-04-29 05:45:24 +02:00
format. A new object file format can be supported simply by
1991-08-22 21:56:14 +02:00
creating a new BFD back end and adding it to the library.
1993-04-29 05:45:24 +02:00
BFD is split into two parts: the front end, and the back ends (one for
each object file format).
1991-08-22 21:56:14 +02:00
@itemize @bullet
@item The front end of BFD provides the interface to the user. It manages
1993-04-29 05:45:24 +02:00
memory and various canonical data structures. The front end also
decides which back end to use and when to call back end routines.
1991-08-22 21:56:14 +02:00
@item The back ends provide BFD its view of the real world. Each back
end provides a set of calls which the BFD front end can use to maintain
its canonical form. The back ends also may keep around information for
their own use, for greater efficiency.
@end itemize
1991-11-14 00:06:07 +01:00
@menu
* History:: History
* How It Works:: How It Works
1993-04-29 05:45:24 +02:00
* What BFD Version 2 Can Do:: What BFD Version 2 Can Do
1991-11-14 00:06:07 +01:00
@end menu
@node History, How It Works, Overview, Overview
1991-08-22 21:56:14 +02:00
@section History
One spur behind BFD was the desire, on the part of the GNU 960 team at
Intel Oregon, for interoperability of applications on their COFF and
b.out file formats. Cygnus was providing GNU support for the team, and
1993-04-29 05:45:24 +02:00
was contracted to provide the required functionality.
1991-08-22 21:56:14 +02:00
The name came from a conversation David Wallace was having with Richard
Stallman about the library: RMS said that it would be quite hard---David
said ``BFD''. Stallman was right, but the name stuck.
At the same time, Ready Systems wanted much the same thing, but for
different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k
coff.
1993-04-29 05:45:24 +02:00
BFD was first implemented by members of Cygnus Support; Steve
1993-08-09 22:31:30 +02:00
Chamberlain (@code{sac@@cygnus.com}), John Gilmore
(@code{gnu@@cygnus.com}), K. Richard Pixley (@code{rich@@cygnus.com})
and David Henkel-Wallace (@code{gumby@@cygnus.com}).
1993-04-29 05:45:24 +02:00
1991-08-22 21:56:14 +02:00
1993-04-29 05:45:24 +02:00
@node How It Works, What BFD Version 2 Can Do, History, Overview
@section How To Use BFD
1991-08-22 21:56:14 +02:00
1993-04-29 05:45:24 +02:00
To use the library, include @file{bfd.h} and link with @file{libbfd.a}.
1991-08-22 21:56:14 +02:00
BFD provides a common interface to the parts of an object file
for a calling application.
1993-04-29 05:45:24 +02:00
When an application sucessfully opens a target file (object, archive, or
1993-08-09 22:31:30 +02:00
whatever), a pointer to an internal structure is returned. This pointer
1991-08-22 21:56:14 +02:00
points to a structure called @code{bfd}, described in
1993-08-09 22:31:30 +02:00
@file{bfd.h}. Our convention is to call this pointer a BFD, and
1991-08-22 21:56:14 +02:00
instances of it within code @code{abfd}. All operations on
the target object file are applied as methods to the BFD. The mapping is
defined within @code{bfd.h} in a set of macros, all beginning
1993-04-29 05:45:24 +02:00
with @samp{bfd_} to reduce namespace pollution.
1991-08-22 21:56:14 +02:00
1993-04-29 05:45:24 +02:00
For example, this sequence does what you would probably expect:
1991-08-22 21:56:14 +02:00
return the number of sections in an object file attached to a BFD
@code{abfd}.
@lisp
1991-11-14 00:06:07 +01:00
@c @cartouche
1991-08-22 21:56:14 +02:00
#include "bfd.h"
unsigned int number_of_sections(abfd)
bfd *abfd;
@{
return bfd_count_sections(abfd);
@}
1991-11-14 00:06:07 +01:00
@c @end cartouche
1991-08-22 21:56:14 +02:00
@end lisp
1993-08-09 22:31:30 +02:00
The abstraction used within BFD is that an object file has:
@itemize @bullet
@item
a header,
@item
a number of sections containing raw data (@pxref{Sections}),
@item
a set of relocations (@pxref{Relocations}), and
@item
some symbol information (@pxref{Symbols}).
@end itemize
@noindent
Also, BFDs opened for archives have the additional attribute of an index
and contain subordinate BFDs. This approach is fine for a.out and coff,
but loses efficiency when applied to formats such as S-records and
IEEE-695.
1991-08-22 21:56:14 +02:00
1993-04-29 05:45:24 +02:00
@node What BFD Version 2 Can Do, , How It Works, Overview
@section What BFD Version 2 Can Do
1993-08-09 22:31:30 +02:00
@include bfdsumm.texi
1991-11-14 00:06:07 +01:00
@node BFD front end, BFD back end, Overview, Top
1991-08-22 21:56:14 +02:00
@chapter BFD front end
1993-08-09 22:31:30 +02:00
@include bfd.texi
1991-08-22 21:56:14 +02:00
1991-11-14 00:06:07 +01:00
@menu
* Memory Usage::
* Initialization::
* Sections::
* Symbols::
* Archives::
* Formats::
* Relocations::
* Core Files::
* Targets::
* Architectures::
* Opening and Closing::
* Constructors::
* Internal::
* File Caching::
@end menu
@node Memory Usage, Initialization, BFD front end, BFD front end
1991-08-22 21:56:14 +02:00
@section Memory Usage
BFD keeps all its internal structures in obstacks. There is one obstack
per open BFD file, into which the current state is stored. When a BFD is
closed, the obstack is deleted, and so everything which has been
1993-04-29 05:45:24 +02:00
allocated by @code{libbfd} for the closing file will be thrown away.
1991-08-22 21:56:14 +02:00
BFD will not free anything created by an application, but pointers into
@code{bfd} structures will be invalidated on a @code{bfd_close}; for example,
after a @code{bfd_close} the vector passed to
@code{bfd_canonicalize_symtab} will still be around, since it has been
allocated by the application, but the data that it pointed to will be
lost.
The general rule is not to close a BFD until all operations dependent
upon data from the BFD have been completed, or all the data from within
1993-04-29 05:45:24 +02:00
the file has been copied. To help with the management of memory, there
is a function (@code{bfd_alloc_size}) which returns the number of bytes
in obstacks associated with the supplied BFD. This could be used to
select the greediest open BFD, close it to reclaim the memory, perform
some operation and reopen the BFD again, to get a fresh copy of the data
structures.
1991-08-22 21:56:14 +02:00
1991-11-14 00:06:07 +01:00
@node Initialization, Sections, Memory Usage, BFD front end
@include init.texi
@node Sections, Symbols, Initialization, BFD front end
1991-08-22 21:56:14 +02:00
@include section.texi
1991-11-14 00:06:07 +01:00
@node Symbols, Archives, Sections, BFD front end
1991-08-22 21:56:14 +02:00
@include syms.texi
1991-11-14 00:06:07 +01:00
@node Archives, Formats, Symbols, BFD front end
1991-08-22 21:56:14 +02:00
@include archive.texi
1991-11-14 00:06:07 +01:00
@node Formats, Relocations, Archives, BFD front end
1991-08-22 21:56:14 +02:00
@include format.texi
1991-11-14 00:06:07 +01:00
@node Relocations, Core Files, Formats, BFD front end
1991-08-22 21:56:14 +02:00
@include reloc.texi
1991-11-14 00:06:07 +01:00
@node Core Files, Targets, Relocations, BFD front end
1991-08-22 21:56:14 +02:00
@include core.texi
1991-11-14 00:06:07 +01:00
@node Targets, Architectures, Core Files, BFD front end
1991-08-22 21:56:14 +02:00
@include targets.texi
1991-11-14 00:06:07 +01:00
@node Architectures, Opening and Closing, Targets, BFD front end
1991-08-22 21:56:14 +02:00
@include archures.texi
1991-11-14 00:06:07 +01:00
@node Opening and Closing, Constructors, Architectures, BFD front end
1991-08-22 21:56:14 +02:00
@include opncls.texi
1991-11-14 00:06:07 +01:00
@node Constructors, Internal, Opening and Closing, BFD front end
@include ctor.texi
@node Internal, File Caching, Constructors, BFD front end
1991-08-22 21:56:14 +02:00
@include libbfd.texi
1991-11-14 00:06:07 +01:00
@node File Caching, , Internal, BFD front end
1991-08-22 21:56:14 +02:00
@include cache.texi
1991-11-14 00:06:07 +01:00
@node BFD back end, Index, BFD front end, Top
1991-08-22 21:56:14 +02:00
@chapter BFD back end
@menu
1993-04-29 05:45:24 +02:00
* What to Put Where::
1991-11-14 00:06:07 +01:00
* aout :: a.out backends
* coff :: coff backends
1993-08-09 22:31:30 +02:00
* elf :: elf backends
1991-11-14 00:06:07 +01:00
@ignore
* oasys :: oasys backends
* ieee :: ieee backend
* srecord :: s-record backend
@end ignore
1991-08-22 21:56:14 +02:00
@end menu
1991-11-14 00:06:07 +01:00
@node What to Put Where, aout, BFD back end, BFD back end
1991-08-22 21:56:14 +02:00
All of BFD lives in one directory.
1991-11-14 00:06:07 +01:00
@node aout, coff, What to Put Where, BFD back end
1991-08-22 21:56:14 +02:00
@include aoutx.texi
1993-08-09 22:31:30 +02:00
@node coff, elf, aout, BFD back end
1991-08-22 21:56:14 +02:00
@include coffcode.texi
1993-08-09 22:31:30 +02:00
@node elf, , coff, BFD back end
@include elf.texi
@include elfcode.texi
1991-11-14 00:06:07 +01:00
@node Index, , BFD back end, Top
1991-08-22 21:56:14 +02:00
@unnumbered Index
@printindex cp
@tex
% I think something like @colophon should be in texinfo. In the
% meantime:
\long\def\colophon{\hbox to0pt{}\vfill
\centerline{The body of this manual is set in}
\centerline{\fontname\tenrm,}
\centerline{with headings in {\bf\fontname\tenbf}}
\centerline{and examples in {\tt\fontname\tentt}.}
\centerline{{\it\fontname\tenit\/} and}
\centerline{{\sl\fontname\tensl\/}}
\centerline{are used for emphasis.}\vfill}
\page\colophon
% Blame: pesch@cygnus.com, 28mar91.
@end tex
@contents
@bye