'add_entry' in symbol_section_accessor was renamed to 'add_symbol'

documentation update
<elfio.hpp> was modified to be <elfio/elfio.hpp>
This commit is contained in:
Serge Lamikhov-Center 2012-11-25 19:58:07 +02:00
parent d3a0732983
commit b74f44443d
10 changed files with 58 additions and 56 deletions

View File

@ -6,7 +6,7 @@
#define BOOST_TEST_MODULE ELFIO_Test
#include <boost/test/unit_test.hpp>
#include <elfio.hpp>
#include <elfio/elfio.hpp>
using namespace ELFIO;

View File

@ -53,7 +53,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\elfio;c:\Developer\boost_1_52_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..;c:\Developer\boost_1_52_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<EnablePREfast>false</EnablePREfast>
</ClCompile>
<Link>

View File

@ -7,7 +7,7 @@
#include <boost/test/output_test_stream.hpp>
using boost::test_tools::output_test_stream;
#include <elfio.hpp>
#include <elfio/elfio.hpp>
using namespace ELFIO;
@ -65,12 +65,12 @@ bool write_obj_i386( bool is64bit )
sym_sec->set_entry_size( writer.get_default_entry_size( SHT_SYMTAB ) );
symbol_section_accessor symbol_writer( writer, sym_sec );
Elf_Word nSymIndex = symbol_writer.add_entry( nStrIndex, 0, 0,
Elf_Word nSymIndex = symbol_writer.add_symbol( nStrIndex, 0, 0,
STB_LOCAL, STT_NOTYPE, 0,
data_sec->get_index() );
// Another way to add symbol
symbol_writer.add_entry( str_writer, "_start", 0x00000000, 0,
symbol_writer.add_symbol( str_writer, "_start", 0x00000000, 0,
STB_WEAK, STT_FUNC, 0,
text_sec->get_index() );

Binary file not shown.

View File

@ -413,7 +413,7 @@ class dump
section_header( out, i, sec );
}
out << "Key to Flags: W (write), A (a lloc), X (execute)\n\n"
out << "Key to Flags: W (write), A (alloc), X (execute)\n\n"
<< std::endl;
}
}

View File

