mirror of
https://github.com/QuasarApp/ELFIO.git
synced 2025-04-29 21:44:32 +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_REQUIRE_NE( sec, (section*)0 );
|
||||||
BOOST_CHECK_EQUAL( sec->get_address(), 0x08048000 );
|
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;
|
virtual void append_data( const std::string& data ) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void set_index( Elf_Half ) = 0;
|
virtual void set_index( Elf_Half ) = 0;
|
||||||
virtual void load( std::ifstream& f,
|
virtual void load( std::ifstream& f,
|
||||||
std::streampos header_offset ) const = 0;
|
std::streampos header_offset ) = 0;
|
||||||
virtual void save( std::ofstream& f,
|
virtual void save( std::ofstream& f,
|
||||||
std::streampos header_offset,
|
std::streampos header_offset,
|
||||||
std::streampos data_offset ) = 0;
|
std::streampos data_offset ) = 0;
|
||||||
virtual bool is_address_initialized() = 0;
|
virtual bool is_address_initialized() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ class section_impl : public section
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
load( std::ifstream& stream,
|
load( std::ifstream& stream,
|
||||||
std::streampos header_offset ) const
|
std::streampos header_offset )
|
||||||
{
|
{
|
||||||
std::fill_n( reinterpret_cast<char*>( &header ), sizeof( header ), '\0' );
|
std::fill_n( reinterpret_cast<char*>( &header ), sizeof( header ), '\0' );
|
||||||
stream.seekg( header_offset );
|
stream.seekg( header_offset );
|
||||||
@ -228,6 +228,7 @@ class section_impl : public section
|
|||||||
data = new char[size];
|
data = new char[size];
|
||||||
stream.seekg( (*convertor)( header.sh_offset ) );
|
stream.seekg( (*convertor)( header.sh_offset ) );
|
||||||
stream.read( data, size );
|
stream.read( data, size );
|
||||||
|
data_size = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,13 +272,13 @@ class section_impl : public section
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
mutable T header;
|
mutable T header;
|
||||||
Elf_Half index;
|
Elf_Half index;
|
||||||
std::string name;
|
std::string name;
|
||||||
mutable char* data;
|
char* data;
|
||||||
Elf_Word data_size;
|
Elf_Word data_size;
|
||||||
const endianess_convertor* convertor;
|
const endianess_convertor* convertor;
|
||||||
bool is_address_set;
|
bool is_address_set;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ELFIO
|
} // namespace ELFIO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user