1999-05-03 07:29:11 +00:00
|
|
|
\input texinfo.tex
|
|
|
|
@setfilename bfd.info
|
2003-02-13 11:26:41 +00:00
|
|
|
@c Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1997, 2000, 2003
|
2001-03-08 21:04:02 +00:00
|
|
|
@c Free Software Foundation, Inc.
|
|
|
|
@c
|
1999-05-03 07:29:11 +00: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
|
|
|
|
@synindex fn cp
|
|
|
|
|
|
|
|
@ifinfo
|
|
|
|
@format
|
|
|
|
START-INFO-DIR-ENTRY
|
|
|
|
* Bfd: (bfd). The Binary File Descriptor library.
|
|
|
|
END-INFO-DIR-ENTRY
|
|
|
|
@end format
|
|
|
|
@end ifinfo
|
|
|
|
|
|
|
|
@ifinfo
|
|
|
|
This file documents the BFD library.
|
|
|
|
|
2003-02-13 11:26:41 +00:00
|
|
|
Copyright (C) 1991, 2000, 2001, 2003 Free Software Foundation, Inc.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2000-11-15 18:24:49 +00:00
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
|
|
under the terms of the GNU Free Documentation License, Version 1.1
|
|
|
|
or any later version published by the Free Software Foundation;
|
|
|
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
|
|
|
Back-Cover Texts. A copy of the license is included in the
|
2003-02-13 11:26:41 +00:00
|
|
|
section entitled ``GNU Free Documentation License''.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
@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
|
|
|
|
@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
|
2001-10-27 07:31:26 +00:00
|
|
|
@subtitle First Edition---BFD version < 3.0 % Since no product is stable berfore version 3.0 :-)
|
|
|
|
@subtitle Original Document Created: April 1991
|
1999-05-03 07:29:11 +00:00
|
|
|
@author {Steve Chamberlain}
|
|
|
|
@author {Cygnus Support}
|
|
|
|
@page
|
|
|
|
|
|
|
|
@tex
|
|
|
|
\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
|
2002-11-16 Klee Dienes <kdienes@apple.com>
* Makefile.am (BFD32_LIBS): Add bfdwin.lo, bfdio.lo.
(BFD32_LIBS_CFILES): Add bfdwin.c, bfdio.c.
(BFD_H_FILES): Add bfdwin.c, bfdio.c.
(LIBBFD_H_FILES): Add bfdwin.c, bfdio.c.
Add dependencies for bfdwin.c, bfdio.c.
* bfd.c: Remove bfd_get_mtime, bfd_get_size.
* libbfd.c: Remove real_read, bfd_bread, _bfd_window_internal,
bfd_init_window, bfd_free_window, bfd_get_file_window, bfd_bwrite,
bfd_tell, bfd_flush, bfd_stat, bfd_seek.
* bfdio.c: New file. Contains real_read, bfd_bread, bfd_write,
bfd_tell, bfd_flush, bfd_stat, bfd_seek, bfd_ge_mtime,
bfd_get_size (moved from libbfd.c and bfd.c).
* bfdwin.c New file. Contains _bfd_window_internal,
bfd_init_window, bfd_free_window, bfd_get_file_window (moved from
libbfd.c and bfd.c).
* po/SRC-POTFILES.in: Regenerate.
* po/bfd.pot: Regenerate.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
* aclocal.m4: Regenerate.
* Makefile.in: Regenerate.
* configure: Regenerate.
2002-11-16 Klee Dienes <kdienes@apple.com>
* Makefile.am (DOCFILES): Add bfdwin.texi, bfdio.texi.
(PROTOS): Add bfdio.p, bfdwin.p.
(SRCDOC): Add bfdio.c, bfdwin.c.
(SRCPROT): Add bfdio.c, bfdwin.c.
(SRCIPROT): Add bfdio.c, bfdwin.c.
(LIBBFD_H_DEP): Add bfdio.c, bfdwin.c.
(BFD_H_DEP): Add bfdio.c, bfdwin.c.
Add rules for bfdio.texi, bfdwin.text.
* bfd.texinfo: Include bfdio.texi.
2002-11-18 16:37:54 +00:00
|
|
|
\xdef\manvers{\1.5} % For use in headers, footers too
|
1999-05-03 07:29:11 +00:00
|
|
|
{\parskip=0pt
|
2001-10-27 07:31:26 +00:00
|
|
|
\hfill Free Software Foundation\par
|
|
|
|
\hfill sac\@www.gnu.org\par
|
1999-05-03 07:29:11 +00: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
|
2003-02-13 11:26:41 +00:00
|
|
|
Copyright @copyright{} 1991, 2001, 2003 Free Software Foundation, Inc.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2000-11-15 18:24:49 +00:00
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
|
|
under the terms of the GNU Free Documentation License, Version 1.1
|
|
|
|
or any later version published by the Free Software Foundation;
|
|
|
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
|
|
|
Back-Cover Texts. A copy of the license is included in the
|
2003-02-13 11:26:41 +00:00
|
|
|
section entitled ``GNU Free Documentation License''.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
@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
|
|
|
|
* BFD front end:: BFD front end
|
|
|
|
* BFD back ends:: BFD back ends
|
2000-11-15 18:24:49 +00:00
|
|
|
* GNU Free Documentation License:: GNU Free Documentation License
|
1999-05-03 07:29:11 +00:00
|
|
|
* Index:: Index
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
@node Overview, BFD front end, Top, Top
|
|
|
|
@chapter Introduction
|
|
|
|
@cindex BFD
|
|
|
|
@cindex what is it?
|
|
|
|
BFD is a package which allows applications to use the
|
|
|
|
same routines to operate on object files whatever the object file
|
|
|
|
format. A new object file format can be supported simply by
|
|
|
|
creating a new BFD back end and adding it to the library.
|
|
|
|
|
|
|
|
BFD is split into two parts: the front end, and the back ends (one for
|
|
|
|
each object file format).
|
|
|
|
@itemize @bullet
|
|
|
|
@item The front end of BFD provides the interface to the user. It manages
|
|
|
|
memory and various canonical data structures. The front end also
|
|
|
|
decides which back end to use and when to call back end routines.
|
|
|
|
@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
|
|
|
|
@menu
|
|
|
|
* History:: History
|
|
|
|
* How It Works:: How It Works
|
|
|
|
* What BFD Version 2 Can Do:: What BFD Version 2 Can Do
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
@node History, How It Works, Overview, Overview
|
|
|
|
@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
|
|
|
|
was contracted to provide the required functionality.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
BFD was first implemented by members of Cygnus Support; Steve
|
|
|
|
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}).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@node How It Works, What BFD Version 2 Can Do, History, Overview
|
|
|
|
@section How To Use BFD
|
|
|
|
|
|
|
|
To use the library, include @file{bfd.h} and link with @file{libbfd.a}.
|
|
|
|
|
|
|
|
BFD provides a common interface to the parts of an object file
|
|
|
|
for a calling application.
|
|
|
|
|
|
|
|
When an application sucessfully opens a target file (object, archive, or
|
|
|
|
whatever), a pointer to an internal structure is returned. This pointer
|
|
|
|
points to a structure called @code{bfd}, described in
|
|
|
|
@file{bfd.h}. Our convention is to call this pointer a BFD, and
|
|
|
|
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
|
|
|
|
with @samp{bfd_} to reduce namespace pollution.
|
|
|
|
|
|
|
|
For example, this sequence does what you would probably expect:
|
|
|
|
return the number of sections in an object file attached to a BFD
|
|
|
|
@code{abfd}.
|
|
|
|
|
2003-02-13 11:26:41 +00:00
|
|
|
@example
|
1999-05-03 07:29:11 +00:00
|
|
|
@c @cartouche
|
|
|
|
#include "bfd.h"
|
|
|
|
|
2003-02-13 11:26:41 +00:00
|
|
|
unsigned int number_of_sections (abfd)
|
1999-05-03 07:29:11 +00:00
|
|
|
bfd *abfd;
|
|
|
|
@{
|
2003-02-13 11:26:41 +00:00
|
|
|
return bfd_count_sections (abfd);
|
1999-05-03 07:29:11 +00:00
|
|
|
@}
|
|
|
|
@c @end cartouche
|
2003-02-13 11:26:41 +00:00
|
|
|
@end example
|
1999-05-03 07:29:11 +00: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.
|
|
|
|
|
|
|
|
@node What BFD Version 2 Can Do, , How It Works, Overview
|
|
|
|
@section What BFD Version 2 Can Do
|
|
|
|
@include bfdsumm.texi
|
|
|
|
|
|
|
|
@node BFD front end, BFD back ends, Overview, Top
|
2003-02-13 11:26:41 +00:00
|
|
|
@chapter BFD Front End
|
1999-05-03 07:29:11 +00:00
|
|
|
@include bfdt.texi
|
2002-11-16 Klee Dienes <kdienes@apple.com>
* Makefile.am (BFD32_LIBS): Add bfdwin.lo, bfdio.lo.
(BFD32_LIBS_CFILES): Add bfdwin.c, bfdio.c.
(BFD_H_FILES): Add bfdwin.c, bfdio.c.
(LIBBFD_H_FILES): Add bfdwin.c, bfdio.c.
Add dependencies for bfdwin.c, bfdio.c.
* bfd.c: Remove bfd_get_mtime, bfd_get_size.
* libbfd.c: Remove real_read, bfd_bread, _bfd_window_internal,
bfd_init_window, bfd_free_window, bfd_get_file_window, bfd_bwrite,
bfd_tell, bfd_flush, bfd_stat, bfd_seek.
* bfdio.c: New file. Contains real_read, bfd_bread, bfd_write,
bfd_tell, bfd_flush, bfd_stat, bfd_seek, bfd_ge_mtime,
bfd_get_size (moved from libbfd.c and bfd.c).
* bfdwin.c New file. Contains _bfd_window_internal,
bfd_init_window, bfd_free_window, bfd_get_file_window (moved from
libbfd.c and bfd.c).
* po/SRC-POTFILES.in: Regenerate.
* po/bfd.pot: Regenerate.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
* aclocal.m4: Regenerate.
* Makefile.in: Regenerate.
* configure: Regenerate.
2002-11-16 Klee Dienes <kdienes@apple.com>
* Makefile.am (DOCFILES): Add bfdwin.texi, bfdio.texi.
(PROTOS): Add bfdio.p, bfdwin.p.
(SRCDOC): Add bfdio.c, bfdwin.c.
(SRCPROT): Add bfdio.c, bfdwin.c.
(SRCIPROT): Add bfdio.c, bfdwin.c.
(LIBBFD_H_DEP): Add bfdio.c, bfdwin.c.
(BFD_H_DEP): Add bfdio.c, bfdwin.c.
Add rules for bfdio.texi, bfdwin.text.
* bfd.texinfo: Include bfdio.texi.
2002-11-18 16:37:54 +00:00
|
|
|
@include bfdio.texi
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
@menu
|
|
|
|
* Memory Usage::
|
|
|
|
* Initialization::
|
|
|
|
* Sections::
|
|
|
|
* Symbols::
|
|
|
|
* Archives::
|
|
|
|
* Formats::
|
|
|
|
* Relocations::
|
|
|
|
* Core Files::
|
|
|
|
* Targets::
|
|
|
|
* Architectures::
|
|
|
|
* Opening and Closing::
|
|
|
|
* Internal::
|
|
|
|
* File Caching::
|
|
|
|
* Linker Functions::
|
|
|
|
* Hash Tables::
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
@node Memory Usage, Initialization, BFD front end, BFD front end
|
2003-02-13 11:26:41 +00:00
|
|
|
@section Memory Usage
|
1999-05-03 07:29:11 +00:00
|
|
|
BFD keeps all of 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
|
|
|
|
allocated by BFD for the closing file is thrown away.
|
|
|
|
|
|
|
|
BFD does not free anything created by an application, but pointers into
|
|
|
|
@code{bfd} structures become invalid on a @code{bfd_close}; for example,
|
|
|
|
after a @code{bfd_close} the vector passed to
|
|
|
|
@code{bfd_canonicalize_symtab} is still around, since it has been
|
|
|
|
allocated by the application, but the data that it pointed to are
|
|
|
|
lost.
|
|
|
|
|
|
|
|
The general rule is to not close a BFD until all operations dependent
|
|
|
|
upon data from the BFD have been completed, or all the data from within
|
|
|
|
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.
|
|
|
|
|
|
|
|
@node Initialization, Sections, Memory Usage, BFD front end
|
|
|
|
@include init.texi
|
|
|
|
|
|
|
|
@node Sections, Symbols, Initialization, BFD front end
|
|
|
|
@include section.texi
|
|
|
|
|
|
|
|
@node Symbols, Archives, Sections, BFD front end
|
|
|
|
@include syms.texi
|
|
|
|
|
|
|
|
@node Archives, Formats, Symbols, BFD front end
|
|
|
|
@include archive.texi
|
|
|
|
|
|
|
|
@node Formats, Relocations, Archives, BFD front end
|
|
|
|
@include format.texi
|
|
|
|
|
|
|
|
@node Relocations, Core Files, Formats, BFD front end
|
|
|
|
@include reloc.texi
|
|
|
|
|
|
|
|
@node Core Files, Targets, Relocations, BFD front end
|
|
|
|
@include core.texi
|
|
|
|
|
|
|
|
@node Targets, Architectures, Core Files, BFD front end
|
|
|
|
@include targets.texi
|
|
|
|
|
|
|
|
@node Architectures, Opening and Closing, Targets, BFD front end
|
|
|
|
@include archures.texi
|
|
|
|
|
|
|
|
@node Opening and Closing, Internal, Architectures, BFD front end
|
|
|
|
@include opncls.texi
|
|
|
|
|
|
|
|
@node Internal, File Caching, Opening and Closing, BFD front end
|
|
|
|
@include libbfd.texi
|
|
|
|
|
|
|
|
@node File Caching, Linker Functions, Internal, BFD front end
|
|
|
|
@include cache.texi
|
|
|
|
|
|
|
|
@node Linker Functions, Hash Tables, File Caching, BFD front end
|
|
|
|
@include linker.texi
|
|
|
|
|
|
|
|
@node Hash Tables, , Linker Functions, BFD front end
|
|
|
|
@include hash.texi
|
|
|
|
|
2000-11-15 18:24:49 +00:00
|
|
|
@node BFD back ends, GNU Free Documentation License, BFD front end, Top
|
1999-05-03 07:29:11 +00:00
|
|
|
@chapter BFD back ends
|
|
|
|
@menu
|
|
|
|
* What to Put Where::
|
|
|
|
* aout :: a.out backends
|
|
|
|
* coff :: coff backends
|
|
|
|
* elf :: elf backends
|
2001-10-30 15:20:14 +00:00
|
|
|
* mmo :: mmo backend
|
1999-05-03 07:29:11 +00:00
|
|
|
@ignore
|
|
|
|
* oasys :: oasys backends
|
|
|
|
* ieee :: ieee backend
|
|
|
|
* srecord :: s-record backend
|
|
|
|
@end ignore
|
|
|
|
@end menu
|
|
|
|
@node What to Put Where, aout, BFD back ends, BFD back ends
|
|
|
|
All of BFD lives in one directory.
|
|
|
|
|
|
|
|
@node aout, coff, What to Put Where, BFD back ends
|
|
|
|
@include aoutx.texi
|
|
|
|
|
|
|
|
@node coff, elf, aout, BFD back ends
|
|
|
|
@include coffcode.texi
|
|
|
|
|
2001-10-30 15:20:14 +00:00
|
|
|
@node elf, mmo, coff, BFD back ends
|
1999-05-03 07:29:11 +00:00
|
|
|
@include elf.texi
|
|
|
|
@c Leave this out until the file has some actual contents...
|
|
|
|
@c @include elfcode.texi
|
|
|
|
|
2001-10-30 15:20:14 +00:00
|
|
|
@node mmo, , elf, BFD back ends
|
|
|
|
@include mmo.texi
|
|
|
|
|
2000-11-15 18:24:49 +00:00
|
|
|
@node GNU Free Documentation License, Index, BFD back ends, Top
|
2003-02-13 11:26:41 +00:00
|
|
|
@include fdl.texi
|
|
|
|
|
|
|
|
@node Index, , GNU Free Documentation License, Top
|
1999-05-03 07:29:11 +00: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: doc@cygnus.com, 28mar91.
|
|
|
|
@end tex
|
|
|
|
|
|
|
|
@contents
|
|
|
|
@bye
|