Add modinfo to VS project

This commit is contained in:
Serge Lamikhov-Center 2020-08-23 09:57:21 +03:00
parent 761d70da2c
commit e00bf98230
5 changed files with 16 additions and 8 deletions

View File

@ -681,7 +681,7 @@ class dump
out << "Section .modinfo" << std::endl;
const_modinfo_section_accessor modinfo( sec );
for ( auto i = 0; i < modinfo.get_attribute_num(); i++ ) {
for ( Elf_Word i = 0; i < modinfo.get_attribute_num(); i++ ) {
std::string field;
std::string value;
if ( modinfo.get_attribute( i, field, value ) ) {

View File

@ -69,7 +69,7 @@ template <class S> class modinfo_section_accessor_template
}
//------------------------------------------------------------------------------
Elf_Word add_attribute( std::string field_name, std::string value )
Elf_Word add_attribute( std::string field, std::string value )
{
Elf_Word current_position = 0;
@ -77,11 +77,11 @@ template <class S> class modinfo_section_accessor_template
// Strings are addeded to the end of the current section data
current_position = (Elf_Word)modinfo_section->get_size();
std::string attribute = field_name + "=" + value;
std::string attribute = field + "=" + value;
modinfo_section->append_data( attribute + '\0' );
content.push_back(
std::pair<std::string, std::string>( field_name, value ) );
std::pair<std::string, std::string>( field, value ) );
}
return current_position;

View File

@ -105,11 +105,13 @@
</PreprocessToFile>
</ClCompile>
<ClCompile Include="ELFIOTest1.cpp" />
<ClCompile Include="ELFIOTest2.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\elfio\elfio.hpp" />
<ClInclude Include="..\elfio\elfio_dynamic.hpp" />
<ClInclude Include="..\elfio\elfio_header.hpp" />
<ClInclude Include="..\elfio\elfio_modinfo.hpp" />
<ClInclude Include="..\elfio\elfio_note.hpp" />
<ClInclude Include="..\elfio\elfio_relocation.hpp" />
<ClInclude Include="..\elfio\elfio_section.hpp" />

View File

@ -21,6 +21,9 @@
<ClCompile Include="ELFIOTest1.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ELFIOTest2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\elfio\elf_types.hpp">
@ -56,5 +59,8 @@
<ClInclude Include="..\elfio\elfio_dynamic.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\elfio\elfio_modinfo.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE( modinfo_read )
BOOST_REQUIRE_NE( modinfo_sec, nullptr );
const_modinfo_section_accessor modinfo( modinfo_sec );
BOOST_REQUIRE_EQUAL( modinfo.get_attribute_num(), 9 );
BOOST_REQUIRE_EQUAL( modinfo.get_attribute_num(), (Elf_Word)9 );
struct
{
@ -67,12 +67,12 @@ BOOST_AUTO_TEST_CASE( modinfo_write )
BOOST_REQUIRE_NE( modinfo_sec, nullptr );
modinfo_section_accessor modinfo( modinfo_sec );
BOOST_REQUIRE_EQUAL( modinfo.get_attribute_num(), 9 );
BOOST_REQUIRE_EQUAL( modinfo.get_attribute_num(), (Elf_Word)9 );
modinfo.add_attribute( "test1", "value1" );
modinfo.add_attribute( "test2", "value2" );
BOOST_REQUIRE_EQUAL( modinfo.get_attribute_num(), 11 );
BOOST_REQUIRE_EQUAL( modinfo.get_attribute_num(), (Elf_Word)11 );
BOOST_REQUIRE_EQUAL( writer.save( "elf_examples/zavl_gen.ko" ), true );
@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE( modinfo_write )
BOOST_REQUIRE_NE( modinfo_sec, nullptr );
const_modinfo_section_accessor modinfo1( modinfo_sec );
BOOST_REQUIRE_EQUAL( modinfo1.get_attribute_num(), 11 );
BOOST_REQUIRE_EQUAL( modinfo1.get_attribute_num(), (Elf_Word)11 );
struct
{