Adjust stream size when section data changes

This commit is contained in:
Serge Lamikhov-Center 2022-01-19 01:24:46 +02:00
parent 36f78fbf28
commit ed2523f095
3 changed files with 7 additions and 15 deletions

View File

@ -140,6 +140,9 @@ template <class T> class section_impl : public section
}
set_size( data_size );
if ( translator->empty() ) {
set_stream_size( data_size );
}
}
//------------------------------------------------------------------------------
@ -171,6 +174,9 @@ template <class T> class section_impl : public section
}
}
set_size( get_size() + size );
if ( translator->empty() ) {
set_stream_size( get_stream_size() + size );
}
}
}

View File

@ -43,8 +43,7 @@ template <class S> class symbol_section_accessor_template
{
Elf_Xword nRet = 0;
if ( 0 != symbol_section->get_entry_size() &&
true ) {
// symbol_section->get_size() < symbol_section->get_stream_size() ) {
symbol_section->get_size() <= symbol_section->get_stream_size() ) {
nRet =
symbol_section->get_size() / symbol_section->get_entry_size();
}

View File

@ -685,19 +685,6 @@ BOOST_AUTO_TEST_CASE( rearrange_local_symbols )
symbols.arrange_local_symbols( [&]( Elf_Xword first, Elf_Xword ) -> void {
static int counter = 0;
BOOST_CHECK_EQUAL( first, ++counter );
// std::string name = "";
// ELFIO::Elf64_Addr value = 0;
// ELFIO::Elf_Xword size = 0;
// unsigned char bind = STB_LOCAL;
// unsigned char type = STT_FUNC;
// ELFIO::Elf_Half section_index = 0;
// unsigned char other = 0;
// std::cout << first << " " << second << std::endl;
// symbols.get_symbol(first, name, value, size, bind, type, section_index, other);
// std::cout << " " << name;
// symbols.get_symbol(second, name, value, size, bind, type, section_index, other);
// std::cout << " " << name << std::endl;
} );
BOOST_REQUIRE_EQUAL( writer.save( file_name ), true );