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