Fix compilation warnings in VS 2019 v16.7.0

This commit is contained in:
Serge Lamikhov-Center 2020-08-07 20:27:13 +03:00
parent a4ad47a7fb
commit b1961db18b
8 changed files with 31 additions and 29 deletions

View File

@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE( load64 )
////////////////////////////////////////////////////////////////////////////
// Check ELF header
checkHeader( reader, ELFCLASS64, ELFDATA2LSB, EV_CURRENT, ET_EXEC,
EM_X86_64, 1, 0x4003c0, 0, 29, 8, 0, 0 );
EM_X86_64, 1, 0x4003c0, 0, 29, 8, 0, 0 );
////////////////////////////////////////////////////////////////////////////
// Check sections
@ -304,22 +304,22 @@ BOOST_AUTO_TEST_CASE( load64 )
sec =reader.sections[ 1 ];
checkSection( sec, 1, ".interp", SHT_PROGBITS, SHF_ALLOC,
0x0000000000400200, 0x1c, 0, 0, 1, 0 );
0x0000000000400200, 0x1c, 0, 0, 1, 0 );
sec =reader.sections[ 9 ];
checkSection( sec, 9, ".rela.plt", SHT_RELA, SHF_ALLOC,
0x0000000000400340, 0x30, 4, 11, 8, 0x18 );
0x0000000000400340, 0x30, 4, 11, 8, 0x18 );
sec =reader.sections[ 20 ];
checkSection( sec, 20, ".dynamic", SHT_DYNAMIC, SHF_WRITE | SHF_ALLOC,
0x0000000000600698, 0x190, 5, 0, 8, 0x10 );
0x0000000000600698, 0x190, 5, 0, 8, 0x10 );
sec =reader.sections[ 28 ];
checkSection( sec, 28, ".strtab", SHT_STRTAB, 0,
0x0, 0x23f, 0, 0, 1, 0 );
0x0, 0x23f, 0, 0, 1, 0 );
const section* sec1 = reader.sections[ ".strtab" ];
BOOST_CHECK_EQUAL( sec->get_index(), sec1->get_index() );
@ -328,15 +328,15 @@ BOOST_AUTO_TEST_CASE( load64 )
// Check segments
segment* seg = reader.segments[0];
checkSegment( seg, PT_PHDR, 0x0000000000400040, 0x0000000000400040,
0x00000000000001c0, 0x00000000000001c0, PF_R + PF_X, 8 );
0x00000000000001c0, 0x00000000000001c0, PF_R + PF_X, 8 );
seg = reader.segments[2];
checkSegment( seg, PT_LOAD, 0x0000000000400000, 0x0000000000400000,
0x000000000000066c, 0x000000000000066c, PF_R + PF_X, 0x200000 );
0x000000000000066c, 0x000000000000066c, PF_R + PF_X, 0x200000 );
seg = reader.segments[7];
checkSegment( seg, 0x6474E551, 0x0, 0x0,
0x0, 0x0, PF_R + PF_W, 8 );
0x0, 0x0, PF_R + PF_W, 8 );
////////////////////////////////////////////////////////////////////////////
// Check symbol table

View File

@ -51,10 +51,10 @@
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;d:\Developer\boost_1_65_1;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..;d:\Developer\boost_1_73_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<EnablePREfast>false</EnablePREfast>
</ClCompile>
<Link>
@ -62,7 +62,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>
</AdditionalDependencies>
<AdditionalLibraryDirectories>d:\Developer\boost_1_65_1\stage\lib</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>d:\Developer\boost_1_73_0\stage\lib</AdditionalLibraryDirectories>
<Profile>false</Profile>
</Link>
<PostBuildEvent>
@ -74,7 +74,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>

View File