@ -78,10 +78,10 @@ class note_section_accessor
}
//------------------------------------------------------------------------------
void add_note( Elf_Word type,
void add_note( Elf_Word type,
const std::string& name,
const void* desc,
Elf_Word descSize )
const void* desc,
Elf_Word descSize )
{
const endianess_convertor& convertor = elf_file.get_convertor();
@ -116,9 +116,9 @@ class note_section_accessor
void process_section()
{
const endianess_convertor& convertor = elf_file.get_convertor();
const char* data = note_section->get_data();
Elf_Xword size = note_section->get_size();
Elf_Xword current = 0;
const char* data = note_section->get_data();
Elf_Xword size = note_section->get_size();
Elf_Xword current = 0;
note_start_positions.clear();

View File

@ -100,7 +100,7 @@ class relocation_section_accessor
bool
get_entry( Elf_Xword index,
Elf64_Addr& offset,
Elf_Word& symbol,
Elf_Word& symbol,
Elf_Word& type,
Elf_Sxword& addend ) const
{
@ -268,7 +268,7 @@ class relocation_section_accessor
unsigned char type )
{
Elf_Word str_index = str_writer.add_string( str );
Elf_Word sym_index = sym_writer.add_entry( str_index, value, size,
Elf_Word sym_index = sym_writer.add_symbol( str_index, value, size,
sym_info, other, shndx );
add_entry( offset, sym_index, type );
}

View File

@ -30,8 +30,9 @@ class symbol_section_accessor
{
public:
//------------------------------------------------------------------------------
symbol_section_accessor( const elfio& elf_file_, section* symbols_section_ ) :
elf_file( elf_file_ ), symbols_section( symbols_section_ )
symbol_section_accessor( const elfio& elf_file_, section* symbol_section_ ) :
elf_file( elf_file_ ),
symbol_section( symbol_section_ )
{
find_hash_section();
}
@ -41,8 +42,8 @@ class symbol_section_accessor
get_symbols_num() const
{
Elf_Xword nRet = 0;
if ( 0 != symbols_section->get_entry_size() ) {
nRet = symbols_section->get_size() / symbols_section->get_entry_size();
if ( 0 != symbol_section->get_entry_size() ) {
nRet = symbol_section->get_size() / symbol_section->get_entry_size();
}
return nRet;
@ -62,12 +63,12 @@ class symbol_section_accessor
bool ret = false;
if ( elf_file.get_class() == ELFCLASS32 ) {
ret = generic_get_symbol<Elf32_Sym>( index, name, value, size, bind, type,
section_index, other );
ret = generic_get_symbol<Elf32_Sym>( index, name, value, size, bind,
type, section_index, other );
}
else {
ret = generic_get_symbol<Elf64_Sym>( index, name, value, size, bind, type,
section_index, other );
ret = generic_get_symbol<Elf64_Sym>( index, name, value, size, bind,
type, section_index, other );
}
return ret;
@ -75,13 +76,13 @@ class symbol_section_accessor
//------------------------------------------------------------------------------
bool
get_symbol( const std::string& name,
Elf64_Addr& value,
Elf_Xword& size,
unsigned char& bind,
unsigned char& type,
Elf_Half& section_index,
unsigned char& other ) const
get_symbol( std::string& name,
Elf64_Addr& value,
Elf_Xword& size,
unsigned char& bind,
unsigned char& type,
Elf_Half& section_index,
unsigned char& other ) const
{
bool ret = false;
@ -108,13 +109,13 @@ class symbol_section_accessor
//------------------------------------------------------------------------------
Elf_Word
add_entry( Elf_Word name, Elf64_Addr value, Elf_Xword size,
unsigned char info, unsigned char other,
Elf_Half shndx )
add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size,
unsigned char info, unsigned char other,
Elf_Half shndx )
{
Elf_Word nRet;
if ( symbols_section->get_size() == 0 ) {
if ( symbol_section->get_size() == 0 ) {
if ( elf_file.get_class() == ELFCLASS32 ) {
nRet = generic_add_symbol<Elf32_Sym>( 0, 0, 0, 0, 0, 0 );
}
@ -137,32 +138,32 @@ class symbol_section_accessor
//------------------------------------------------------------------------------
Elf_Word
add_entry( Elf_Word name, Elf64_Addr value, Elf_Xword size,
unsigned char bind, unsigned char type, unsigned char other,
Elf_Half shndx )
add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size,
unsigned char bind, unsigned char type, unsigned char other,
Elf_Half shndx )
{
return add_entry( name, value, size, ELF_ST_INFO( bind, type ), other, shndx );
return add_symbol( name, value, size, ELF_ST_INFO( bind, type ), other, shndx );
}
//------------------------------------------------------------------------------
Elf_Word
add_entry( string_section_accessor& pStrWriter, const char* str,
Elf64_Addr value, Elf_Xword size,
unsigned char info, unsigned char other,
Elf_Half shndx )
add_symbol( string_section_accessor& pStrWriter, const char* str,
Elf64_Addr value, Elf_Xword size,
unsigned char info, unsigned char other,
Elf_Half shndx )
{
Elf_Word index = pStrWriter.add_string( str );
return add_entry( index, value, size, info, other, shndx );
return add_symbol( index, value, size, info, other, shndx );
}
//------------------------------------------------------------------------------
Elf_Word
add_entry( string_section_accessor& pStrWriter, const char* str,
Elf64_Addr value, Elf_Xword size,
unsigned char bind, unsigned char type, unsigned char other,
Elf_Half shndx )
add_symbol( string_section_accessor& pStrWriter, const char* str,
Elf64_Addr value, Elf_Xword size,
unsigned char bind, unsigned char type, unsigned char other,
Elf_Half shndx )
{
return add_entry( pStrWriter, str, value, size, ELF_ST_INFO( bind, type ), other, shndx );
return add_symbol( pStrWriter, str, value, size, ELF_ST_INFO( bind, type ), other, shndx );
}
//------------------------------------------------------------------------------
@ -176,7 +177,7 @@ class symbol_section_accessor
Elf_Half nSecNo = elf_file.sections.size();
for ( Elf_Half i = 0; i < nSecNo && 0 == hash_section_index; ++i ) {
const section* sec = elf_file.sections[i];
if ( sec->get_link() == symbols_section->get_index() ) {
if ( sec->get_link() == symbol_section->get_index() ) {
hash_section = sec;
hash_section_index = i;
}
@ -187,7 +188,7 @@ class symbol_section_accessor
Elf_Half
get_string_table_index() const
{
return (Elf_Half)symbols_section->get_link();
return (Elf_Half)symbol_section->get_link();
}
//------------------------------------------------------------------------------
@ -211,7 +212,8 @@ class symbol_section_accessor
if ( index < get_symbols_num() ) {
const T* pSym = reinterpret_cast<const T*>(
symbols_section->get_data() + index * symbols_section->get_entry_size() );
symbol_section->get_data() +
index * symbol_section->get_entry_size() );
const endianess_convertor& convertor = elf_file.get_convertor();
@ -253,10 +255,10 @@ class symbol_section_accessor
entry.st_other = convertor( other );
entry.st_shndx = convertor( shndx );
symbols_section->append_data( reinterpret_cast<char*>( &entry ),
sizeof( entry ) );
symbol_section->append_data( reinterpret_cast<char*>( &entry ),
sizeof( entry ) );
Elf_Word nRet = symbols_section->get_size() / sizeof( entry ) - 1;
Elf_Word nRet = symbol_section->get_size() / sizeof( entry ) - 1;
return nRet;
}
@ -264,7 +266,7 @@ class symbol_section_accessor
//------------------------------------------------------------------------------
private:
const elfio& elf_file;
section* symbols_section;
section* symbol_section;
Elf_Half hash_section_index;
const section* hash_section;
};

View File

@ -1 +1 @@
SUBDIRS = ELFDump tutorial
SUBDIRS = elfdump tutorial

View File

@ -53,7 +53,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\elfio;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>