You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
5.1 KiB
HTML
127 lines
5.1 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- This file documents the BFD library.
|
|
|
|
Copyright (C) 1991-2019 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with the
|
|
Invariant Sections being "GNU General Public License" and "Funding
|
|
Free Software", the Front-Cover texts being (a) (see below), and with
|
|
the Back-Cover Texts being (b) (see below). A copy of the license is
|
|
included in the section entitled "GNU Free Documentation License".
|
|
|
|
(a) The FSF's Front-Cover Text is:
|
|
|
|
A GNU Manual
|
|
|
|
(b) The FSF's Back-Cover Text is:
|
|
|
|
You have freedom to copy and modify this GNU Manual, like GNU
|
|
software. Copies published by the Free Software Foundation raise
|
|
funds for GNU development. -->
|
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>How It Works (Untitled Document)</title>
|
|
|
|
<meta name="description" content="How It Works (Untitled Document)">
|
|
<meta name="keywords" content="How It Works (Untitled Document)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link href="index.html#Top" rel="start" title="Top">
|
|
<link href="BFD-Index.html#BFD-Index" rel="index" title="BFD Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Overview.html#Overview" rel="up" title="Overview">
|
|
<link href="What-BFD-Version-2-Can-Do.html#What-BFD-Version-2-Can-Do" rel="next" title="What BFD Version 2 Can Do">
|
|
<link href="History.html#History" rel="prev" title="History">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
div.smalllisp {margin-left: 3.2em}
|
|
kbd {font-style: oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
|
pre.smallexample {font-size: smaller}
|
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
|
pre.smalllisp {font-size: smaller}
|
|
span.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<a name="How-It-Works"></a>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="What-BFD-Version-2-Can-Do.html#What-BFD-Version-2-Can-Do" accesskey="n" rel="next">What BFD Version 2 Can Do</a>, Previous: <a href="History.html#History" accesskey="p" rel="prev">History</a>, Up: <a href="Overview.html#Overview" accesskey="u" rel="up">Overview</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<hr>
|
|
<a name="How-To-Use-BFD"></a>
|
|
<h3 class="section">1.2 How To Use BFD</h3>
|
|
|
|
<p>To use the library, include <samp>bfd.h</samp> and link with <samp>libbfd.a</samp>.
|
|
</p>
|
|
<p>BFD provides a common interface to the parts of an object file
|
|
for a calling application.
|
|
</p>
|
|
<p>When an application successfully 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</code>, described in
|
|
<samp>bfd.h</samp>. Our convention is to call this pointer a BFD, and
|
|
instances of it within code <code>abfd</code>. All operations on
|
|
the target object file are applied as methods to the BFD. The mapping is
|
|
defined within <code>bfd.h</code> in a set of macros, all beginning
|
|
with ‘<samp>bfd_</samp>’ to reduce namespace pollution.
|
|
</p>
|
|
<p>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</code>.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">#include "bfd.h"
|
|
|
|
unsigned int number_of_sections (abfd)
|
|
bfd *abfd;
|
|
{
|
|
return bfd_count_sections (abfd);
|
|
}
|
|
</pre></div>
|
|
|
|
<p>The abstraction used within BFD is that an object file has:
|
|
</p>
|
|
<ul>
|
|
<li> a header,
|
|
</li><li> a number of sections containing raw data (see <a href="Sections.html#Sections">Sections</a>),
|
|
</li><li> a set of relocations (see <a href="Relocations.html#Relocations">Relocations</a>), and
|
|
</li><li> some symbol information (see <a href="Symbols.html#Symbols">Symbols</a>).
|
|
</li></ul>
|
|
<p>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.
|
|
</p>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|