mirror of
https://github.com/QuasarApp/ELFIO.git
synced 2025-04-29 13:34:31 +00:00
- Fix a reported problem with section data size not updating at 'load' time
This commit is contained in:
parent
1a957edfba
commit
00e37476c0
@ -340,3 +340,18 @@ BOOST_AUTO_TEST_CASE( section_header_address_update )
|
||||
BOOST_REQUIRE_NE( sec, (section*)0 );
|
||||
BOOST_CHECK_EQUAL( sec->get_address(), 0x08048000 );
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
BOOST_AUTO_TEST_CASE( elfio_copy )
|
||||
{
|
||||
elfio e;
|
||||
|
||||
write_exe_i386( false, true, 0x0100 );
|
||||
|
||||
e.load( "../elf_examples/write_exe_i386_32" );
|
||||
Elf_Half num = e.sections.size();
|
||||
section* new_sec = e.sections.add( "new" );
|
||||
e.save( "../elf_examples/write_exe_i386_32" );
|
||||
BOOST_CHECK_EQUAL( num + 1, e.sections.size() );
|
||||
}
|
||||
|
@ -66,13 +66,13 @@ class section
|
||||
virtual void append_data( const std::string& data ) = 0;
|
||||
|
||||
protected:
|
||||
virtual void set_index( Elf_Half ) = 0;
|
||||
virtual void set_index( Elf_Half ) = 0;
|
||||
virtual void load( std::ifstream& f,
|
||||
std::streampos header_offset ) const = 0;
|
||||
std::streampos header_offset ) = 0;
|
||||
virtual void save( std::ofstream& f,
|
||||
std::streampos header_offset,
|
||||
std::streampos data_offset ) = 0;
|
||||
virtual bool is_address_initialized() = 0;
|
||||
std::streampos data_offset ) = 0;
|
||||
virtual bool is_address_initialized() = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -216,7 +216,7 @@ class section_impl : public section
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
load( std::ifstream& stream,
|
||||
std::streampos header_offset ) const
|
||||
std::streampos header_offset )
|
||||
{
|
||||
std::fill_n( reinterpret_cast<char*>( &header ), sizeof( header ), '\0' );
|
||||
stream.seekg( header_offset );
|
||||
@ -228,6 +228,7 @@ class section_impl : public section
|
||||
data = new char[size];
|
||||
stream.seekg( (*convertor)( header.sh_offset ) );
|
||||
stream.read( data, size );
|
||||
data_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,13 +272,13 @@ class section_impl : public section
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
private:
|
||||
mutable T header;
|
||||
Elf_Half index;
|
||||
std::string name;
|
||||
mutable char* data;
|
||||
Elf_Word data_size;
|
||||
const endianess_convertor* convertor;
|
||||
bool is_address_set;
|
||||
mutable T header;
|
||||
Elf_Half index;
|
||||
std::string name;
|
||||
char* data;
|
||||
Elf_Word data_size;
|
||||
const endianess_convertor* convertor;
|
||||
bool is_address_set;
|
||||
};
|
||||
|
||||
} // namespace ELFIO
|
||||
|
Loading…
x
Reference in New Issue
Block a user