mirror of
https://github.com/serge1/ELFIO.git
synced 2025-01-30 15:32:44 +00:00
'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:
parent
d3a0732983
commit
b74f44443d
@ -6,7 +6,7 @@
|
|||||||
#define BOOST_TEST_MODULE ELFIO_Test
|
#define BOOST_TEST_MODULE ELFIO_Test
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include <elfio.hpp>
|
#include <elfio/elfio.hpp>
|
||||||
|
|
||||||
using namespace ELFIO;
|
using namespace ELFIO;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<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>
|
<EnablePREfast>false</EnablePREfast>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <boost/test/output_test_stream.hpp>
|
#include <boost/test/output_test_stream.hpp>
|
||||||
using boost::test_tools::output_test_stream;
|
using boost::test_tools::output_test_stream;
|
||||||
|
|
||||||
#include <elfio.hpp>
|
#include <elfio/elfio.hpp>
|
||||||
|
|
||||||
using namespace ELFIO;
|
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 ) );
|
sym_sec->set_entry_size( writer.get_default_entry_size( SHT_SYMTAB ) );
|
||||||
|
|
||||||
symbol_section_accessor symbol_writer( writer, sym_sec );
|
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,
|
STB_LOCAL, STT_NOTYPE, 0,
|
||||||
data_sec->get_index() );
|
data_sec->get_index() );
|
||||||
|
|
||||||
// Another way to add symbol
|
// 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,
|
STB_WEAK, STT_FUNC, 0,
|
||||||
text_sec->get_index() );
|
text_sec->get_index() );
|
||||||
|
|
||||||
|
BIN
doc/elfio.docx
BIN
doc/elfio.docx
Binary file not shown.
@ -413,7 +413,7 @@ class dump
|
|||||||
section_header( out, i, sec );
|
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;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 std::string& name,
|
||||||
const void* desc,
|
const void* desc,
|
||||||
Elf_Word descSize )
|
Elf_Word descSize )
|
||||||
{
|
{
|
||||||
const endianess_convertor& convertor = elf_file.get_convertor();
|
const endianess_convertor& convertor = elf_file.get_convertor();
|
||||||
|
|
||||||
@ -116,9 +116,9 @@ class note_section_accessor
|
|||||||
void process_section()
|
void process_section()
|
||||||
{
|
{
|
||||||
const endianess_convertor& convertor = elf_file.get_convertor();
|
const endianess_convertor& convertor = elf_file.get_convertor();
|
||||||
const char* data = note_section->get_data();
|
const char* data = note_section->get_data();
|
||||||
Elf_Xword size = note_section->get_size();
|
Elf_Xword size = note_section->get_size();
|
||||||
Elf_Xword current = 0;
|
Elf_Xword current = 0;
|
||||||
|
|
||||||
note_start_positions.clear();
|
note_start_positions.clear();
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class relocation_section_accessor
|
|||||||
bool
|
bool
|
||||||
get_entry( Elf_Xword index,
|
get_entry( Elf_Xword index,
|
||||||
Elf64_Addr& offset,
|
Elf64_Addr& offset,
|
||||||
Elf_Word& symbol,
|
Elf_Word& symbol,
|
||||||
Elf_Word& type,
|
Elf_Word& type,
|
||||||
Elf_Sxword& addend ) const
|
Elf_Sxword& addend ) const
|
||||||
{
|
{
|
||||||
@ -268,7 +268,7 @@ class relocation_section_accessor
|
|||||||
unsigned char type )
|
unsigned char type )
|
||||||
{
|
{
|
||||||
Elf_Word str_index = str_writer.add_string( str );
|
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 );
|
sym_info, other, shndx );
|
||||||
add_entry( offset, sym_index, type );
|
add_entry( offset, sym_index, type );
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,9 @@ class symbol_section_accessor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
symbol_section_accessor( const elfio& elf_file_, section* symbols_section_ ) :
|
symbol_section_accessor( const elfio& elf_file_, section* symbol_section_ ) :
|
||||||
elf_file( elf_file_ ), symbols_section( symbols_section_ )
|
elf_file( elf_file_ ),
|
||||||
|
symbol_section( symbol_section_ )
|
||||||
{
|
{
|
||||||
find_hash_section();
|
find_hash_section();
|
||||||
}
|
}
|
||||||
@ -41,8 +42,8 @@ class symbol_section_accessor
|
|||||||
get_symbols_num() const
|
get_symbols_num() const
|
||||||
{
|
{
|
||||||
Elf_Xword nRet = 0;
|
Elf_Xword nRet = 0;
|
||||||
if ( 0 != symbols_section->get_entry_size() ) {
|
if ( 0 != symbol_section->get_entry_size() ) {
|
||||||
nRet = symbols_section->get_size() / symbols_section->get_entry_size();
|
nRet = symbol_section->get_size() / symbol_section->get_entry_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nRet;
|
return nRet;
|
||||||
@ -62,12 +63,12 @@ class symbol_section_accessor
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if ( elf_file.get_class() == ELFCLASS32 ) {
|
if ( elf_file.get_class() == ELFCLASS32 ) {
|
||||||
ret = generic_get_symbol<Elf32_Sym>( index, name, value, size, bind, type,
|
ret = generic_get_symbol<Elf32_Sym>( index, name, value, size, bind,
|
||||||
section_index, other );
|
type, section_index, other );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = generic_get_symbol<Elf64_Sym>( index, name, value, size, bind, type,
|
ret = generic_get_symbol<Elf64_Sym>( index, name, value, size, bind,
|
||||||
section_index, other );
|
type, section_index, other );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -75,13 +76,13 @@ class symbol_section_accessor
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
get_symbol( const std::string& name,
|
get_symbol( std::string& name,
|
||||||
Elf64_Addr& value,
|
Elf64_Addr& value,
|
||||||
Elf_Xword& size,
|
Elf_Xword& size,
|
||||||
unsigned char& bind,
|
unsigned char& bind,
|
||||||
unsigned char& type,
|
unsigned char& type,
|
||||||
Elf_Half& section_index,
|
Elf_Half& section_index,
|
||||||
unsigned char& other ) const
|
unsigned char& other ) const
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
@ -108,13 +109,13 @@ class symbol_section_accessor
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
Elf_Word
|
Elf_Word
|
||||||
add_entry( Elf_Word name, Elf64_Addr value, Elf_Xword size,
|
add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size,
|
||||||
unsigned char info, unsigned char other,
|
unsigned char info, unsigned char other,
|
||||||
Elf_Half shndx )
|
Elf_Half shndx )
|
||||||
{
|
{
|
||||||
Elf_Word nRet;
|
Elf_Word nRet;
|
||||||
|
|
||||||
if ( symbols_section->get_size() == 0 ) {
|
if ( symbol_section->get_size() == 0 ) {
|
||||||
if ( elf_file.get_class() == ELFCLASS32 ) {
|
if ( elf_file.get_class() == ELFCLASS32 ) {
|
||||||
nRet = generic_add_symbol<Elf32_Sym>( 0, 0, 0, 0, 0, 0 );
|
nRet = generic_add_symbol<Elf32_Sym>( 0, 0, 0, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
@ -137,32 +138,32 @@ class symbol_section_accessor
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
Elf_Word
|
Elf_Word
|
||||||
add_entry( Elf_Word name, Elf64_Addr value, Elf_Xword size,
|
add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size,
|
||||||
unsigned char bind, unsigned char type, unsigned char other,
|
unsigned char bind, unsigned char type, unsigned char other,
|
||||||
Elf_Half shndx )
|
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
|
Elf_Word
|
||||||
add_entry( string_section_accessor& pStrWriter, const char* str,
|
add_symbol( string_section_accessor& pStrWriter, const char* str,
|
||||||
Elf64_Addr value, Elf_Xword size,
|
Elf64_Addr value, Elf_Xword size,
|
||||||
unsigned char info, unsigned char other,
|
unsigned char info, unsigned char other,
|
||||||
Elf_Half shndx )
|
Elf_Half shndx )
|
||||||
{
|
{
|
||||||
Elf_Word index = pStrWriter.add_string( str );
|
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
|
Elf_Word
|
||||||
add_entry( string_section_accessor& pStrWriter, const char* str,
|
add_symbol( string_section_accessor& pStrWriter, const char* str,
|
||||||
Elf64_Addr value, Elf_Xword size,
|
Elf64_Addr value, Elf_Xword size,
|
||||||
unsigned char bind, unsigned char type, unsigned char other,
|
unsigned char bind, unsigned char type, unsigned char other,
|
||||||
Elf_Half shndx )
|
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();
|
Elf_Half nSecNo = elf_file.sections.size();
|
||||||
for ( Elf_Half i = 0; i < nSecNo && 0 == hash_section_index; ++i ) {
|
for ( Elf_Half i = 0; i < nSecNo && 0 == hash_section_index; ++i ) {
|
||||||
const section* sec = elf_file.sections[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 = sec;
|
||||||
hash_section_index = i;
|
hash_section_index = i;
|
||||||
}
|
}
|
||||||
@ -187,7 +188,7 @@ class symbol_section_accessor
|
|||||||
Elf_Half
|
Elf_Half
|
||||||
get_string_table_index() const
|
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() ) {
|
if ( index < get_symbols_num() ) {
|
||||||
const T* pSym = reinterpret_cast<const T*>(
|
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();
|
const endianess_convertor& convertor = elf_file.get_convertor();
|
||||||
|
|
||||||
@ -253,10 +255,10 @@ class symbol_section_accessor
|
|||||||
entry.st_other = convertor( other );
|
entry.st_other = convertor( other );
|
||||||
entry.st_shndx = convertor( shndx );
|
entry.st_shndx = convertor( shndx );
|
||||||
|
|
||||||
symbols_section->append_data( reinterpret_cast<char*>( &entry ),
|
symbol_section->append_data( reinterpret_cast<char*>( &entry ),
|
||||||
sizeof( 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;
|
return nRet;
|
||||||
}
|
}
|
||||||
@ -264,7 +266,7 @@ class symbol_section_accessor
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
const elfio& elf_file;
|
const elfio& elf_file;
|
||||||
section* symbols_section;
|
section* symbol_section;
|
||||||
Elf_Half hash_section_index;
|
Elf_Half hash_section_index;
|
||||||
const section* hash_section;
|
const section* hash_section;
|
||||||
};
|
};
|
||||||
|
@ -1 +1 @@
|
|||||||
SUBDIRS = ELFDump tutorial
|
SUBDIRS = elfdump tutorial
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\..\elfio;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user