@ -317,7 +317,7 @@ void checkExeAreEqual( std::string file_name1, std::string file_name2, int skipT
// truncate the data if the header and the segment table is
// part of the segment
Elf64_Off afterPHDR = file1.get_segments_offset() +
file1.get_segment_entry_size() * file1.segments.size();
file1.get_segment_entry_size() * (Elf64_Off)file1.segments.size();
if( file1.segments[i]->get_offset() < afterPHDR ) {
pdata1 = pdata1.substr( (unsigned int)afterPHDR );
pdata2 = pdata2.substr( (unsigned int)afterPHDR );

View File

@ -176,7 +176,7 @@ class elfio
// Layout the first section right after the segment table
current_file_pos = header->get_header_size() +
header->get_segment_entry_size() * header->get_segments_num();
header->get_segment_entry_size() * (Elf_Xword)header->get_segments_num();
calc_segment_alignment();
@ -404,7 +404,7 @@ class elfio
for ( Elf_Half i = 0; i < num; ++i ) {
section* sec = create_section();
sec->load( stream, (std::streamoff)offset + i * entry_size );
sec->load( stream, (std::streamoff)offset + (std::streampos)i * entry_size );
sec->set_index( i );
// To mark that the section is not permitted to reassign address
// during layout calculation
@ -460,7 +460,7 @@ class elfio
return false;
}
seg->load( stream, (std::streamoff)offset + i * entry_size );
seg->load( stream, (std::streamoff)offset + (std::streampos)i * entry_size );
seg->set_index( i );
// Add sections to the segments (similar to readelfs algorithm)
@ -503,7 +503,7 @@ class elfio
std::streampos headerPosition =
(std::streamoff)header->get_sections_offset() +
header->get_section_entry_size() * sec->get_index();
(std::streampos)header->get_section_entry_size() * sec->get_index();
sec->save(stream,headerPosition,sec->get_offset());
}
@ -517,7 +517,7 @@ class elfio
segment *seg = segments_.at(i);
std::streampos headerPosition = header->get_segments_offset() +
header->get_segment_entry_size()*seg->get_index();
(std::streampos)header->get_segment_entry_size()*seg->get_index();
seg->save( stream, headerPosition, seg->get_offset() );
}
@ -662,7 +662,7 @@ class elfio
if ( seg->get_type() == PT_PHDR && seg->get_sections_num() == 0 ) {
seg_start_pos = header->get_segments_offset();
segment_memory = segment_filesize =
header->get_segment_entry_size() * header->get_segments_num();
header->get_segment_entry_size() * (Elf_Xword)header->get_segments_num();
}
// Special case:
else if ( seg->is_offset_initialized() && seg->get_offset() == 0 ) {

View File

@ -629,7 +629,7 @@ class dump
//------------------------------------------------------------------------------
static void
symbol_table( std::ostream& out,
Elf_Half no,
Elf_Xword no,
std::string& name,
Elf64_Addr value,
Elf_Xword size,
@ -679,7 +679,7 @@ class dump
section* sec = reader.sections[i];
if ( SHT_NOTE == sec->get_type() ) { // Look at notes
note_section_accessor notes( reader, sec );
int no_notes = notes.get_notes_num();
Elf_Word no_notes = notes.get_notes_num();
if ( no > 0 ) {
out << "Note section (" << sec->get_name() << ")" << std::endl
<< " No Type Name"

View File

@ -72,13 +72,14 @@ class note_section_accessor_template
int align = sizeof( Elf_Word );
const endianess_convertor& convertor = elf_file.get_convertor();
type = convertor( *(const Elf_Word*)( pData + 2*align ) );
type = convertor( *(const Elf_Word*)( pData + 2*align ) );
Elf_Word namesz = convertor( *(const Elf_Word*)( pData ) );
descSize = convertor( *(const Elf_Word*)( pData + sizeof( namesz ) ) );
Elf_Xword max_name_size = note_section->get_size() - note_start_positions[index];
if ( namesz < 1 ||
namesz > max_name_size ||
namesz + descSize > max_name_size ) {
(Elf_Xword)namesz + descSize > max_name_size ) {
return false;
}
name.assign( pData + 3*align, namesz - 1);
@ -142,17 +143,17 @@ class note_section_accessor_template
return;
}
int align = sizeof( Elf_Word );
while ( current + 3*align <= size ) {
Elf_Word align = sizeof( Elf_Word );
while ( current + (Elf_Xword)3*align <= size ) {
note_start_positions.push_back( current );
Elf_Word namesz = convertor(
*(const Elf_Word*)( data + current ) );
Elf_Word descsz = convertor(
*(const Elf_Word*)( data + current + sizeof( namesz ) ) );
current += 3*sizeof( Elf_Word ) +
( ( namesz + align - 1 ) / align ) * align +
( ( descsz + align - 1 ) / align ) * align;
current += (Elf_Xword)3*sizeof( Elf_Word ) +
( ( namesz + align - 1 ) / align ) * (Elf_Xword)align +
( ( descsz + align - 1 ) / align ) * (Elf_Xword)align;
}
}

View File

@ -79,6 +79,8 @@ class section_impl : public section
is_address_set = false;
data = 0;
data_size = 0;
index = 0;
stream_size = 0;
}
//------------------------------------------------------------------------------

View File

@ -133,7 +133,6 @@ class symbol_section_accessor_template
const endianess_convertor& convertor = elf_file.get_convertor();
section* string_section = elf_file.sections[get_string_table_index()];
Elf_Xword idx = 0;
bool match = false;