mirror of
https://github.com/serge1/ELFIO.git
synced 2024-11-19 20:19:07 +00:00
251 lines
3.9 KiB
HTML
251 lines
3.9 KiB
HTML
<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
|
|
>
|