mirror of
https://github.com/serge1/ELFIO.git
synced 2025-04-16 14:42:39 +00:00
- Add const attribute to several functions of section interface
- Doc change
This commit is contained in:
parent
bd5b04bf40
commit
2d514544fc
2
doc/build.sh
Normal file
2
doc/build.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
xsltproc -o elfio.fo /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl elfio.docbook
|
||||||
|
fop -fo elfio.fo -pdf elfio.pdf
|
428
doc/elfio.html
428
doc/elfio.html
@ -1,428 +0,0 @@
|
|||||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>ELFIO</title><meta name="generator" content="DocBook XSL Stylesheets V1.77.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book"><div class="titlepage"><div><div><h1 class="title"><a name="id36112626"></a>ELFIO</h1></div><div><h2 class="subtitle">User's Guide</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Serge</span> <span class="surname">Lamikhov-Center</span></h3></div></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="preface"><a href="#introduction">Introduction</a></span></dt><dt><span class="chapter"><a href="#get-started">1. Getting Started With ELFIO</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id36100317">ELF File Reader</a></span></dt><dt><span class="sect1"><a href="#id36103638">ELF Section Data Accessors</a></span></dt><dt><span class="sect1"><a href="#id36094302">ELFDump Utility</a></span></dt><dt><span class="sect1"><a href="#id36085990">ELF File Writer</a></span></dt></dl></dd><dt><span class="chapter"><a href="#library-classes">2. ELFIO Library Classes</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id36110529">Class <code class="classname">elfio</code></a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36098224">Data members</a></span></dt><dt><span class="sect2"><a href="#id36121095">Member functions</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36062867">Class <code class="classname">section</code></a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36062881">Member functions</a></span></dt></dl></dd></dl></dd></dl></div><div class="list-of-tables"><p><b>List of Tables</b></p><dl><dt>2.1. <a href="#id36120114">Class <code class="classname">elfio</code> member functions</a></dt><dt>2.2. <a href="#id36109698">Class <code class="classname">elfio</code> member functions</a></dt><dt>2.3. <a href="#id36116252">Class <code class="classname">elfio</code> member functions (continue)</a></dt><dt>2.4. <a href="#id36062910">Class <code class="classname">section</code> member functions</a></dt></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a name="introduction"></a>Introduction</h1></div></div></div><p>
|
|
||||||
ELFIO is a C++ library for reading and generating files in ELF binary
|
|
||||||
format. This library is independent and does not require any other product.
|
|
||||||
It is also cross-platform - the library uses standard ANSI C++ constructions
|
|
||||||
and runs on wide variety of architectures.
|
|
||||||
</p><p>
|
|
||||||
While the library's implementation does make your work much easier: basic
|
|
||||||
knowledge of the ELF binary format is required. Information about ELF
|
|
||||||
format can be found widely on the web.
|
|
||||||
</p></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="get-started"></a>Chapter 1. Getting Started With ELFIO</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id36100317">ELF File Reader</a></span></dt><dt><span class="sect1"><a href="#id36103638">ELF Section Data Accessors</a></span></dt><dt><span class="sect1"><a href="#id36094302">ELFDump Utility</a></span></dt><dt><span class="sect1"><a href="#id36085990">ELF File Writer</a></span></dt></dl></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36100317"></a>ELF File Reader</h2></div></div></div><p>
|
|
||||||
The ELFIO library is a header only library. No preparatory compilation
|
|
||||||
steps are required. To make your application be aware about the
|
|
||||||
ELFIO classes and types declarations, just include <code class="filename">elfio.hpp</code> header file.
|
|
||||||
All ELFIO library declarations reside in ELFIO namespace.
|
|
||||||
So, this tutorial code starts from the following code:
|
|
||||||
</p><div class="programlistingco"><pre class="programlisting">
|
|
||||||
#include <iostream>
|
|
||||||
#include <elfio.hpp>
|
|
||||||
|
|
||||||
using namespace ELFIO;
|
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
|
||||||
{
|
|
||||||
if ( argc != 2 ) {
|
|
||||||
std::cout << "Usage: tutorial <elf_file>" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
</pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><span><img src="images/callouts/1.png" alt="1" border="0"></span></p></td><td valign="top" align="left"><p>
|
|
||||||
Include <code class="filename">elfio.hpp</code> header file
|
|
||||||
</p></td></tr><tr><td width="5%" valign="top" align="left"><p><span><img src="images/callouts/2.png" alt="2" border="0"></span></p></td><td valign="top" align="left"><p>
|
|
||||||
The ELFIO namespace usage
|
|
||||||
</p></td></tr></table></div></div><p>
|
|
||||||
This chapter will explain how to work with the reader portion
|
|
||||||
of the ELFIO library. The first step would be creation of the <code class="classname">elfio</code>
|
|
||||||
class instance. The <code class="classname">elfio</code> constructor does not
|
|
||||||
receive any parameters. After creation of a class object, we initialize
|
|
||||||
the instance by invoking <code class="function">load</code> function
|
|
||||||
passing ELF file name as a parameter.
|
|
||||||
</p><div class="programlistingco"><pre class="programlisting">
|
|
||||||
// Create an elfio reader
|
|
||||||
elfio reader;
|
|
||||||
|
|
||||||
// Load ELF data
|
|
||||||
if ( !reader.load( argv[1] ) ) {
|
|
||||||
std::cout << "Can't find or process ELF file " << argv[1] << std::endl;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
</pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><span><img src="images/callouts/1.png" alt="1" border="0"></span></p></td><td valign="top" align="left"><p>
|
|
||||||
Create <code class="classname">elfio</code> class instance
|
|
||||||
</p></td></tr><tr><td width="5%" valign="top" align="left"><p><span><img src="images/callouts/2.png" alt="2" border="0"></span></p></td><td valign="top" align="left"><p>
|
|
||||||
Initialize the instance by loading ELF file. The function
|
|
||||||
<code class="function">load</code> returns
|
|
||||||
<span class="returnvalue">true</span>
|
|
||||||
if the ELF file was found and processed successfully. It returns
|
|
||||||
<span class="returnvalue">false</span> otherwise.
|
|
||||||
</p></td></tr></table></div></div><p>
|
|
||||||
</p><p>
|
|
||||||
From here, ELF header properties are accessible. This makes it possible
|
|
||||||
to request file parameters such as encoding, machine type,
|
|
||||||
entry point, etc. To get the class and the encoding of the file use:
|
|
||||||
</p><div class="programlistingco"><pre class="programlisting">
|
|
||||||
// Print ELF file properties
|
|
||||||
std::cout << "ELF file class : ";
|
|
||||||
if ( reader.get_class() == ELFCLASS32 )
|
|
||||||
std::cout << "ELF32" << std::endl;
|
|
||||||
else
|
|
||||||
std::cout << "ELF64" << std::endl;
|
|
||||||
|
|
||||||
std::cout << "ELF file encoding : ";
|
|
||||||
if ( reader.get_encoding() == ELFDATA2LSB )
|
|
||||||
std::cout << "Little endian" << std::endl;
|
|
||||||
else
|
|
||||||
std::cout << "Big endian" << std::endl;
|
|
||||||
</pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><span><img src="images/callouts/1.png" alt="1" border="0"></span></p></td><td valign="top" align="left"><p>
|
|
||||||
Member function <code class="function">get_class()</code> returns ELF file
|
|
||||||
class. Possible values are <code class="constant">ELFCLASS32</code> or
|
|
||||||
<code class="constant">ELFCLASS64</code>.
|
|
||||||
</p></td></tr><tr><td width="5%" valign="top" align="left"><p><span><img src="images/callouts/2.png" alt="2" border="0"></span></p></td><td valign="top" align="left"><p>
|
|
||||||
Member function <code class="function">get_encoding()</code> returns ELF file
|
|
||||||
format encoding. Possible values are <code class="constant">ELFDATA2LSB</code>
|
|
||||||
and <code class="constant">ELFDATA2MSB</code>.
|
|
||||||
</p></td></tr></table></div></div><p>
|
|
||||||
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
|
|
||||||
Standard ELF types, flags and constants
|
|
||||||
are defined in the <code class="filename">elf_types.hpp</code> header file.
|
|
||||||
This file is included automatically into the project.
|
|
||||||
For example: <code class="constant">ELFCLASS32</code>,
|
|
||||||
<code class="constant">ELFCLASS64</code> constants define a value for 32/64 bit
|
|
||||||
architectures. <code class="constant">ELFDATA2LSB</code> and
|
|
||||||
<code class="constant">ELFDATA2MSB</code> constants define value
|
|
||||||
for little and big endian encoding.
|
|
||||||
</p></div><p>
|
|
||||||
ELF binary files may consist of several sections. Each section has it's own
|
|
||||||
responsibility: some contain executable code; others describe program
|
|
||||||
dependencies; others symbol tables and so on. See ELF binary format
|
|
||||||
documentation for a full description of each section.
|
|
||||||
</p><p>
|
|
||||||
The following code demonstrates how to find out the amount of sections
|
|
||||||
the ELF file contains. The code also presents how to access particular
|
|
||||||
section properties like names and sizes:
|
|
||||||
</p><pre class="programlisting">
|
|
||||||
// Print ELF file sections info
|
|
||||||
Elf_Half sec_num = reader.sections.size();
|
|
||||||
std::cout << "Number of sections: " << sec_num << std::endl;
|
|
||||||
for ( int i = 0; i < sec_num; ++i ) {
|
|
||||||
const section* psec = reader.sections[i];
|
|
||||||
std::cout << " [" << i << "] "
|
|
||||||
<< psec->get_name()
|
|
||||||
<< "\t"
|
|
||||||
<< psec->get_size()
|
|
||||||
<< std::endl;
|
|
||||||
// Access to section's data
|
|
||||||
// const char* p = reader.sections[i]->get_data()
|
|
||||||
}
|
|
||||||
</pre><p>
|
|
||||||
</p><p>
|
|
||||||
<code class="methodname">sections</code> member of <code class="classname">reader</code>
|
|
||||||
object permits to obtain number of sections the ELF file contains. It
|
|
||||||
also serves for getting access to individual section by using
|
|
||||||
<code class="methodname">operator[]</code>, which returns a pointer to
|
|
||||||
corresponding section's interface.
|
|
||||||
</p><p>
|
|
||||||
Similarly, segments of the ELF file can be processed:
|
|
||||||
</p><pre class="programlisting">
|
|
||||||
// Print ELF file segments info
|
|
||||||
Elf_Half seg_num = reader.segments.size();
|
|
||||||
std::cout << "Number of segments: " << seg_num << std::endl;
|
|
||||||
for ( int i = 0; i < seg_num; ++i ) {
|
|
||||||
const segment* pseg = reader.segments[i];
|
|
||||||
std::cout << " [" << i << "] 0x" << std::hex
|
|
||||||
<< pseg->get_flags()
|
|
||||||
<< "\t0x"
|
|
||||||
<< pseg->get_virtual_address()
|
|
||||||
<< "\t0x"
|
|
||||||
<< pseg->get_file_size()
|
|
||||||
<< "\t0x"
|
|
||||||
<< pseg->get_memory_size()
|
|
||||||
<< std::endl;
|
|
||||||
// Access to segments's data
|
|
||||||
// const char* p = reader.segments[i]->get_data()
|
|
||||||
}
|
|
||||||
</pre><p>
|
|
||||||
In this case, segments' attributes and data are obtained by using
|
|
||||||
<code class="methodname">segments</code> member of the <code class="classname">reader</code>.
|
|
||||||
</p><p>
|
|
||||||
The full text of this example comes together with ELFIO library
|
|
||||||
distribution.
|
|
||||||
</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36103638"></a>ELF Section Data Accessors</h2></div></div></div><p>
|
|
||||||
To simplify creation and interpretation of the ELF sections' data,
|
|
||||||
the ELFIO library comes with auxiliary classes - accessors. To the moment
|
|
||||||
of this document writing, the following accessors are available:
|
|
||||||
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: opencircle; "><li class="listitem" style="list-style-type: circle"><p>
|
|
||||||
<code class="classname">string_section_accessor</code>
|
|
||||||
</p></li><li class="listitem" style="list-style-type: circle"><p>
|
|
||||||
<code class="classname">symbol_section_accessor</code>
|
|
||||||
</p></li><li class="listitem" style="list-style-type: circle"><p>
|
|
||||||
<code class="classname">relocation_section_accessor</code>
|
|
||||||
</p></li><li class="listitem" style="list-style-type: circle"><p>
|
|
||||||
<code class="classname">note_section_accessor</code>
|
|
||||||
</p></li></ul></div><p>
|
|
||||||
Definitely, it is possible to extend the library by implementing additional
|
|
||||||
accessors serving particular purposes.
|
|
||||||
</p><p>
|
|
||||||
Let's see how the accessors can be used with the previous ELF file reader
|
|
||||||
example. For this example purposes, we will print out all symbols in a
|
|
||||||
symbol section.
|
|
||||||
</p><pre class="programlisting">
|
|
||||||
if ( psec->get_type() == SHT_SYMTAB ) {
|
|
||||||
const symbol_section_accessor symbols( reader, psec );
|
|
||||||
for ( unsigned int j = 0; j < symbols.get_symbols_num(); ++j ) {
|
|
||||||
std::string name;
|
|
||||||
Elf64_Addr value;
|
|
||||||
Elf_Xword size;
|
|
||||||
unsigned char bind;
|
|
||||||
unsigned char type;
|
|
||||||
Elf_Half section_index;
|
|
||||||
unsigned char other;
|
|
||||||
|
|
||||||
symbols.get_symbol( j, name, value, size, bind,
|
|
||||||
type, section_index, other );
|
|
||||||
std::cout << j << " " << name << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</pre><p>
|
|
||||||
We create <code class="classname">symbol_section_accessor</code> instance first.
|
|
||||||
Usually, accessors receive the <code class="classname">elfio</code> and
|
|
||||||
<code class="classname">section*</code> parameters for their constructors.
|
|
||||||
<code class="methodname">get_symbol</code> is used to retrieve a particular entry
|
|
||||||
in the symbol table.
|
|
||||||
</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36094302"></a>ELFDump Utility</h2></div></div></div><p>
|
|
||||||
The source code for the ELF Dumping Utility can be found in
|
|
||||||
the "examples" directory; there also located more examples on how
|
|
||||||
to use different ELFIO reader interfaces.
|
|
||||||
</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36085990"></a>ELF File Writer</h2></div></div></div><p>
|
|
||||||
TODO
|
|
||||||
</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="library-classes"></a>Chapter 2. ELFIO Library Classes</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id36110529">Class <code class="classname">elfio</code></a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36098224">Data members</a></span></dt><dt><span class="sect2"><a href="#id36121095">Member functions</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36062867">Class <code class="classname">section</code></a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36062881">Member functions</a></span></dt></dl></dd></dl></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36110529"></a>Class <code class="classname">elfio</code></h2></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id36098224"></a>Data members</h3></div></div></div><p>
|
|
||||||
The ELFIO library's main class is <code class="classname">elfio</code>. The class
|
|
||||||
contains the following two public data members: sections and segments:
|
|
||||||
</p><p>
|
|
||||||
</p><div class="table"><a name="id36120114"></a><p class="title"><b>Table 2.1. Class <code class="classname">elfio</code> member functions</b></p><div class="table-contents"><table summary="Class elfio member functions" border="1"><colgroup><col align="left" class="c1"><col align="left" class="c2"></colgroup><thead><tr><th align="center">Data member</th><th align="center">Description</th></tr></thead><tbody><tr><td align="left">
|
|
||||||
sections
|
|
||||||
</td><td align="left">
|
|
||||||
The container stores ELFIO library section instances.
|
|
||||||
Implements operator[] and size(). operator[] permits access to
|
|
||||||
individual ELF file section according to its index.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
segments
|
|
||||||
</td><td align="left">
|
|
||||||
The container stores ELFIO library segment instances.
|
|
||||||
Implements operator[] and size(). operator[] permits access to
|
|
||||||
individual ELF file segment according to its index.
|
|
||||||
</td></tr></tbody></table></div></div><p><br class="table-break">
|
|
||||||
|
|
||||||
</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id36121095"></a>Member functions</h3></div></div></div><p>
|
|
||||||
Here is the list of <code class="classname">elfio</code> public member functions.
|
|
||||||
Most of the functions permit to retrieve or set ELF file properties.
|
|
||||||
</p><p>
|
|
||||||
</p><div class="table"><a name="id36109698"></a><p class="title"><b>Table 2.2. Class <code class="classname">elfio</code> member functions</b></p><div class="table-contents"><table summary="Class elfio member functions" border="1"><colgroup><col align="left" class="c1"><col align="left" class="c2"></colgroup><thead><tr><th align="center">Function</th><th align="center">Description</th></tr></thead><tbody><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">
|
|
||||||
<b class="fsfunc">elfio</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
The constructor.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">
|
|
||||||
<b class="fsfunc">~elfio</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
The destructor.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">create</b>
|
|
||||||
(</code></td><td><var class="pdparam">file_class</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">encoding</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>unsigned char <var class="pdparam">file_class</var>
|
|
||||||
</code>;<br><code>unsigned char <var class="pdparam">encoding</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Cleans and initializes empty <code class="classname">elfio</code> object.
|
|
||||||
<em class="parameter"><code>file_class</code></em> is either ELFCLASS32 or ELFCLASS64.
|
|
||||||
<em class="parameter"><code>file_class</code></em> is either ELFDATA2LSB or ELFDATA2MSB.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">bool <b class="fsfunc">load</b>
|
|
||||||
(</code></td><td><var class="pdparam">file_name</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>const std::string& <var class="pdparam">file_name</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Initializes <code class="classname">elfio</code> object by loading data
|
|
||||||
from ELF binary file. File name provided in <em class="parameter"><code>file_name</code></em>.
|
|
||||||
Returns <span class="returnvalue">true</span> if the file was processed successfully.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">bool <b class="fsfunc">save</b>
|
|
||||||
(</code></td><td><var class="pdparam">file_name</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>const std::string& <var class="pdparam">file_name</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Creates a file in ELF binary format. File name provided in <em class="parameter"><code>file_name</code></em>.
|
|
||||||
Returns <span class="returnvalue">true</span> if the file was created successfully.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">unsigned char <b class="fsfunc">get_class</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns ELF file class. Possible values are ELFCLASS32 or ELFCLASS64.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">unsigned char <b class="fsfunc">get_elf_version</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns ELF file format version.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">unsigned char <b class="fsfunc">get_encoding</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns ELF file format encoding. Possible values are ELFDATA2LSB and
|
|
||||||
ELFDATA2MSB.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Word <b class="fsfunc">get_version</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Identifies the object file version.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Half <b class="fsfunc">get_header_size</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns the ELF header's size in bytes.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Half <b class="fsfunc">get_section_entry_size</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns a section's entry size in ELF file header section table.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Half <b class="fsfunc">get_segment_entry_size</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns a segment's entry size in ELF file header program table.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">unsigned char <b class="fsfunc">get_os_abi</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns operating system ABI identification.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_os_abi</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>unsigned char <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets operating system ABI identification.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">unsigned char <b class="fsfunc">get_abi_version</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns ABI version.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_abi_version</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>unsigned char <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets ABI version.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Half <b class="fsfunc">get_type</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns the object file type.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_type</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>Elf_Half <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets the object file type.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Half <b class="fsfunc">get_machine</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns the object file's architecture.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_machine</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>Elf_Half <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets the object file's architecture.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Word <b class="fsfunc">get_flags</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns processor-specific flags associated with the file.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_flags</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>Elf_Word <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets processor-specific flags associated with the file.
|
|
||||||
</td></tr></tbody></table></div></div><p><br class="table-break">
|
|
||||||
|
|
||||||
|
|
||||||
</p><div class="table"><a name="id36116252"></a><p class="title"><b>Table 2.3. Class <code class="classname">elfio</code> member functions (continue)</b></p><div class="table-contents"><table summary="Class elfio member functions (continue)" border="1"><colgroup><col align="left" class="c1"><col align="left" class="c2"></colgroup><thead><tr><th align="center">Function</th><th align="center">Description</th></tr></thead><tbody><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf64_Addr <b class="fsfunc">get_entry</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns the virtual address to which the system first transfers control.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_entry</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>Elf64_Addr <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets the virtual address to which the system first transfers control.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf64_Off <b class="fsfunc">get_sections_offset</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns the section header table's file offset in bytes.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_sections_offset</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>Elf64_Off <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets the section header table's file offset. Attention!
|
|
||||||
The value can be overridden by the library, when it creates new ELF
|
|
||||||
file layout.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf64_Off <b class="fsfunc">get_segments_offset</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns the program header table's file offset.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_segments_offset</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>Elf64_Off <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets the program header table's file offset. Attention!
|
|
||||||
The value can be overridden by the library, when it creates new ELF
|
|
||||||
file layout.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Half <b class="fsfunc">get_section_name_str_index</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns the section header table index of the entry associated with
|
|
||||||
the section name string table.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">set_section_name_str_index</b>
|
|
||||||
(</code></td><td><var class="pdparam">value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>Elf_Half <var class="pdparam">value</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Sets the section header table index of the entry associated with
|
|
||||||
the section name string table.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">endianess_convertor& <b class="fsfunc">get_convertor</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns endianess convertor reference for the specific
|
|
||||||
<code class="classname">elfio</code> object instance.
|
|
||||||
</td></tr><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Xword <b class="fsfunc">get_default_entry_size</b>
|
|
||||||
(</code></td><td><var class="pdparam">section_type</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>Elf_Word <var class="pdparam">section_type</var>
|
|
||||||
</code>;</div><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns default entry size for known section types having different values
|
|
||||||
on 32 and 64 bit architectures. At the moment, only SHT_RELA, SHT_REL,
|
|
||||||
SHT_SYMTAB and SHT_DYNAMIC are 'known' section types. The function
|
|
||||||
returns 0 for other section types.
|
|
||||||
</td></tr></tbody></table></div></div><p><br class="table-break">
|
|
||||||
|
|
||||||
</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36062867"></a>Class <code class="classname">section</code></h2></div></div></div><p>
|
|
||||||
Class <code class="classname">section</code> has no public data members.
|
|
||||||
</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id36062881"></a>Member functions</h3></div></div></div><p>
|
|
||||||
Here is the list of <code class="classname">section</code> public member functions.
|
|
||||||
These functions permit to retrieve or set ELF file section properties.
|
|
||||||
</p><p>
|
|
||||||
</p><div class="table"><a name="id36062910"></a><p class="title"><b>Table 2.4. Class <code class="classname">section</code> member functions</b></p><div class="table-contents"><table summary="Class section member functions" border="1"><colgroup><col align="left" class="c1"><col align="left" class="c2"></colgroup><thead><tr><th align="center">Function</th><th align="center">Description</th></tr></thead><tbody><tr><td align="left">
|
|
||||||
<div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">Elf_Half <b class="fsfunc">get_index</b>
|
|
||||||
(</code></td><td><code>)</code>;</td><td> </td></tr></table><div class="funcprototype-spacer"> </div></div>
|
|
||||||
</td><td align="left">
|
|
||||||
Returns section index within ELF file.
|
|
||||||
</td></tr></tbody></table></div></div><p><br class="table-break">
|
|
||||||
|
|
||||||
</p></div></div></div></div></body></html>
|
|
BIN
doc/elfio.pdf
BIN
doc/elfio.pdf
Binary file not shown.
@ -336,23 +336,6 @@
|
|||||||
Sets processor-specific flags associated with the file.
|
Sets processor-specific flags associated with the file.
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
|
||||||
</tgroup>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
<table frame='all'>
|
|
||||||
<title>Class <classname>elfio</classname> member functions (continue)</title>
|
|
||||||
<tgroup cols='2' align='left' colsep='1' rowsep='1'>
|
|
||||||
<colspec colname='c1'/>
|
|
||||||
<colspec colname='c2'/>
|
|
||||||
<thead>
|
|
||||||
<row>
|
|
||||||
<entry align="center">Function</entry>
|
|
||||||
<entry align="center">Description</entry>
|
|
||||||
</row>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<row>
|
<row>
|
||||||
<entry>
|
<entry>
|
||||||
<funcsynopsis>
|
<funcsynopsis>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
</row>
|
</row>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry>
|
<entry>
|
||||||
<funcsynopsis>
|
<funcsynopsis>
|
||||||
@ -24,6 +25,36 @@
|
|||||||
Returns section index within ELF file.
|
Returns section index within ELF file.
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry>
|
||||||
|
<funcsynopsis>
|
||||||
|
<funcprototype>
|
||||||
|
<funcdef>Elf_Half <function>get_index</function>
|
||||||
|
</funcdef>
|
||||||
|
<void/>
|
||||||
|
</funcprototype>
|
||||||
|
</funcsynopsis>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
Returns section index within ELF file.
|
||||||
|
</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>
|
||||||
|
<funcsynopsis>
|
||||||
|
<funcprototype>
|
||||||
|
<funcdef>Elf_Half <function>get_index</function>
|
||||||
|
</funcdef>
|
||||||
|
<void/>
|
||||||
|
</funcprototype>
|
||||||
|
</funcsynopsis>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
Returns section index within ELF file.
|
||||||
|
</entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</table>
|
</table>
|
||||||
|
@ -1,250 +0,0 @@
|
|||||||
<HTML
|
|
||||||
><HEAD
|
|
||||||
><TITLE
|
|
||||||
>Getting Started With ELFIO</TITLE
|
|
||||||
><META
|
|
||||||
NAME="GENERATOR"
|
|
||||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
|
|
||||||
REL="HOME"
|
|
||||||
TITLE="ELFIO"
|
|
||||||
HREF="index.php"><LINK
|
|
||||||
REL="PREVIOUS"
|
|
||||||
TITLE="Introduction"
|
|
||||||
HREF="f14.htm"><LINK
|
|
||||||
REL="NEXT"
|
|
||||||
TITLE="ELF File Sections"
|
|
||||||
HREF="x35.htm"></HEAD
|
|
||||||
><BODY
|
|
||||||
CLASS="CHAPTER"
|
|
||||||
BGCOLOR="#FFFFFF"
|
|
||||||
TEXT="#000000"
|
|
||||||
LINK="#0000FF"
|
|
||||||
VLINK="#840084"
|
|
||||||
ALINK="#0000FF"
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVHEADER"
|
|
||||||
><TABLE
|
|
||||||
SUMMARY="Header navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TH
|
|
||||||
COLSPAN="3"
|
|
||||||
ALIGN="center"
|
|
||||||
>ELFIO: Tutorial</TH
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="f14.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="80%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="bottom"
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="x35.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"></DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="CHAPTER"
|
|
||||||
><H1
|
|
||||||
><A
|
|
||||||
NAME="get-started"
|
|
||||||
>Chapter 1. Getting Started With ELFIO</A
|
|
||||||
></H1
|
|
||||||
><DIV
|
|
||||||
CLASS="TOC"
|
|
||||||
><DL
|
|
||||||
><DT
|
|
||||||
><B
|
|
||||||
>Table of Contents</B
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="c18.htm#AEN20"
|
|
||||||
>Initialization</A
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="x35.htm"
|
|
||||||
>ELF File Sections</A
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="x45.htm"
|
|
||||||
>Section Readers</A
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="x57.htm"
|
|
||||||
>Finalization</A
|
|
||||||
></DT
|
|
||||||
></DL
|
|
||||||
></DIV
|
|
||||||
>
|
|
||||||
|
|
||||||
<DIV
|
|
||||||
CLASS="SECT1"
|
|
||||||
><H1
|
|
||||||
CLASS="SECT1"
|
|
||||||
><A
|
|
||||||
NAME="AEN20"
|
|
||||||
>Initialization</A
|
|
||||||
></H1
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> The ELFIO library consists of two independent parts: ELF File Reader
|
|
||||||
(<FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFI</FONT
|
|
||||||
>)
|
|
||||||
and ELF Producer (<FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFO</FONT
|
|
||||||
>).
|
|
||||||
Each is represented by its own set of interfaces.
|
|
||||||
The library does not contain any classes that need to be explicitly
|
|
||||||
instantiated. ELFIO itself provides the interfaces that
|
|
||||||
are used to access the library's functionality.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> To make the program recognize all ELFIO interface classes, the ELFIO.h
|
|
||||||
header file is needed. This header file defines all
|
|
||||||
standard definitions from the TIS documentation.
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> #include <ELFIO.h></PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> This chapter will explain how to work with the reader component
|
|
||||||
of the ELFIO library. The first step is to get a pointer
|
|
||||||
onto the ELF File Reader:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> IELFI* pReader;
|
|
||||||
ELFIO::GetInstance()->CreateELFI( &pReader );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Now, that there is a pointer on the <FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFI</FONT
|
|
||||||
>
|
|
||||||
interface: initialize the object by loading the ELF file:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> char* filename = "file.o";
|
|
||||||
pReader->Load( filename );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> From here, there is access to the ELF header. This makes it possible to request file
|
|
||||||
parameters such as encoding, machine type, entry point, etc.
|
|
||||||
To get the encoding of the file use:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> unsigned char encoding = pReader->GetEncoding();</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Please note: standard types and constants from the TIS document are defined
|
|
||||||
in the ELFTypes.h header file. This file is included automatically into the
|
|
||||||
project. For example: ELFDATA2LSB and ELFDATA2MSB constants
|
|
||||||
define a value for little and big endian encoding.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
</DIV
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVFOOTER"
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"><TABLE
|
|
||||||
SUMMARY="Footer navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="f14.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="H"
|
|
||||||
>Home</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="x35.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
>Introduction</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
>ELF File Sections</TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
></DIV
|
|
||||||
></BODY
|
|
||||||
></HTML
|
|
||||||
>
|
|
@ -1,146 +0,0 @@
|
|||||||
<HTML
|
|
||||||
><HEAD
|
|
||||||
><TITLE
|
|
||||||
>ELFDump Utility</TITLE
|
|
||||||
><META
|
|
||||||
NAME="GENERATOR"
|
|
||||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
|
|
||||||
REL="HOME"
|
|
||||||
TITLE="ELFIO"
|
|
||||||
HREF="index.php"><LINK
|
|
||||||
REL="PREVIOUS"
|
|
||||||
TITLE="Finalization"
|
|
||||||
HREF="x57.htm"><LINK
|
|
||||||
REL="NEXT"
|
|
||||||
TITLE=" IELFO - ELF File Producer Interface
|
|
||||||
"
|
|
||||||
HREF="c66.htm"></HEAD
|
|
||||||
><BODY
|
|
||||||
CLASS="CHAPTER"
|
|
||||||
BGCOLOR="#FFFFFF"
|
|
||||||
TEXT="#000000"
|
|
||||||
LINK="#0000FF"
|
|
||||||
VLINK="#840084"
|
|
||||||
ALINK="#0000FF"
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVHEADER"
|
|
||||||
><TABLE
|
|
||||||
SUMMARY="Header navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TH
|
|
||||||
COLSPAN="3"
|
|
||||||
ALIGN="center"
|
|
||||||
>ELFIO: Tutorial</TH
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="x57.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="80%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="bottom"
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="c66.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"></DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="CHAPTER"
|
|
||||||
><H1
|
|
||||||
><A
|
|
||||||
NAME="elfdump"
|
|
||||||
>Chapter 2. ELFDump Utility</A
|
|
||||||
></H1
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> The source code for the ELF Dumping Utility can be found in the "Examples"
|
|
||||||
directory; included there are more examples on how to use different ELFIO
|
|
||||||
reader interfaces.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
</DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVFOOTER"
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"><TABLE
|
|
||||||
SUMMARY="Footer navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="x57.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="H"
|
|
||||||
>Home</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="c66.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
>Finalization</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
><FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFO</FONT
|
|
||||||
> - ELF File Producer Interface</TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
></DIV
|
|
||||||
></BODY
|
|
||||||
></HTML
|
|
||||||
>
|
|
@ -1,264 +0,0 @@
|
|||||||
<HTML
|
|
||||||
><HEAD
|
|
||||||
><TITLE
|
|
||||||
> IELFO - ELF File Producer Interface
|
|
||||||
</TITLE
|
|
||||||
><META
|
|
||||||
NAME="GENERATOR"
|
|
||||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
|
|
||||||
REL="HOME"
|
|
||||||
TITLE="ELFIO"
|
|
||||||
HREF="index.php"><LINK
|
|
||||||
REL="PREVIOUS"
|
|
||||||
TITLE="ELFDump Utility"
|
|
||||||
HREF="c63.htm"></HEAD
|
|
||||||
><BODY
|
|
||||||
CLASS="CHAPTER"
|
|
||||||
BGCOLOR="#FFFFFF"
|
|
||||||
TEXT="#000000"
|
|
||||||
LINK="#0000FF"
|
|
||||||
VLINK="#840084"
|
|
||||||
ALINK="#0000FF"
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVHEADER"
|
|
||||||
><TABLE
|
|
||||||
SUMMARY="Header navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TH
|
|
||||||
COLSPAN="3"
|
|
||||||
ALIGN="center"
|
|
||||||
>ELFIO: Tutorial</TH
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="c63.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="80%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="bottom"
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="bottom"
|
|
||||||
> </TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"></DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="CHAPTER"
|
|
||||||
><H1
|
|
||||||
><A
|
|
||||||
NAME="ielfo"
|
|
||||||
>Chapter 3. <FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFO</FONT
|
|
||||||
> - ELF File Producer Interface
|
|
||||||
</A
|
|
||||||
></H1
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> The ELFIO library can help you build a very short ELF executable file.
|
|
||||||
This chapter shows how to build an executable file that will run on
|
|
||||||
x86 Linux machines and print "Hello World!" on your console.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Just as with the reader, the first step is to get
|
|
||||||
a pointer onto the ELF File Writer (Producer):
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> IELFO* pELFO;
|
|
||||||
ELFIO::GetInstance()->CreateELFO( &pELFO );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Before continuing, the library must be informed about the main
|
|
||||||
attributes of the executable file to be built. To do this, declare
|
|
||||||
that the executable ELF file will run on a 32 bit x86 machine; has little
|
|
||||||
endian encoding and uses the current version of the ELF file format:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> // You can't proceed without this function call!
|
|
||||||
pELFO->SetAttr( ELFCLASS32, ELFDATA2LSB, EV_CURRENT,
|
|
||||||
ET_EXEC, EM_386, EV_CURRENT, 0 );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Some sections of an ELF executable file should reside in the program
|
|
||||||
segments. To create this loadable segment call the
|
|
||||||
<TT
|
|
||||||
CLASS="METHODNAME"
|
|
||||||
>AddSegment()</TT
|
|
||||||
> function.
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> // Create a loadable segment
|
|
||||||
IELFOSegment* pSegment = pELFO->AddSegment( PT_LOAD,
|
|
||||||
0x08040000,
|
|
||||||
0x08040000,
|
|
||||||
PF_X | PF_R,
|
|
||||||
0x1000 );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> The following segment serves as a placeholder for our code section. To create
|
|
||||||
this code section call the AddSection() function:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> // Create code section
|
|
||||||
IELFOSection* pTextSec = pELFO->AddSection( ".text",
|
|
||||||
SHT_PROGBITS,
|
|
||||||
SHF_ALLOC | SHF_EXECINSTR,
|
|
||||||
0,
|
|
||||||
0x10,
|
|
||||||
0 );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Then, add the executable code for the section:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> char text[] =
|
|
||||||
{ '\xB8', '\x04', '\x00', '\x00', '\x00', // mov eax, 4
|
|
||||||
'\xBB', '\x01', '\x00', '\x00', '\x00', // mov ebx, 1
|
|
||||||
'\xB9', '\xFD', '\x00', '\x04', '\x08', // mov ecx, msg
|
|
||||||
'\xBA', '\x0E', '\x00', '\x00', '\x00', // mov edx, 14
|
|
||||||
'\xCD', '\x80', // int 0x80
|
|
||||||
'\xB8', '\x01', '\x00', '\x00', '\x00', // mov eax, 1
|
|
||||||
'\xCD', '\x80', // int 0x80
|
|
||||||
'\x48', '\x65', '\x6C', '\x6C', '\x6F', // db 'Hello'
|
|
||||||
'\x2C', '\x20', '\x57', '\x6F', '\x72', // db ', Wor'
|
|
||||||
'\x6C', '\x64', '\x21', '\x0A' // db 'ld!', 10
|
|
||||||
};
|
|
||||||
pTextSec->SetData( text, sizeof( text ) );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Next, this code section is put into the loadable segment:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> // Add code section into program segment
|
|
||||||
pSegment->AddSection( pTextSec );
|
|
||||||
pTextSec->Release();
|
|
||||||
pSegment->Release();</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Finally, define the start address of the program
|
|
||||||
and create the result file:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> // Set program entry point
|
|
||||||
pELFO->SetEntry( 0x08040000 );
|
|
||||||
// Create ELF file
|
|
||||||
pELFO->Save( "test.elf" );
|
|
||||||
pELFO->Release();</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Please note: Call the <TT
|
|
||||||
CLASS="METHODNAME"
|
|
||||||
>Release()</TT
|
|
||||||
> functions
|
|
||||||
for each interface you have used.
|
|
||||||
This will free all resources the ELFIO library has created.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Now compile the program and run it. The result is a new ELF file
|
|
||||||
called "test.elf". The size of this working executable file is only
|
|
||||||
267 bytes! Run it on your Linux machine with the following commands:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> [Writer]$ ./Writer
|
|
||||||
[Writer]$ chmod +x test.elf
|
|
||||||
[Writer]$ ./test.elf
|
|
||||||
Hello, World!</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> The full text for this program can be found in the "Writer" directory.
|
|
||||||
Also, in the "Examples" directory, two other programs "WriteObj"
|
|
||||||
and "WriteObj2" demonstrate the creation of ELF object files.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
</DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVFOOTER"
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"><TABLE
|
|
||||||
SUMMARY="Footer navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="c63.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="H"
|
|
||||||
>Home</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
>ELFDump Utility</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
></DIV
|
|
||||||
></BODY
|
|
||||||
></HTML
|
|
||||||
>
|
|
@ -1,151 +0,0 @@
|
|||||||
<HTML
|
|
||||||
><HEAD
|
|
||||||
><TITLE
|
|
||||||
>Introduction</TITLE
|
|
||||||
><META
|
|
||||||
NAME="GENERATOR"
|
|
||||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
|
|
||||||
REL="HOME"
|
|
||||||
TITLE="ELFIO"
|
|
||||||
HREF="index.php"><LINK
|
|
||||||
REL="PREVIOUS"
|
|
||||||
TITLE="ELFIO"
|
|
||||||
HREF="index.php"><LINK
|
|
||||||
REL="NEXT"
|
|
||||||
TITLE="Getting Started With ELFIO"
|
|
||||||
HREF="c18.htm"></HEAD
|
|
||||||
><BODY
|
|
||||||
CLASS="PREFACE"
|
|
||||||
BGCOLOR="#FFFFFF"
|
|
||||||
TEXT="#000000"
|
|
||||||
LINK="#0000FF"
|
|
||||||
VLINK="#840084"
|
|
||||||
ALINK="#0000FF"
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVHEADER"
|
|
||||||
><TABLE
|
|
||||||
SUMMARY="Header navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TH
|
|
||||||
COLSPAN="3"
|
|
||||||
ALIGN="center"
|
|
||||||
>ELFIO: Tutorial</TH
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="80%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="bottom"
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="c18.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"></DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="PREFACE"
|
|
||||||
><H1
|
|
||||||
><A
|
|
||||||
NAME="introduction"
|
|
||||||
>Introduction</A
|
|
||||||
></H1
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> ELFIO is a C++ library for reading and generating files
|
|
||||||
in the ELF binary format. This library is unique and not based on
|
|
||||||
any other product. It is also platform independent.
|
|
||||||
The library uses standard ANSI C++ constructions and
|
|
||||||
runs on a wide variety of architectures.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> While the library's implementation does make your work easier:
|
|
||||||
a basic knowledge of the ELF binary format is required. Information about ELF
|
|
||||||
is included in the TIS (Tool Interface Standards) documentation you received
|
|
||||||
with the library's source code.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
</DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVFOOTER"
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"><TABLE
|
|
||||||
SUMMARY="Footer navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="H"
|
|
||||||
>Home</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="c18.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
>ELFIO</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
>Getting Started With ELFIO</TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
></DIV
|
|
||||||
></BODY
|
|
||||||
></HTML
|
|
||||||
>
|
|
@ -1,165 +0,0 @@
|
|||||||
<HTML
|
|
||||||
><HEAD
|
|
||||||
><TITLE
|
|
||||||
>ELFIO</TITLE
|
|
||||||
><META
|
|
||||||
NAME="GENERATOR"
|
|
||||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
|
|
||||||
REL="NEXT"
|
|
||||||
TITLE="Introduction"
|
|
||||||
HREF="f14.htm"></HEAD
|
|
||||||
><BODY
|
|
||||||
CLASS="BOOK"
|
|
||||||
BGCOLOR="#FFFFFF"
|
|
||||||
TEXT="#000000"
|
|
||||||
LINK="#0000FF"
|
|
||||||
VLINK="#840084"
|
|
||||||
ALINK="#0000FF"
|
|
||||||
><DIV
|
|
||||||
CLASS="BOOK"
|
|
||||||
><A
|
|
||||||
NAME="AEN1"
|
|
||||||
>
|
|
||||||
<div align="right"><A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=19959&type=2" width="125" height="37" border="0" alt="SourceForge Logo"></A></div>
|
|
||||||
</A
|
|
||||||
><DIV
|
|
||||||
CLASS="TITLEPAGE"
|
|
||||||
><H1
|
|
||||||
CLASS="TITLE"
|
|
||||||
><A
|
|
||||||
NAME="AEN2"
|
|
||||||
>ELFIO</A
|
|
||||||
></H1
|
|
||||||
><H2
|
|
||||||
CLASS="SUBTITLE"
|
|
||||||
>Tutorial</H2
|
|
||||||
> <H3
|
|
||||||
CLASS="AUTHOR"
|
|
||||||
><A
|
|
||||||
NAME="AEN7"
|
|
||||||
>Allan Finch</A
|
|
||||||
></H3
|
|
||||||
>
|
|
||||||
<H3
|
|
||||||
CLASS="AUTHOR"
|
|
||||||
><A
|
|
||||||
NAME="AEN10"
|
|
||||||
>Serge Lamikhov-Center</A
|
|
||||||
></H3
|
|
||||||
>
|
|
||||||
<HR></DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="TOC"
|
|
||||||
><DL
|
|
||||||
><DT
|
|
||||||
><B
|
|
||||||
>Table of Contents</B
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="f14.htm"
|
|
||||||
>Introduction</A
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
>1. <A
|
|
||||||
HREF="c18.htm"
|
|
||||||
>Getting Started With ELFIO</A
|
|
||||||
></DT
|
|
||||||
><DD
|
|
||||||
><DL
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="c18.htm#AEN20"
|
|
||||||
>Initialization</A
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="x35.htm"
|
|
||||||
>ELF File Sections</A
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="x45.htm"
|
|
||||||
>Section Readers</A
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
><A
|
|
||||||
HREF="x57.htm"
|
|
||||||
>Finalization</A
|
|
||||||
></DT
|
|
||||||
></DL
|
|
||||||
></DD
|
|
||||||
><DT
|
|
||||||
>2. <A
|
|
||||||
HREF="c63.htm"
|
|
||||||
>ELFDump Utility</A
|
|
||||||
></DT
|
|
||||||
><DT
|
|
||||||
>3. <A
|
|
||||||
HREF="c66.htm"
|
|
||||||
><FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFO</FONT
|
|
||||||
> - ELF File Producer Interface</A
|
|
||||||
></DT
|
|
||||||
></DL
|
|
||||||
></DIV
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVFOOTER"
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"><TABLE
|
|
||||||
SUMMARY="Footer navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="f14.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
> </TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
>Introduction</TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
></DIV
|
|
||||||
></BODY
|
|
||||||
></HTML
|
|
||||||
>
|
|
@ -1,187 +0,0 @@
|
|||||||
<HTML
|
|
||||||
><HEAD
|
|
||||||
><TITLE
|
|
||||||
>ELF File Sections</TITLE
|
|
||||||
><META
|
|
||||||
NAME="GENERATOR"
|
|
||||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
|
|
||||||
REL="HOME"
|
|
||||||
TITLE="ELFIO"
|
|
||||||
HREF="index.php"><LINK
|
|
||||||
REL="UP"
|
|
||||||
TITLE="Getting Started With ELFIO"
|
|
||||||
HREF="c18.htm"><LINK
|
|
||||||
REL="PREVIOUS"
|
|
||||||
TITLE="Getting Started With ELFIO"
|
|
||||||
HREF="c18.htm"><LINK
|
|
||||||
REL="NEXT"
|
|
||||||
TITLE="Section Readers"
|
|
||||||
HREF="x45.htm"></HEAD
|
|
||||||
><BODY
|
|
||||||
CLASS="SECT1"
|
|
||||||
BGCOLOR="#FFFFFF"
|
|
||||||
TEXT="#000000"
|
|
||||||
LINK="#0000FF"
|
|
||||||
VLINK="#840084"
|
|
||||||
ALINK="#0000FF"
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVHEADER"
|
|
||||||
><TABLE
|
|
||||||
SUMMARY="Header navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TH
|
|
||||||
COLSPAN="3"
|
|
||||||
ALIGN="center"
|
|
||||||
>ELFIO: Tutorial</TH
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="c18.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="80%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="bottom"
|
|
||||||
>Chapter 1. Getting Started With ELFIO</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="x45.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"></DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="SECT1"
|
|
||||||
><H1
|
|
||||||
CLASS="SECT1"
|
|
||||||
><A
|
|
||||||
NAME="AEN35"
|
|
||||||
>ELF File Sections</A
|
|
||||||
></H1
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> ELF binary files consist of several sections. Each section has it's own
|
|
||||||
responsibility: some contain executable code; others describe program dependencies;
|
|
||||||
others symbol tables and so on. See the TIS documentation for a full description of each section.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> To see how many sections the ELF file contains, including their
|
|
||||||
names and sizes, is demonstated in the following code:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> int nSecNo = pReader->GetSectionsNum();
|
|
||||||
for ( int i = 0; i < nSecNo; ++i ) { // For all sections
|
|
||||||
const IELFISection* pSec = pReader->GetSection( i );
|
|
||||||
std::cout << pSec->GetName() << '' ''
|
|
||||||
<< pSec->GetSize() << std::endl;
|
|
||||||
pSec->Release();
|
|
||||||
}</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> First, the number of sections are received; next, a pointer
|
|
||||||
on the <FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFISection</FONT
|
|
||||||
> interface. Using this interface,
|
|
||||||
access is gained to the different section attributes: size, type, flags and address.
|
|
||||||
To get a buffer that contains the section's bytes use the
|
|
||||||
<TT
|
|
||||||
CLASS="METHODNAME"
|
|
||||||
>GetData()</TT
|
|
||||||
> member function of this interface.
|
|
||||||
See the <FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFISection</FONT
|
|
||||||
> declaration for a full
|
|
||||||
description of the <FONT
|
|
||||||
COLOR="RED"
|
|
||||||
>IELFISection</FONT
|
|
||||||
> interface.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
</DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVFOOTER"
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"><TABLE
|
|
||||||
SUMMARY="Footer navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="c18.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="H"
|
|
||||||
>Home</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="x45.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
>Getting Started With ELFIO</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="c18.htm"
|
|
||||||
ACCESSKEY="U"
|
|
||||||
>Up</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
>Section Readers</TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
></DIV
|
|
||||||
></BODY
|
|
||||||
></HTML
|
|
||||||
>
|
|
@ -1,214 +0,0 @@
|
|||||||
<HTML
|
|
||||||
><HEAD
|
|
||||||
><TITLE
|
|
||||||
>Section Readers</TITLE
|
|
||||||
><META
|
|
||||||
NAME="GENERATOR"
|
|
||||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
|
|
||||||
REL="HOME"
|
|
||||||
TITLE="ELFIO"
|
|
||||||
HREF="index.php"><LINK
|
|
||||||
REL="UP"
|
|
||||||
TITLE="Getting Started With ELFIO"
|
|
||||||
HREF="c18.htm"><LINK
|
|
||||||
REL="PREVIOUS"
|
|
||||||
TITLE="ELF File Sections"
|
|
||||||
HREF="x35.htm"><LINK
|
|
||||||
REL="NEXT"
|
|
||||||
TITLE="Finalization"
|
|
||||||
HREF="x57.htm"></HEAD
|
|
||||||
><BODY
|
|
||||||
CLASS="SECT1"
|
|
||||||
BGCOLOR="#FFFFFF"
|
|
||||||
TEXT="#000000"
|
|
||||||
LINK="#0000FF"
|
|
||||||
VLINK="#840084"
|
|
||||||
ALINK="#0000FF"
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVHEADER"
|
|
||||||
><TABLE
|
|
||||||
SUMMARY="Header navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TH
|
|
||||||
COLSPAN="3"
|
|
||||||
ALIGN="center"
|
|
||||||
>ELFIO: Tutorial</TH
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="x35.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="80%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="bottom"
|
|
||||||
>Chapter 1. Getting Started With ELFIO</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="x57.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"></DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="SECT1"
|
|
||||||
><H1
|
|
||||||
CLASS="SECT1"
|
|
||||||
><A
|
|
||||||
NAME="AEN45"
|
|
||||||
>Section Readers</A
|
|
||||||
></H1
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> After the section data is received through the <TT
|
|
||||||
CLASS="METHODNAME"
|
|
||||||
>GetData()</TT
|
|
||||||
>
|
|
||||||
function call, the data can be manipulated.
|
|
||||||
There are special sections
|
|
||||||
that provide information in predefined forms. The ELFIO library
|
|
||||||
processes these sections. The library provides a set of
|
|
||||||
section readers that understand these predefined formats and how to process their data.
|
|
||||||
The ELFIO.h header file currently defines the types of readers as:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> enum ReaderType {
|
|
||||||
ELFI_STRING, // Strings reader
|
|
||||||
ELFI_SYMBOL, // Symbol table reader
|
|
||||||
ELFI_RELOCATION, // Relocation table reader
|
|
||||||
ELFI_NOTE, // Notes reader
|
|
||||||
ELFI_DYNAMIC, // Dynamic section reader
|
|
||||||
ELFI_HASH // Hash
|
|
||||||
};</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> How to use the symbol table reader will be demonstated in the following example:
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> First, get the symbol section:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> const IELFISection* pSec = pReader->GetSection( ''.symtab'' );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> Second, create a symbol section reader:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> IELFISymbolTable* pSymTbl = 0;
|
|
||||||
pReader->CreateSectionReader( IELFI::ELFI_SYMBOL,
|
|
||||||
pSec,
|
|
||||||
(void**)&pSymTbl );</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> And finally, use the section reader to process all entries
|
|
||||||
(print operations are omitted):
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> std::string name;
|
|
||||||
Elf32_Addr value;
|
|
||||||
Elf32_Word size;
|
|
||||||
unsigned char bind;
|
|
||||||
unsigned char type;
|
|
||||||
Elf32_Half section;
|
|
||||||
int nSymNo = pSymTbl->GetSymbolNum();
|
|
||||||
if ( 0 < nSymNo ) {
|
|
||||||
for ( int i = 0; i < nSymNo; ++i ) {
|
|
||||||
pSymTbl->GetSymbol( i, name, value, size,
|
|
||||||
bind, type, section );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pSymTbl->Release();
|
|
||||||
pSec->Release();</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
</DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVFOOTER"
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"><TABLE
|
|
||||||
SUMMARY="Footer navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="x35.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="H"
|
|
||||||
>Home</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="x57.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
>ELF File Sections</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="c18.htm"
|
|
||||||
ACCESSKEY="U"
|
|
||||||
>Up</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
>Finalization</TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
></DIV
|
|
||||||
></BODY
|
|
||||||
></HTML
|
|
||||||
>
|
|
@ -1,163 +0,0 @@
|
|||||||
<HTML
|
|
||||||
><HEAD
|
|
||||||
><TITLE
|
|
||||||
>Finalization</TITLE
|
|
||||||
><META
|
|
||||||
NAME="GENERATOR"
|
|
||||||
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
|
|
||||||
REL="HOME"
|
|
||||||
TITLE="ELFIO"
|
|
||||||
HREF="index.php"><LINK
|
|
||||||
REL="UP"
|
|
||||||
TITLE="Getting Started With ELFIO"
|
|
||||||
HREF="c18.htm"><LINK
|
|
||||||
REL="PREVIOUS"
|
|
||||||
TITLE="Section Readers"
|
|
||||||
HREF="x45.htm"><LINK
|
|
||||||
REL="NEXT"
|
|
||||||
TITLE="ELFDump Utility"
|
|
||||||
HREF="c63.htm"></HEAD
|
|
||||||
><BODY
|
|
||||||
CLASS="SECT1"
|
|
||||||
BGCOLOR="#FFFFFF"
|
|
||||||
TEXT="#000000"
|
|
||||||
LINK="#0000FF"
|
|
||||||
VLINK="#840084"
|
|
||||||
ALINK="#0000FF"
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVHEADER"
|
|
||||||
><TABLE
|
|
||||||
SUMMARY="Header navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TH
|
|
||||||
COLSPAN="3"
|
|
||||||
ALIGN="center"
|
|
||||||
>ELFIO: Tutorial</TH
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="x45.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="80%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="bottom"
|
|
||||||
>Chapter 1. Getting Started With ELFIO</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="10%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="bottom"
|
|
||||||
><A
|
|
||||||
HREF="c63.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"></DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="SECT1"
|
|
||||||
><H1
|
|
||||||
CLASS="SECT1"
|
|
||||||
><A
|
|
||||||
NAME="AEN57"
|
|
||||||
>Finalization</A
|
|
||||||
></H1
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> All interfaces from the ELFIO library should be freed after
|
|
||||||
use. Each interface has a <TT
|
|
||||||
CLASS="METHODNAME"
|
|
||||||
>Release()</TT
|
|
||||||
> function.
|
|
||||||
It is not enough to only free the high level interface because
|
|
||||||
one of the sections or readers will still be held and its resources will not be cleared.
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
<P
|
|
||||||
> The interfaces are freed immediately after their use, in this
|
|
||||||
example we will free only the pReader object:
|
|
||||||
<PRE
|
|
||||||
CLASS="PROGRAMLISTING"
|
|
||||||
> pReader->Release();</PRE
|
|
||||||
>
|
|
||||||
</P
|
|
||||||
>
|
|
||||||
</DIV
|
|
||||||
><DIV
|
|
||||||
CLASS="NAVFOOTER"
|
|
||||||
><HR
|
|
||||||
ALIGN="LEFT"
|
|
||||||
WIDTH="100%"><TABLE
|
|
||||||
SUMMARY="Footer navigation table"
|
|
||||||
WIDTH="100%"
|
|
||||||
BORDER="0"
|
|
||||||
CELLPADDING="0"
|
|
||||||
CELLSPACING="0"
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="x45.htm"
|
|
||||||
ACCESSKEY="P"
|
|
||||||
>Prev</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="index.php"
|
|
||||||
ACCESSKEY="H"
|
|
||||||
>Home</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="c63.htm"
|
|
||||||
ACCESSKEY="N"
|
|
||||||
>Next</A
|
|
||||||
></TD
|
|
||||||
></TR
|
|
||||||
><TR
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="left"
|
|
||||||
VALIGN="top"
|
|
||||||
>Section Readers</TD
|
|
||||||
><TD
|
|
||||||
WIDTH="34%"
|
|
||||||
ALIGN="center"
|
|
||||||
VALIGN="top"
|
|
||||||
><A
|
|
||||||
HREF="c18.htm"
|
|
||||||
ACCESSKEY="U"
|
|
||||||
>Up</A
|
|
||||||
></TD
|
|
||||||
><TD
|
|
||||||
WIDTH="33%"
|
|
||||||
ALIGN="right"
|
|
||||||
VALIGN="top"
|
|
||||||
>ELFDump Utility</TD
|
|
||||||
></TR
|
|
||||||
></TABLE
|
|
||||||
></DIV
|
|
||||||
></BODY
|
|
||||||
></HTML
|
|
||||||
>
|
|
@ -62,7 +62,7 @@ class section
|
|||||||
virtual void save( std::ofstream& f,
|
virtual void save( std::ofstream& f,
|
||||||
std::streampos header_offset,
|
std::streampos header_offset,
|
||||||
std::streampos data_offset ) = 0;
|
std::streampos data_offset ) = 0;
|
||||||
virtual bool is_address_initialized() = 0;
|
virtual bool is_address_initialized() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class section_impl : public section
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
is_address_initialized()
|
is_address_initialized() const
|
||||||
{
|
{
|
||||||
return is_address_set;
|
return is_address_set;
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ class section_impl : public section
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
save_header( std::ofstream& f,
|
save_header( std::ofstream& f,
|
||||||
std::streampos header_offset )
|
std::streampos header_offset ) const
|
||||||
{
|
{
|
||||||
f.seekp( header_offset );
|
f.seekp( header_offset );
|
||||||
f.write( reinterpret_cast<const char*>( &header ), sizeof( header ) );
|
f.write( reinterpret_cast<const char*>( &header ), sizeof( header ) );
|
||||||
@ -254,7 +254,7 @@ class section_impl : public section
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
save_data( std::ofstream& f,
|
save_data( std::ofstream& f,
|
||||||
std::streampos data_offset )
|
std::streampos data_offset ) const
|
||||||
{
|
{
|
||||||
f.seekp( data_offset );
|
f.seekp( data_offset );
|
||||||
f.write( get_data(), get_size() );
|
f.write( get_data(), get_size() );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user